@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 void run() { try { SourceState state = future.checkedGet(); plugin.initiateMetadataRefresh(); String result = state.getStatus() == SourceStatus.bad ? "started in bad state" : "started sucessfully"; logger.info("Plugin {} {} after {}ms. Current status: {}", plugin.getName(), result, plugin.getStartupTime(), state); } catch (Exception ex) { logger.error("Failure while starting plugin {} after {}ms.", plugin.getName(), plugin.getStartupTime(), ex); plugin.initiateFixFailedStartTask(); } }
@Override public void run() { try { refreshState(); initiateMetadataRefresh(); } catch (Exception e) { // Failure to refresh state means that we should just reschedule the next fix } synchronized(fixLock) { if (state.getStatus() == SourceState.SourceStatus.bad) { // Failed to start, again. Schedule the next retry final long nextRefresh = getNextScheduledTimeMs(); fixFailedStartScheduled = scheduler.schedule(ScheduleUtils.scheduleForRunningOnceAt(Instant.ofEpochMilli(nextRefresh)), fixFailedStartTask); } else { // Successful start fixFailedStartTask = null; fixFailedStartScheduled = null; } } }
SourceState state = future.checkedGet(); p.initiateMetadataRefresh(); String result = state.getStatus() == SourceStatus.bad ? "started in bad state" : "success"; sb.append(String.format("\t%s: %s (%dms). %s\n", name, result, p.getStartupTime(), state)); }catch (Exception ex) {
SourceState.SourceStatus sourceStatus = sourceState.getStatus();
@Override public RuleSet getStorageRules(OptimizerRulesContext context, PlannerPhase phase) { final ImmutableSet.Builder<RelOptRule> rules = ImmutableSet.builder(); final Set<SourceType> types = new HashSet<>(); try { for(ManagedStoragePlugin plugin : plugins.managed()){ if(plugin.getState().getStatus() == SourceStatus.bad) { // we shouldn't consider rules for misbehaving plugins. continue; } final StoragePluginId pluginId = plugin.getId(); StoragePluginRulesFactory factory = plugin.getRulesFactory(); if(factory != null) { // add instance level rules. rules.addAll(factory.getRules(context, phase, pluginId)); // add type level rules. if(types.add(pluginId.getType())) { rules.addAll(factory.getRules(context, phase, pluginId.getType())); } } } } catch (InstantiationException | IllegalAccessException e) { throw UserException.validationError(e).message("Failure getting plugin rules.").build(logger); } ImmutableSet<RelOptRule> rulesSet = rules.build(); return RuleSets.ofList(rulesSet); }
msp.refreshState(); SourceState sourceState = msp.getState(); if (sourceState == null || sourceState.getStatus() == SourceStatus.bad) { logger.info("Ignoring metadata load for source {} since it is currently in a bad state.", sourceKey); return;
if(SourceStatus.bad == state.getStatus()) { logger.warn("Source [{}] in bad state after synchronization. Info: {}", targetConfig.getName(), state);
/** * 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); } } }
if (SourceStatus.bad == state.getStatus() && context.get().getOptionManager().getOption(CatalogOptions.STORAGE_PLUGIN_CHECK_STATE)) { plugins.deleteSource(config);