@Override public void delete() { clear(); SimpleSchedulerConfig config = new SimpleSchedulerConfig(getParams()); SimpleSchedulerBuilder.delete(config.getId()); }
@Override public SimpleScheduler build(){ final SimpleSchedulerConfig config = new SimpleSchedulerConfig(getParams()); String id = config.getId(); if (id == null) { id = new UUID().toString(); LOG.warning("Parameter 'id' is required for SimpleScheduler. (giving temporary name: " + id + ")"); } SimpleScheduler result = null; if (INSTANCES.containsKey(id)) { result = INSTANCES.get(id); final Handler<Receiver> oldHandle = result.getHandle(); oldHandle.update(TYPEUTIL.inject(getHandle())); } else { result = new SimpleScheduler(config, TYPEUTIL.inject(getHandle())); } INSTANCES.put(id, result); return result; }
/** * Creates the agent. * * @param agentType * the agent type * @param agentId * the agent id * @param config * the config * @return the agent */ public Agent createAgent(String agentType, String agentId, final ObjectNode config) { final AgentConfig conf = new AgentConfig(config); conf.setClassName(agentType); conf.setId(agentId); conf.setScheduler(new SimpleSchedulerConfig()); conf.setState(new MemoryStateConfig()); final Agent agent = new AgentBuilder().with(conf).build(); addAgent(agentId, agent); return agent; }
/** * Load scheduler. * * @param schedulerConfig * the scheduler config */ private void loadScheduler(final ObjectNode params) { final SimpleSchedulerConfig schedulerConfig = new SimpleSchedulerConfig( params); if (schedulerConfig != null) { if (agentId != null && schedulerConfig.has("state")) { final StateConfig stateConfig = new StateConfig( (ObjectNode) schedulerConfig.get("state")); if (stateConfig.getId() == null) { stateConfig.setId("scheduler_" + agentId); schedulerConfig.set("state", stateConfig); } } if (agentId != null && schedulerConfig.getId() == null) { schedulerConfig.setId(agentId); } scheduler = new SchedulerBuilder().withConfig(schedulerConfig) .withHandle(receiver).build(); config.set("scheduler", schedulerConfig); } }