本文整理了Java中co.cask.coopr.common.queue.internal.ZKQueueGroup.<init>()
方法的一些代码示例,展示了ZKQueueGroup.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKQueueGroup.<init>()
方法的具体详情如下:
包路径:co.cask.coopr.common.queue.internal.ZKQueueGroup
类名称:ZKQueueGroup
方法名:<init>
[英]Create a zookeeper queue group of the given type, using the given zookeeper client. Physical queues in the group are namespaced by the namespace of the client plus the queue type and queue name. As such, if two queue groups of the same type should not conflict, the namespace of their clients should not be the same.
[中]使用给定的zookeeper客户端创建给定类型的zookeeper队列组。组中的物理队列由客户端的名称空间加上队列类型和队列名称命名。因此,如果同一类型的两个队列组不应该冲突,那么它们的客户机的名称空间就不应该相同。
代码示例来源:origin: caskdata/coopr
@Inject
private ZKQueueService(ZKClient zkClient) {
ImmutableMap.Builder<QueueType, QueueGroup> builder = ImmutableMap.builder();
for (QueueType type : QueueType.GROUP_TYPES) {
builder.put(type, new ZKQueueGroup(zkClient, type));
}
this.queueGroups = builder.build();
}
代码示例来源:origin: caskdata/coopr
@Test
public void testInstanceInitializedWithExistingData() throws Exception {
QueueGroup instance1 = new ZKQueueGroup(zkClient, QueueType.PROVISIONER);
instance1.startAndWait();
instance1.add("tenant1", new Element("val1"));
instance1.add("tenant2", new Element("val2"));
QueueGroup instance2 = new ZKQueueGroup(zkClient, QueueType.PROVISIONER);
instance2.startAndWait();
waitForQueueNames(Sets.newHashSet("tenant1", "tenant2"), instance2);
instance1.stop();
instance2.stop();
}
代码示例来源:origin: caskdata/coopr
@Test
public void testChangesSeenAcrossInstances() throws Exception {
QueueGroup instance1 = new ZKQueueGroup(zkClient, QueueType.PROVISIONER);
QueueGroup instance2 = new ZKQueueGroup(zkClient, QueueType.PROVISIONER);
instance1.startAndWait();
instance2.startAndWait();
// add a queue for tenant3 with 2 elements
String tenant = "tenantX";
Set<String> expectedQueueNames = Sets.newHashSet(tenant);
instance1.add(tenant, new Element("id3-1", "val1"));
instance1.add(tenant, new Element("id3-2", "val2"));
// check both instances see tenant3
Assert.assertEquals(expectedQueueNames, instance1.getQueueNames());
waitForQueueNames(expectedQueueNames, instance2);
// make sure each instance gets an accurate picture of the queue
Iterator<GroupElement> queuesIter1 = instance1.takeIterator("consumer1");
Iterator<GroupElement> queuesIter2 = instance1.takeIterator("consumer2");
GroupElement gelement = queuesIter1.next();
Assert.assertEquals(tenant, gelement.getQueueName());
Assert.assertEquals("id3-1", gelement.getElement().getId());
Assert.assertEquals("val1", gelement.getElement().getValue());
gelement = queuesIter2.next();
Assert.assertEquals(tenant, gelement.getQueueName());
Assert.assertEquals("id3-2", gelement.getElement().getId());
Assert.assertEquals("val2", gelement.getElement().getValue());
Assert.assertFalse(queuesIter1.hasNext());
Assert.assertFalse(queuesIter2.hasNext());
instance1.stop();
instance2.stop();
}
内容来源于网络,如有侵权,请联系作者删除!