本文整理了Java中org.apache.zookeeper.server.ZKDatabase.<init>()
方法的一些代码示例,展示了ZKDatabase.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKDatabase.<init>()
方法的具体详情如下:
包路径:org.apache.zookeeper.server.ZKDatabase
类名称:ZKDatabase
方法名:<init>
[英]the filetxnsnaplog that this zk database maps to. There is a one to one relationship between a filetxnsnaplog and zkdatabase.
[中]这个zk数据库映射到的文件txnsnaplog。filetxnsnaplog和zkdatabase之间存在一对一的关系。
代码示例来源:origin: apache/zookeeper
/**
* creates a zookeeperserver instance.
* @param txnLogFactory the file transaction snapshot logging class
* @param tickTime the ticktime for the server
* @throws IOException
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime)
throws IOException {
this(txnLogFactory, tickTime, -1, -1, new ZKDatabase(txnLogFactory));
}
代码示例来源:origin: apache/zookeeper
/**
* Default constructor, relies on the config for its argument values
*
* @throws IOException
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory)
throws IOException
{
this(txnLogFactory, DEFAULT_TICK_TIME, -1, -1, new ZKDatabase(txnLogFactory));
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
/**
* Default constructor, relies on the config for its agrument values
*
* @throws IOException
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory,
DataTreeBuilder treeBuilder)
throws IOException
{
this(txnLogFactory, DEFAULT_TICK_TIME, -1, -1, treeBuilder,
new ZKDatabase(txnLogFactory));
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
/**
* creates a zookeeperserver instance.
* @param txnLogFactory the file transaction snapshot logging class
* @param tickTime the ticktime for the server
* @param treeBuilder the datatree builder
* @throws IOException
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime,
DataTreeBuilder treeBuilder) throws IOException {
this(txnLogFactory, tickTime, -1, -1, treeBuilder,
new ZKDatabase(txnLogFactory));
}
代码示例来源:origin: apache/zookeeper
public SimpleLearnerZooKeeperServer(FileTxnSnapLog ftsl, QuorumPeer self)
throws IOException {
super(ftsl, 2000, 2000, 2000, new ZKDatabase(ftsl), self);
}
代码示例来源:origin: apache/zookeeper
public void startdata()
throws IOException, InterruptedException {
//check to see if zkDb is not null
if (zkDb == null) {
zkDb = new ZKDatabase(this.txnLogFactory);
}
if (!zkDb.isInitialized()) {
loadData();
}
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
public void startdata()
throws IOException, InterruptedException {
//check to see if zkDb is not null
if (zkDb == null) {
zkDb = new ZKDatabase(this.txnLogFactory);
}
if (!zkDb.isInitialized()) {
loadData();
}
}
代码示例来源:origin: apache/zookeeper
@Test
public void testAbsentRecentSnapshot() throws IOException {
ZKDatabase zkDatabase = new ZKDatabase(new FileTxnSnapLog(new File("foo"), new File("bar")){
@Override
public File findMostRecentSnapshot() throws IOException {
return null;
}
});
assertEquals(0, zkDatabase.calculateTxnLogSizeLimit());
}
代码示例来源:origin: apache/zookeeper
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.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) quorumConfig = new QuorumMaj(quorumPeers);
setQuorumVerifier(quorumConfig, false);
adminServer = AdminServerFactory.createAdminServer();
}
代码示例来源:origin: apache/zookeeper
private void deserializeSnapshot(InputArchive ia)
throws IOException {
ZKDatabase zkdb = new ZKDatabase(null);
zkdb.deserializeSnapshot(ia);
String signature = ia.readString("signature");
assertEquals("BenWasHere", signature);
}
代码示例来源:origin: apache/zookeeper
private static LeaderZooKeeperServer prepareLeader(File tmpDir, QuorumPeer peer)
throws IOException, NoSuchFieldException, IllegalAccessException {
FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir);
peer.setTxnFactory(logFactory);
ZKDatabase zkDb = new ZKDatabase(logFactory);
LeaderZooKeeperServer zk = new LeaderZooKeeperServer(logFactory, peer, zkDb);
return zk;
}
代码示例来源:origin: apache/zookeeper
@Before
public void setUp() throws IOException, X509Exception {
qp = new QuorumPeer();
long myId = qp.getId();
int clientPort = PortAssignment.unique();
Map<Long, QuorumServer> peersView = new HashMap<Long, QuorumServer>();
InetAddress clientIP = InetAddress.getLoopbackAddress();
peersView.put(Long.valueOf(myId),
new QuorumServer(myId, new InetSocketAddress(clientIP, PortAssignment.unique()),
new InetSocketAddress(clientIP, PortAssignment.unique()),
new InetSocketAddress(clientIP, clientPort), LearnerType.PARTICIPANT));
quorumVerifierMock = mock(QuorumVerifier.class);
when(quorumVerifierMock.getAllMembers()).thenReturn(peersView);
qp.setQuorumVerifier(quorumVerifierMock, false);
File tmpDir = ClientBase.createEmptyTestDir();
fileTxnSnapLog = new FileTxnSnapLog(new File(tmpDir, "data"),
new File(tmpDir, "data_txnlog"));
ZKDatabase zkDb = new ZKDatabase(fileTxnSnapLog);
zks = new LeaderZooKeeperServer(fileTxnSnapLog, qp, zkDb);
leader = new Leader(qp, zks);
leaderBean = new LeaderBean(leader, zks);
}
代码示例来源:origin: org.apache.zookeeper/zookeeper
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;
}
代码示例来源:origin: apache/zookeeper
private ConversableFollower createFollower(File tmpDir, QuorumPeer peer)
throws IOException {
FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir);
peer.setTxnFactory(logFactory);
ZKDatabase zkDb = new ZKDatabase(logFactory);
FollowerZooKeeperServer zk = new FollowerZooKeeperServer(logFactory, peer, zkDb);
peer.setZKDatabase(zkDb);
return new ConversableFollower(peer, zk);
}
代码示例来源:origin: apache/zookeeper
private ConversableObserver createObserver(File tmpDir, QuorumPeer peer)
throws IOException {
FileTxnSnapLog logFactory = new FileTxnSnapLog(tmpDir, tmpDir);
peer.setTxnFactory(logFactory);
ZKDatabase zkDb = new ZKDatabase(logFactory);
ObserverZooKeeperServer zk = new ObserverZooKeeperServer(logFactory, peer, zkDb);
peer.setZKDatabase(zkDb);
return new ConversableObserver(peer, zk);
}
代码示例来源:origin: apache/zookeeper
@Test
public void testTruncationNullLog() throws Exception {
File tmpdir = ClientBase.createTmpDir();
FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpdir, tmpdir);
ZKDatabase zkdb = new ZKDatabase(snaplog);
for (int i = 1; i <= 100; i++) {
append(zkdb, i);
}
zkdb.close();
File[] logs = snaplog.getDataDir().listFiles();
for(int i = 0; i < logs.length; i++) {
LOG.debug("Deleting: {}", logs[i].getName());
Assert.assertTrue("Failed to delete log file: " + logs[i].getName(), logs[i].delete());
}
try {
zkdb.truncateLog(1);
Assert.assertTrue("Should not get here", false);
}
catch(IOException e) {
Assert.assertTrue("Should have received an IOException", true);
}
catch(NullPointerException npe) {
Assert.fail("This should not throw NPE!");
}
ClientBase.recursiveDelete(tmpdir);
}
代码示例来源:origin: apache/zookeeper
new ErrorTxn(1), zxid));
logFactory.commit();
ZKDatabase zkDb = new ZKDatabase(logFactory);
QuorumPeer peer = QuorumPeer.testingQuorumPeer();
peer.setZKDatabase(zkDb);
代码示例来源:origin: apache/zookeeper
ZKDatabase newDB = new ZKDatabase(fileTxnSnapLogWithError);
zooKeeperServer.setZKDatabase(newDB);
代码示例来源:origin: apache/zookeeper
ZKDatabase zkDb = new ZKDatabase(snapLog);
代码示例来源:origin: apache/zookeeper
@Test
public void testTruncationStreamReset() throws Exception {
File tmpdir = ClientBase.createTmpDir();
FileTxnSnapLog snaplog = new FileTxnSnapLog(tmpdir, tmpdir);
ZKDatabase zkdb = new ZKDatabase(snaplog);
// make sure to snapshot, so that we have something there when
// truncateLog reloads the db
snaplog.save(zkdb.getDataTree(), zkdb.getSessionWithTimeOuts(), false);
for (int i = 1; i <= 100; i++) {
append(zkdb, i);
}
zkdb.truncateLog(1);
append(zkdb, 200);
zkdb.close();
// verify that the truncation and subsequent append were processed
// correctly
FileTxnLog txnlog = new FileTxnLog(new File(tmpdir, "version-2"));
TxnIterator iter = txnlog.read(1);
TxnHeader hdr = iter.getHeader();
Record txn = iter.getTxn();
Assert.assertEquals(1, hdr.getZxid());
Assert.assertTrue(txn instanceof SetDataTxn);
iter.next();
hdr = iter.getHeader();
txn = iter.getTxn();
Assert.assertEquals(200, hdr.getZxid());
Assert.assertTrue(txn instanceof SetDataTxn);
iter.close();
ClientBase.recursiveDelete(tmpdir);
}
内容来源于网络,如有侵权,请联系作者删除!