@Override public void destroy() { setServiceState(Lifecycle.DESTROYED); super.destroy(); }
@Override public void onManagementStarting() { super.onManagementStarting(); Preconditions.checkNotNull(getName(), "Name must be specified"); }
/** * Returns the application, looking it up if not yet known (registering if necessary) */ @Override public Application getApplication() { if (application != null) return application; Entity parent = getParent(); Application app = (parent != null) ? parent.getApplication() : null; if (app != null) { if (getManagementSupport().isFullyManaged()) // only do this once fully managed, in case root app becomes parented setApplication(app); } return app; }
@Override public void refreshInheritedConfig() { if (getParent() != null) { configsInternal.setInheritedConfig(((EntityInternal)getParent()).getAllConfig()); } else { configsInternal.clearInheritedConfig(); } refreshInheritedConfigOfChildren(); }
((AbstractEntity)entity).setDisplayName(spec.getDisplayName()); ((AbstractEntity)entity).setManagementContext(managementContext); ((AbstractEntity)entity).setProxy(createEntityProxy(spec, entity)); ((AbstractEntity)entity).configure(MutableMap.copyOf(spec.getFlags())); ((EntityLocal)entity).setConfig((ConfigKey)entry.getKey(), entry.getValue()); ((AbstractEntity)entity).init(); for (EntityInitializer initializer: spec.getInitializers()) initializer.apply((EntityInternal)entity); parent = (parent instanceof AbstractEntity) ? ((AbstractEntity)parent).getProxyIfAvailable() : parent; entity.setParent(parent);
if (entity.getParent()!=null) entity.getParent().removeChild(entity.getProxyIfAvailable()); entity.onManagementNoLongerMaster(); entity.onManagementStopped();
entity.onManagementBecomingMaster(); entity.onManagementStarted();
@GET @Path("/{config}") @ApiOperation(value = "Fetch config value", responseClass = "Object") @ApiErrors(value = { @ApiError(code = 404, reason = "Could not find application, entity or config key") }) public String get( @ApiParam(value = "Application ID or name", required = true) @PathParam("application") String application, @ApiParam(value = "Entity ID or name", required = true) @PathParam("entity") String entityToken, @ApiParam(value = "Config key ID", required = true) @PathParam("config") String configKeyName ) { EntityLocal entity = brooklyn().getEntity(application, entityToken); ConfigKey<?> ck = entity.getEntityType().getConfigKey(configKeyName); if (ck==null) ck = new BasicConfigKey<Object>(Object.class, configKeyName); return getValueForDisplay(entity, ((AbstractEntity)entity).getConfigMap().getRawConfig(ck)); }
@Override public void onManagementBecomingMaster() { super.onManagementBecomingMaster(); beginPoll(); } @Override
@Override public void onManagementNoLongerMaster() { endPoll(); super.onManagementNoLongerMaster(); }
/** Default String representation is simplified name of class, together with selected fields. */ @Override public String toString() { return toStringHelper().toString(); }
@Override public void init() { super.init(); setAttribute(Changeable.GROUP_SIZE, 0); }
@Override public RabbitBroker getParent() { return (RabbitBroker) super.getParent(); }
@Override public void onManagementStarted() { super.onManagementStarted(); Lifecycle state = getAttribute(SERVICE_STATE); if (state != null && state != Lifecycle.CREATED) { postRebind(); } }
@Override public String get(String application, String entityToken, String configKeyName) { EntityLocal entity = brooklyn().getEntity(application, entityToken); ConfigKey<?> ck = entity.getEntityType().getConfigKey(configKeyName); if (ck==null) ck = new BasicConfigKey<Object>(Object.class, configKeyName); return getValueForDisplay(entity, ((AbstractEntity)entity).getConfigMap().getRawConfig(ck)); }
@Override protected ToStringHelper toStringHelper() { return super.toStringHelper().add("virtualHost", getParent().getVirtualHost()).add("exchange", getExchangeName()); } }
@Override public void init() { super.init();
public void destroy() { disconnectSensors(); delete(); super.destroy(); } }
@Override public void onManagementStarting() { super.onManagementStarting(); Lifecycle state = getAttribute(SERVICE_STATE); if (state == Lifecycle.RUNNING) { rebind(); } else if (state != null && state != Lifecycle.CREATED) { log.warn("On start-up of {}, not (re)binding because state is {}", this, state); } else { // Expect this is a normal start() sequence (i.e. start() will subsequently be called) setAttribute(SERVICE_UP, false); setAttribute(SERVICE_STATE, Lifecycle.CREATED); } }
/** * stops, destroys, and unmanages the given application -- and terminates the mangaement context; * does as many as are valid given the type and state * @deprecated since 0.6.0 use destroy(Application) if you DONT want to destroy the mgmt context, * or destroy(app.getManagementContext()) if you want to destory everything in the app's mgmt context */ @Deprecated public static void destroyAll(Application app) { if (isManaged(app)) { ManagementContext managementContext = app.getManagementContext(); if (app instanceof Startable) Entities.invokeEffector((EntityLocal)app, app, Startable.STOP).getUnchecked(); if (app instanceof AbstractEntity) ((AbstractEntity)app).destroy(); unmanage(app); if (managementContext instanceof ManagementContextInternal) ((ManagementContextInternal)managementContext).terminate(); } }