@Override public void delete() { clear(); SimpleSchedulerConfig config = new SimpleSchedulerConfig(getParams()); SimpleSchedulerBuilder.delete(config.getId()); }
/** * Sets the id. * * @param id * the new id */ public void setId(final String id) { this.put("id", id); }
/** * 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); } }
@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; }
/** * Schedule an RPC call at a specified due time. * * @param method * the method * @param params * the params * @param delay * the delay * @return the string */ @Access(AccessType.UNAVAILABLE) protected String schedule(final String method, final ObjectNode params, final long delay) { final Scheduler scheduler = this.scheduler; if (scheduler == null) return ""; return scheduler.schedule(new JSONRequest(method, params), delay); }
@Override public String schedule(Object msg, int delay) { return schedule(msg, DateTime.now().plus(delay)); }
/** * Cancel. * * @param taskId * the task id */ @Access(AccessType.UNAVAILABLE) protected void cancel(final String taskId) { final Scheduler scheduler = this.scheduler; if (scheduler == null) return; scheduler.cancel(taskId); }
/** * Instantiates a new simple scheduler config. * * @param node * the node */ public SimpleSchedulerConfig(final ObjectNode node) { super(node); if (node == null || !node.has("class")) { setClassName(SimpleSchedulerBuilder.class.getName()); } }
/** * Destroy the agent. */ @Access(AccessType.UNAVAILABLE) protected void destroy() { eventCaller.on("destroy"); if (scheduler != null) { scheduler.delete(); scheduler = null; } if (transport != null) { transport.disconnect(); transport.delete(); transport = null; } if (protocolStack != null) { protocolStack.delete(); protocolStack = null; } if (state != null) { state.delete(); state = null; } if (is != null) { is.deregister(agentId); is = null; } }
/** * Schedule an RPC call at a specified due time. * * @param method * the method * @param params * the params * @param delay * the delay * @return the string */ @Access(AccessType.UNAVAILABLE) protected String schedule(final String method, final ObjectNode params, final int delay) { final Scheduler scheduler = this.scheduler; if (scheduler == null) return ""; return scheduler.schedule(new JSONRequest(method, params), delay); }
/** * Sets the sender url. * * @param senderUrl * the new sender url */ public void setSenderUrl(String senderUrl) { this.put("senderUrl", senderUrl); }
@Override public String schedule(Object msg, long delay) { return schedule(msg, DateTime.now().plus(delay)); }
/** * Schedule an RPC call at a specified due time. * * @param method * the method * @param params * the params * @param due * the due * @return the string */ @Access(AccessType.UNAVAILABLE) protected String schedule(final String method, final ObjectNode params, final DateTime due) { final Scheduler scheduler = this.scheduler; if (scheduler == null) return ""; return scheduler.schedule(new JSONRequest(method, params), due); }