/** * Creates a new user exception builder. * * @see com.dremio.exec.proto.UserBitShared.DremioPBError.ErrorType#CONNECTION * @return user exception builder */ public static Builder connectionError() { return connectionError(null); }
@Override public void operationComplete(Future<? super Void> future) throws Exception { for (final UserResultsListener listener : queryIdToResultsListenersMap.values()) { listener.submissionFailed(UserException.connectionError() .message("Connection %s closed unexpectedly. SabotNode down?", connection.getName()) .build(logger)); if (listener instanceof BufferingResultsListener) { // the appropriate listener will be failed by SubmissionListener#failed logger.warn("Buffering listener failed before results were transferred to the actual listener."); } } } });
public ElasticConnection getConnection(List<String> hosts) { //if whitelist then only keep the hosts in the list if(useWhitelist) { List<String> whitelistedHosts = new ArrayList<>(); for (String host : hosts) { if (clients.containsKey(host)) { whitelistedHosts.add(host); } } if(whitelistedHosts.size() == 0) { return getRandomConnection(); } hosts = whitelistedHosts; } final int index = ThreadLocalRandom.current().nextInt(hosts.size()); final String host = hosts.get(index); WebTarget target = clients.get(host); if(target == null){ missingHost(host); target = clients.get(host); if(target == null){ throw UserException.connectionError() .message("Unable to find defined host [%s] in cluster. Available hosts: \n", host, getAvailableHosts()) .build(logger); } } return new ElasticConnection(Preconditions.checkNotNull(clients.get(host), String.format("The host specified [%s] was not among the list of connected nodes.", host))); }
@Override public Iterable<RefreshInfo> getRefreshInfos() { if (contextProvider.get().isMaster() || (contextProvider.get().isCoordinator() && contextProvider.get().getDremioConfig().getBoolean(ENABLE_MASTERLESS_BOOL))) { return StreamSupport.stream(reflectionStatusService.get().getRefreshInfos().spliterator(), false) .map(RefreshInfo::fromRefreshInfo).collect(Collectors.toList()); } // need to do RPC call // trying to get master Optional<CoordinationProtos.NodeEndpoint> master = contextProvider.get().getMaster(); if (!master.isPresent()) { throw UserException.connectionError().message("Unable to get master while trying to get Reflection Information") .build(logger); } final ReflectionTunnel reflectionTunnel = reflectionTunnelCreator.getTunnel(master.get()); try { final ReflectionRPC.RefreshInfoResp refreshInfosResp = reflectionTunnel.requestRefreshInfos().get(15, TimeUnit.SECONDS); return refreshInfosResp.getRefreshInfoList().stream() .map(RefreshInfo::fromRefreshInfo).collect(Collectors.toList()); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw UserException.connectionError(e).message("Error while getting Refresh Information") .build(logger); } } }
@Override public Iterable<ReflectionInfo> getReflections() { if (contextProvider.get().isMaster() || (contextProvider.get().isCoordinator() && contextProvider.get().getDremioConfig().getBoolean(ENABLE_MASTERLESS_BOOL))) { return reflectionStatusService.get().getReflections(); } // need to do RPC call // trying to get master Optional<CoordinationProtos.NodeEndpoint> master = contextProvider.get().getMaster(); if (!master.isPresent()) { throw UserException.connectionError().message("Unable to get master while trying to get Reflection Information") .build(logger); } final ReflectionTunnel reflectionTunnel = reflectionTunnelCreator.getTunnel(master.get()); try { final ReflectionRPC.ReflectionInfoResp reflectionCombinedStatusResp = reflectionTunnel.requestReflectionStatus().get(15, TimeUnit.SECONDS); return reflectionCombinedStatusResp.getReflectionInfoList().stream() .map(ReflectionInfo::getReflectionInfo).collect(Collectors.toList()); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw UserException.connectionError(e).message("Error while getting Reflection Information") .build(logger); } }
throw UserException.connectionError().message("Unable to get Elasticsearch node version information.").build(logger);
@Override public Iterable<DependencyInfo> getReflectionDependencies() { if (contextProvider.get().isMaster() || (contextProvider.get().isCoordinator() && contextProvider.get().getDremioConfig().getBoolean(ENABLE_MASTERLESS_BOOL))) { return reflectionService.get().getReflectionDependencies(); } // need to do RPC call // trying to get master Optional<CoordinationProtos.NodeEndpoint> master = contextProvider.get().getMaster(); if (!master.isPresent()) { throw UserException.connectionError().message("Unable to get master while trying to get Reflection Information") .build(logger); } final ReflectionTunnel reflectionTunnel = reflectionTunnelCreator.getTunnel(master.get()); try { final ReflectionRPC.DependencyInfoResp dependencyInfosResp = reflectionTunnel.requestDependencyInfos().get(15, TimeUnit.SECONDS); return dependencyInfosResp.getDependencyInfoList().stream() .map(DependencyInfo::getDependencyInfo).collect(Collectors.toList()); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw UserException.connectionError(e).message("Error while getting Dependency Information") .build(logger); } }
result = action.getResult(target); } catch (Exception e) { addContextAndThrow(UserException.connectionError(e).message("Encountered a problem while executing %s. %s", action, unauthorizedMsg), contextWithAlias); addContextAndThrow(UserException.connectionError().message("Something went wrong. " + "Please make sure the source is available. %s", unauthorizedMsg), contextWithAlias); contextWithAlias.add(result.getErrorMessage()); addContextAndThrow( UserException.connectionError() .message("Something went wrong, error code " + responseCode + ". Please provide the correct host and credentials.") .addContext("responseCode", responseCode),
private static String getSql(final RunQuery q) { if(q.getType() == QueryType.PREPARED_STATEMENT){ try{ final ServerPreparedStatementState preparedStatement = ServerPreparedStatementState.PARSER.parseFrom(q.getPreparedStatementHandle().getServerInfo()); return preparedStatement.getSqlQuery(); }catch(Exception ex){ throw UserException.connectionError(ex).message("Prepared statement provided is corrupt.").build(logger); } } else { return q.getPlan(); } }
if(numIntFragments > 0 && !endpointLatch.awaitUninterruptibly(timeout)){ long numberRemaining = endpointLatch.getCount(); throw UserException.connectionError() .message( "Exceeded timeout (%d) while waiting send intermediate work fragments to remote nodes. " + throw UserException.connectionError(submissionExceptions.get(0).rpcException) .message("Error setting up remote intermediate fragment execution") .addContext("Nodes with failures", sb.toString())
@Test public void testBuildUserExceptionWithFormattedMessage() { String format = "This is test #%d"; UserException uex = UserException.connectionError().message(format, 5).build(logger); DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(ErrorType.CONNECTION, error.getErrorType()); Assert.assertEquals(String.format(format, 5), uex.getOriginalMessage()); }
context.get().getOptionManager().getOption(CatalogOptions.STORAGE_PLUGIN_CHECK_STATE)) { plugins.deleteSource(config); throw UserException.connectionError().message("Failure while configuring source [%s]. Info: %s", config.getName(), state).build(logger); throw UserException.connectionError(e).message("Failure while configuring source [%s]", config.getName()) .build(logger);
@Test public void testBuildUserExceptionWithUserExceptionCauseAndMessage() { String messageA = "Test message A"; String messageB = "Test message B"; UserException original = UserException.connectionError().message(messageA).build(logger); UserException uex = UserException.dataWriteError(wrap(original, 5)).message(messageB).build(logger); //builder should return the unwrapped original user exception and not build a new one Assert.assertEquals(original, uex); DremioPBError error = uex.getOrCreatePBError(false); Assert.assertEquals(messageA, uex.getOriginalMessage()); Assert.assertFalse(error.getMessage().contains(messageB)); // messageB should not be part of the context }
throw UserException.connectionError(e) .message("Unable to parse provided prepared statement. " + "It is likely that the client failed to handle this message.")