org.apache.brooklyn.core.entity.AbstractEntity Java Examples
The following examples show how to use
org.apache.brooklyn.core.entity.AbstractEntity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpecParameterParsingOsgiTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testOsgiClassScanned() { TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH); TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_V2_PATH); addCatalogItems(CatalogScanOsgiTest.bomForLegacySiblingLibraries()); RegisteredType item = mgmt().getTypeRegistry().get(OsgiTestResources.BROOKLYN_TEST_MORE_ENTITIES_MORE_ENTITY); AbstractBrooklynObjectSpec<?,?> spec = createSpec(item); List<SpecParameter<?>> inputs = spec.getParameters(); if (inputs.isEmpty()) Assert.fail("no inputs (if you're in the IDE, mvn clean install may need to be run to rebuild osgi test JARs)"); Set<SpecParameter<?>> actual = ImmutableSet.copyOf(inputs); Set<SpecParameter<?>> expected = ImmutableSet.<SpecParameter<?>>of( new BasicSpecParameter<>("more_config", false, ConfigKeys.newStringConfigKey("more_config")), new BasicSpecParameter<>(AbstractEntity.DEFAULT_DISPLAY_NAME.getName(), false, AbstractEntity.DEFAULT_DISPLAY_NAME)); assertEquals(actual, expected); }
Example #2
Source File: ActivePartialRebindTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test public void testRebindParentSimple() throws Exception { TestEntity c1 = origApp.addChild(EntitySpec.create(TestEntity.class)); AbstractEntity origAppr = Entities.deproxy(origApp); doPartialRebindOfIds(origApp.getId()); BrooklynObject app2 = origManagementContext.lookup(origApp.getId()); AbstractEntity app2r = Entities.deproxy((Entity)app2); Assert.assertTrue(app2 == origApp, "Proxy instance should be the same: "+app2+" / "+origApp); Assert.assertFalse(app2r == origAppr, "Real instance should NOT be the same: "+app2r+" / "+origAppr); Assert.assertTrue(c1.getManagementSupport().isDeployed()); // check that child of parent is not a new unmanaged entity Entity c1b = origApp.getChildren().iterator().next(); Assert.assertTrue(c1.getManagementSupport().isDeployed()); Assert.assertTrue( ((EntityInternal)c1b).getManagementSupport().isDeployed(), "Not deployed: "+c1b ); }
Example #3
Source File: EntityLocationsTest.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Test(groups="Integration") // because takes a second public void testNotNotifiedDuplicateAddedLocations() throws Exception { final Location l = app.newSimulatedLocation(); final RecordingSensorEventListener<Object> addedEvents = new RecordingSensorEventListener<>(); final RecordingSensorEventListener<Object> removedEvents = new RecordingSensorEventListener<>(); app.subscriptions().subscribe(app, AbstractEntity.LOCATION_ADDED, addedEvents); app.subscriptions().subscribe(app, AbstractEntity.LOCATION_REMOVED, removedEvents); // Add first location app.addLocations(ImmutableList.of(l, l)); assertEventValuesEqualsEventually(addedEvents, ImmutableList.of(l)); assertEventValuesEquals(removedEvents, ImmutableList.of()); // Add second location app.addLocations(ImmutableList.of(l)); assertEventValuesEqualsContinually(addedEvents, ImmutableList.of(l)); assertEventValuesEquals(removedEvents, ImmutableList.of()); }
Example #4
Source File: InternalEntityFactory.java From brooklyn-server with Apache License 2.0 | 6 votes |
/** * Constructs a new-style entity (fails if no no-arg constructor). * Sets the entity's id and proxy. * <p> * For use during rebind. */ // TODO would it be cleaner to have rebind create a spec and deprecate this? public <T extends Entity> T constructEntity(Class<T> clazz, Iterable<Class<?>> interfaces, String entityId) { if (!isNewStyle(clazz)) { throw new IllegalStateException("Cannot construct old-style entity "+clazz); } checkNotNull(entityId, "entityId"); checkState(interfaces != null && !Iterables.isEmpty(interfaces), "must have at least one interface for entity %s:%s", clazz, entityId); T entity = constructEntityImpl(clazz, null, null, Optional.of(entityId)); if (((AbstractEntity)entity).getProxy() == null) { Entity proxy = managementContext.getEntityManager().getEntity(entity.getId()); if (proxy==null) { // normal case, proxy does not exist proxy = createEntityProxy(interfaces, entity); } else { // only if rebinding to existing; don't create a new proxy, then we have proxy explosion // but callers must be careful that the entity's proxy does not yet point to it } ((AbstractEntity)entity).setProxy(proxy); } return entity; }
Example #5
Source File: LocalEntityManager.java From brooklyn-server with Apache License 2.0 | 6 votes |
@Beta @SuppressWarnings("unchecked") @Override public <T extends Entity> T createEntity(EntitySpec<T> spec, Optional<String> entityId) { if (entityId.isPresent()) { if (!ENTITY_ID_PATTERN.matcher(entityId.get()).matches()) { throw new IllegalArgumentException("Invalid entity id '"+entityId.get()+"'"); } } try { T entity = entityFactory.createEntity(spec, entityId); Entity proxy = ((AbstractEntity)entity).getProxy(); checkNotNull(proxy, "proxy for entity %s, spec %s", entity, spec); manage(entity); return (T) proxy; } catch (Throwable e) { log.warn("Failed to create entity using spec "+spec+" (rethrowing)", e); throw Exceptions.propagate(e); } }
Example #6
Source File: AbstractManagementContext.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Override public ExecutionContext getExecutionContext(Entity e) { // BEC is a thin wrapper around EM so fine to create a new one here; but make sure it gets the real entity if (e instanceof AbstractEntity) { ImmutableSet<Object> tags = ImmutableSet.<Object>of( BrooklynTaskTags.tagForContextEntity(e), this ); return new BasicExecutionContext(getExecutionManager(), tags); } else { return ((EntityInternal)e).getExecutionContext(); } }
Example #7
Source File: MethodEffector.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public T call(Entity entity, Map parameters) { if (entity instanceof AbstractEntity) { return EffectorUtils.invokeMethodEffector(entity, this, (Map<String,?>)parameters); } else { // we are dealing with a proxy here // this implementation invokes the method on the proxy // (requiring it to be on the interface) // and letting the proxy deal with the remoting / runAtEntity; // alternatively we could create the task here and pass it to runAtEntity; // the latter may allow us to simplify/remove a lot of the stuff from // EffectorUtils and possibly Effectors and Entities // TODO Should really find method with right signature, rather than just the right args. // TODO prepareArgs can miss things out that have "default values"! Code below will probably fail if that happens. Object[] parametersArray = EffectorUtils.prepareArgsForEffector(this, parameters); Method[] methods = entity.getClass().getMethods(); for (Method method : methods) { if (method.getName().equals(getName())) { if (parametersArray.length == method.getParameterTypes().length) { try { return (T) method.invoke(entity, parametersArray); } catch (Exception e) { // exception handled by the proxy invocation (which leads to EffectorUtils.invokeEffectorMethod...) throw Exceptions.propagate(e); } } } } String msg = "Could not find method for effector "+getName()+" with "+parametersArray.length+" parameters on "+entity; log.warn(msg+" (throwing); available methods are: "+Arrays.toString(methods)); throw new IllegalStateException(msg); } }
Example #8
Source File: DynamicClusterTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void defaultRemovalStrategyShutsDownNewestFirstWhenResizing() throws Exception { final List<Entity> creationOrder = Lists.newArrayList(); DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class) .configure("initialSize", 0) .configure("memberSpec", EntitySpec.create(TestEntity.class))); cluster.subscriptions().subscribe(cluster, AbstractEntity.CHILD_ADDED, new SensorEventListener<Entity>() { @Override public void onEvent(SensorEvent<Entity> event) { if (event.getValue() instanceof TestEntity) { creationOrder.add(event.getValue()); } }}); cluster.start(ImmutableList.of(loc)); cluster.resize(1); //Prevent the two entities created in the same ms //so that the removal strategy can always choose the //entity created next Thread.sleep(1); cluster.resize(2); Asserts.eventually(Suppliers.ofInstance(creationOrder), CollectionFunctionals.sizeEquals(2)); assertEquals(cluster.getCurrentSize(), (Integer)2); assertEquals(ImmutableSet.copyOf(cluster.getMembers()), ImmutableSet.copyOf(creationOrder), "actual="+cluster.getMembers()); // Now stop one cluster.resize(1); assertEquals(cluster.getCurrentSize(), (Integer)1); assertEquals(ImmutableList.copyOf(cluster.getMembers()), creationOrder.subList(0, 1)); }
Example #9
Source File: ClassLoaderUtilsTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testLoadClassNotInOsgi() throws Exception { ClassLoaderUtils clu = new ClassLoaderUtils(getClass()); assertLoadSucceeds(clu, getClass().getName(), getClass()); assertLoadSucceeds(clu, Entity.class.getName(), Entity.class); assertLoadSucceeds(clu, AbstractEntity.class.getName(), AbstractEntity.class); assertLoadFails(clu, "org.apache.brooklyn.this.name.does.not.Exist"); }
Example #10
Source File: EntityLocationsTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testNotifiedOfAddAndRemoveLocations() throws Exception { final Location l = app.newSimulatedLocation(); final Location l2 = app.newSimulatedLocation(); final RecordingSensorEventListener<Object> addedEvents = new RecordingSensorEventListener<>(); final RecordingSensorEventListener<Object> removedEvents = new RecordingSensorEventListener<>(); app.subscriptions().subscribe(app, AbstractEntity.LOCATION_ADDED, addedEvents); app.subscriptions().subscribe(app, AbstractEntity.LOCATION_REMOVED, removedEvents); // Add first location app.addLocations(ImmutableList.of(l)); assertEventValuesEqualsEventually(addedEvents, ImmutableList.of(l)); assertEventValuesEquals(removedEvents, ImmutableList.of()); // Add second location app.addLocations(ImmutableList.of(l2)); assertEventValuesEqualsEventually(addedEvents, ImmutableList.of(l, l2)); assertEventValuesEquals(removedEvents, ImmutableList.of()); // Remove first location app.removeLocations(ImmutableList.of(l)); assertEventValuesEqualsEventually(removedEvents, ImmutableList.of(l)); assertEventValuesEquals(addedEvents, ImmutableList.of(l, l2)); // Remove second location app.removeLocations(ImmutableList.of(l2)); assertEventValuesEqualsEventually(removedEvents, ImmutableList.of(l, l2)); assertEventValuesEquals(addedEvents, ImmutableList.of(l, l2)); }
Example #11
Source File: BasicSpecParameterFromClassTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testConfigInImplVisible() { Map<String, ConfigKey<?>> expectedKeys = ImmutableMap.<String, ConfigKey<?>>of( ConfigInImplParameterTestEntityImpl.SUGGESTED_VERSION.getName(), ConfigInImplParameterTestEntityImpl.SUGGESTED_VERSION, AbstractEntity.DEFAULT_DISPLAY_NAME.getName(), AbstractEntity.DEFAULT_DISPLAY_NAME); List<SpecParameter<?>> inputs = BasicSpecParameter.fromClass(mgmt, ConfigInImplParameterTestEntity.class); assertEquals(inputs.size(), expectedKeys.size()); for (SpecParameter<?> in : inputs) { ConfigKey<?> key = expectedKeys.get(in.getConfigKey().getName()); assertNotNull(key); assertInput(in, key.getName(), false, key); } }
Example #12
Source File: LocalEntityManager.java From brooklyn-server with Apache License 2.0 | 5 votes |
private Entity toRealEntity(Entity e) { checkNotNull(e, "entity"); if (e instanceof AbstractEntity) { return e; } else { Entity result = toRealEntityOrNull(e.getId()); if (result == null) { throw new IllegalStateException("No concrete entity known for entity "+e+" ("+e.getId()+", "+e.getEntityType().getName()+")"); } return result; } }
Example #13
Source File: LocalEntityManager.java From brooklyn-server with Apache License 2.0 | 5 votes |
private Entity toProxyEntityIfAvailable(Entity e) { checkNotNull(e, "entity"); if (e instanceof EntityProxy) { return e; } else if (e instanceof AbstractEntity) { Entity result = ((AbstractEntity)e).getProxy(); return (result == null) ? e : result; } else { // If we don't already know about the proxy, then use the real thing; presumably it's // the legacy way of creating the entity so didn't get a preManage() call return e; } }
Example #14
Source File: NonDeploymentManagementContext.java From brooklyn-server with Apache License 2.0 | 5 votes |
public NonDeploymentManagementContext(AbstractEntity entity, NonDeploymentManagementContextMode mode) { this.entity = checkNotNull(entity, "entity"); this.mode = checkNotNull(mode, "mode"); qsm = new QueueingSubscriptionManager(); entityManager = new NonDeploymentEntityManager(null); locationManager = new NonDeploymentLocationManager(null); accessManager = new NonDeploymentAccessManager(null); usageManager = new NonDeploymentUsageManager(null); }
Example #15
Source File: InternalEntityFactory.java From brooklyn-server with Apache License 2.0 | 5 votes |
private <T extends Entity> T constructEntityImpl(Class<? extends T> clazz, EntitySpec<?> optionalSpec, Map<String, ?> optionalConstructorFlags, Optional<String> entityId) { T entity = construct(clazz, optionalSpec, optionalConstructorFlags); if (entityId.isPresent()) { FlagUtils.setFieldsFromFlags(ImmutableMap.of("id", entityId.get()), entity); } if (entity instanceof AbstractApplication) { FlagUtils.setFieldsFromFlags(ImmutableMap.of("mgmt", managementContext), entity); } managementContext.prePreManage(entity); ((AbstractEntity)entity).setManagementContext(managementContext); return entity; }
Example #16
Source File: ClassLoaderFromStackOfBrooklynClassLoadingContextTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testLoadClassFromBundle() throws Exception { TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_PATH); ClassLoader classLoader = getClass().getClassLoader(); Bundle apiBundle = getBundle(mgmt, "org.apache.brooklyn.api"); Bundle coreBundle = getBundle(mgmt, "org.apache.brooklyn.core"); String bundleUrl = OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL; Bundle otherBundle = installBundle(mgmt, bundleUrl); assertLoads(classLoader, Entity.class, Optional.of(apiBundle)); assertLoads(classLoader, AbstractEntity.class, Optional.of(coreBundle)); assertLoads(classLoader, OsgiTestResources.BROOKLYN_TEST_OSGI_ENTITIES_SIMPLE_ENTITY, Optional.of(otherBundle)); }
Example #17
Source File: ClassLoaderFromStackOfBrooklynClassLoadingContextTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testLoadClassVanilla() throws Exception { ClassLoader classLoader = getClass().getClassLoader(); assertLoads(classLoader, Entity.class, Optional.<Bundle>absent()); assertLoads(classLoader, AbstractEntity.class, Optional.<Bundle>absent()); }
Example #18
Source File: InternalEntityFactory.java From brooklyn-server with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) protected <T extends Entity> T loadUnitializedEntity(final T entity, final EntitySpec<T> spec) { try { final AbstractEntity theEntity = (AbstractEntity) entity; if (spec.getDisplayName()!=null) theEntity.setDisplayName(spec.getDisplayName()); if (spec.getCatalogItemId()!=null) { theEntity.setCatalogItemIdAndSearchPath(spec.getCatalogItemId(), spec.getCatalogItemIdSearchPath()); } entity.tags().addTags(spec.getTags()); 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()); } Entity parent = spec.getParent(); if (parent != null) { parent = (parent instanceof AbstractEntity) ? ((AbstractEntity)parent).getProxyIfAvailable() : parent; entity.setParent(parent); } return entity; } catch (Exception e) { throw Exceptions.propagate(e); } }
Example #19
Source File: ActivePartialRebindTest.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Test public void testRebindChildSimple() throws Exception { TestEntity c1 = origApp.addChild(EntitySpec.create(TestEntity.class)); AbstractEntity c1r = Entities.deproxy(c1); doPartialRebindOfIds(c1.getId()); BrooklynObject c2 = origManagementContext.lookup(c1.getId()); AbstractEntity c2r = Entities.deproxy((Entity)c2); Assert.assertTrue(c2 == c1, "Proxy instance should be the same: "+c1+" / "+c2); Assert.assertFalse(c2r == c1r, "Real instance should NOT be the same: "+c1r+" / "+c2r); }
Example #20
Source File: ElectPrimaryPolicy.java From brooklyn-server with Apache License 2.0 | 5 votes |
protected void addSubscriptions(Entity entity) { String weightSensorName = config().get(PRIMARY_WEIGHT_NAME); TargetMode target = config().get(TARGET_MODE); if (target==TargetMode.AUTO) target = entity instanceof Group ? TargetMode.MEMBERS : TargetMode.CHILDREN; highlightTriggers("Listening for "+weightSensorName+" and service up, state on all " + target.name().toLowerCase()); Change<Entity> candidateSetChange = new Change<Entity>(); Change<Boolean> candidateUpChange = new Change<Boolean>(); Change<Lifecycle> candidateLifecycleChange = new Change<Lifecycle>(); Change<Number> candidateWeightChange = new Change<Number>(); AttributeSensor<Number> weightSensor = Sensors.newSensor(Number.class, weightSensorName); switch (target) { case CHILDREN: subscriptions().subscribe(entity, AbstractEntity.CHILD_ADDED, candidateSetChange); subscriptions().subscribe(entity, AbstractEntity.CHILD_REMOVED, candidateSetChange); subscriptions().subscribeToChildren(entity, Attributes.SERVICE_UP, candidateUpChange); subscriptions().subscribeToChildren(entity, Attributes.SERVICE_STATE_ACTUAL, candidateLifecycleChange); subscriptions().subscribeToChildren(entity, weightSensor, candidateWeightChange); break; case MEMBERS: subscriptions().subscribe(entity, DynamicGroup.MEMBER_ADDED, candidateSetChange); subscriptions().subscribe(entity, DynamicGroup.MEMBER_REMOVED, candidateSetChange); subscriptions().subscribeToMembers(((Group)entity), Attributes.SERVICE_UP, candidateUpChange); subscriptions().subscribeToMembers(((Group)entity), Attributes.SERVICE_STATE_ACTUAL, candidateLifecycleChange); subscriptions().subscribeToMembers(((Group)entity), weightSensor, candidateWeightChange); break; default: throw new IllegalArgumentException("Unexpected target mode "+target); } }
Example #21
Source File: RebindIteration.java From brooklyn-server with Apache License 2.0 | 4 votes |
protected Entity newEntity(EntityMementoManifest entityManifest) { String entityId = entityManifest.getId(); CatalogItemIdAndSearchPath idPath = findCatalogItemIds(classLoader, mementoManifest.getEntityIdToManifest(), entityManifest); String entityType = entityManifest.getType(); LoadedClass<? extends Entity> loaded = load(Entity.class, entityType, idPath.getCatalogItemId(), idPath.getSearchPath(), entityId); Class<? extends Entity> entityClazz = loaded.clazz; Entity entity; if (InternalFactory.isNewStyle(entityClazz)) { // Not using entityManager.createEntity(EntitySpec) because don't want init() to be called. // Creates an uninitialized entity, but that has correct id + proxy. InternalEntityFactory entityFactory = managementContext.getEntityFactory(); entity = entityFactory.constructEntity(entityClazz, Reflections.getAllInterfaces(entityClazz), entityId); } else { LOG.warn("Deprecated rebind of entity without no-arg constructor; " + "this may not be supported in future versions: id=" + entityId+"; type=" + entityType); // There are several possibilities for the constructor; find one that works. // Prefer passing in the flags because required for Application to set the management context // TODO Feels very hacky! Map<Object,Object> flags = Maps.newLinkedHashMap(); flags.put("id", entityId); if (AbstractApplication.class.isAssignableFrom(entityClazz)) flags.put("mgmt", managementContext); // TODO document the multiple sources of flags, and the reason for setting the mgmt context *and* // supplying it as the flag // (NB: merge reported conflict as the two things were added separately) entity = invokeConstructor(null, entityClazz, new Object[] {flags}, new Object[] {flags, null}, new Object[] {null}, new Object[0]); // In case the constructor didn't take the Map arg, then also set it here. // e.g. for top-level app instances such as WebClusterDatabaseExampleApp will (often?) not have // interface + constructor. // TODO On serializing the memento, we should capture which interfaces so can recreate // the proxy+spec (including for apps where there's not an obvious interface). FlagUtils.setFieldsFromFlags(ImmutableMap.of("id", entityId), entity); if (entity instanceof AbstractApplication) { FlagUtils.setFieldsFromFlags(ImmutableMap.of("mgmt", managementContext), entity); } ((AbstractEntity)entity).setManagementContext(managementContext); managementContext.prePreManage(entity); } setCatalogItemIds(entity, loaded.catalogItemId, loaded.searchPath); return entity; }
Example #22
Source File: AbstractEntityLegacyTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override public AbstractEntity configure(Map flags) { configureCount++; return super.configure(flags); }
Example #23
Source File: EntityProxyTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
private void assertIsProxy(Entity e) { assertFalse(e instanceof AbstractEntity, "e="+e+";e.class="+(e != null ? e.getClass() : null)); assertTrue(e instanceof EntityProxy, "e="+e+";e.class="+(e != null ? e.getClass() : null)); }
Example #24
Source File: TestEntityImpl.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override public AbstractEntity configure(Map flags) { this.configureProperties = flags; configureCount++; return super.configure(flags); }
Example #25
Source File: DynamicClusterTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Test public void concurrentResizesToSameNumberCreatesCorrectNumberOfNodes() throws Exception { final int OVERHEAD_MS = 500; final Duration STARTUP_TIME = Duration.millis(50); final AtomicInteger numCreated = new AtomicInteger(0); final DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class) .configure("memberSpec", EntitySpec.create(BlockingEntity.class) .configure(BlockingEntity.STARTUP_DELAY, STARTUP_TIME))); cluster.subscriptions().subscribe(cluster, AbstractEntity.CHILD_ADDED, new SensorEventListener<Entity>() { @Override public void onEvent(SensorEvent<Entity> event) { if (event.getValue() instanceof BlockingEntity) { numCreated.incrementAndGet(); } }}); assertEquals(cluster.getCurrentSize(), (Integer)0); cluster.start(ImmutableList.of(loc)); ExecutorService executor = Executors.newCachedThreadPool(); final List<Throwable> throwables = new CopyOnWriteArrayList<Throwable>(); try { for (int i = 0; i < 10; i++) { executor.submit(new Runnable() { @Override public void run() { try { cluster.resize(2); } catch (Throwable e) { throwables.add(e); } }}); } executor.shutdown(); assertTrue(executor.awaitTermination(10*STARTUP_TIME.toMilliseconds()+OVERHEAD_MS, TimeUnit.MILLISECONDS)); if (throwables.size() > 0) throw Exceptions.propagate(throwables.get(0)); assertEquals(cluster.getCurrentSize(), (Integer)2); assertEquals(cluster.getAttribute(Changeable.GROUP_SIZE), (Integer)2); Asserts.succeedsEventually(new Runnable() { public void run() { assertEquals(numCreated.get(), 2); }}); } finally { executor.shutdownNow(); } }
Example #26
Source File: BasicEntityRebindSupport.java From brooklyn-server with Apache License 2.0 | 4 votes |
protected Entity proxy(Entity target) { return target instanceof AbstractEntity ? ((AbstractEntity)target).getProxyIfAvailable() : target; }
Example #27
Source File: BasicEntityRebindSupport.java From brooklyn-server with Apache License 2.0 | 4 votes |
public BasicEntityRebindSupport(AbstractEntity entity) { super(entity); this.entity = checkNotNull(entity, "entity"); }
Example #28
Source File: CreateUserPolicy.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override public void setEntity(EntityLocal entity) { super.setEntity(entity); subscriptions().subscribe(entity, AbstractEntity.LOCATION_ADDED, this); }
Example #29
Source File: EntityManagementSupport.java From brooklyn-server with Apache License 2.0 | 4 votes |
public EntityManagementSupport(AbstractEntity entity) { this.entity = entity; nonDeploymentManagementContext = new NonDeploymentManagementContext(entity, NonDeploymentManagementContextMode.PRE_MANAGEMENT); }
Example #30
Source File: LocalEntityManager.java From brooklyn-server with Apache License 2.0 | 4 votes |
private Entity deproxyIfNecessary(Entity e) { return (e instanceof AbstractEntity) ? e : Entities.deproxy(e); }