@Override public int size() { return queue.size(); }
public static void main(String[] args) throws Exception { HazelcastInstance hz1 = Hazelcast.newHazelcastInstance(); HazelcastInstance hz2 = Hazelcast.newHazelcastInstance(); IQueue<String> q1 = hz1.getQueue("q"); IQueue<String> q2 = hz2.getQueue("q"); q1.add("foo"); System.out.println("q1.size: " + q1.size() + " q2.size:" + q2.size()); q1.destroy(); System.out.println("q1.size: " + q1.size() + " q2.size:" + q2.size()); } }
public void run() { IQueue queue = hazelcast.getQueue("myQ"); queue.size(); } }, 1);
@Override public void close() throws Exception { logger.trace("close.enter; queue remaining size: {}", queue.size()); queue.clear(); //queue.destroy(); }
@Override public boolean add(T result) { int size = queue.size(); if (size < limit) { return queue.add(result); } //logger.debug("add; queue {} is full: {}; limit: {}", queueName, size, limit); return false; }
@Override public int size(String queueName) { return hazelcast.getQueue(queueName).size(); }
@Override public int size(String queueName) { return hazelcast.getQueue(queueName).size(); }
private void logState(long iter) { log.info(Thread.currentThread().getName() + " prod-id:" + id + " iteration: " + iter + " produced:" + produced.get() + " workqueue:" + workQueue.size() + " consumed:" + consumed.get()); } }
@Override public void run() { try { long iteration = 0; while (!testContext.isStopped()) { long item = fromQueue.take(); toQueue.put(item + 1); if (iteration % 200 == 0) { log.info(Thread.currentThread().getName() + " At iteration: " + iteration+" fromQueue size="+fromQueue.size()+", toQueue size="+toQueue.size()); } iteration++; } toQueue.put(0L); totalCounter.addAndGet(iteration); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
@Override public void run() { long iter = 0; while (!testContext.isStopped()) { try { Thread.sleep(rand.nextInt(maxIntervalMillis) * consumerCount); produced.incrementAndGet(); workQueue.offer(new Work()); iter++; if (iter % 10 == 0) { log.info(Thread.currentThread().getName() + " prod-id:" + id + " iteration: " + iter + " prodoced:" + produced.get() + " workqueue:" + workQueue.size() + " consumed:" + consumed.get()); } } catch (Exception e) { throw new RuntimeException(e); } } } }
@Verify public void verify() { long expected = workQueue.size() + consumed.get(); long actual = produced.get(); assertEquals(expected, actual); }
protected void handleSize(String[] args) { int size = 0; String iteratorStr = args[0]; if (iteratorStr.startsWith("s.")) { size = getSet().size(); } else if (iteratorStr.startsWith("m.")) { size = getMap().size(); } else if (iteratorStr.startsWith("mm.")) { size = getMultiMap().size(); } else if (iteratorStr.startsWith("q.")) { size = getQueue().size(); } else if (iteratorStr.startsWith("l.")) { size = getList().size(); } println("Size: " + size); }
protected void handleSize(String[] args) { int size = 0; String iteratorStr = args[0]; if (iteratorStr.startsWith("s.")) { size = getSet().size(); } else if (iteratorStr.startsWith("m.")) { size = getMap().size(); } else if (iteratorStr.startsWith("mm.")) { size = getMultiMap().size(); } else if (iteratorStr.startsWith("q.")) { size = getQueue().size(); } else if (iteratorStr.startsWith("l.")) { size = getList().size(); } println("Size: " + size); }
protected void handleSize(String[] args) { int size = 0; String iteratorStr = args[0]; if (iteratorStr.startsWith("s.")) { size = getSet().size(); } else if (iteratorStr.startsWith("m.")) { size = getMap().size(); } else if (iteratorStr.startsWith("mm.")) { size = getMultiMap().size(); } else if (iteratorStr.startsWith("q.")) { size = getQueue().size(); } else if (iteratorStr.startsWith("l.")) { size = getList().size(); } println("Size = " + size); }
protected void handleSize(String[] args) { int size = 0; String iteratorStr = args[0]; if (iteratorStr.startsWith("s.")) { size = getSet().size(); } else if (iteratorStr.startsWith("m.")) { size = getMap().size(); } else if (iteratorStr.startsWith("mm.")) { size = getMultiMap().size(); } else if (iteratorStr.startsWith("q.")) { size = getQueue().size(); } else if (iteratorStr.startsWith("l.")) { size = getList().size(); } println("Size = " + size); }
@Verify(global = true) public void verify() { IQueue queue = instance.getQueue(basename +"q"); ILock firstLock = instance.getLock(basename +"l1"); ILock secondLock = instance.getLock(basename +"l2"); IList<TxnCounter> results = instance.getList(basename +"results"); TxnCounter total = new TxnCounter(); for(TxnCounter counter : results){ total.add(counter); } System.out.println(basename +": "+ total+" from "+results.size()); assertFalse(firstLock.isLocked()); assertFalse(secondLock.isLocked()); assertEquals(total.committed - total.rolled, queue.size()); }
public void start(String[] args) { getMap().size(); getList().size(); getSet().size(); getQueue().size(); getMultiMap().size(); if (lineReader == null) { lineReader = new DefaultLineReader(); } running = true; while (running) { print("hazelcast[" + namespace + "] > "); try { final String command = lineReader.readLine(); handleCommand(command); } catch (Throwable e) { e.printStackTrace(); } } }
@Verify public void globalVerify() { IQueue queue = targetInstance.getQueue(name + 'q'); IList<TxnCounter> results = targetInstance.getList(name + "results"); TxnCounter total = new TxnCounter(); for (TxnCounter counter : results) { total.add(counter); } logger.info(name + ": " + total + " from " + results.size() + " worker Threads Queue size=" + queue.size()); assertFalse(name + ": firstLock.isLocked()", firstLock.isLocked()); assertFalse(name + ": secondLock.isLocked()", secondLock.isLocked()); // TODO: check if this assert can be re-enabled: assertEquals(total.committed - total.rolled, queue.size()) } }
public void start(String[] args) { getMap().size(); getList().size(); getSet().size(); getQueue().size(); getMultiMap().size(); if (lineReader == null) { lineReader = new DefaultLineReader(); } running = true; while (running) { print("hazelcast[" + namespace + "] > "); try { final String command = lineReader.readLine(); handleCommand(command); } catch (Throwable e) { e.printStackTrace(); } } }
public void start() throws Exception { getMap().size(); getList().size(); getSet().size(); getQueue().size(); getTopic().getLocalTopicStats(); getMultiMap().size(); hazelcast.getExecutorService("default").getLocalExecutorStats(); for (int i = 1; i <= LOAD_EXECUTORS_COUNT; i++) { hazelcast.getExecutorService(EXECUTOR_NAMESPACE + " " + i).getLocalExecutorStats(); } if (lineReader == null) { lineReader = new DefaultLineReader(); } running = true; while (running) { print("hazelcast[" + namespace + "] > "); try { final String command = lineReader.readLine(); handleCommand(command); } catch (Throwable e) { e.printStackTrace(); } } }