当前位置: 首页>>代码示例>>Java>>正文


Java ObserverBean类代码示例

本文整理汇总了Java中org.apache.zookeeper.server.ObserverBean的典型用法代码示例。如果您正苦于以下问题:Java ObserverBean类的具体用法?Java ObserverBean怎么用?Java ObserverBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ObserverBean类属于org.apache.zookeeper.server包,在下文中一共展示了ObserverBean类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: observeLeader

import org.apache.zookeeper.server.ObserverBean; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:37,代码来源:Observer.java

示例2: observeLeader

import org.apache.zookeeper.server.ObserverBean; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:38,代码来源:Observer.java

示例3: observeLeader

import org.apache.zookeeper.server.ObserverBean; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:37,代码来源:Observer.java

示例4: observeLeader

import org.apache.zookeeper.server.ObserverBean; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:37,代码来源:Observer.java

示例5: observeLeader

import org.apache.zookeeper.server.ObserverBean; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:txazo,项目名称:zookeeper,代码行数:37,代码来源:Observer.java

示例6: observeLeader

import org.apache.zookeeper.server.ObserverBean; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:38,代码来源:Observer.java

示例7: observeLeader

import org.apache.zookeeper.server.ObserverBean; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:40,代码来源:Observer.java


注:本文中的org.apache.zookeeper.server.ObserverBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。