本文整理汇总了Java中org.apache.zookeeper.server.persistence.Util类的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Util类属于org.apache.zookeeper.server.persistence包,在下文中一共展示了Util类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRequestToSyncProcessor
import org.apache.zookeeper.server.persistence.Util; //导入依赖的package包/类
private void addRequestToSyncProcessor() {
long zxid = ZxidUtils.makeZxid(3, 7);
TxnHeader hdr = new TxnHeader(1, 1, zxid, 1,
ZooDefs.OpCode.setData);
Record txn = new SetDataTxn("/foo" + zxid, new byte[0], 1);
byte[] buf;
try {
buf = Util.marshallTxnEntry(hdr, txn);
} catch (IOException e) {
LOG.error("IOException while adding request to SyncRequestProcessor", e);
Assert.fail("IOException while adding request to SyncRequestProcessor!");
return;
}
NettyServerCnxnFactory factory = new NettyServerCnxnFactory();
final MockNettyServerCnxn nettyCnxn = new MockNettyServerCnxn(null,
this, factory);
Request req = new Request(nettyCnxn, 1, 1, ZooDefs.OpCode.setData,
ByteBuffer.wrap(buf), null);
req.hdr = hdr;
req.txn = txn;
syncProcessor.processRequest(req);
}
示例2: testSortDataDirAscending
import org.apache.zookeeper.server.persistence.Util; //导入依赖的package包/类
@Test
public void testSortDataDirAscending() {
File[] files = new File[5];
files[0] = new File("foo.10027c6de");
files[1] = new File("foo.10027c6df");
files[2] = new File("bar.10027c6dd");
files[3] = new File("foo.10027c6dc");
files[4] = new File("foo.20027c6dc");
File[] orig = files.clone();
List<File> filelist = Util.sortDataDir(files, "foo", true);
Assert.assertEquals(orig[2], filelist.get(0));
Assert.assertEquals(orig[3], filelist.get(1));
Assert.assertEquals(orig[0], filelist.get(2));
Assert.assertEquals(orig[1], filelist.get(3));
Assert.assertEquals(orig[4], filelist.get(4));
}
示例3: testSortDataDirDescending
import org.apache.zookeeper.server.persistence.Util; //导入依赖的package包/类
@Test
public void testSortDataDirDescending() {
File[] files = new File[5];
files[0] = new File("foo.10027c6de");
files[1] = new File("foo.10027c6df");
files[2] = new File("bar.10027c6dd");
files[3] = new File("foo.10027c6dc");
files[4] = new File("foo.20027c6dc");
File[] orig = files.clone();
List<File> filelist = Util.sortDataDir(files, "foo", false);
Assert.assertEquals(orig[4], filelist.get(0));
Assert.assertEquals(orig[1], filelist.get(1));
Assert.assertEquals(orig[0], filelist.get(2));
Assert.assertEquals(orig[3], filelist.get(3));
Assert.assertEquals(orig[2], filelist.get(4));
}
示例4: testInvalidSnapshot
import org.apache.zookeeper.server.persistence.Util; //导入依赖的package包/类
@Test
public void testInvalidSnapshot() {
File f = null;
File tmpFileDir = null;
try {
tmpFileDir = ClientBase.createTmpDir();
f = new File(tmpFileDir, "snapshot.0");
if (!f.exists()) {
f.createNewFile();
}
Assert.assertFalse("Snapshot file size is greater than 9 bytes", Util.isValidSnapshot(f));
Assert.assertTrue("Can't delete file", f.delete());
} catch (IOException e) {
} finally {
if (null != tmpFileDir) {
ClientBase.recursiveDelete(tmpFileDir);
}
}
}
示例5: testSortDataDirAscending
import org.apache.zookeeper.server.persistence.Util; //导入依赖的package包/类
@Test
public void testSortDataDirAscending() {
File[] files = new File[5];
files[0] = new File("foo.10027c6de");
files[1] = new File("foo.10027c6df");
files[2] = new File("bar.10027c6dd");
files[3] = new File("foo.10027c6dc");
files[4] = new File("foo.20027c6dc");
File[] orig = files.clone();
List<File> filelist = Util.sortDataDir(files, "foo", true);
assertEquals(orig[2], filelist.get(0));
assertEquals(orig[3], filelist.get(1));
assertEquals(orig[0], filelist.get(2));
assertEquals(orig[1], filelist.get(3));
assertEquals(orig[4], filelist.get(4));
}
示例6: testSortDataDirDescending
import org.apache.zookeeper.server.persistence.Util; //导入依赖的package包/类
@Test
public void testSortDataDirDescending() {
File[] files = new File[5];
files[0] = new File("foo.10027c6de");
files[1] = new File("foo.10027c6df");
files[2] = new File("bar.10027c6dd");
files[3] = new File("foo.10027c6dc");
files[4] = new File("foo.20027c6dc");
File[] orig = files.clone();
List<File> filelist = Util.sortDataDir(files, "foo", false);
assertEquals(orig[4], filelist.get(0));
assertEquals(orig[1], filelist.get(1));
assertEquals(orig[0], filelist.get(2));
assertEquals(orig[3], filelist.get(3));
assertEquals(orig[2], filelist.get(4));
}
示例7: testInvalidSnapshot
import org.apache.zookeeper.server.persistence.Util; //导入依赖的package包/类
@Test
public void testInvalidSnapshot() {
File f = null;
File tmpFileDir = null;
try {
tmpFileDir = ClientBase.createTmpDir();
f = new File(tmpFileDir, "snapshot.0");
if (!f.exists()) {
f.createNewFile();
}
Assert.assertFalse("Snapshot file size is greater than 9 bytes",
Util.isValidSnapshot(f));
Assert.assertTrue("Can't delete file", f.delete());
} catch (IOException e) {
} finally {
if (null != tmpFileDir) {
ClientBase.recursiveDelete(tmpFileDir);
}
}
}