Java 类org.apache.zookeeper.server.ObserverBean 实例源码

项目:fuck_zookeeper    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (this.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (Exception e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:https-github.com-apache-zookeeper    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 * @throws Exception 
 */
void observeLeader() throws Exception {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);
            if (self.isReconfigStateChange())
               throw new Exception("learned about role change");

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (this.isRunning()) {
                readPacket(qp);
                processPacket(qp);
            }
        } catch (Exception e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:ZooKeeper    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        QuorumServer leaderServer = findLeader();
        LOG.info("Observing " + leaderServer.addr);
        try {
            connectToLeader(leaderServer.addr, leaderServer.hostname);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (this.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (Exception e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:StreamProcessingInfrastructure    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (this.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (Exception e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:bigstreams    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:bigstreams    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:zookeeper-src-learning    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:zookeeper    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (Exception e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:SecureKeeper    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 * @throws Exception 
 */
void observeLeader() throws Exception {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);
            if (self.isReconfigStateChange())
               throw new Exception("learned about role change");

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);
            }
        } catch (Exception e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:SecureKeeper    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 * @throws Exception 
 */
void observeLeader() throws Exception {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);
            if (self.isReconfigStateChange())
               throw new Exception("learned about role change");

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);
            }
        } catch (Exception e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:StreamBench    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:ACaZoo    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:LoadBalanced_zk    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:LoadBalanced_zk    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:zookeeper.dsc    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            synchronized (pendingRevalidations) {
                // clear pending revalidations
                pendingRevalidations.clear();
                pendingRevalidations.notifyAll();
            }
        }
    } finally {
        zk.unregisterJMX(this);
    }
}
项目:zookeeper-pkg    文件:Observer.java   
/**
 * the main method called by the observer to observe the leader
 *
 * @throws InterruptedException
 */
void observeLeader() throws InterruptedException {
    zk.registerJMX(new ObserverBean(this, zk), self.jmxLocalPeerBean);

    try {
        InetSocketAddress addr = findLeader();
        LOG.info("Observing " + addr);
        try {
            connectToLeader(addr);
            long newLeaderZxid = registerWithLeader(Leader.OBSERVERINFO);

            syncWithLeader(newLeaderZxid);
            QuorumPacket qp = new QuorumPacket();
            while (self.isRunning()) {
                readPacket(qp);
                processPacket(qp);                   
            }
        } catch (IOException e) {
            LOG.warn("Exception when observing the leader", e);
            try {
                sock.close();
            } catch (IOException e1) {
                e1.printStackTrace();
            }

            // clear pending revalidations
            pendingRevalidations.clear();
        }
    } finally {
        zk.unregisterJMX(this);
    }
}