• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DeleteBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: delete

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
public void delete(String path, boolean isDeleteChildren) {
    try {
        if (!exist(path)) {
            return;
        }

        DeleteBuilder builder = client.delete();

        if (isDeleteChildren) {
            builder.guaranteed().deletingChildrenIfNeeded().forPath(path);
        } else {
            builder.guaranteed().forPath(path);
        }
    } catch (Throwable e) {
        throw checkException(String.format("Fail to delete node of path: %s", path), e);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:18,代码来源:ZKClient.java


示例2: deleteWithoutGuaranteed

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
public void deleteWithoutGuaranteed(String path, boolean isDeleteChildren) {
    try {
        if (!exist(path)) {
            return;
        }

        DeleteBuilder builder = client.delete();

        if (isDeleteChildren) {
            builder.deletingChildrenIfNeeded().forPath(path);
        } else {
            builder.forPath(path);
        }
    } catch (Throwable e) {
        throw checkException(String.format("Fail to delete node of path: %s", path), e);
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:18,代码来源:ZKClient.java


示例3: shouldDeleteSetupInProgressNodeAfterCompletion

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void shouldDeleteSetupInProgressNodeAfterCompletion() throws Exception {
    Set<SetupStep> steps = new LinkedHashSet<>();
    SetupStep setupStep1 = mock(SetupStep.class);
    steps.add(setupStep1);

    when(configuration.
            getString(HAConfiguration.ATLAS_SERVER_HA_ZK_ROOT_KEY, HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT)).
            thenReturn(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT);
    when(configuration.getString(HAConfiguration.HA_ZOOKEEPER_ACL)).thenReturn("digest:user:pwd");

    List<ACL> aclList = Arrays.asList(new ACL(ZooDefs.Perms.ALL, new Id("digest", "user:pwd")));
    setupServerIdSelectionMocks();
    DeleteBuilder deleteBuilder = setupSetupInProgressPathMocks(aclList).getRight();

    InterProcessMutex lock = mock(InterProcessMutex.class);
    when(curatorFactory.lockInstance(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT)).
            thenReturn(lock);
    SetupSteps setupSteps = new SetupSteps(steps, curatorFactory, configuration);
    setupSteps.runSetup();

    verify(deleteBuilder).forPath(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT+SetupSteps.SETUP_IN_PROGRESS_NODE);
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:24,代码来源:SetupStepsTest.java


示例4: testDeletesEphemeralNode

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testDeletesEphemeralNode() throws Exception {
    CuratorFramework framework = mockFramework();
    ExistsBuilder ceBuilder = mock(ExistsBuilder.class);
    CreateBuilder createBuilder = mock(CreateBuilder.class);
    when(framework.checkExists()).thenReturn(ceBuilder);
    when(ceBuilder.forPath("/services/myservice/nodes")).thenReturn(mock(Stat.class));
    when(ceBuilder.forPath("/services/myservice/nodes/foo:4321")).thenReturn(mock(Stat.class));
    when(framework.create()).thenReturn(createBuilder);
    when(framework.getState()).thenReturn(CuratorFrameworkState.STARTED);
    DeleteBuilder deleteBuilder = mock(DeleteBuilder.class);
    when(framework.delete()).thenReturn(deleteBuilder);
    ACLBackgroundPathAndBytesable<String> os = mock(ACLBackgroundPathAndBytesable.class);
    when(createBuilder.withMode(CreateMode.EPHEMERAL)).thenReturn(os);
    DiscoService service = new DiscoService(framework, "myservice");
    byte[] payload = "foo bar baz bingo".getBytes();
    service.start("foo", 4321, true, payload);
    verify(deleteBuilder).forPath("/services/myservice/nodes/foo:4321");
    verify(os).forPath(eq("/services/myservice/nodes/foo:4321"), eq(payload));
}
 
开发者ID:librato,项目名称:disco-java,代码行数:22,代码来源:DiscoServiceTest.java


示例5: testDeleteNodeIfNoChildren_withNodeThatDoesntExist

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
/**
 * Tests that if we attempt to delete a node that doesnt actually exist
 * just silently returns.
 *
 * To simulate a race condition we do this using mocks.
 */
@Test
public void testDeleteNodeIfNoChildren_withNodeThatDoesntExist() throws Exception {
    final String basePath = "/testDeleteNodeIfNoChildren_withNodeThatDoesntExist";

    final CuratorFramework mockCurator = mock(CuratorFramework.class);

    // Exists builder should return true saying our basePath exists.
    final ExistsBuilder mockExistsBuilder = mock(ExistsBuilder.class);
    when(mockExistsBuilder.forPath(eq(basePath))).thenReturn(new Stat());
    when(mockCurator.checkExists()).thenReturn(mockExistsBuilder);

    // When we look for children, make sure it returns an empty list.
    final GetChildrenBuilder mockGetChildrenBuilder = mock(GetChildrenBuilder.class);
    when(mockGetChildrenBuilder.forPath(eq(basePath))).thenReturn(new ArrayList<>());
    when(mockCurator.getChildren()).thenReturn(mockGetChildrenBuilder);

    // When we go to delete the actual node, we toss a no-node exception.
    // This effectively simulates a race condition between checking if the node exists (our mock above says yes)
    // and it being removed before we call delete on it.
    final DeleteBuilder mockDeleteBuilder = mock(DeleteBuilder.class);
    when(mockDeleteBuilder.forPath(eq(basePath))).thenThrow(new KeeperException.NoNodeException());
    when(mockCurator.delete()).thenReturn(mockDeleteBuilder);

    // Now create our helper
    final CuratorHelper curatorHelper = new CuratorHelper(mockCurator);

    // Call our method
    curatorHelper.deleteNodeIfNoChildren(basePath);
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:36,代码来源:CuratorHelperTest.java


示例6: remove

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Override
public void remove(String uuid, Handler<AsyncResult<Record>> resultHandler) {
  Objects.requireNonNull(uuid, "No registration id in the record");
  Context context = Vertx.currentContext();

  ensureConnected(x -> {
    if (x.failed()) {
      resultHandler.handle(Future.failedFuture(x.cause()));
    } else {
      getRecordById(context, uuid, record -> {
        if (record == null) {
          resultHandler.handle(Future.failedFuture("Unknown registration " + uuid));
        } else {
          try {
            DeleteBuilder delete = client.delete();
            if (guaranteed) {
              delete.guaranteed();
            }
            delete
                .deletingChildrenIfNeeded()
                .inBackground((curatorFramework, curatorEvent)
                    -> callback(context, record, resultHandler, curatorEvent))

                .withUnhandledErrorListener((s, throwable)
                    -> resultHandler.handle(Future.failedFuture(throwable)))

                .forPath(getPath(uuid));
          } catch (Exception e) {
            resultHandler.handle(Future.failedFuture(e));
          }
        }
      });
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:36,代码来源:ZookeeperBackendService.java


示例7: setupSetupInProgressPathMocks

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
private Pair<CreateBuilder, DeleteBuilder> setupSetupInProgressPathMocks(List<ACL> acls, Stat stat) throws Exception {
    when(curatorFactory.clientInstance()).thenReturn(client);
    CreateBuilder createBuilder = mock(CreateBuilder.class);
    when(createBuilder.withACL(acls)).thenReturn(createBuilder);
    when(client.create()).thenReturn(createBuilder);
    DeleteBuilder deleteBuilder = mock(DeleteBuilder.class);
    when(client.delete()).thenReturn(deleteBuilder);
    Pair<CreateBuilder, DeleteBuilder> pair = Pair.of(createBuilder, deleteBuilder);
    ExistsBuilder existsBuilder = mock(ExistsBuilder.class);
    when(client.checkExists()).thenReturn(existsBuilder);
    when(existsBuilder.forPath(HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT+SetupSteps.SETUP_IN_PROGRESS_NODE)).
            thenReturn(stat);
    return pair;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:15,代码来源:SetupStepsTest.java


示例8: deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class);

  assertFalse(sensorIndexingConfigService.delete("bro"));
}
 
开发者ID:apache,项目名称:metron,代码行数:10,代码来源:SensorIndexingConfigServiceImplTest.java


示例9: deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception {
  exception.expect(RestException.class);

  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenThrow(Exception.class);

  assertFalse(sensorIndexingConfigService.delete("bro"));
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:SensorIndexingConfigServiceImplTest.java


示例10: deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenReturn(null);

  assertTrue(sensorIndexingConfigService.delete("bro"));

  verify(curatorFramework).delete();
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:SensorIndexingConfigServiceImplTest.java


示例11: deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenThrow(KeeperException.NoNodeException.class);

  assertFalse(globalConfigService.delete());
}
 
开发者ID:apache,项目名称:metron,代码行数:10,代码来源:GlobalConfigServiceImplTest.java


示例12: deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception {
  exception.expect(RestException.class);

  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenThrow(Exception.class);

  assertFalse(globalConfigService.delete());
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:GlobalConfigServiceImplTest.java


示例13: deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenReturn(null);

  assertTrue(globalConfigService.delete());

  verify(curatorFramework).delete();
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:GlobalConfigServiceImplTest.java


示例14: deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class);

  assertFalse(sensorParserConfigService.delete("bro"));
}
 
开发者ID:apache,项目名称:metron,代码行数:10,代码来源:SensorParserConfigServiceImplTest.java


示例15: deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception {
  exception.expect(RestException.class);

  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(Exception.class);

  assertFalse(sensorParserConfigService.delete("bro"));
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:SensorParserConfigServiceImplTest.java


示例16: deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenReturn(null);

  assertTrue(sensorParserConfigService.delete("bro"));

  verify(curatorFramework).delete();
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:SensorParserConfigServiceImplTest.java


示例17: deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class);

  assertFalse(sensorEnrichmentConfigService.delete("bro"));
}
 
开发者ID:apache,项目名称:metron,代码行数:10,代码来源:SensorEnrichmentConfigServiceImplTest.java


示例18: deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception {
  exception.expect(RestException.class);

  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenThrow(Exception.class);

  assertFalse(sensorEnrichmentConfigService.delete("bro"));
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:SensorEnrichmentConfigServiceImplTest.java


示例19: deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
@Test
public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception {
  DeleteBuilder builder = mock(DeleteBuilder.class);

  when(curatorFramework.delete()).thenReturn(builder);
  when(builder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenReturn(null);

  assertTrue(sensorEnrichmentConfigService.delete("bro"));

  verify(curatorFramework).delete();
}
 
开发者ID:apache,项目名称:metron,代码行数:12,代码来源:SensorEnrichmentConfigServiceImplTest.java


示例20: testDeleteNode

import org.apache.curator.framework.api.DeleteBuilder; //导入依赖的package包/类
/**
 * Test deleteNode method
 * @throws Exception
 */
@Test
public void testDeleteNode() throws Exception {
  CuratorStateManager spyStateManager = spy(new CuratorStateManager());
  CuratorFramework mockClient = mock(CuratorFramework.class);
  DeleteBuilder mockDeleteBuilder = mock(DeleteBuilder.class);
  // Mockito doesn't support mock type-parametrized class, thus suppress the warning
  @SuppressWarnings("rawtypes")
  BackgroundPathable mockBackPathable = mock(BackgroundPathable.class);

  doReturn(mockClient)
      .when(spyStateManager).getCuratorClient();
  doReturn(true)
      .when(mockClient).blockUntilConnected(anyInt(), any(TimeUnit.class));
  doReturn(mockDeleteBuilder)
      .when(mockClient).delete();
  doReturn(mockBackPathable)
      .when(mockDeleteBuilder).withVersion(-1);

  spyStateManager.initialize(config);

  ListenableFuture<Boolean> result = spyStateManager.deleteExecutionState(PATH);

  // Verify the node is deleted correctly
  verify(mockDeleteBuilder).withVersion(-1);
  assertTrue(result.get());
}
 
开发者ID:twitter,项目名称:heron,代码行数:31,代码来源:CuratorStateManagerTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FlowLayout类代码示例发布时间:2022-05-21
下一篇:
Java FooNumberFormat类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap