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


Java Ids类代码示例

本文整理汇总了Java中org.apache.zookeeper.ZooDefs.Ids的典型用法代码示例。如果您正苦于以下问题:Java Ids类的具体用法?Java Ids怎么用?Java Ids使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testChRootCreateDelete

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Test
public void testChRootCreateDelete() throws Exception {
    // creating the subtree for chRoot clients.
    String chRoot = createNameSpace();
    // Creating child using chRoot client.
    zk_chroot = createClient(this.hostPort + chRoot);
    Op createChild = Op.create("/myid", new byte[0],
            Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    multi(zk_chroot, Arrays.asList(createChild));
    
    Assert.assertNotNull("zNode is not created under chroot:" + chRoot, zk
            .exists(chRoot + "/myid", false));
    Assert.assertNotNull("zNode is not created under chroot:" + chRoot,
            zk_chroot.exists("/myid", false));
    Assert.assertNull("zNode is created directly under '/', ignored configured chroot",
            zk.exists("/myid", false));
    
    // Deleting child using chRoot client.
    Op deleteChild = Op.delete("/myid", 0);
    multi(zk_chroot, Arrays.asList(deleteChild));
    Assert.assertNull("zNode exists under chroot:" + chRoot, zk.exists(
            chRoot + "/myid", false));
    Assert.assertNull("zNode exists under chroot:" + chRoot, zk_chroot
            .exists("/myid", false));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:26,代码来源:MultiTransactionTest.java

示例2: setUp

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    String hp = hostPort;
    hostPort = hostPort + "/chrootasynctest";

    super.setUp();

    LOG.info("Creating client " + getTestName());

    ZooKeeper zk = createClient(hp);
    try {
        zk.create("/chrootasynctest", null, Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);
    } finally {
        zk.close();
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:18,代码来源:ChrootAsyncTest.java

示例3: testGetPreviousRecoveryMode

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Ignore("DLR is broken by HBASE-12751") @Test(timeout=60000)
public void testGetPreviousRecoveryMode() throws Exception {
  LOG.info("testGetPreviousRecoveryMode");
  SplitLogCounters.resetCounters();
  // Not actually enabling DLR for the cluster, just for the ZkCoordinatedStateManager to use.
  // The test is just manipulating ZK manually anyways.
  conf.setBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, true);

  zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, "testRecovery"),
    new SplitLogTask.Unassigned(
      ServerName.valueOf("mgr,1,1"), RecoveryMode.LOG_SPLITTING).toByteArray(),
      Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

  slm = new SplitLogManager(ds, conf, stopper, master, DUMMY_MASTER);
  LOG.info("Mode1=" + slm.getRecoveryMode());
  assertTrue(slm.isLogSplitting());
  zkw.getRecoverableZooKeeper().delete(ZKSplitLog.getEncodedNodeName(zkw, "testRecovery"), -1);
  LOG.info("Mode2=" + slm.getRecoveryMode());
  slm.setRecoveryMode(false);
  LOG.info("Mode3=" + slm.getRecoveryMode());
  assertTrue("Mode4=" + slm.getRecoveryMode(), slm.isLogReplaying());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestSplitLogManager.java

示例4: testSaslNotRequiredWithInvalidCredentials

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
/**
 * Test to verify that server is able to start with invalid credentials if
 * the configuration is set to quorum.auth.serverRequireSasl=false.
 * Quorum will talk each other even if the authentication is not succeeded
 */
@Test(timeout = 30000)
public void testSaslNotRequiredWithInvalidCredentials() throws Exception {
    Map<String, String> authConfigs = new HashMap<String, String>();
    authConfigs.put(QuorumAuth.QUORUM_LEARNER_SASL_LOGIN_CONTEXT, "QuorumLearnerInvalid");
    authConfigs.put(QuorumAuth.QUORUM_SASL_AUTH_ENABLED, "false");
    authConfigs.put(QuorumAuth.QUORUM_SERVER_SASL_AUTH_REQUIRED, "false");
    String connectStr = startQuorum(3, authConfigs, 3, false);
    CountdownWatcher watcher = new CountdownWatcher();
    zk = new ZooKeeper(connectStr, ClientBase.CONNECTION_TIMEOUT, watcher);
    watcher.waitForConnected(ClientBase.CONNECTION_TIMEOUT);
    for (int i = 0; i < 10; i++) {
        zk.create("/" + i, new byte[0], Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:21,代码来源:QuorumDigestAuthTest.java

示例5: run

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
public void run() {
    byte b[] = new byte[256];
    try {
        for (; current < count; current++) {
            // Simulate a bit of network latency...
            Thread.sleep(HAMMERTHREAD_LATENCY);
            zk.create(prefix + current, b, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
    } catch (Throwable t) {
        LOG.error("Client create operation Assert.failed", t);
    } finally {
        try {
            zk.close();
        } catch (InterruptedException e) {
            LOG.warn("Unexpected", e);
        }
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:19,代码来源:ClientHammerTest.java

示例6: testNoWatchesTriggeredForFailedMultiRequest

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Test
public void testNoWatchesTriggeredForFailedMultiRequest() throws InterruptedException, KeeperException {
    HasTriggeredWatcher watcher = new HasTriggeredWatcher();
    zk.getChildren("/", watcher);
    try {
        multi(zk, Arrays.asList(
                Op.create("/t", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
                Op.delete("/nonexisting", -1)
        ));
        fail("expected previous multi op to fail!");
    } catch (KeeperException.NoNodeException e) {
        // expected
    }
    SyncCallback cb = new SyncCallback();
    zk.sync("/", cb, null);

    // by waiting for the callback we're assured that the event queue is flushed
    cb.done.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
    assertEquals(1, watcher.triggered.getCount());
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:21,代码来源:MultiTransactionTest.java

示例7: testChRootSetData

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Test
public void testChRootSetData() throws Exception {
    // creating the subtree for chRoot clients.
    String chRoot = createNameSpace();
    // setData using chRoot client.
    zk_chroot = createClient(this.hostPort + chRoot);
    String[] names = {"/multi0", "/multi1", "/multi2"};
    List<Op> ops = new ArrayList<Op>();

    for (int i = 0; i < names.length; i++) {
        ops.add(Op.create(names[i], new byte[0], Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT));
        ops.add(Op.setData(names[i], names[i].getBytes(), 0));
    }

    multi(zk_chroot, ops) ;

    for (int i = 0; i < names.length; i++) {
        Assert.assertArrayEquals("zNode data not matching", names[i]
                .getBytes(), zk_chroot.getData(names[i], false, null));
    }
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:23,代码来源:MultiTransactionTest.java

示例8: rescan

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
/**
 * signal the workers that a task was resubmitted by creating the RESCAN node.
 */
private void rescan(long retries) {
  // The RESCAN node will be deleted almost immediately by the
  // SplitLogManager as soon as it is created because it is being
  // created in the DONE state. This behavior prevents a buildup
  // of RESCAN nodes. But there is also a chance that a SplitLogWorker
  // might miss the watch-trigger that creation of RESCAN node provides.
  // Since the TimeoutMonitor will keep resubmitting UNASSIGNED tasks
  // therefore this behavior is safe.
  SplitLogTask slt = new SplitLogTask.Done(this.details.getServerName(), getRecoveryMode());
  this.watcher
      .getRecoverableZooKeeper()
      .getZooKeeper()
      .create(ZKSplitLog.getRescanNode(watcher), slt.toByteArray(), Ids.OPEN_ACL_UNSAFE,
        CreateMode.EPHEMERAL_SEQUENTIAL, new CreateRescanAsyncCallback(), Long.valueOf(retries));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:ZKSplitLogManagerCoordination.java

示例9: testMultiRollbackNoLastChange

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
/**
 * ZOOKEEPER-2052:
 * This test checks that if a multi operation aborted, and during the multi there is side effect
 * that changed outstandingChangesForPath, after aborted the side effect should be removed and
 * everything should be restored correctly.
 */
@Test
public void testMultiRollbackNoLastChange() throws Exception {
    zks.getZKDatabase().dataTree.createNode("/foo", new byte[0], Ids.OPEN_ACL_UNSAFE, 0, 0, 0, 0);
    zks.getZKDatabase().dataTree.createNode("/foo/bar", new byte[0], Ids.OPEN_ACL_UNSAFE, 0, 0, 0, 0);

    Assert.assertNull(zks.outstandingChangesForPath.get("/foo"));

    // multi record:
    //   set "/foo" => succeed, leave a outstanding change
    //   delete "/foo" => fail, roll back change
    process(Arrays.asList(
            Op.setData("/foo", new byte[0], -1),
            Op.delete("/foo", -1)));

    // aborting multi shouldn't leave any record.
    Assert.assertNull(zks.outstandingChangesForPath.get("/foo"));
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:PrepRequestProcessorTest.java

示例10: testRemoveNodeDataChangedWatches

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
/**
 * Test verifies deletion of NodeDataChanged watches
 */
@Test(timeout = 30000)
public void testRemoveNodeDataChangedWatches() throws Exception {
    LOG.info("Adding data watcher using getData()");
    List<EventType> expectedEvents = new ArrayList<Watcher.Event.EventType>();
    expectedEvents.add(EventType.DataWatchRemoved);
    MyWatcher myWatcher = new MyWatcher("/testnode1", expectedEvents, 1);

    zk.create("/testnode1", "data".getBytes(), Ids.OPEN_ACL_UNSAFE,
            CreateMode.PERSISTENT);
    zk.getData("/testnode1", myWatcher, null);

    String cmdstring = "removewatches /testnode1 -d";
    LOG.info("Remove watchers using shell command : {}", cmdstring);
    zkMain.cl.parseCommand(cmdstring);
    Assert.assertTrue("Removewatches cmd fails to remove data watches",
            zkMain.processZKCmd(zkMain.cl));

    LOG.info("Waiting for the DataWatchRemoved event");
    myWatcher.matches();

    // verifying that other path data watches are removed
    Assert.assertEquals(
            "Data watches are not removed : " + zk.getDataWatches(), 0, zk
                    .getDataWatches().size());
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:29,代码来源:RemoveWatchesCmdTest.java

示例11: testQuitElectionRemovesBreadcrumbNode

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Test
public void testQuitElectionRemovesBreadcrumbNode() throws Exception {
  mockNoPriorActive();
  elector.joinElection(data);
  elector.processResult(Code.OK.intValue(), ZK_LOCK_NAME, mockZK,
      ZK_LOCK_NAME);
  // Writes its own active info
  Mockito.verify(mockZK, Mockito.times(1)).create(
      Mockito.eq(ZK_BREADCRUMB_NAME), Mockito.eq(data),
      Mockito.eq(Ids.OPEN_ACL_UNSAFE),
      Mockito.eq(CreateMode.PERSISTENT));
  mockPriorActive(data);
  
  elector.quitElection(false);
  
  // Deletes its own active data
  Mockito.verify(mockZK, Mockito.times(1)).delete(
      Mockito.eq(ZK_BREADCRUMB_NAME), Mockito.eq(0));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestActiveStandbyElector.java

示例12: testLargeNodeData

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Test
public void testLargeNodeData() throws Exception {
    ZooKeeper zk= null;
    String queue_handle = "/large";
    try {
        zk = createClient();

        zk.create(queue_handle, new byte[500000], Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);
    } finally {
        if (zk != null) {
            zk.close();
        }
    }

}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:17,代码来源:ClientTest.java

示例13: testNestedCreate

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
@Test
public void testNestedCreate() throws Exception {

    multi(zk, Arrays.asList(
            /* Create */
            Op.create("/multi", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
            Op.create("/multi/a", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
            Op.create("/multi/a/1", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),

            /* Delete */
            Op.delete("/multi/a/1", 0),
            Op.delete("/multi/a", 0),
            Op.delete("/multi", 0)
            ));

    //Verify tree deleted
    Assert.assertNull(zk.exists("/multi/a/1", null));
    Assert.assertNull(zk.exists("/multi/a", null));
    Assert.assertNull(zk.exists("/multi", null));
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:21,代码来源:MultiTransactionTest.java

示例14: testCreateNodeResultRetryNoNode

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
/**
 * verify that if create znode results in nodeexists and that znode is deleted
 * before exists() watch is set then the return of the exists() method results
 * in attempt to re-create the znode and become active
 */
@Test
public void testCreateNodeResultRetryNoNode() {
  elector.joinElection(data);

  elector.processResult(Code.CONNECTIONLOSS.intValue(), ZK_LOCK_NAME, mockZK,
      ZK_LOCK_NAME);
  elector.processResult(Code.CONNECTIONLOSS.intValue(), ZK_LOCK_NAME, mockZK,
      ZK_LOCK_NAME);
  elector.processResult(Code.NODEEXISTS.intValue(), ZK_LOCK_NAME, mockZK,
      ZK_LOCK_NAME);
  verifyExistCall(1);

  elector.processResult(Code.NONODE.intValue(), ZK_LOCK_NAME, mockZK,
      (Stat) null);
  Mockito.verify(mockApp, Mockito.times(1)).enterNeutralMode();
  Mockito.verify(mockZK, Mockito.times(4)).create(ZK_LOCK_NAME, data,
      Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, elector, mockZK);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestActiveStandbyElector.java

示例15: createNode

import org.apache.zookeeper.ZooDefs.Ids; //导入依赖的package包/类
public boolean createNode(String parent, String nodeName) {
    if (connected) {
        try {
            String[] nodeElements = nodeName.split("/");
            for (String nodeElement : nodeElements) {
                String node = parent + "/" + nodeElement;
                Stat s = zooKeeper.exists(node, false);
                if (s == null) {
                    zooKeeper.create(node, this.encryptionManager
                            .encryptData(null), Ids.OPEN_ACL_UNSAFE,
                            CreateMode.PERSISTENT);
                    parent = node;
                }
            }
            return true;
        } catch (Exception e) {
            LoggerFactory.getLogger().error(
                    "Error occurred creating node: " + parent + "/"
                            + nodeName, e);
        }
    }
    return false;
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:ZooInspectorManagerImpl.java


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