/** * Take care of int overflow */ public static int current_time_secs() { return (int) (Time.currentTimeMillis() / 1000); }
public static void sleep_secs(long secs) throws InterruptedException { Time.sleep(1000 * secs); }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis() + ms); }
@Override public Boolean isSleeping() { return Time.isThreadWaiting(thread); }
@Override public Boolean isSleeping() { return Time.isThreadWaiting(thread); } }
private long now() { return Time.currentTimeMillis(); }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis()+ms); }
public static void sleep(long millis) { try { Time.sleep(millis); } catch (InterruptedException e) { throw new RuntimeException(e); } }
@Override public boolean waiting() { return Time.isThreadWaiting(runningThread) || (processed.get() == added.get()); }
public static int currentTimeSecs() { return (int) (currentTimeMillis() / 1000); }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis() + ms); }
public static void sleep(long millis) { try { Time.sleep(millis); } catch (InterruptedException e) { throw new RuntimeException(e); } }
@Override public Boolean isSleeping() { return Time.isThreadWaiting(thread); }
public static int current_time_secs() { return (int) (Time.currentTimeMillis() / 1000); }
public static void sleep(long ms) throws InterruptedException { sleepUntil(currentTimeMillis()+ms); }
public void run() { try { while (true) { Map<K, V> dead; Time.sleep(sleepTime); synchronized (_lock) { dead = _buckets.removeLast(); _buckets.addFirst(new HashMap<K, V>()); } if (_callback != null) { for (Entry<K, V> entry : dead.entrySet()) { _callback.expire(entry.getKey(), entry.getValue()); } } } } catch (InterruptedException ignored) { } } });
public static boolean isThreadWaiting(Thread t) { if (!simulating.get()) throw new IllegalStateException("Must be in simulation mode"); AtomicLong time; synchronized (sleepTimesLock) { time = threadSleepTimes.get(t); } return !t.isAlive() || time != null && currentTimeMillis() < time.longValue(); } }
public void run() { try { while(true) { Map<K, V> dead = null; Time.sleep(sleepTime); synchronized(_lock) { dead = _buckets.removeLast(); _buckets.addFirst(new HashMap<K, V>()); } if(_callback!=null) { for(Entry<K, V> entry: dead.entrySet()) { _callback.expire(entry.getKey(), entry.getValue()); } } } } catch (InterruptedException ex) { } } });
public static boolean isThreadWaiting(Thread t) { if(!simulating.get()) throw new IllegalStateException("Must be in simulation mode"); AtomicLong time; synchronized(sleepTimesLock) { time = threadSleepTimes.get(t); } return !t.isAlive() || time!=null && currentTimeMillis() < time.longValue(); } }
private void executeNextTupe() { // гȣС趨ĻСôִspout.nextTuple(); if (max_spout_pending == null || pending.size() < max_spout_pending) { if (this.IsActive()) { try { spout.nextTuple(); } catch (RuntimeException e) { error = e; LOG.error("spout execute error ", e); } catch (Exception e) { error = e; LOG.error("spout execute error ", e); } } else { try { Time.sleep(100); } catch (InterruptedException e) { LOG.error("spout sleep error ", e); } } } }