本文整理汇总了Java中org.apache.zookeeper.server.quorum.FastLeaderElection类的典型用法代码示例。如果您正苦于以下问题:Java FastLeaderElection类的具体用法?Java FastLeaderElection怎么用?Java FastLeaderElection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FastLeaderElection类属于org.apache.zookeeper.server.quorum包,在下文中一共展示了FastLeaderElection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: genNotification
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
/**
* Helper method to build notifications and populate outofelection.
*
*
* @param version
* @param leader
* @param zxid
* @param electionEpoch
* @param state
* @param sid
* @param peerEpoch
* @param outofelection
* @return
*/
FastLeaderElection.Notification genNotification(int version,
long leader,
long zxid,
long electionEpoch,
ServerState state,
long sid,
long peerEpoch,
HashMap<Long,Vote> outofelection) {
FastLeaderElection.Notification n = new FastLeaderElection.Notification();
n.version = version;
n.leader = leader;
n.zxid = zxid;
n.electionEpoch = electionEpoch;
n.state = state;
n.sid = sid;
n.peerEpoch = peerEpoch;
outofelection.put(n.sid, new Vote(n.version,
n.leader,
n.zxid,
n.electionEpoch,
n.peerEpoch,
n.state));
return n;
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:41,代码来源:FLEDontCareTest.java
示例2: testLostMessage
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLostMessage() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestLE: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
int clientport = PortAssignment.unique();
peers.put(Long.valueOf(i),
new QuorumServer(i, "0.0.0.0", clientport,
PortAssignment.unique(), null));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = clientport;
}
/*
* Start server 0
*/
QuorumPeer peer = new QuorumPeer(peers, tmpdir[1], tmpdir[1], port[1], 3, 1, 1000, 2, 2);
peer.startLeaderElection();
FLETestUtils.LEThread thread = new FLETestUtils.LEThread(peer, 1);
thread.start();
/*
* Start mock server 1
*/
mockServer();
thread.join(5000);
if (thread.isAlive()) {
Assert.fail("Threads didn't join");
}
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:33,代码来源:FLELostMessageTest.java
示例3: testZeroWeightQuorum
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testZeroWeightQuorum() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestZeroWeightQuorum: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i, "0.0.0.0", PortAssignment.unique(), PortAssignment.unique(), null));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < le.length; i++) {
QuorumHierarchical hq = new QuorumHierarchical(qp);
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2, hq);
peer.startLeaderElection();
LEThread thread = new LEThread(peer, i);
thread.start();
threads.add(thread);
}
LOG.info("Started threads " + getTestName());
for(int i = 0; i < threads.size(); i++) {
threads.get(i).join(15000);
if (threads.get(i).isAlive()) {
Assert.fail("Threads didn't join");
} else {
if(threads.get(i).fail)
Assert.fail("Elected zero-weight server");
}
}
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:33,代码来源:FLEZeroWeightTest.java
示例4: testLERestart
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLERestart() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
leaderDies = true;
boolean allowOneBadLeader = leaderDies;
LOG.info("TestLE: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i, "0.0.0.0", PortAssignment.unique(),
PortAssignment.unique(), null));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < count; i++) {
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2);
peer.startLeaderElection();
FLERestartThread thread = new FLERestartThread(peer, i);
thread.start();
restartThreads.add(thread);
}
LOG.info("Started threads " + getTestName());
for(int i = 0; i < restartThreads.size(); i++) {
restartThreads.get(i).join(10000);
if (restartThreads.get(i).isAlive()) {
Assert.fail("Threads didn't join");
}
}
}
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:33,代码来源:FLERestartTest.java
示例5: testZeroWeightQuorum
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testZeroWeightQuorum() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestZeroWeightQuorum: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(PortAssignment.unique()),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < le.length; i++) {
QuorumHierarchical hq = new QuorumHierarchical(qp);
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2, hq);
peer.startLeaderElection();
LEThread thread = new LEThread(peer, i);
thread.start();
threads.add(thread);
}
LOG.info("Started threads " + getTestName());
for(int i = 0; i < threads.size(); i++) {
threads.get(i).join(15000);
if (threads.get(i).isAlive()) {
Assert.fail("Threads didn't join");
} else {
if(threads.get(i).fail)
Assert.fail("Elected zero-weight server");
}
}
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:35,代码来源:FLEZeroWeightTest.java
示例6: testLostMessage
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLostMessage() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestLE: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
int clientport = PortAssignment.unique();
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(clientport),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = clientport;
}
/*
* Start server 0
*/
QuorumPeer peer = new QuorumPeer(peers, tmpdir[1], tmpdir[1], port[1], 3, 1, 1000, 2, 2);
peer.startLeaderElection();
FLETestUtils.LEThread thread = new FLETestUtils.LEThread(peer, 1);
thread.start();
/*
* Start mock server 1
*/
mockServer();
thread.join(5000);
if (thread.isAlive()) {
Assert.fail("Threads didn't join");
}
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:FLELostMessageTest.java
示例7: testLERestart
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLERestart() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
leaderDies = true;
boolean allowOneBadLeader = leaderDies;
LOG.info("TestLE: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(PortAssignment.unique()),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < count; i++) {
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2);
peer.startLeaderElection();
FLERestartThread thread = new FLERestartThread(peer, i);
thread.start();
restartThreads.add(thread);
}
LOG.info("Started threads " + getTestName());
for(int i = 0; i < restartThreads.size(); i++) {
restartThreads.get(i).join(10000);
if (restartThreads.get(i).isAlive()) {
Assert.fail("Threads didn't join");
}
}
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:FLERestartTest.java
示例8: testZeroWeightQuorum
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testZeroWeightQuorum() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestZeroWeightQuorum: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(PortAssignment.unique()),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < le.length; i++) {
QuorumHierarchical hq = new QuorumHierarchical(qp);
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 2, 2, 2, hq);
peer.startLeaderElection();
LEThread thread = new LEThread(peer, i);
thread.start();
threads.add(thread);
}
LOG.info("Started threads " + getTestName());
for(int i = 0; i < threads.size(); i++) {
threads.get(i).join(15000);
if (threads.get(i).isAlive()) {
Assert.fail("Threads didn't join");
} else {
if(threads.get(i).fail)
Assert.fail("Elected zero-weight server");
}
}
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:35,代码来源:FLEZeroWeightTest.java
示例9: testLostMessage
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLostMessage() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestLE: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
int clientport = PortAssignment.unique();
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(clientport),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = clientport;
}
/*
* Start server 0
*/
QuorumPeer peer = new QuorumPeer(peers, tmpdir[1], tmpdir[1], port[1], 3, 1, 2, 2, 2);
peer.startLeaderElection();
LEThread thread = new LEThread(peer, 1);
thread.start();
/*
* Start mock server 1
*/
mockServer();
thread.join(5000);
if (thread.isAlive()) {
Assert.fail("Threads didn't join");
}
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:FLELostMessageTest.java
示例10: testLERestart
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLERestart() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
leaderDies = true;
boolean allowOneBadLeader = leaderDies;
LOG.info("TestLE: " + getTestName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(PortAssignment.unique()),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < count; i++) {
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 2, 2, 2);
peer.startLeaderElection();
FLERestartThread thread = new FLERestartThread(peer, i);
thread.start();
restartThreads.add(thread);
}
LOG.info("Started threads " + getTestName());
for(int i = 0; i < restartThreads.size(); i++) {
restartThreads.get(i).join(10000);
if (restartThreads.get(i).isAlive()) {
Assert.fail("Threads didn't join");
}
}
}
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:FLERestartTest.java
示例11: tearDown
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
for(int i = 0; i < threads.size(); i++) {
((FastLeaderElection) threads.get(i).peer.getElectionAlg()).shutdown();
}
LOG.info("FINISHED " + getName());
}
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:8,代码来源:FLENewEpochTest.java
示例12: testZeroWeightQuorum
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testZeroWeightQuorum() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestZeroWeightQuorum: " + getName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(PortAssignment.unique()),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < le.length; i++) {
QuorumHierarchical hq = new QuorumHierarchical(qp);
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2, hq);
peer.startLeaderElection();
LEThread thread = new LEThread(peer, i);
thread.start();
threads.add(thread);
}
LOG.info("Started threads " + getName());
for(int i = 0; i < threads.size(); i++) {
threads.get(i).join(15000);
if (threads.get(i).isAlive()) {
fail("Threads didn't join");
} else {
if(threads.get(i).fail)
fail("Elected zero-weight server");
}
}
}
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:35,代码来源:FLEZeroWeightTest.java
示例13: testLostMessage
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLostMessage() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
LOG.info("TestLE: " + getName()+ ", " + count);
for(int i = 0; i < count; i++) {
int clientport = PortAssignment.unique();
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(clientport),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = clientport;
}
/*
* Start server 0
*/
QuorumPeer peer = new QuorumPeer(peers, tmpdir[1], tmpdir[1], port[1], 3, 1, 1000, 2, 2);
peer.startLeaderElection();
LEThread thread = new LEThread(peer, 1);
thread.start();
/*
* Start mock server 1
*/
mockServer();
thread.join(5000);
if (thread.isAlive()) {
fail("Threads didn't join");
}
}
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:34,代码来源:FLELostMessageTest.java
示例14: tearDown
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Override
public void tearDown() throws Exception {
for(int i = 0; i < restartThreads.size(); i++) {
((FastLeaderElection) restartThreads.get(i).peer.getElectionAlg()).shutdown();
}
LOG.info("FINISHED " + getName());
}
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:8,代码来源:FLERestartTest.java
示例15: testLERestart
import org.apache.zookeeper.server.quorum.FastLeaderElection; //导入依赖的package包/类
@Test
public void testLERestart() throws Exception {
FastLeaderElection le[] = new FastLeaderElection[count];
leaderDies = true;
boolean allowOneBadLeader = leaderDies;
LOG.info("TestLE: " + getName()+ ", " + count);
for(int i = 0; i < count; i++) {
peers.put(Long.valueOf(i),
new QuorumServer(i,
new InetSocketAddress(PortAssignment.unique()),
new InetSocketAddress(PortAssignment.unique())));
tmpdir[i] = ClientBase.createTmpDir();
port[i] = PortAssignment.unique();
}
for(int i = 0; i < count; i++) {
QuorumPeer peer = new QuorumPeer(peers, tmpdir[i], tmpdir[i], port[i], 3, i, 1000, 2, 2);
peer.startLeaderElection();
FLERestartThread thread = new FLERestartThread(peer, i);
thread.start();
restartThreads.add(thread);
}
LOG.info("Started threads " + getName());
for(int i = 0; i < restartThreads.size(); i++) {
restartThreads.get(i).join(10000);
if (restartThreads.get(i).isAlive()) {
fail("Threads didn't join");
}
}
}
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:34,代码来源:FLERestartTest.java
注:本文中的org.apache.zookeeper.server.quorum.FastLeaderElection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论