Examples of ZkQueue


Examples of io.s4.comm.zk.ZkQueue

import org.apache.zookeeper.KeeperException;

public class ZkQueueTest {
    public static void main(String args[]) {
        ZkQueue q = new ZkQueue(args[0], "/app1");

        System.out.println("Input: " + args[0]);
        int i;
        Integer max = new Integer(args[1]);

        if (args[2].equals("p")) {
            System.out.println("Producer");
            for (i = 0; i < max; i++)
                try {
                    q.produce(new Integer(10 + i));
                } catch (KeeperException e) {

                } catch (InterruptedException e) {

                }
        } else {
            System.out.println("Consumer");

            for (i = 0; i < max || true; i++) {
                try {
                    Integer r = (Integer) q.consume();
                    System.out.println("Item: " + r);
                } catch (KeeperException e) {
                    e.printStackTrace();
                    i--;
                } catch (InterruptedException e) {
View Full Code Here

Examples of org.apache.s4.comm.zk.ZkQueue

import org.apache.zookeeper.KeeperException;

public class ZkQueueTest {
    public static void main(String args[]) {
        ZkQueue q = new ZkQueue(args[0], "/app1");

        System.out.println("Input: " + args[0]);
        int i;
        Integer max = new Integer(args[1]);

        if (args[2].equals("p")) {
            System.out.println("Producer");
            for (i = 0; i < max; i++)
                try {
                    q.produce(new Integer(10 + i));
                } catch (KeeperException e) {

                } catch (InterruptedException e) {

                }
        } else {
            System.out.println("Consumer");

            for (i = 0; i < max || true; i++) {
                try {
                    Integer r = (Integer) q.consume();
                    System.out.println("Item: " + r);
                } catch (KeeperException e) {
                    e.printStackTrace();
                    i--;
                } catch (InterruptedException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.