@Override public void run() { pool.flushTargets(false); jrtTask.schedule(1.0); } }
public void handleRequestDone(Request req) { requestDone = true; updateTask.scheduleNow(); } };
/** * Create a {@link Task} that can be scheduled for execution in * the transport thread. * * @return the newly created Task * @param cmd what to run when the task is executed **/ public Task createTask(Runnable cmd) { return new Task(scheduler, cmd); }
updateTask.schedule(0.1); // be nice return; updateTask.scheduleNow(); // try next slobrok return; updateTask.schedule(0.1); // be nice
private void handleFetchMirrorFlush() { for (FetchMirror fetch : pendingFetch) { fetch.task.kill(); dumpServices(fetch.req); fetch.req.returnRequest(); } pendingFetch.clear(); }
private static boolean isActive(Task task) { return (task.next() != null); }
public synchronized boolean kill(Task task) { task.setKilled(); if (isActive(task)) { linkOut(task); return true; } return false; }
public void checkTasks(long now) { if (slots[SLOTS] == null && now < nextTick) { return; } synchronized (this) { queueTasks(SLOTS, 0); for (int i = 0; now >= nextTick; i++, nextTick += TICK) { if (i < 3) { if (++currSlot >= SLOTS) { currSlot = 0; currIter++; } queueTasks(currSlot, currIter); } } } while (!queue.isEmpty()) { Task task = (Task) queue.dequeue(); task.perform(); } } }
public synchronized void schedule(Task task, double seconds) { if (task.isKilled()) { return; } if (seconds < 0.0) { throw new IllegalArgumentException("cannot schedule a Task in the past"); } int ticks = 1 + (int) (seconds * 10.0 + 0.5); if (isActive(task)) { linkOut(task); } task.slot((ticks + currSlot) & MASK); task.iter(currIter + ((ticks + currSlot) >> SHIFT)); linkIn(task); }
private void linkOut(Task task) { Task head = slots[task.slot()]; if (task.next() == task) { slots[task.slot()] = null; } else { task.prev().next(task.next()); task.next().prev(task.prev()); if (head == task) { slots[task.slot()] = task.next(); } } task.next(null); task.prev(null); --counts[task.slot()]; }
/** * Handle connection down. **/ public void handleConnectionDown() { timeoutTask.kill(); req.setError(ErrorCode.CONNECTION, "Connection error"); reqWaiter.handleRequestDone(req); }
public void handleRequestDone(Request req) { reqDone = true; updateTask.scheduleNow(); } };
TargetPoolTask(RPCTargetPool pool, Supervisor orb) { this.pool = pool; this.jrtTask = orb.transport().createTask(this); this.jrtTask.schedule(1.0); }
/** * Shut down the Mirror. This will close any open connections, * stop the regular mirror updates, and discard all entries. */ public void shutdown() { updateTask.kill(); orb.transport().perform(new Runnable() { public void run() { handleShutdown(); } }); }
/** * Register a service with the slobrok cluster. * * @param name service name */ public synchronized void registerName(String name) { if (names.indexOf(name) >= 0) { return; } names.add(name); pending.add(name); discard(unreg, name); updateTask.scheduleNow(); }
public FetchMirror(Request req, int timeout) { req.detach(); this.req = req; task = orb.transport().createTask(this); task.schedule(((double)timeout)/1000.0); } public void run() { // timeout
/** * Shut down the Register. This will close any open connections * and stop the regular re-registration. */ public void shutdown() { updateTask.kill(); orb.transport().perform(new Runnable() { public void run() { handleShutdown(); } }); }