@Override public void handleErrorInTracerSpan(ActiveSpan span, Throwable t) { TracerUtils.handleErrorInTracerSpan(span, t); }
@Override public void execute(ILifecycleProgressMonitor monitor) throws SiteWhereException { monitor.pushContext(new LifecycleProgressContext(steps.size(), getName())); try { for (ILifecycleStep step : steps) { LOGGER.debug("Starting " + step.getName()); ActiveSpan span = monitor.getMicroservice().getTracer().activeSpan(); try { TracerUtils.logToSpan(span, "Starting step '" + step.getName() + "'."); monitor.startProgress(step.getName()); step.execute(monitor); monitor.finishProgress(); } catch (SiteWhereException e) { TracerUtils.handleErrorInTracerSpan(span, e); throw e; } catch (Throwable t) { SiteWhereException e = new SiteWhereException("Unhandled exception in composite lifecycle step.", t); TracerUtils.handleErrorInTracerSpan(span, e); throw e; } } } finally { monitor.popContext(); } }
@Override public void waitForInstanceInitialization() throws SiteWhereException { ActiveSpan span = null; try { span = getTracer().buildSpan("Wait for instance to be bootstrapped").startActive(); getLogger().info(MicroserviceMessages.INSTANCE_VERIFY_BOOTSTRAPPED); while (true) { if (getZookeeperManager().getCurator().checkExists().forPath(getInstanceBootstrappedMarker()) != null) { break; } getLogger().info(MicroserviceMessages.INSTANCE_BOOTSTRAP_MARKER_NOT_FOUND, getInstanceBootstrappedMarker()); Thread.sleep(INSTANCE_BOOTSTRAP_CHECK_INTERVAL_SECS * 1000); } getLogger().info(MicroserviceMessages.INSTANCE_BOOTSTRAP_CONFIRMED); } catch (Exception e) { TracerUtils.handleErrorInTracerSpan(span, e); throw new SiteWhereException("Error waiting on instance to be bootstrapped.", e); } finally { TracerUtils.finishTracerSpan(span); } }
} catch (Throwable t) { LOGGER.error("Unable to bootstrap tenant engine for '" + getTenantEngine().getTenant().getName() + "'.", t); TracerUtils.handleErrorInTracerSpan(span, t); getCompletableFuture().completeExceptionally(t); throw t;