@Override public LifecycleStatus getLifecycleStatus() { return delegate.getLifecycleStatus(); }
@Override public LifecycleStatus getLifecycleStatus() { return getDelegate().getLifecycleStatus(); }
@Override public T get(String key) throws SiteWhereException { if (getParent().getLifecycleStatus() == LifecycleStatus.Started) { T result = (T) hMap.get(key); requestCount.incrementAndGet(); if (result != null) { hitCount.incrementAndGet(); } return result; } else { throw new SiteWhereException("Cache get() called after shutdown."); } }
/** * Recursively log state for a component. * * @param pad * @param component */ protected String logState(String pad, ILifecycleComponent component) { String entry = "\n" + pad + "+ " + component.getComponentName() + " " + component.getLifecycleStatus(); List<ILifecycleComponent> subcomponents = new ArrayList<ILifecycleComponent>( component.getLifecycleComponents().values()); // Sort components by created date. Collections.sort(subcomponents, new Comparator<ILifecycleComponent>() { @Override public int compare(ILifecycleComponent o1, ILifecycleComponent o2) { return o1.getCreatedDate().compareTo(o2.getCreatedDate()); } }); for (ILifecycleComponent subcomponent : subcomponents) { entry = entry + logState(" " + pad, subcomponent); } return entry; }
/** * Recursively log state for a component. * * @param pad * @param component */ protected String logState(String pad, ILifecycleComponent component) { String entry = "\n" + pad + "+ " + component.getComponentName() + " " + component.getLifecycleStatus(); List<ILifecycleComponent> subcomponents = new ArrayList<ILifecycleComponent>( component.getLifecycleComponents().values()); // Sort components by created date. Collections.sort(subcomponents, new Comparator<ILifecycleComponent>() { @Override public int compare(ILifecycleComponent o1, ILifecycleComponent o2) { return o1.getCreatedDate().compareTo(o2.getCreatedDate()); } }); for (ILifecycleComponent subcomponent : subcomponents) { entry = entry + logState(" " + pad, subcomponent); } return entry; }
@Override public void put(String key, T value) throws SiteWhereException { if (getParent().getLifecycleStatus() == LifecycleStatus.Started) { hMap.put(key, value); } else { throw new SiteWhereException("Cache put() called after shutdown."); } }
@Override public void clear() throws SiteWhereException { if (getParent().getLifecycleStatus() == LifecycleStatus.Started) { hMap.clear(); } else { throw new SiteWhereException("Cache clear() called after shutdown."); } }
@Override public void remove(String key) throws SiteWhereException { if (getParent().getLifecycleStatus() == LifecycleStatus.Started) { hMap.remove(key); } else { throw new SiteWhereException("Cache put() called after shutdown."); } }
@Override public int getElementCount() throws SiteWhereException { if (getParent().getLifecycleStatus() == LifecycleStatus.Started) { return hMap.size(); } else { throw new SiteWhereException("Cache getElementCount() called after shutdown."); } }
public void startNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor, String errorMessage, boolean require) throws SiteWhereException { component.lifecycleStart(monitor); if (require) { if (component.getLifecycleStatus() == LifecycleStatus.Error) { throw new ServerStartupException(component, errorMessage); } } getLifecycleComponents().put(component.getComponentId(), component); }
public void startNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor, boolean require) throws SiteWhereException { component.lifecycleStart(monitor); if (require) { if (component.getLifecycleStatus() == LifecycleStatus.LifecycleError) { throw new ServerStartupException(component, "Unable to start '" + component.getComponentName() + "'", component.getLifecycleError()); } } getLifecycleComponents().put(component.getComponentId(), component); }
@Override public void stopNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor) throws SiteWhereException { component.lifecycleStop(monitor); if (component.getLifecycleStatus() == LifecycleStatus.LifecycleError) { getLogger().error("Unable to stop '" + component.getComponentName() + "'", component.getLifecycleError()); } getLifecycleComponents().remove(component.getComponentId(), component); }
@Override public void initializeNestedComponent(ILifecycleComponent component, ILifecycleProgressMonitor monitor, boolean require) throws SiteWhereException { if (getMicroservice() == null) { throw new SiteWhereException("Microservice reference not set in parent component: " + getClass().getName()); } component.setMicroservice(getMicroservice()); component.lifecycleInitialize(monitor); if (require) { if (component.getLifecycleStatus() == LifecycleStatus.InitializationError) { throw new ServerStartupException(component, "Error initializing '" + component.getComponentName() + "'", component.getLifecycleError()); } } getLifecycleComponents().put(component.getComponentId(), component); }
/** * Recursive call to capture hierarchy of components. * * @param parent * @param results */ protected void getComponentHierarchyState(ILifecycleComponent parent, List<ITenantEngineComponent> results) { Map<String, ILifecycleComponent> children = parent.getLifecycleComponents(); for (ILifecycleComponent child : children.values()) { TenantEngineComponent component = new TenantEngineComponent(); component.setId(child.getComponentId()); component.setName(child.getComponentName()); component.setStatus(child.getLifecycleStatus()); component.setType(child.getComponentType()); component.setParentId(parent.getComponentId()); results.add(component); getComponentHierarchyState(child, results); } }
for (UUID id : getLifecycleComponents().keySet()) { ILifecycleComponent sub = getLifecycleComponents().get(id); if ((sub.getLifecycleStatus() == LifecycleStatus.LifecycleError) || (sub.getLifecycleStatus() == LifecycleStatus.StoppedWithErrors)) { status = LifecycleStatus.StoppedWithErrors;
for (UUID id : getLifecycleComponents().keySet()) { ILifecycleComponent sub = getLifecycleComponents().get(id); if ((sub.getLifecycleStatus() == LifecycleStatus.LifecycleError) || (sub.getLifecycleStatus() == LifecycleStatus.StartedWithErrors)) { status = LifecycleStatus.StartedWithErrors;