} catch (Exception e) { Exceptions.propagateIfFatal(e); ServiceProblemsLogic.updateProblemsIndicator(this, "children", "Could not add child; removing all new children for now: "+Exceptions.collapseText(e)); ServiceProblemsLogic.clearProblemsIndicator(this, "children"); buckets.put(name, bucket);
ServiceProblemsLogic.clearProblemsIndicator(this, START); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL, "Application starting"); ServiceStateLogic.ServiceNotUpLogic.clearNotUpIndicator(this, START.getName());
ServiceStateLogic.ServiceProblemsLogic.updateProblemsIndicator(e1, "test", "foo"); EntityAsserts.assertAttributeEqualsEventually(e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null); ServiceStateLogic.ServiceProblemsLogic.clearProblemsIndicator(e1, "test"); EntityAsserts.assertAttributeEqualsEventually(e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertHasEventEventually(HASensors.ENTITY_RECOVERED, Predicates.<Object>equalTo(e1), null);
ServiceProblemsLogic.clearProblemsIndicator(this, START); ServiceStateLogic.ServiceNotUpLogic.updateNotUpIndicator(this, Attributes.SERVICE_STATE_ACTUAL, "Application starting"); ServiceStateLogic.ServiceNotUpLogic.clearNotUpIndicator(this, START.getName());
ServiceProblemsLogic.updateProblemsIndicator(entity, INDICATOR_KEY_1, "We're pretending to block service state also"); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED); ServiceProblemsLogic.clearProblemsIndicator(entity, INDICATOR_KEY_1); assertAttributeEqualsEventually(entity, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
ServiceProblemsLogic.clearProblemsIndicator(this, START); try { doStart(); DynamicTasks.waitForLast(); } catch (Exception e) { ServiceProblemsLogic.updateProblemsIndicator(this, START, "start failed with error: "+e); ServiceStateLogic.setExpectedStateRunningWithErrors(this); throw Exceptions.propagate(e);
ServiceProblemsLogic.updateProblemsIndicator(this, MASTER_NODE, MSG_NO_MASTER); return null; ServiceStateLogic.ServiceProblemsLogic.clearProblemsIndicator(this, MASTER_NODE); return (BrooklynNode)Iterables.getOnlyElement(masters); ServiceProblemsLogic.updateProblemsIndicator(this, MASTER_NODE, MSG_TOO_MANY_MASTERS); String msg = "Multiple (>=3) master nodes in cluster: " + masters; LOG.error(msg);
@Test(groups="Integration") // Has a 1 second wait public void testOnFailureDelayFromProblemAndRecover() throws Exception { e1.enrichers().add(EnricherSpec.create(ServiceFailureDetector.class) .configure(ServiceFailureDetector.SERVICE_ON_FIRE_STABILIZATION_DELAY, Duration.ONE_SECOND) .configure(ServiceFailureDetector.ENTITY_RECOVERED_STABILIZATION_DELAY, Duration.ONE_SECOND)); // Set the entity to healthy e1.sensors().set(TestEntity.SERVICE_UP, true); ServiceStateLogic.setExpectedState(e1, Lifecycle.RUNNING); EntityAsserts.assertAttributeEqualsEventually(e1, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); // Make the entity fail; won't set on-fire for 1s but will publish FAILED immediately. ServiceStateLogic.ServiceProblemsLogic.updateProblemsIndicator(e1, "test", "foo"); EntityAsserts.assertAttributeEqualsContinually(ImmutableMap.of("timeout", 100), e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null); assertEquals(e1.getAttribute(TestEntity.SERVICE_STATE_ACTUAL), Lifecycle.RUNNING); EntityAsserts.assertAttributeEqualsEventually(e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); // Now recover: will publish RUNNING immediately, but has 1s stabilisation for RECOVERED ServiceStateLogic.ServiceProblemsLogic.clearProblemsIndicator(e1, "test"); EntityAsserts.assertAttributeEqualsEventually(e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); assertEquals(events.size(), 1, "events="+events); assertHasEventEventually(HASensors.ENTITY_RECOVERED, Predicates.<Object>equalTo(e1), null); assertEquals(events.size(), 2, "events="+events); }
@Override public void init() { super.init(); getMutableEntityType().addEffector(SelectMasterEffectorBody.SELECT_MASTER); getMutableEntityType().addEffector(BrooklynClusterUpgradeEffectorBody.UPGRADE_CLUSTER); ServiceProblemsLogic.updateProblemsIndicator(this, MASTER_NODE, MSG_NO_MASTER); addFeed(FunctionFeed.builder() .entity(this) .poll(new FunctionPollConfig<Object, BrooklynNode>(MASTER_NODE) .period(Duration.ONE_SECOND) .callable(new MasterChildFinder())) .build()); enrichers().add( Enrichers.builder().transforming(MASTER_NODE) .uniqueTag("master-node-web-uri") .publishing(BrooklynNode.WEB_CONSOLE_URI) .computing(EntityFunctions.attribute(BrooklynNode.WEB_CONSOLE_URI)) .build() ); }
@Test public void testCreatesDriverAfterRebind() throws Exception { MyService origE = origApp.createAndManageChild(EntitySpec.create(MyService.class) .configure(BrooklynConfigKeys.SKIP_ON_BOX_BASE_DIR_RESOLUTION, true)); //the entity skips enricher initialization, do it explicitly origE.enrichers().add(ServiceStateLogic.newEnricherForServiceStateFromProblemsAndUp()); MyProvisioningLocation origLoc = mgmt().getLocationManager().createLocation(LocationSpec.create(MyProvisioningLocation.class) .displayName("mylocname")); origApp.start(ImmutableList.of(origLoc)); assertEquals(origE.getAttribute(Attributes.SERVICE_STATE_EXPECTED).getState(), Lifecycle.RUNNING); EntityAsserts.assertAttributeEqualsEventually(origE, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); ServiceProblemsLogic.updateProblemsIndicator(origE, "test", "fire"); EntityAsserts.assertAttributeEqualsEventually(origE, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); newApp = rebind(); MyService newE = (MyService) Iterables.getOnlyElement(newApp.getChildren()); assertTrue(newE.getDriver() != null, "driver should be initialized"); }
@Test public void testNotifiedOfRecoveryFromProblems() throws Exception { e1.enrichers().add(EnricherSpec.create(ServiceFailureDetector.class)); e1.sensors().set(TestEntity.SERVICE_UP, true); ServiceStateLogic.setExpectedState(e1, Lifecycle.RUNNING); // Make the entity fail ServiceProblemsLogic.updateProblemsIndicator(e1, "test", "foo"); assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null); EntityAsserts.assertAttributeEqualsEventually(e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); // And make the entity recover ServiceProblemsLogic.clearProblemsIndicator(e1, "test"); assertHasEventEventually(HASensors.ENTITY_RECOVERED, Predicates.<Object>equalTo(e1), null); assertEquals(events.size(), 2, "events="+events); EntityAsserts.assertAttributeEqualsEventually(e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); }
@Test public void testNotifiedOfFailureOnProblem() throws Exception { e1.enrichers().add(EnricherSpec.create(ServiceFailureDetector.class)); e1.sensors().set(TestEntity.SERVICE_UP, true); ServiceStateLogic.setExpectedState(e1, Lifecycle.RUNNING); assertEquals(events.size(), 0, "events="+events); ServiceProblemsLogic.updateProblemsIndicator(e1, "test", "foo"); assertHasEventEventually(HASensors.ENTITY_FAILED, Predicates.<Object>equalTo(e1), null); assertEquals(events.size(), 1, "events="+events); EntityAsserts.assertAttributeEqualsEventually(e1, TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.ON_FIRE); }
@Override public void update() { try { Task<?> task = updateAsync(); if (task != null) task.getUnchecked(); ServiceStateLogic.ServiceProblemsLogic.clearProblemsIndicator(this, "update"); } catch (Exception e) { ServiceStateLogic.ServiceProblemsLogic.updateProblemsIndicator(this, "update", "update failed with: "+Exceptions.collapseText(e)); throw Exceptions.propagate(e); } }
protected void onReplacementFailed(String msg) { LOG.warn("ServiceReplacer failed for "+entity+": "+msg); consecutiveReplacementFailureTimes.add(currentTimeMillis()); if (getConfig(SET_ON_FIRE_ON_FAILURE)) { ServiceProblemsLogic.updateProblemsIndicator(entity, "ServiceReplacer", "replacement failed: "+msg); } entity.sensors().emit(ENTITY_REPLACEMENT_FAILED, new FailureDescriptor(entity, msg)); } }
@Override public void update() { try { Task<?> task = updateAsync(); if (task != null) task.getUnchecked(); ServiceStateLogic.ServiceProblemsLogic.clearProblemsIndicator(this, "update"); } catch (Exception e) { ServiceStateLogic.ServiceProblemsLogic.updateProblemsIndicator(this, "update", "update failed with: "+Exceptions.collapseText(e)); throw Exceptions.propagate(e); } }