本文整理汇总了Java中org.apache.zookeeper.server.quorum.flexible.QuorumMaj类的典型用法代码示例。如果您正苦于以下问题:Java QuorumMaj类的具体用法?Java QuorumMaj怎么用?Java QuorumMaj使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QuorumMaj类属于org.apache.zookeeper.server.quorum.flexible包,在下文中一共展示了QuorumMaj类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: QuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
File dataLogDir, int electionType,
long myid, int tickTime, int initLimit, int syncLimit,
boolean quorumListenOnAllIPs,
ServerCnxnFactory cnxnFactory,
QuorumVerifier quorumConfig) throws IOException {
this();
this.cnxnFactory = cnxnFactory;
this.quorumPeers = quorumPeers;
this.electionType = electionType;
this.myid = myid;
this.tickTime = tickTime;
this.initLimit = initLimit;
this.syncLimit = syncLimit;
this.quorumListenOnAllIPs = quorumListenOnAllIPs;
this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
this.zkDb = new ZKDatabase(this.logFactory);
if(quorumConfig == null)
this.quorumConfig = new QuorumMaj(countParticipants(quorumPeers));
else this.quorumConfig = quorumConfig;
}
示例2: createQuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
private QuorumPeer createQuorumPeer(File tmpDir) throws IOException,
FileNotFoundException {
QuorumPeer peer = new QuorumPeer();
peer.syncLimit = SYNC_LIMIT;
peer.initLimit = 2;
peer.tickTime = 2000;
peer.quorumPeers = new HashMap<Long, QuorumServer>();
peer.quorumPeers.put(1L, new QuorumServer(0, "0.0.0.0", 33221, 0, null));
peer.quorumPeers.put(1L, new QuorumServer(1, "0.0.0.0", 33223, 0, null));
peer.setQuorumVerifier(new QuorumMaj(3));
peer.setCnxnFactory(new NullServerCnxnFactory());
File version2 = new File(tmpDir, "version-2");
version2.mkdir();
FileOutputStream fos;
fos = new FileOutputStream(new File(version2, "currentEpoch"));
fos.write("0\n".getBytes());
fos.close();
fos = new FileOutputStream(new File(version2, "acceptedEpoch"));
fos.write("0\n".getBytes());
fos.close();
return peer;
}
示例3: QuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
File dataLogDir, int electionType,
long myid, int tickTime, int initLimit, int syncLimit,
ServerCnxnFactory cnxnFactory,
QuorumVerifier quorumConfig) throws IOException {
this();
this.cnxnFactory = cnxnFactory;
this.quorumPeers = quorumPeers;
this.electionType = electionType;
this.myid = myid;
this.tickTime = tickTime;
this.initLimit = initLimit;
this.syncLimit = syncLimit;
this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
this.zkDb = new ZKDatabase(this.logFactory);
if(quorumConfig == null)
this.quorumConfig = new QuorumMaj(countParticipants(quorumPeers));
else this.quorumConfig = quorumConfig;
}
示例4: createQuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
private QuorumPeer createQuorumPeer(File tmpDir) throws IOException,
FileNotFoundException {
QuorumPeer peer = new QuorumPeer();
peer.syncLimit = 2;
peer.initLimit = 2;
peer.tickTime = 2000;
peer.quorumPeers = new HashMap<Long, QuorumServer>();
peer.quorumPeers.put(1L, new QuorumServer(0, new InetSocketAddress(33221)));
peer.quorumPeers.put(1L, new QuorumServer(1, new InetSocketAddress(33223)));
peer.setQuorumVerifier(new QuorumMaj(3));
peer.setCnxnFactory(new NullServerCnxnFactory());
File version2 = new File(tmpDir, "version-2");
version2.mkdir();
new FileOutputStream(new File(version2, "currentEpoch")).write("0\n".getBytes());
new FileOutputStream(new File(version2, "acceptedEpoch")).write("0\n".getBytes());
return peer;
}
示例5: createQuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
private QuorumPeer createQuorumPeer(File tmpDir) throws IOException,
FileNotFoundException {
QuorumPeer peer = new QuorumPeer();
peer.syncLimit = SYNC_LIMIT;
peer.initLimit = 2;
peer.tickTime = 2000;
peer.quorumPeers = new HashMap<Long, QuorumServer>();
peer.quorumPeers.put(1L, new QuorumServer(0, new InetSocketAddress(33221)));
peer.quorumPeers.put(1L, new QuorumServer(1, new InetSocketAddress(33223)));
peer.setQuorumVerifier(new QuorumMaj(3));
peer.setCnxnFactory(new NullServerCnxnFactory());
File version2 = new File(tmpDir, "version-2");
version2.mkdir();
FileOutputStream fos;
fos = new FileOutputStream(new File(version2, "currentEpoch"));
fos.write("0\n".getBytes());
fos.close();
fos = new FileOutputStream(new File(version2, "acceptedEpoch"));
fos.write("0\n".getBytes());
fos.close();
return peer;
}
示例6: processConfigData
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
private void processConfigData(byte[] data) throws Exception
{
Properties properties = new Properties();
properties.load(new ByteArrayInputStream(data));
log.info("New config event received: {}", properties);
if (!properties.isEmpty())
{
QuorumMaj newConfig = new QuorumMaj(properties);
String connectionString = configToConnectionString(newConfig);
if (connectionString.trim().length() > 0)
{
currentConfig.set(newConfig);
ensembleProvider.setConnectionString(connectionString);
}
else
{
log.error("Invalid config event received: {}", properties);
}
}
else
{
log.debug("Ignoring new config as it is empty");
}
}
示例7: QuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
File dataLogDir, int electionType,
long myid, int tickTime, int initLimit, int syncLimit,
NIOServerCnxn.Factory cnxnFactory,
QuorumVerifier quorumConfig) throws IOException {
this();
this.cnxnFactory = cnxnFactory;
this.quorumPeers = quorumPeers;
this.electionType = electionType;
this.myid = myid;
this.tickTime = tickTime;
this.initLimit = initLimit;
this.syncLimit = syncLimit;
this.logFactory = new FileTxnSnapLog(dataLogDir, dataDir);
this.zkDb = new ZKDatabase(this.logFactory);
if(quorumConfig == null)
this.quorumConfig = new QuorumMaj(countParticipants(quorumPeers));
else this.quorumConfig = quorumConfig;
}
示例8: MockQuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
public MockQuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
File logDir, int clientPort, int electionAlg,
long myid, int tickTime, int initLimit, int syncLimit)
throws IOException
{
super(quorumPeers, snapDir, logDir, electionAlg,
myid,tickTime, initLimit,syncLimit, false,
ServerCnxnFactory.createFactory(clientPort, -1),
new QuorumMaj(countParticipants(quorumPeers)));
}
示例9: QuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
/**
* For backward compatibility purposes, we instantiate QuorumMaj by default.
*/
public QuorumPeer(Map<Long, QuorumServer> quorumPeers, File dataDir,
File dataLogDir, int electionType,
long myid, int tickTime, int initLimit, int syncLimit,
ServerCnxnFactory cnxnFactory) throws IOException {
this(quorumPeers, dataDir, dataLogDir, electionType, myid, tickTime,
initLimit, syncLimit, false, cnxnFactory,
new QuorumMaj(quorumPeers));
}
示例10: createQuorumVerifier
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
private static QuorumVerifier createQuorumVerifier(Properties dynamicConfigProp, boolean isHierarchical) throws ConfigException{
if(isHierarchical){
return new QuorumHierarchical(dynamicConfigProp);
} else {
/*
* The default QuorumVerifier is QuorumMaj
*/
//LOG.info("Defaulting to majority quorums");
return new QuorumMaj(dynamicConfigProp);
}
}
示例11: MockQuorumPeer
import org.apache.zookeeper.server.quorum.flexible.QuorumMaj; //导入依赖的package包/类
public MockQuorumPeer(Map<Long,QuorumServer> quorumPeers, File snapDir,
File logDir, int clientPort, int electionAlg,
long myid, int tickTime, int initLimit, int syncLimit)
throws IOException
{
super(quorumPeers, snapDir, logDir, electionAlg,
myid,tickTime, initLimit,syncLimit,
ServerCnxnFactory.createFactory(clientPort, -1),
new QuorumMaj(countParticipants(quorumPeers)));
}