当前位置: 首页>>代码示例>>Java>>正文


Java Util.sortDataDir方法代码示例

本文整理汇总了Java中org.apache.zookeeper.server.persistence.Util.sortDataDir方法的典型用法代码示例。如果您正苦于以下问题:Java Util.sortDataDir方法的具体用法?Java Util.sortDataDir怎么用?Java Util.sortDataDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.server.persistence.Util的用法示例。


在下文中一共展示了Util.sortDataDir方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:21,代码来源:ZooKeeperServerTest.java

示例2: 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));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:21,代码来源:ZooKeeperServerTest.java

示例3: 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));
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:21,代码来源:ZooKeeperServerTest.java

示例4: 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));
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:21,代码来源:ZooKeeperServerTest.java

示例5: findMostRecentSnapshot

import org.apache.zookeeper.server.persistence.Util; //导入方法依赖的package包/类
/**
 * find the most recent snapshot 
 * in the snapshot directory
 * @return
 * @throws IOException
 */
private File findMostRecentSnapshot() throws IOException {
    List<File> files = Util.sortDataDir(snapShotDir.listFiles(),
            "snapshot", false);
    for (File f: files) {
        try {
            if (Util.isValidSnapshot(f))
                return f;
        } catch(IOException e) {
            LOG.info("Invalid snapshot " + f, e);
        }
    }
    return null;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:20,代码来源:UpgradeSnapShotV1.java

示例6: testDirtySnapshot

import org.apache.zookeeper.server.persistence.Util; //导入方法依赖的package包/类
/**
 * verify that a peer with dirty snapshot joining an established cluster
 * does not go into an inconsistent state.
 *
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1558}
 */
@Test
public void testDirtySnapshot()
throws IOException,
    InterruptedException,
    KeeperException,
    NoSuchFieldException,
    IllegalAccessException {
    Socket pair[] = getSocketPair();
    Socket leaderSocket = pair[0];
    Socket followerSocket = pair[1];
    File tmpDir = File.createTempFile("test", "dir");
    tmpDir.delete();
    tmpDir.mkdir();
    LeadThread leadThread = null;
    Leader leader = null;
    try {
        // Setup a database with two znodes
        FileTxnSnapLog snapLog = new FileTxnSnapLog(tmpDir, tmpDir);
        ZKDatabase zkDb = new ZKDatabase(snapLog);

        long zxid = ZxidUtils.makeZxid(0, 1);
        String path = "/foo";
        zkDb.processTxn(new TxnHeader(13,1000,zxid,30,ZooDefs.OpCode.create),
                                        new CreateTxn(path, "fpjwasalsohere".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, false, 1));
        Stat stat = new Stat();
        Assert.assertEquals("fpjwasalsohere", new String(zkDb.getData(path, stat, null)));

        // Close files
        snapLog.close();

        QuorumPeer peer = createQuorumPeer(tmpDir);

        leader = createLeader(tmpDir, peer);
        peer.leader = leader;

        // Set the last accepted epoch and current epochs to be 1
        peer.setAcceptedEpoch(0);
        peer.setCurrentEpoch(0);

        leadThread = new LeadThread(leader);
        leadThread.start();

        while(leader.cnxAcceptor == null || !leader.cnxAcceptor.isAlive()) {
            Thread.sleep(20);
        }

        leader.shutdown("Shutting down the leader");

        // Check if there is a valid snapshot (we better not have it)
        File snapDir = new File (tmpDir, FileTxnSnapLog.version + FileTxnSnapLog.VERSION);
        List<File> files = Util.sortDataDir(snapDir.listFiles(),"snapshot", false);

        for (File f : files) {
            try {
                Assert.assertFalse("Found a valid snapshot", Util.isValidSnapshot(f));
            } catch (IOException e) {
                LOG.info("invalid snapshot " + f, e);
            }
        }

    } finally {
        if (leader != null) {
            leader.shutdown("end of test");
        }
        if (leadThread != null) {
            leadThread.interrupt();
            leadThread.join();
        }
        recursiveDelete(tmpDir);
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:78,代码来源:Zab1_0Test.java


注:本文中的org.apache.zookeeper.server.persistence.Util.sortDataDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。