@Override public void init() { super.init(); constructed = true; exampleAppConstructed = true; } @Override public void start(Collection<? extends Location> locations) {
this.addLocations(locations); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL, "Application starting"); ServiceStateLogic.ServiceNotUpLogic.clearNotUpIndicator(this, START.getName()); setExpectedStateAndRecordLifecycleEvent(Lifecycle.STARTING); try { try { preStart(locationsToUse); Object val = config().get(START_LATCH); if (val != null) log.debug("{} finished waiting for start-latch; continuing...", this); doStart(locationsToUse); postStart(locationsToUse); recordApplicationEvent(Lifecycle.ON_FIRE); ServiceStateLogic.setExpectedStateRunningWithErrors(this); setExpectedStateAndRecordLifecycleEvent(Lifecycle.RUNNING); logApplicationLifecycle("Started");
@Override public void stop() { super.stop(); running = false; exampleAppRunning = false; } }
@Override public void doStart(Collection<? extends Location> locs) { List<Location> locations = MutableList.of(); sensors().set(SERVICE_UP, Boolean.FALSE); ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); LOG.info("Creating new MesosLocation"); createLocation(MutableMap.<String, Object>of()); // Start frameworks try { Group frameworks = sensors().get(MESOS_FRAMEWORKS); Entities.invokeEffectorList(this, frameworks.getMembers(), Startable.START, ImmutableMap.of("locations", locations)).getUnchecked(); } catch (Exception e) { LOG.warn("Error starting frameworks", e); ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE); Exceptions.propagate(e); } super.doStart(locations); connectSensors(); ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING); sensors().set(SERVICE_UP, Boolean.TRUE); }
protected void doStart(Collection<? extends Location> locations) { doStartChildren(locations); }
/** as {@link AbstractEntity#initEnrichers()} but also adding default service not-up and problem indicators from children */ @Override protected void initEnrichers() { super.initEnrichers(); // default app logic; easily overridable by adding a different enricher with the same tag ServiceStateLogic.newEnricherFromChildren().checkChildrenAndMembers() .configure(ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers.UP_QUORUM_CHECK, config().get(UP_QUORUM_CHECK)) .configure(ServiceStateLogic.ComputeServiceIndicatorsFromChildrenAndMembers.RUNNING_QUORUM_CHECK, config().get(RUNNING_QUORUM_CHECK)) .addTo(this); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL, "Application created but not yet started, at "+Time.makeDateString()); }
@Override public void doStart(Collection<? extends Location> locs) { addLocations(locs); List<Location> locations = MutableList.copyOf(Locations.getLocationsCheckingAncestors(locs, this)); sensors().set(SERVICE_UP, Boolean.FALSE); ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING); // TODO support multiple provisioners Location provisioner = Iterables.getOnlyElement(locations); LOG.info("Creating new DockerLocation wrapping {}", provisioner); Map<String, ?> flags = MutableMap.<String, Object>builder() .putAll(config().get(LOCATION_FLAGS)) .put("provisioner", provisioner) .putIfNotNull("strategies", config().get(PLACEMENT_STRATEGIES)) .build(); createLocation(flags); super.doStart(locations); ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING); sensors().set(SERVICE_UP, Boolean.TRUE); }
@Override public void init() { // Code below copied from BasicAppliationImpl. // Set the default name *before* calling super.init(), and only do so if we don't have an // explicit default. This is a belt-and-braces fix: before we overwrote the defaultDisplayName // that was inferred from the catalog item name. if (Strings.isBlank(getConfig(DEFAULT_DISPLAY_NAME))) { setDefaultDisplayName("Application ("+getId()+")"); } super.init(); }
@Override public void doStart(Collection<? extends Location> locations) { // TODO support multiple locations sensors().set(SERVICE_UP, Boolean.FALSE); Location provisioner = Iterables.getOnlyElement(locations); LOG.info("Creating new DockerLocation wrapping {}", provisioner); Map<String, ?> flags = MutableMap.<String, Object>builder() .putAll(config().get(LOCATION_FLAGS)) .put("provisioner", provisioner) .build(); createLocation(flags); super.doStart(locations); sensors().set(SERVICE_UP, Boolean.TRUE); }
super.stop(); } catch (Exception e) { LOG.warn("Error stopping children", e);
@Override public void init() { // Set the default name *before* calling super.init(), and only do so if we don't have an // explicit default. This is a belt-and-braces fix: before we overwrote the defaultDisplayName // that was inferred from the catalog item name. if (Strings.isBlank(getConfig(DEFAULT_DISPLAY_NAME))) { setDefaultDisplayName("Application ("+getId()+")"); } super.init(); }
LOG.info("Starting Mesos cluster id {}", getId()); registerLocationResolver(); super.init();
@Override public void init() { super.init();