List of usage examples for com.google.common.util.concurrent UncheckedExecutionException getCause
public synchronized Throwable getCause()
From source file:org.apache.hadoop.hbase.client.BigtableAdmin.java
@Override public HTableDescriptor getTableDescriptor(TableName tableName) throws TableNotFoundException, IOException { if (tableName == null) { return null; }/* w w w .j a va 2 s . c om*/ String bigtableTableName = TableMetadataSetter.getBigtableName(tableName, options); GetTableRequest request = GetTableRequest.newBuilder().setName(bigtableTableName).build(); try { return tableAdapter.adapt(bigtableAdminClient.getTable(request)); } catch (UncheckedExecutionException e) { if (e.getCause() != null && e.getCause() instanceof OperationRuntimeException) { Status status = ((OperationRuntimeException) e.getCause()).getStatus(); if (status.getCode() == Status.NOT_FOUND.getCode()) { throw new TableNotFoundException(tableName); } } throw new IOException("Failed to getTableDescriptor() on " + tableName, e); } catch (Throwable throwable) { throw new IOException("Failed to getTableDescriptor() on " + tableName, throwable); } }
From source file:org.apache.usergrid.corepersistence.CpEntityManagerFactory.java
private void checkManagementApp(Properties properties) { int maxRetries = 100; try {//from www.ja v a2 s .co m maxRetries = Integer.parseInt(properties.getProperty(MANAGEMENT_APP_INIT_MAXRETRIES, "100")); } catch (Exception e) { logger.error("Error parsing " + MANAGEMENT_APP_INIT_MAXRETRIES + ". Will use " + maxRetries, e); } int interval = 1000; try { interval = Integer.parseInt(properties.getProperty(MANAGEMENT_APP_INIT_INTERVAL, "1000")); } catch (Exception e) { logger.error("Error parsing " + MANAGEMENT_APP_INIT_INTERVAL + ". Will use " + maxRetries, e); } // hold up construction until we can access the management app int retries = 0; boolean managementAppFound = false; boolean bootstrapping = false; Set<Class> seenBefore = new HashSet<>(10); while (!managementAppFound && retries++ < maxRetries) { try { // bypass entity manager cache and get managementApp managementApp = _getEntityManager(getManagementAppId()).getApplication(); managementAppFound = true; } catch (Throwable t) { if (t instanceof CollectionRuntimeException) { CollectionRuntimeException cre = (CollectionRuntimeException) t; if (cre.isBootstrapping()) { // we're bootstrapping, ignore this and continue bootstrapping = true; break; } } Throwable cause = t; // there was an error, be as informative as possible StringBuilder sb = new StringBuilder(); sb.append(retries).append(": Error ("); if (t instanceof UncheckedExecutionException) { UncheckedExecutionException uee = (UncheckedExecutionException) t; if (uee.getCause() instanceof RuntimeException) { cause = uee.getCause().getCause(); sb.append(cause.getClass().getSimpleName()).append(") ") .append(uee.getCause().getMessage()); } else { cause = uee.getCause(); sb.append(cause.getClass().getSimpleName()).append(") ").append(t.getMessage()); } } else { sb.append(t.getCause().getClass().getSimpleName()).append(") ").append(t.getMessage()); } String msg = sb.toString(); if (!seenBefore.contains(cause.getClass())) { logger.error(msg, t); } else { logger.error(msg); } seenBefore.add(cause.getClass()); try { Thread.sleep(interval); } catch (InterruptedException ignored) { } } } if (!managementAppFound && !bootstrapping) { // exception here will prevent WAR from being deployed throw new RuntimeException("Unable to get management app after " + retries + " retries"); } }
From source file:com.facebook.presto.metadata.StaticFunctionNamespace.java
private SpecializedFunctionKey getSpecializedFunctionKey(Signature signature) { try {//from ww w.j a va2 s . c om return specializedFunctionKeyCache.getUnchecked(signature); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
From source file:com.facebook.presto.metadata.StaticFunctionNamespace.java
public ScalarFunctionImplementation getScalarFunctionImplementation(Signature signature) { checkArgument(signature.getKind() == SCALAR, "%s is not a scalar function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature);/* w w w . ja v a 2s . co m*/ try { return specializedScalarCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
From source file:com.facebook.presto.metadata.StaticFunctionNamespace.java
public InternalAggregationFunction getAggregateFunctionImplementation(FunctionHandle functionHandle) { checkArgument(functionHandle instanceof StaticFunctionHandle, "Expect StaticFunctionHandle"); Signature signature = ((StaticFunctionHandle) functionHandle).getSignature(); checkArgument(signature.getKind() == AGGREGATE, "%s is not an aggregate function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature);// w w w. jav a 2s .co m try { return specializedAggregationCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
From source file:com.facebook.presto.metadata.StaticFunctionNamespace.java
public WindowFunctionSupplier getWindowFunctionImplementation(FunctionHandle functionHandle) { checkArgument(functionHandle instanceof StaticFunctionHandle, "Expect StaticFunctionHandle"); Signature signature = ((StaticFunctionHandle) functionHandle).getSignature(); checkArgument(signature.getKind() == WINDOW || signature.getKind() == AGGREGATE, "%s is not a window function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature);//ww w . ja v a 2 s . com try { return specializedWindowCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
From source file:com.facebook.presto.metadata.StaticFunctionNamespace.java
@Override public FunctionMetadata getFunctionMetadata(FunctionHandle functionHandle) { checkArgument(functionHandle instanceof StaticFunctionHandle, "Expect StaticFunctionHandle"); Signature signature = ((StaticFunctionHandle) functionHandle).getSignature(); SpecializedFunctionKey functionKey;//w w w . java 2 s . c o m try { functionKey = specializedFunctionKeyCache.getUnchecked(signature); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } SqlFunction function = functionKey.getFunction(); Optional<OperatorType> operatorType = tryGetOperatorType(signature.getName()); if (operatorType.isPresent()) { return new FunctionMetadata(operatorType.get(), signature.getArgumentTypes(), signature.getReturnType(), signature.getKind(), function.isDeterministic(), function.isCalledOnNullInput()); } else { return new FunctionMetadata(signature.getName(), signature.getArgumentTypes(), signature.getReturnType(), signature.getKind(), function.isDeterministic(), function.isCalledOnNullInput()); } }
From source file:io.prestosql.metadata.FunctionRegistry.java
public InternalAggregationFunction getAggregateFunctionImplementation(Signature signature) { checkArgument(signature.getKind() == AGGREGATE, "%s is not an aggregate function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature);/*from w w w.j a v a 2 s.c o m*/ try { return specializedAggregationCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
From source file:io.prestosql.metadata.FunctionRegistry.java
public WindowFunctionSupplier getWindowFunctionImplementation(Signature signature) { checkArgument(signature.getKind() == WINDOW || signature.getKind() == AGGREGATE, "%s is not a window function", signature); checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature);/*w w w . j a v a 2s . c o m*/ try { return specializedWindowCache.getUnchecked(getSpecializedFunctionKey(signature)); } catch (UncheckedExecutionException e) { throwIfInstanceOf(e.getCause(), PrestoException.class); throw e; } }
From source file:com.facebook.buck.apple.xcode.ProjectGenerator.java
public void createXcodeProjects() throws IOException { try {// ww w .j a v a 2 s. c o m targetNameToGIDMap = buildTargetNameToGIDMap(); Iterable<BuildRule> allRules = RuleDependencyFinder.getAllRules(partialGraph, initialTargets); ImmutableMap.Builder<BuildRule, PBXTarget> ruleToTargetMapBuilder = ImmutableMap.builder(); for (BuildRule rule : allRules) { if (isBuiltByCurrentProject(rule)) { // Trigger the loading cache to call the generateTargetForBuildRule function. Optional<PBXTarget> target = buildRuleToXcodeTarget.getUnchecked(rule); if (target.isPresent()) { ruleToTargetMapBuilder.put(rule, target.get()); } } } if (options.contains(Option.REFERENCE_EXISTING_XCCONFIGS)) { setProjectLevelConfigs(project, repoRootRelativeToOutputDirectory, collectProjectLevelConfigsIfIdenticalOrFail( xcodeConfigurationLayersMultimapBuilder.build())); } addGeneratedSignedSourceTarget(project); writeProjectFile(project); if (options.contains(Option.GENERATE_WORKSPACE)) { writeWorkspace(projectPath); } if (options.contains(Option.GENERATE_SCHEME)) { scheme = SchemeGenerator.createScheme(partialGraph, projectPath, ruleToTargetMapBuilder.build()); SchemeGenerator.writeScheme(projectFilesystem, scheme, projectPath); } if (shouldPlaceAssetCatalogCompiler) { Path placedAssetCatalogCompilerPath = projectFilesystem.getPathForRelativePath( BuckConstant.BIN_PATH.resolve("xcode-scripts/compile_asset_catalogs.py")); projectFilesystem.createParentDirs(placedAssetCatalogCompilerPath); projectFilesystem.createParentDirs(placedAssetCatalogBuildPhaseScript); projectFilesystem.copyFile(Paths.get(PATH_TO_ASSET_CATALOG_COMPILER), placedAssetCatalogCompilerPath); projectFilesystem.copyFile(Paths.get(PATH_TO_ASSET_CATALOG_BUILD_PHASE_SCRIPT), placedAssetCatalogBuildPhaseScript); } } catch (UncheckedExecutionException e) { // if any code throws an exception, they tend to get wrapped in LoadingCache's // UncheckedExecutionException. Unwrap it if its cause is HumanReadable. if (e.getCause() instanceof HumanReadableException) { throw (HumanReadableException) e.getCause(); } else { throw e; } } }