/** * Builds and manages the application, calling the user's {@link #doBuild()} method. * * @throws IllegalStateException If already managed, or if called during {@link #doBuild()}, or if * multiple concurrent calls */ public final StartableApplication manage(ManagementContext managementContext) { if (!inManage.compareAndSet(false, true)) { throw new IllegalStateException("Concurrent and re-entrant calls to manage() forbidden on "+this); } try { checkNotManaged(); this.app = managementContext.getEntityManager().createEntity(appSpec); this.managementContext = managementContext; doBuild(); Entities.startManagement(app, managementContext); managed = true; return app; } finally { inManage.set(false); } }
/** Launches the web console on the given port, and a Brooklyn application, with a single command. * For readability and flexibility, clients may prefer the {@link #newLauncher()} builder-style syntax. * * @deprecated in 0.5; use newInstance().webconsolePort(port).shutdownOnExit(shutdownApp).webconsole(startWebConsole).application(app).start() */ @Deprecated public static ManagementContext manage(final AbstractApplication app, int port, boolean shutdownApp, boolean startWebConsole) { // Locate the management context Entities.startManagement(app); LocalManagementContext context = (LocalManagementContext) app.getManagementContext(); if (startWebConsole) { try { new BrooklynWebServer(context, port).start(); } catch (Exception e) { LOG.warn("Failed to start Brooklyn web-console", e); } } if (shutdownApp) Entities.invokeStopOnShutdown(app); return context; }
/** convenience for starting an entity, esp a new Startable instance which has been created dynamically * (after the application is started) */ public static void start(Entity e, Collection<? extends Location> locations) { if (!isManaged(e) && !manage(e)) { log.warn("Using discouraged mechanism to start management -- Entities.start(Application, Locations) -- caller should create and use the preferred management context"); startManagement(e); } if (e instanceof Startable) Entities.invokeEffector((EntityLocal)e, e, Startable.START, MutableMap.of("locations", locations)).getUnchecked(); }
public synchronized void attemptLegacyAutodeployment(String effectorName) { if (managementContext!=null) { log.warn("Autodeployment suggested but not required for "+entity+"."+effectorName); return; } if (entity instanceof Application) { log.warn("Autodeployment with new management context triggered for "+entity+"."+effectorName+" -- will not be supported in future. Explicit manage call required."); if (initialManagementContext != null) { initialManagementContext.getEntityManager().manage(entity); } else { Entities.startManagement(entity); } return; } if ("start".equals(effectorName)) { Entity e=entity; if (e.getParent()!=null && ((EntityInternal)e.getParent()).getManagementSupport().isDeployed()) { log.warn("Autodeployment in parent's management context triggered for "+entity+"."+effectorName+" -- will not be supported in future. Explicit manage call required."); ((EntityInternal)e.getParent()).getManagementContext().getEntityManager().manage(entity); return; } } log.warn("Autodeployment not available for "+entity+"."+effectorName); }
Entities.startManagement(app, managementContext); apps.add(app);
Entities.startManagement((Application)rebindContext.getEntity(appId), managementContext);
Entities.startManagement(instance, mgmt); Entities.startManagement(instance, mgmt);
Entities.startManagement(instance, mgmt); Entities.startManagement(instance, mgmt);