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); } }
@Override public SourceState getState() { try { connection.validate(); } catch(Exception ex) { return SourceState.badState(ex); } return SourceState.GOOD; }
@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); } }
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 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); } }
@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.");