Package org.jgroups

Examples of org.jgroups.Event


        byte[] buf=new byte[1000];
        JChannel ch1=null, ch2=null;

        try {
            ch1=createChannel(true, 2);
            ch1.down(new Event(Event.CONFIG, m));
            ch2=createChannel(ch1); // same props as ch1 above
            ch2.down(new Event(Event.CONFIG, m));
            MyReceiver receiver=new MyReceiver();
            ch2.setReceiver(receiver);
            ch1.connect(cluster_name);
            ch2.connect(cluster_name);
View Full Code Here


    public Lock getLock(String lock_name) {
        return new LockImpl(lock_name);
    }

    public void unlockAll() {
        ch.down(new Event(Event.UNLOCK_ALL));
    }
View Full Code Here

        public LockImpl(String name) {
            this.name=name;
        }

        public void lock() {
            ch.down(new Event(Event.LOCK, new LockInfo(name, false, false, false, 0, TimeUnit.MILLISECONDS)));
            holder.set(Thread.currentThread());
        }
View Full Code Here

            ch.down(new Event(Event.LOCK, new LockInfo(name, false, false, false, 0, TimeUnit.MILLISECONDS)));
            holder.set(Thread.currentThread());
        }

        public void lockInterruptibly() throws InterruptedException {
            ch.down(new Event(Event.LOCK, new LockInfo(name, false, true, false, 0, TimeUnit.MILLISECONDS)));
            Thread currentThread = Thread.currentThread();
            if(currentThread.isInterrupted())
                throw new InterruptedException();
            else
                holder.set(Thread.currentThread());
View Full Code Here

            else
                holder.set(Thread.currentThread());
        }

        public boolean tryLock() {
            Boolean retval=(Boolean)ch.downcall(new Event(Event.LOCK, new LockInfo(name, true, false, false, 0, TimeUnit.MILLISECONDS)));
            if (retval == Boolean.TRUE) {
                holder.set(Thread.currentThread());
            }
            return retval.booleanValue();
        }
View Full Code Here

            }
            return retval.booleanValue();
        }

        public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
            Boolean retval=(Boolean)ch.downcall(new Event(Event.LOCK, new LockInfo(name, true, true, true, time, unit)));
            if(Thread.currentThread().isInterrupted())
                throw new InterruptedException();
            if (retval == Boolean.TRUE) {
                holder.set(Thread.currentThread());
            }
View Full Code Here

            }
            return retval.booleanValue();
        }

        public void unlock() {
            ch.down(new Event(Event.UNLOCK, new LockInfo(name, false, false, false, 0, TimeUnit.MILLISECONDS)));
            holder.set(null);
        }
View Full Code Here

            this.holder=holder;
        }
       
        @Override
        public void await() throws InterruptedException {
            ch.down(new Event(Event.LOCK_AWAIT, new LockInfo(name, false,
                true, false, 0, TimeUnit.MILLISECONDS)));
            if(Thread.currentThread().isInterrupted())
                throw new InterruptedException();
        }
View Full Code Here

                throw new InterruptedException();
        }

        @Override
        public void awaitUninterruptibly() {
            ch.down(new Event(Event.LOCK_AWAIT, new LockInfo(name, false,
                false, false, 0, TimeUnit.MILLISECONDS)));
        }
View Full Code Here

                false, false, 0, TimeUnit.MILLISECONDS)));
        }

        @Override
        public long awaitNanos(long nanosTimeout) throws InterruptedException {
            Long waitLeft = (Long)ch.downcall(new Event(Event.LOCK_AWAIT,
                new LockInfo(name, false, true, true, nanosTimeout,
                    TimeUnit.NANOSECONDS)));
            if(Thread.currentThread().isInterrupted())
                throw new InterruptedException();
            return waitLeft.longValue();
View Full Code Here

TOP

Related Classes of org.jgroups.Event

Copyright © 2018 www.massapicom. 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.