@Override public void init() { super.init(); initApp(); }
@Override public void onManagementStarted() { super.onManagementStarted(); startTracker(); }
@Override public void onManagementStarting() { super.onManagementStarting(); Preconditions.checkNotNull(getName(), "Name must be specified"); }
/** * Default entity initialization sets ID sensors and calls {@link #initEnrichers()}. */ @Override public void init() { super.init(); initEnrichers(); if (Strings.isNonBlank(getConfig(DEFAULT_DISPLAY_NAME))) { setDefaultDisplayName(getConfig(DEFAULT_DISPLAY_NAME)); } sensors().set(ENTITY_ID, getId()); sensors().set(APPLICATION_ID, getApplicationId()); sensors().set(CATALOG_ID, getCatalogItemId()); }
/** * 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; }
/** * @deprecated since 0.5; instead use no-arg constructor with EntityManager().createEntity(spec) */ @Deprecated public AbstractEntity(@SuppressWarnings("rawtypes") Map flags, Entity parent) { super(checkConstructorFlags(flags, parent)); // TODO Don't let `this` reference escape during construction entityType = new EntityDynamicType(this); if (isLegacyConstruction()) { AbstractEntity checkWeGetThis = configure(flags); assert this.equals(checkWeGetThis) : this+" configure method does not return itself; returns "+checkWeGetThis+" instead of "+this; boolean deferConstructionChecks = (flags.containsKey("deferConstructionChecks") && TypeCoercions.coerce(flags.get("deferConstructionChecks"), Boolean.class)); if (!deferConstructionChecks) { FlagUtils.checkRequiredFields(this); } } }
@Override public void run() { ((AbstractEntity)entity).init(); ((AbstractEntity)entity).addLocations(MutableList.<Location>of( managementContext.getLocationManager().createLocation(taggedSpec))); ((AbstractEntity)entity).addLocations(spec.getLocations());
final AbstractEntity theEntity = (AbstractEntity) entity; if (spec.getDisplayName()!=null) theEntity.setDisplayName(spec.getDisplayName()); theEntity.setCatalogItemIdAndSearchPath(spec.getCatalogItemId(), spec.getCatalogItemIdSearchPath()); addSpecParameters(spec, theEntity.getMutableEntityType()); theEntity.configure(MutableMap.copyOf(spec.getFlags())); for (Map.Entry<ConfigKey<?>, Object> entry : spec.getConfig().entrySet()) { entity.config().set((ConfigKey)entry.getKey(), entry.getValue()); parent = (parent instanceof AbstractEntity) ? ((AbstractEntity)parent).getProxyIfAvailable() : parent; entity.setParent(parent);
if (entity.getParent()!=null) entity.getParent().removeChild(entity.getProxyIfAvailable()); entity.onManagementNoLongerMaster(); entity.onManagementStopped();
@Override protected void initEnrichers() { super.initEnrichers(); // Because can have multiple children (similar to groups/clusters/apps), need to // monitor their health and indicate this has failed if any of them have failed. enrichers().add(ServiceStateLogic.newEnricherFromChildren() .suppressDuplicates(true) .configure(ComputeServiceIndicatorsFromChildrenAndMembers.UP_QUORUM_CHECK, QuorumCheck.QuorumChecks.all())); }
entity.onManagementBecomingMaster(); entity.onManagementStarted();
@Override public AbstractEntity configure(Map flags) { this.configureProperties = flags; configureCount++; return super.configure(flags); }
@Override public void destroy() { setServiceState(Lifecycle.DESTROYED); super.destroy(); }
@Override public RabbitBroker getParent() { return (RabbitBroker) super.getParent(); }
@Override protected void initEnrichers() { super.initEnrichers(); enrichers().add(ServiceStateLogic.newEnricherFromChildrenUp() .checkChildrenOnly() .requireUpChildren(QuorumCheck.QuorumChecks.all()) .suppressDuplicates(true)); }
@Override public AbstractEntity configure(Map flags) { configureCount++; return super.configure(flags); }
@Override public void destroy() { disconnectSensors(); delete(); super.destroy(); } }
@Override public void init() { super.init(); sensors().set(SERVER_POOL_TARGETS, ImmutableMap.<Entity, String>of()); }
@Override public void onManagementStarting() { super.onManagementStarting(); Lifecycle state = getAttribute(SERVICE_STATE_ACTUAL); if (state == null || state == Lifecycle.CREATED) { // Expect this is a normal start() sequence (i.e. start() will subsequently be called) sensors().set(SERVICE_UP, false); ServiceStateLogic.setExpectedState(this, Lifecycle.CREATED); // force actual to be created because this is expected subsequently sensors().set(SERVICE_STATE_ACTUAL, Lifecycle.CREATED); } }
@Override public void onManagementStarted() { super.onManagementStarted(); if (!isRebinding()) { recordApplicationEvent(Lifecycle.CREATED); } }