public SourceState getSourceState(String sourceName) throws SourceNotFoundException { try { SourceState state = catalogService.getSourceState(sourceName); if(state == null) { return SourceState.badState("Unable to find source."); } return state; } catch (Exception e) { return SourceState.badState(e); } }
private static SourceState getSourceState(SourceState.SourceStatus status, MessageLevel level, String... msgs) { List<Message> messageList = new ArrayList<>(); for (String msg : msgs) { messageList.add(new Message(level, msg)); } return new SourceState(status, messageList); }
case "green": if (connectionPool.getCapabilities().getCapability(SUPPORTS_NEW_FEATURES)) { return SourceState.goodState(String.format("Elastic version %s.", connectionPool.getMinVersionInCluster())); } else { return SourceState.warnState( String.format("Detected Elastic version %s. Full query pushdown in Dremio requires version %s or above.", connectionPool.getMinVersionInCluster(), return SourceState.warnState("Elastic cluster health is yellow."); case "red": return SourceState.badState("Elastic cluster health is red."); default: return SourceState.badState(String.format("Elastic cluster health is unknown health state of %s.", clusterHealth)); return SourceState.badState("Failure getting Elastic health. " + result.getErrorMessage()); return SourceState.badState("Failure getting Elastic health. " + e.getMessage());
@Override public void run() { try { startup = Stopwatch.createStarted(); logger.debug("Starting: {}", sourceConfig.getName()); plugin.start(); setLocals(config); startup.stop(); if (state.getStatus() == SourceStatus.bad) { // Check the state here and throw exception so that we close the partially started plugin properly in the // exception handling code throw new Exception(state.toString()); } future.set(state); } catch(Throwable e) { state = SourceState.badState(e.getMessage()); try { // failed to startup, make sure to close. plugin.close(); plugin = null; } catch (Exception ex) { e.addSuppressed(new RuntimeException("Cleanup exception after initial failure.", ex)); } future.setException(e); } }}));
@Override public SourceState getState() { try { ensureDefaultName(); S3FileSystem fs = getFS(ImpersonationUtil.getProcessUserName()).unwrap(S3FileSystem.class); fs.refreshFileSystems(); List<ContainerFailure> failures = fs.getSubFailures(); if(failures.isEmpty()) { return SourceState.GOOD; } StringBuilder sb = new StringBuilder(); for(ContainerFailure f : failures) { sb.append(f.getName()); sb.append(": "); sb.append(f.getException().getMessage()); sb.append("\n"); } return SourceState.warnState(sb.toString()); } catch (Exception e) { return SourceState.badState(e); } }
@Override public SourceState getState() { return SourceState.goodState(); }
/** * Before doing any operation associated with plugin, we should check the state of the plugin. */ private void checkState() { if(!options.getOption(CatalogOptions.STORAGE_PLUGIN_CHECK_STATE)) { return; } try(AutoCloseableLock l = readLock()) { SourceState state = this.state; if(state.getStatus() == SourceState.SourceStatus.bad) { UserException.Builder builder = UserException.sourceInBadState() .message("The source [%s] is currently unavailable. Info: [%s].", sourceKey, state.getMessages()); for(Message message : state.getMessages()) { builder.addContext(message.getLevel().name(), message.getMessage()); } throw builder.build(logger); } } }
public static SourceState warnState(String... e) { return getSourceState(SourceStatus.warn, MessageLevel.WARN, e); }
public static SourceState badState(String... e) { return getSourceState(SourceStatus.bad, MessageLevel.ERROR, e); }
@Override public SourceState getState() { try { connection.validate(); } catch(Exception ex) { return SourceState.badState(ex); } return SourceState.GOOD; }
@Override public SourceState getState() { // Executors maintain no state about Hive; they do not communicate with the Hive meta store, so only tables can // have a bad state, and not the source. if (!isCoordinator) { return SourceState.GOOD; } try { processUserMetastoreClient.getDatabases(false); return SourceState.GOOD; } catch (Exception ex) { logger.debug("Caught exception while trying to get status of HIVE source, error: ", ex); return new SourceState(SourceStatus.bad, Collections.singletonList(new SourceState.Message(MessageLevel.ERROR, "Failure connecting to source: " + ex.getMessage()))); } }
public static SourceState goodState(String... e){ return getSourceState(SourceStatus.good, MessageLevel.INFO, e); }
@Override public void close() throws Exception { synchronized (fixLock) { Cancellable lastTask = this.fixFailedStartScheduled; if (lastTask != null && !lastTask.isCancelled()) { lastTask.cancel(false); } } try(AutoCloseableLock l = writeLock()) { state = SourceState.badState("Source is being shutdown."); AutoCloseables.close(metadataManager, plugin); } }
public static SourceState badState(Exception e) { return getSourceState(SourceStatus.bad, MessageLevel.ERROR, e.getMessage()); }
@Override public SourceState getState() { final FileSystemWrapper fs = getFS(ImpersonationUtil.getProcessUserName()); if (!fs.isPdfs()) { try { fs.listStatus(config.getPath()); return SourceState.GOOD; } catch (Exception e) { return SourceState.badState(e); } } else { return SourceState.GOOD; } }
this.state = SourceState.badState("Plugin settings changed, restarting.");