@Override public void run() { Entities.unmanage(dryRunChild); } }
protected void discardNode(Entity entity) { removeMember(entity); try { Entities.unmanage(entity); } catch (IllegalStateException e) { //probably already unmanaged LOG.debug("Exception during removing member of cluster " + this + ", unmanaging node " + entity + ". The node is probably already unmanaged.", e); } }
@Override public Void call() { try { containerToStop.offloadAndStop(containers.get(containers.size()-1)); Entities.unmanage(containerToStop); } catch (Throwable t) { LOG.error("Error stopping container "+containerToStop, t); } return null; }}); }
@Override public void run() { try { addingMemberReachedLatch.await(); } catch (InterruptedException e) { throw Exceptions.propagate(e); } Entities.unmanage(e2); }});
@Override public void removeHost(DockerHost host) { SdnAgent agent = host.sensors().get(SdnAgent.SDN_AGENT); if (agent == null) { LOG.warn("{} cannot find Weave service: {}", this, host); return; } agent.stop(); getAgents().removeMember(agent); Entities.unmanage(agent); LOG.debug("{} removed Weave service {}", this, agent); }
@Test public void testManaged() throws Exception { assertTrue(EntityPredicates.isManaged().apply(entity)); Entities.unmanage(entity); assertFalse(EntityPredicates.isManaged().apply(entity)); }
protected void stopAndRemoveNode(Entity member) { removeMember(member); try { if (member instanceof Startable) { Task<?> task = newThrottledEffectorTask(member, Startable.STOP, Collections.<String, Object>emptyMap()); DynamicTasks.queueIfPossible(task).orSubmitAsync(); task.getUnchecked(); } } finally { Entities.unmanage(member); } }
@Test(groups = "Integration") public void testTargetMappingsRemovesUnmanagedMember() { Iterable<StubAppServer> members = Iterables.filter(cluster.getChildren(), StubAppServer.class); assertEquals(Iterables.size(members), 2); StubAppServer target1 = Iterables.get(members, 0); StubAppServer target2 = Iterables.get(members, 1); // First wait for targets to be listed assertExpectedTargetsEventually(members); // Unmanage one member, and expect the URL Mapping to be updated accordingly Entities.unmanage(target1); assertExpectedTargetsEventually(ImmutableSet.of(target2)); }
@Test public void testUnmanagedMemberAutomaticallyRemoved() throws Exception { group.addMember(entity1); Entities.unmanage(entity1); assertGroupMembers(new Entity[0]); }
@Test public void testUnmanagedGroupAutomaticallyRemovedMembers() throws Exception { group.addMember(entity1); Entities.unmanage(group); Asserts.assertEqualsIgnoringOrder(entity1.groups(), ImmutableSet.of()); }
@Test public void testStartOnManagedAppDoesNotStartUnmanagedChildren() { TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class)); Entities.unmanage(child); app.start(locs); assertEquals(child.getCallHistory(), ImmutableList.of()); }
@Override public void deleteUnmanagedTasks() { for (Entity member : getTaskCluster().getMembers()) { if (member instanceof MesosTask && Boolean.FALSE.equals(member.config().get(MesosTask.MANAGED))) { // TODO Presumably `unmanage(member)` would be enough, but leaving like this // because that is what Andrew previously used! getTaskCluster().removeMember(member); getTaskCluster().removeChild(member); Entities.unmanage(member); } } }
@Test public void testStopDoesNotStopUnmanagedChildren() { TestEntity child = app.createAndManageChild(EntitySpec.create(TestEntity.class)); app.start(locs); assertEquals(child.getCallHistory(), ImmutableList.of("start")); Entities.unmanage(child); app.stop(); assertEquals(child.getCallHistory(), ImmutableList.of("start")); }
@Test public void testUnmanageEntityRemovedAsChild() { Entity e = app.addChild(EntitySpec.create(TestEntity.class)); Entities.unmanage(e); assertEqualsIgnoringOrder(app.getChildren(), ImmutableList.of()); assertEquals(e.getParent(), null); }
@Test public void testStartManagementFailsIfAppDeleted() throws Exception { TestApplication app2 = mgmt.getEntityManager().createEntity(EntitySpec.create(TestApplication.class)); Entities.unmanage(app2); try { Entities.startManagement(app2, mgmt); fail("Managed deleted app "+app2+" in "+mgmt); } catch (IllegalStateException e) { if (!(e.toString().contains("No concrete entity known"))) throw e; } }
@Test public void testContainerRemovedWillRemoveItsItems() throws Exception { MockContainerEntity containerA = newContainer(app, "A", "ingroup"); MockItemEntity item1 = newItem(app, containerA, "1"); assertItemsEventually(item1); Entities.unmanage(containerA); assertItemsEventually(); }
@Test public void testGroupRemovesUnmanagedEntity() throws Exception { group.setEntityFilter(EntityPredicates.idEqualTo(e1.getId())); assertEqualsIgnoringOrder(group.getMembers(), ImmutableSet.of(e1)); Entities.unmanage(e1); Asserts.succeedsEventually(new Runnable() { @Override public void run() { assertEqualsIgnoringOrder(group.getMembers(), ImmutableSet.of()); }}); }
@Override public Void call() throws Exception { TestEntity entity = app.addChild(EntitySpec.create(TestEntity.class)); entity.sensors().set(TestEntity.SERVICE_UP, true); entity.sensors().set(TestEntity.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING); Thread.sleep(10); assertEquals(entity.sensors().get(TestEntity.SERVICE_UP), Boolean.TRUE); assertEquals(entity.sensors().get(TestEntity.SERVICE_STATE_ACTUAL), Lifecycle.RUNNING); Entities.unmanage(entity); return null; }}); futures.add(future);