public Task<?> destroy(final Application application) { return mgmt.getExecutionManager().submit(new Runnable() { @Override public void run() { ((EntityInternal)application).destroy(); mgmt.getEntityManager().unmanage(application); } }); }
@Override public void onItemAdded(final Item item) { executor.submit(MutableMap.of("tag", delegate), new Runnable() { public void run() { try { delegate.onItemAdded(item); } catch (Throwable t) { LOG.warn("Error notifying listener of itemAdded("+item+")", t); Exceptions.propagate(t); } } }); }
@Override public void onItemRemoved(final Item item) { executor.submit(MutableMap.of("tag", delegate), new Runnable() { public void run() { try { delegate.onItemRemoved(item); } catch (Throwable t) { LOG.warn("Error notifying listener of itemAdded("+item+")", t); Exceptions.propagate(t); } } }); }
public BasicBrooklynCatalog(final ManagementContext mgmt, final CatalogDto dto) { this.mgmt = Preconditions.checkNotNull(mgmt, "managementContext"); this.catalog = new CatalogDo(dto); mgmt.getExecutionManager().submit(MutableMap.of("name", "loading catalog"), new Runnable() { public void run() { log.debug("Loading catalog for "+mgmt); catalog.load(mgmt, null); if (log.isDebugEnabled()) log.debug("Loaded catalog for "+mgmt+": "+catalog+"; search classpath is "+catalog.getRootClassLoader()); } }); }
public Task<?> destroy(final Application application) { return mgmt.getExecutionManager().submit( MutableMap.of("displayName", "destroying "+application, "description", "REST call to destroy application "+application.getDisplayName()+" ("+application+")"), new Runnable() { @Override public void run() { ((EntityInternal)application).destroy(); mgmt.getEntityManager().unmanage(application); } }); }
public PeriodicDeltaChangeListener(ExecutionManager executionManager, BrooklynMementoPersister persister, long periodMillis) { this.executionManager = executionManager; this.persister = persister; Callable<Task<?>> taskFactory = new Callable<Task<?>>() { @Override public Task<Void> call() { return new BasicTask<Void>(new Callable<Void>() { public Void call() { try { persistNow(); return null; } catch (Exception e) { // Don't rethrow: the behaviour of executionManager is different from a scheduledExecutorService, // if we throw an exception, then our task will never get executed again LOG.warn("Problem persisting change-delta", e); return null; } catch (Throwable t) { LOG.warn("Problem persisting change-delta (rethrowing)", t); throw Throwables.propagate(t); } }}); } }; ScheduledTask scheduledTask = new ScheduledTask(taskFactory).period(periodMillis); executionManager.submit(scheduledTask); }
@SuppressWarnings("deprecation") protected void submitIfNecessary(TaskAdaptable<?> task) { if (!task.asTask().isSubmitted()) { if (BasicExecutionContext.getCurrentExecutionContext() == null) { if (em!=null) { log.warn("Discouraged submission of compound task ({}) from {} without execution context; using execution manager", task, this); em.submit(task); } else { throw new IllegalStateException("Compound task ("+task+") launched from "+this+" missing required execution context"); } } else { BasicExecutionContext.getCurrentExecutionContext().submit(task); } } }
continue; final Subscription sAtClosureCreation = s; em.submit(mapOf("tag", s.subscriberExecutionManagerTag), new Runnable() { public void run() { sAtClosureCreation.listener.onEvent(event);
}}); return executionManager.submit(properties, task);