本文整理汇总了Java中org.apache.zookeeper.test.ClientBase.recursiveDelete方法的典型用法代码示例。如果您正苦于以下问题:Java ClientBase.recursiveDelete方法的具体用法?Java ClientBase.recursiveDelete怎么用?Java ClientBase.recursiveDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.zookeeper.test.ClientBase
的用法示例。
在下文中一共展示了ClientBase.recursiveDelete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: teardown
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
@After
public void teardown() throws Exception {
// count down to avoid infinite blocking call due to this latch, if
// any.
startupDelayLatch.countDown();
if (servcnxnf != null) {
servcnxnf.shutdown();
}
if (zks != null) {
zks.shutdown();
}
if (zks.getZKDatabase() != null) {
zks.getZKDatabase().close();
}
if (tmpDir != null) {
ClientBase.recursiveDelete(tmpDir);
}
}
示例2: testLearnerHandlerAuthFailed
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* Test verifies that the LearnerHandler should authenticate the connecting
* quorumpeer. Here its simulating authentication failure and it should throw
* SaslException
*/
@Test(timeout = 30000)
public void testLearnerHandlerAuthFailed() throws Exception {
File testData = ClientBase.createTmpDir();
Socket leaderSocket = getSocketPair();
File tmpDir = File.createTempFile("test", ".dir", testData);
tmpDir.delete();
tmpDir.mkdir();
Leader leader = null;
QuorumPeer peer = createQuorumPeer(tmpDir, true, false, true,
"QuorumLearner", "QuorumServer",
QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL_DEFAULT_VALUE);
leader = createLeader(tmpDir, peer);
peer.leader = leader;
// authentication failed as qpserver didn't get auth packet from qpclient.
try {
new LearnerHandler(leaderSocket,
new BufferedInputStream(leaderSocket.getInputStream()), leader);
Assert.fail("Must throw exception as there is an authentication failure");
} catch (SaslException e){
Assert.assertEquals("Mistakely added to learners", 0,
leader.getLearners().size());
}
ClientBase.recursiveDelete(testData);
}
示例3: testPurgeTxnLogWithoutDataDir
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* PurgeTxnLog is called with dataLogDir -n count This test case verify
* these values are parsed properly and functionality works fine
*/
@Test
public void testPurgeTxnLogWithoutDataDir()
throws Exception {
tmpDir = ClientBase.createTmpDir();
File dataDir = new File(tmpDir, "dataDir");
File dataLogDir = new File(tmpDir, "dataLogDir");
File dataDirVersion2 = new File(dataDir, "version-2");
dataDirVersion2.mkdirs();
File dataLogDirVersion2 = new File(dataLogDir, "version-2");
dataLogDirVersion2.mkdirs();
// create dummy log and transaction file
int totalFiles = 20;
// create transaction and snapshot files in data directory
for (int i = 0; i < totalFiles; i++) {
// simulate log file
File logFile = new File(dataLogDirVersion2, "log."
+ Long.toHexString(i));
logFile.createNewFile();
// simulate snapshot file
File snapFile = new File(dataLogDirVersion2, "snapshot."
+ Long.toHexString(i));
snapFile.createNewFile();
}
int numberOfFilesToKeep = 10;
// scenario where only three parameter are passed
String[] args = new String[] { dataLogDir.getAbsolutePath(), "-n",
Integer.toString(numberOfFilesToKeep) };
PurgeTxnLog.main(args);
assertEquals(numberOfFilesToKeep + numberOfFilesToKeep,
dataLogDirVersion2.listFiles().length);
ClientBase.recursiveDelete(tmpDir);
}
示例4: testGenFile
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
@Test
public void testGenFile() throws Exception {
VerGen.Version v = VerGen.parseVersionString(input);
File outputDir = ClientBase.createTmpDir();
VerGen.generateFile(outputDir, v, 1, "Nov1");
ClientBase.recursiveDelete(outputDir);
}
示例5: testPurgeTxnLogWithoutDataDir
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* PurgeTxnLog is called with dataLogDir -n count This test case verify
* these values are parsed properly and functionality works fine
*/
@Test
public void testPurgeTxnLogWithoutDataDir()
throws Exception {
tmpDir = ClientBase.createTmpDir();
File dataDir = new File(tmpDir, "dataDir");
File dataLogDir = new File(tmpDir, "dataLogDir");
File dataDirVersion2 = new File(dataDir, "version-2");
dataDirVersion2.mkdirs();
File dataLogDirVersion2 = new File(dataLogDir, "version-2");
dataLogDirVersion2.mkdirs();
// create dummy log and transaction file
int totalFiles = 20;
// create transaction and snapshot files in data directory
for (int i = 0; i < totalFiles; i++) {
// simulate log file
File logFile = new File(dataLogDirVersion2, "log."
+ Long.toHexString(i));
logFile.createNewFile();
// simulate snapshot file
File snapFile = new File(dataLogDirVersion2, "snapshot."
+ Long.toHexString(i));
snapFile.createNewFile();
}
int numberOfSnapFilesToKeep = 10;
// scenario where only three parameter are passed
String[] args = new String[] { dataLogDir.getAbsolutePath(), "-n",
Integer.toString(numberOfSnapFilesToKeep) };
PurgeTxnLog.main(args);
assertEquals(numberOfSnapFilesToKeep * 2, // Since for each snapshot we have a log file with same zxid, expect same # logs as snaps to be kept
dataLogDirVersion2.listFiles().length);
ClientBase.recursiveDelete(tmpDir);
}
示例6: testGenFile
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
@Test
public void testGenFile() throws Exception {
VerGen.Version v = VerGen.parseVersionString(input);
File outputDir = ClientBase.createTmpDir();
VerGen.generateFile(outputDir, v, "1", "Nov1");
ClientBase.recursiveDelete(outputDir);
}
示例7: testAuthLearnerConnectsToServerWithAuthRequired
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* Test verifies that the Leader should authenticate the connecting learner
* quorumpeer. After the successful authentication it should add this
* learner to the learnerHandler list.
*/
@Test(timeout = 30000)
public void testAuthLearnerConnectsToServerWithAuthRequired()
throws Exception {
File testDataLearner = ClientBase.createTmpDir();
File tmpDir = File.createTempFile("test", ".dir", testDataLearner);
tmpDir.delete();
FileTxnSnapLog ftsl = new FileTxnSnapLog(tmpDir, tmpDir);
QuorumPeer learnerPeer = createQuorumPeer(tmpDir, true, true, true,
"QuorumLearner", "QuorumServer",
QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL_DEFAULT_VALUE);
SimpleLearner sl = new SimpleLearner(ftsl, learnerPeer);
File testDataLeader = ClientBase.createTmpDir();
tmpDir = File.createTempFile("test", ".dir", testDataLeader);
tmpDir.delete();
tmpDir.mkdir();
Leader leader = null;
QuorumPeer peer = createQuorumPeer(tmpDir, true, true, true, "QuorumLearner",
"QuorumServer",
QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL_DEFAULT_VALUE);
CountDownLatch learnerLatch = new CountDownLatch(1);
leader = createSimpleLeader(tmpDir, peer, learnerLatch);
peer.leader = leader;
startLearnerCnxAcceptorThread(leader);
LOG.info("Start establishing a connection with the Leader");
String hostname = getLeaderHostname(peer);
sl.connectToLeader(peer.getQuorumAddress(), hostname);
// wait till leader socket soTimeout period
Assert.assertTrue("Leader should accept the auth learner connection",
learnerLatch.await(leader.self.tickTime * leader.self.initLimit + 1000,
TimeUnit.MILLISECONDS));
Assert.assertEquals("Failed to added the learner", 1,
leader.getLearners().size());
ClientBase.recursiveDelete(testDataLearner);
ClientBase.recursiveDelete(testDataLeader);
}
示例8: testAuthLearnerConnectsToServerWithAuthNotRequired
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* Test verifies that the Leader should authenticate the connecting learner
* quorumpeer. After the successful authentication it should add this
* learner to the learnerHandler list.
*/
@Test(timeout = 30000)
public void testAuthLearnerConnectsToServerWithAuthNotRequired()
throws Exception {
File testDataLearner = ClientBase.createTmpDir();
File tmpDir = File.createTempFile("test", ".dir", testDataLearner);
tmpDir.delete();
FileTxnSnapLog ftsl = new FileTxnSnapLog(tmpDir, tmpDir);
QuorumPeer learnerPeer = createQuorumPeer(tmpDir, true, true, true,
"QuorumLearner", "QuorumServer",
QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL_DEFAULT_VALUE);
SimpleLearner sl = new SimpleLearner(ftsl, learnerPeer);
File testDataLeader = ClientBase.createTmpDir();
tmpDir = File.createTempFile("test", ".dir", testDataLeader);
tmpDir.delete();
tmpDir.mkdir();
Leader leader = null;
QuorumPeer peer = createQuorumPeer(tmpDir, true, true, false, "QuorumLearner",
"QuorumServer",
QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL_DEFAULT_VALUE);
CountDownLatch learnerLatch = new CountDownLatch(1);
leader = createSimpleLeader(tmpDir, peer, learnerLatch);
peer.leader = leader;
startLearnerCnxAcceptorThread(leader);
LOG.info("Start establishing a connection with the Leader");
String hostname = getLeaderHostname(peer);
sl.connectToLeader(peer.getQuorumAddress(), hostname);
// wait till leader socket soTimeout period
Assert.assertTrue("Leader should accept the auth learner connection",
learnerLatch.await(leader.self.tickTime * leader.self.initLimit + 1000,
TimeUnit.MILLISECONDS));
Assert.assertEquals("Failed to added the learner", 1,
leader.getLearners().size());
ClientBase.recursiveDelete(testDataLearner);
ClientBase.recursiveDelete(testDataLeader);
}
示例9: testNoAuthLearnerConnectsToServerWithAuthNotRequired
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* Test verifies that the No Auth enabled Learner is connecting to a No Auth
* Leader server. Learner should be able to establish a connection with
* Leader as auth is not required.
*/
@Test(timeout = 30000)
public void testNoAuthLearnerConnectsToServerWithAuthNotRequired()
throws Exception {
File testDataLearner = ClientBase.createTmpDir();
File tmpDir = File.createTempFile("test", ".dir", testDataLearner);
tmpDir.delete();
FileTxnSnapLog ftsl = new FileTxnSnapLog(tmpDir, tmpDir);
QuorumPeer learnerPeer = createQuorumPeer(tmpDir, true, false, false,
"QuorumLearner", "QuorumServer", "");
SimpleLearner sl = new SimpleLearner(ftsl, learnerPeer);
File testDataLeader = ClientBase.createTmpDir();
tmpDir = File.createTempFile("test", ".dir", testDataLeader);
tmpDir.delete();
tmpDir.mkdir();
Leader leader = null;
QuorumPeer peer = createQuorumPeer(tmpDir, true, false, false, "QuorumLearner",
"QuorumServer",
QuorumAuth.QUORUM_KERBEROS_SERVICE_PRINCIPAL_DEFAULT_VALUE);
CountDownLatch learnerLatch = new CountDownLatch(1);
leader = createSimpleLeader(tmpDir, peer, learnerLatch);
peer.leader = leader;
startLearnerCnxAcceptorThread(leader);
LOG.info("Start establishing a connection with the Leader");
String hostname = getLeaderHostname(peer);
sl.connectToLeader(peer.getQuorumAddress(), hostname);
Assert.assertTrue("Leader should accept no auth learner connection",
learnerLatch.await(leader.self.tickTime * leader.self.initLimit + 1000,
TimeUnit.MILLISECONDS));
ClientBase.recursiveDelete(testDataLearner);
ClientBase.recursiveDelete(testDataLeader);
}
示例10: clean
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
public void clean() {
ClientBase.recursiveDelete(main.quorumPeer.getTxnFactory()
.getDataDir());
}
示例11: teardown
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
@After
public void teardown() {
if (null != tmpDir) {
ClientBase.recursiveDelete(tmpDir);
}
}
示例12: testPurgeTxnLogWithDataDir
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* PurgeTxnLog is called with dataLogDir snapDir -n count This test case
* verify these values are parsed properly and functionality works fine
*/
@Test
public void testPurgeTxnLogWithDataDir()
throws Exception {
tmpDir = ClientBase.createTmpDir();
File dataDir = new File(tmpDir, "dataDir");
File dataLogDir = new File(tmpDir, "dataLogDir");
File dataDirVersion2 = new File(dataDir, "version-2");
dataDirVersion2.mkdirs();
File dataLogDirVersion2 = new File(dataLogDir, "version-2");
dataLogDirVersion2.mkdirs();
// create dummy log and transaction file
int totalFiles = 20;
// create transaction and snapshot files in different-different
// directories
for (int i = 0; i < totalFiles; i++) {
// simulate log file
File logFile = new File(dataLogDirVersion2, "log."
+ Long.toHexString(i));
logFile.createNewFile();
// simulate snapshot file
File snapFile = new File(dataDirVersion2, "snapshot."
+ Long.toHexString(i));
snapFile.createNewFile();
}
int numberOfFilesToKeep = 10;
// scenario where four parameter are passed
String[] args = new String[] { dataLogDir.getAbsolutePath(),
dataDir.getAbsolutePath(), "-n",
Integer.toString(numberOfFilesToKeep) };
PurgeTxnLog.main(args);
assertEquals(numberOfFilesToKeep, dataDirVersion2.listFiles().length);
assertEquals(numberOfFilesToKeep, dataLogDirVersion2.listFiles().length);
ClientBase.recursiveDelete(tmpDir);
}
示例13: reinitialize
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
public void reinitialize() throws IOException {
File dataDir = main.quorumPeer.getTxnFactory().getDataDir();
ClientBase.recursiveDelete(dataDir);
ClientBase.createInitializeFile(dataDir.getParentFile());
}
示例14: testPurgeTxnLogWithDataDir
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
/**
* PurgeTxnLog is called with dataLogDir snapDir -n count This test case
* verify these values are parsed properly and functionality works fine
*/
@Test
public void testPurgeTxnLogWithDataDir()
throws Exception {
tmpDir = ClientBase.createTmpDir();
File dataDir = new File(tmpDir, "dataDir");
File dataLogDir = new File(tmpDir, "dataLogDir");
File dataDirVersion2 = new File(dataDir, "version-2");
dataDirVersion2.mkdirs();
File dataLogDirVersion2 = new File(dataLogDir, "version-2");
dataLogDirVersion2.mkdirs();
// create dummy log and transaction file
int totalFiles = 20;
// create transaction and snapshot files in different-different
// directories
for (int i = 0; i < totalFiles; i++) {
// simulate log file
File logFile = new File(dataLogDirVersion2, "log."
+ Long.toHexString(i));
logFile.createNewFile();
// simulate snapshot file
File snapFile = new File(dataDirVersion2, "snapshot."
+ Long.toHexString(i));
snapFile.createNewFile();
}
int numberOfSnapFilesToKeep = 10;
// scenario where four parameter are passed
String[] args = new String[] { dataLogDir.getAbsolutePath(),
dataDir.getAbsolutePath(), "-n",
Integer.toString(numberOfSnapFilesToKeep) };
PurgeTxnLog.main(args);
assertEquals(numberOfSnapFilesToKeep, dataDirVersion2.listFiles().length);
// Since for each snapshot we have a log file with same zxid, expect same # logs as snaps to be kept
assertEquals(numberOfSnapFilesToKeep, dataLogDirVersion2.listFiles().length);
ClientBase.recursiveDelete(tmpDir);
}
示例15: deleteBaseDir
import org.apache.zookeeper.test.ClientBase; //导入方法依赖的package包/类
public void deleteBaseDir() {
ClientBase.recursiveDelete(baseDir);
}