public void run() { sp1.addListener(key, this); long stamp = System.nanoTime(); for (int i = 0; i < COUNT; i++) sp1.out(key, Boolean.TRUE); long stamp2 = System.nanoTime(); t1.add(stamp2 - stamp); System.err.println("Perform. " + key + " out: " + (stamp2 - stamp) / 1000000); }
public void setConfiguration(Configuration cfg) { if (this.cfg != null) sp.removeListener(from, this); this.cfg = cfg; from = cfg.get("from"); to = cfg.get("to"); sp.addListener(from, this); }
@Ignore("Remove it when TSpace can pass it") @Test public void testStolenEntryAtNotify() throws Throwable { int size = 10; final ExecutorService es = new ThreadPoolExecutor( size * 2, Integer.MAX_VALUE, 30, TimeUnit.SECONDS, new SynchronousQueue()); ((ThreadPoolExecutor) es).prestartAllCoreThreads(); for (int i = 0; i < size; i++) es.execute(new WriteSpaceWithNotifyReadTask("WriteTask-" + i)); // Threads which may stole entries for (int i = 0; i < size; i++) es.execute(new ReadSpaceTask("WriteTask-" + i)); assertNull("Detected stolen entry at notify", sp2.in("lost-entry", 200)); es.shutdownNow(); // es.awaitTermination(5, TimeUnit.SECONDS); }
public void notify(Object key, Object value) { Object o = sp.inp(key); if (o != null) sp.out(to, o); }
public Connector(String from, String to) { this(); this.from = from; this.to = to; sp.addListener(from, this); }
public void notify(Object key, Object value) { if ((++count % 100) == 0) { sp2.out((String) key, value); } }