protected EntityConfigTemplateModel(EntityInternal entity) { this.entity = checkNotNull(entity, "entity"); this.mgmt = entity.getManagementContext(); }
public ClassLoaderUtils(Class<?> callingClass, Entity entity) { checkNotNull(callingClass, "callingClass"); this.classLoader = getValidClassLoader(callingClass.getClassLoader()); this.entity = checkNotNull(entity, "entity"); this.mgmt = ((EntityInternal)entity).getManagementContext(); }
protected EntityAndMapTemplateModel(EntityInternal entity, Map<String,? extends Object> extraSubstitutions) { this.entity = entity; this.driver = null; this.mgmt = entity.getManagementContext(); this.extraSubstitutionsModel = new DotSplittingTemplateModel(extraSubstitutions); }
protected EntityAndMapTemplateModel(EntityDriver driver, Map<String,? extends Object> extraSubstitutions) { this.driver = driver; this.entity = (EntityInternal) driver.getEntity(); this.mgmt = entity.getManagementContext(); this.extraSubstitutionsModel = new DotSplittingTemplateModel(extraSubstitutions); }
public static DownloadResolver newDownloader(EntityDriver driver, Map<String,?> properties) { EntityInternal internal = (EntityInternal) driver.getEntity(); return internal.getManagementContext().getEntityDownloadsManager().newDownloader(driver, properties); }
public static DownloadResolver newDownloader(EntityDriver driver, String addon, Map<String,?> properties) { EntityInternal internal = (EntityInternal) driver.getEntity(); return internal.getManagementContext().getEntityDownloadsManager().newDownloader(driver, addon, properties); }
/** * The environment variables to be set when executing the commands (for install, run, check running, etc). * @see SoftwareProcess#SHELL_ENVIRONMENT */ public Map<String, String> getShellEnvironment() { Map<String, Object> env = entity.getConfig(SoftwareProcess.SHELL_ENVIRONMENT); ShellEnvironmentSerializer envSerializer = new ShellEnvironmentSerializer(((EntityInternal)entity).getManagementContext()); return envSerializer.serialize(env); }
public static boolean isManaged(Entity e) { return ((EntityInternal)e).getManagementSupport().isDeployed() && ((EntityInternal)e).getManagementContext().isRunning(); }
@Override public Void call(ConfigBag parameters) { Collection<? extends Location> locations = null; Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollectionOfLocationsManaged(entity().getManagementContext(), locationsRaw); if (locations == null) { // null/empty will mean to inherit from parent locations = Collections.emptyList(); } start(locations); return null; }
public static void unmanage(Entity entity) { if (((EntityInternal)entity).getManagementSupport().isDeployed()) { ((EntityInternal)entity).getManagementContext().getEntityManager().unmanage(entity); } }
@Override public Void call(ConfigBag parameters) { Collection<? extends Location> locations = null; Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollectionOfLocationsManaged(entity().getManagementContext(), locationsRaw); if (locations==null) { // null/empty will mean to inherit from parent locations = Collections.emptyList(); } start(locations); return null; } };
private void checkEntitiesHealthy(TestApplication app, TestEntity entity) { Assert.assertNotNull(app.getManagementContext()); Assert.assertTrue( app.getManagementContext().isRunning() ); Assert.assertNotNull(entity.getManagementContext()); Assert.assertNotNull( ((EntityInternal)app.getChildren().iterator().next()).getManagementContext() ); Assert.assertTrue( ((EntityInternal)app.getChildren().iterator().next()).getManagementSupport().isDeployed()); Assert.assertTrue( ((EntityInternal)app.getChildren().iterator().next()).getManagementContext() instanceof LocalManagementContext ); }
@Override public Iterable<Entity> call() throws Exception { return ((EntityManagerInternal)((EntityInternal)app).getManagementContext().getEntityManager()).getAllEntitiesInApplication((Application)app); } }).get();
@Override public Entity call() { EntityInternal entity = entity(); Collection<Entity> entitiesToSearch = entity.getManagementContext().getEntityManager().getEntities(); Optional<Entity> result = Iterables.tryFind(entitiesToSearch, EntityPredicates.configEqualTo(TAG, tag)); if (result.isPresent()) { return result.get(); } else { throw new NoSuchElementException("No entity matching id " + tag+" in "+entitiesToSearch); } }}) .build();
@Override public void run() { forceGc(); Collection<Task<?>> tasks = BrooklynTaskTags.getTasksInEntityContext(((EntityInternal)entity).getManagementContext().getExecutionManager(), entity); Assert.assertTrue(tasks.size() <= expectedMaxCount, "Expected tasks count max of " + expectedMaxCount + ". Tasks were "+tasks); }}); }
@Override public void run() { forceGc(); Collection<Task<?>> tasks = BrooklynTaskTags.getTasksInEntityContext(((EntityInternal)entity).getManagementContext().getExecutionManager(), entity); Assert.assertEquals(tasks.size(), expectedCount, "Tasks were "+tasks); }}); }
@Test public void testAutoCheckpointsOnUnmanageEntity() throws Exception { Entities.unmanage(origE); newApp = rebind(); // Assert does not container unmanaged entity assertEquals(ImmutableList.copyOf(newApp.getChildren()), Collections.emptyList()); assertNull(((EntityInternal)newApp).getManagementContext().getEntityManager().getEntity(origE.getId())); }
public static BrooklynClassLoadingContext getClassLoadingContext(Entity entity) { ManagementContext mgmt = ((EntityInternal)entity).getManagementContext(); String catId = entity.getCatalogItemId(); if (Strings.isBlank(catId)) return JavaBrooklynClassLoadingContext.create(mgmt); Maybe<RegisteredType> cat = RegisteredTypes.tryValidate(mgmt.getTypeRegistry().get(catId), RegisteredTypeLoadingContexts.spec(Entity.class)); if (cat.isNull()) { log.warn("Cannot load "+catId+" to get classloader for "+entity+"; will try with standard loader, but might fail subsequently"); return JavaBrooklynClassLoadingContext.create(mgmt); } return newClassLoadingContext(mgmt, cat.get(), JavaBrooklynClassLoadingContext.create(mgmt)); }
@Override public Void call(ConfigBag parameters) { parameters.put(LOCATIONS, entity().getManagementContext().getLocationRegistry().getListOfLocationsManaged(parameters.get(LOCATIONS))); return new MethodEffector<Void>(Startable.class, "start").call(entity(), parameters.getAllConfig()); } }
@Override public void setEntity(EntityLocal entity) { assert entity instanceof Group; super.setEntity(entity); subscriptions().subscribe(null, Startable.SERVICE_UP, handler); for (Entity e : ((EntityInternal) entity).getManagementContext().getEntityManager().getEntities()) { if (Objects.equal(e.getApplicationId(), entity.getApplicationId())) updateMembership(e); } }