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


Java Sets.newConcurrentHashSet方法代码示例

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


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

示例1: register

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public void register(TreeComponent component) {
	TreeComponent preExist = componentCacheLoc.remove((Locatable) component); // did we have one here already?
	if (preExist != null) {
		CropControl.getPlugin().debug("Replacing treecomponent at {0}: {1}", (Locatable) component, component);
		componentCacheID.remove(preExist.getTreeComponentID());
	} else {
		CropControl.getPlugin().debug("Putting treecomponent at {0}: {1}", (Locatable) component, component);
	}
	componentCacheLoc.put(new Locatable(component.getChunkID(), component.getX(), component.getY(), component.getZ()), component);
	componentCacheID.put(component.getTreeComponentID(), component);
	
	Set<TreeComponent> treeComponents = WorldChunk.universalTreeComponentCache.get(component.getTreeID());
	if (treeComponents == null) {
		treeComponents = Sets.newConcurrentHashSet();
		WorldChunk.universalTreeComponentCache.put(component.getTreeID(), treeComponents);
	}
	treeComponents.add(component);
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:19,代码来源:WorldChunk.java

示例2: clientStreaming_error_break_flow

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Test
public void clientStreaming_error_break_flow() throws Exception {
  PublishSubject<Integer> publishSubject = PublishSubject.create();
  Set<Integer> resultsHolder = Sets.newConcurrentHashSet();
  Set<Throwable> exceptionsHolder = Sets.newConcurrentHashSet();
  AtomicBoolean complete = new AtomicBoolean(false);
  Disposable disposable = publishSubject
      .doOnNext(num->resultsHolder.add(num))
      .doOnError(t->exceptionsHolder.add(t))
      .doOnComplete(()->complete.compareAndSet(false,true))
      .subscribe();
  assertThat(disposable.isDisposed()).isFalse();
  RxStreamObserver<Integer> rxStreamObserver = new RxStreamObserver<>(publishSubject);

  rxStreamObserver.onError(new IllegalStateException());

  assertThat(disposable.isDisposed()).isTrue();
  assertThat(resultsHolder).isEmpty();
  assertThat(exceptionsHolder.size()).isEqualTo(1);
  assertThat(exceptionsHolder.iterator().next()).isInstanceOf(IllegalStateException.class);
  assertThat(complete).isFalse();
}
 
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:23,代码来源:RxStreamObserverTest.java

示例3: addJoin

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public void addJoin(Datasource ds, Join j) {
	addDatasource(ds);
	j.setDatasource(ds);
	
	if( j.getLeft() != null  &&
			j.getRight() != null){
	
		if(dsJoins.containsKey(ds)) {
			dsJoins.get(ds).add(j);
		}else {
			Set<Join> n = Sets.newConcurrentHashSet();
			n.add(j);
			dsJoins.put(ds, n);
		}
		
	}		
	
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:19,代码来源:Schema.java

示例4: doSubscribe

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
protected synchronized void doSubscribe(GrpcURL url,
    NotifyListener.NotifyServiceListener listener) {
  Pair<GrpcURL, Set<NotifyListener.NotifyServiceListener>> listenersPair =
      notifyServiceListeners.get(url.getServiceKey());
  if (listenersPair == null) {
    Set<NotifyListener.NotifyServiceListener> listeners = Sets.newConcurrentHashSet();
    listeners.add(listener);
    listenersPair =
        new ImmutablePair<GrpcURL, Set<NotifyListener.NotifyServiceListener>>(url, listeners);
  } else {
    listenersPair.getValue().add(listener);
  }
  notifyServiceListeners.putIfAbsent(url.getServiceKey(), listenersPair);
  if (!serviceGroupLookUped.contains(url.getGroup())) {
    serviceGroupLookUped.add(url.getGroup());
    ServiceLookUper serviceLookUper = new ServiceLookUper(url.getGroup());
    serviceLookUper.setDaemon(true);
    serviceLookUper.start();
    ConsulEphemralNode ephemralNode = this.buildEphemralNode(url, ThrallRoleType.CONSUMER);
    client.registerEphemralNode(ephemralNode);
  } else {
    notifyListener(url, listener);
  }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:26,代码来源:ConsulRegistry.java

示例5: subscribe

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public void subscribe(GrpcURL url, NotifyRouterListener listener) {
  String serviceKey = url.getServiceKey();
  Set<NotifyListener.NotifyRouterListener> listeners = notifyRouterListeners.get(serviceKey);
  if (listeners == null) {
    listeners = Sets.newConcurrentHashSet();
    listeners.add(listener);
  } else {
    listeners.add(listener);
  }
  notifyRouterListeners.put(serviceKey, listeners);
  if (!routerGroupLookUped.contains(serviceKey)) {
    routerGroupLookUped.add(serviceKey);
    RouterLookUper routerLookUper = new RouterLookUper(url);
    routerLookUper.setDaemon(true);
    routerLookUper.start();
  }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:19,代码来源:ConsulRegistry.java

示例6: unsubscribe

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public void unsubscribe(GrpcURL url, NotifyListener.NotifyServiceListener listener) {
  super.unsubscribe(url, listener);
  removeFailedSubscribed(url, listener);
  try {
    // 向服务器端发送取消订阅请求
    doUnsubscribe(url, listener);
  } catch (Exception e) {
    logger.error("Failed to unsubscribe " + url + ", waiting for retry, cause: " + e.getMessage(),
        e);
    // 将失败的取消订阅请求记录到失败列表,定时重试
    Set<NotifyListener.NotifyServiceListener> listeners = failedUnsubscribed.get(url);
    if (listeners == null) {
      listeners = Sets.newConcurrentHashSet();
      listeners = failedUnsubscribed.putIfAbsent(url, listeners);
    }
    listeners.add(listener);
  }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:20,代码来源:FailbackRegistry.java

示例7: activate

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Activate
public void activate() {
    cpuMetrics = genMDbBuilder(DEFAULT_RESOURCE, Type.CPU, CPU_METRICS);
    memoryMetrics = genMDbBuilder(DEFAULT_RESOURCE, Type.MEMORY, MEMORY_METRICS);
    controlMessageMap = Maps.newConcurrentMap();
    diskMetricsMap = Maps.newConcurrentMap();
    networkMetricsMap = Maps.newConcurrentMap();

    cpuBuf = Maps.newConcurrentMap();
    memoryBuf = Maps.newConcurrentMap();
    diskBuf = Maps.newConcurrentMap();
    networkBuf = Maps.newConcurrentMap();
    ctrlMsgBuf = Maps.newConcurrentMap();

    availableResourceMap = Maps.newConcurrentMap();
    availableDeviceIdSet = Sets.newConcurrentHashSet();

    communicationService.<ControlMetricsRequest, ControlLoadSnapshot>addSubscriber(CONTROL_STATS,
            SERIALIZER::decode, this::handleMetricsRequest, SERIALIZER::encode);

    communicationService.<ControlResourceRequest, Set<String>>addSubscriber(CONTROL_RESOURCE,
            SERIALIZER::decode, this::handleResourceRequest, SERIALIZER::encode);

    log.info("Started");
}
 
开发者ID:shlee89,项目名称:athena,代码行数:26,代码来源:ControlPlaneMonitor.java

示例8: testGenerateReleaseKey

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Test
public void testGenerateReleaseKey() throws Exception {
  String someAppId = "someAppId";
  String someCluster = "someCluster";
  String someNamespace = "someNamespace";

  String anotherAppId = "anotherAppId";

  Namespace namespace = MockBeanFactory.mockNamespace(someAppId, someCluster, someNamespace);
  Namespace anotherNamespace = MockBeanFactory.mockNamespace(anotherAppId, someCluster, someNamespace);
  int generateTimes = 50000;
  Set<String> releaseKeys = Sets.newConcurrentHashSet();

  ExecutorService executorService = Executors.newFixedThreadPool(2);
  CountDownLatch latch = new CountDownLatch(1);

  executorService.submit(generateReleaseKeysTask(namespace, releaseKeys, generateTimes, latch));
  executorService.submit(generateReleaseKeysTask(anotherNamespace, releaseKeys, generateTimes, latch));

  latch.countDown();

  executorService.shutdown();
  executorService.awaitTermination(10, TimeUnit.SECONDS);

  //make sure keys are unique
  assertEquals(generateTimes * 2, releaseKeys.size());
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:28,代码来源:ReleaseKeyGeneratorTest.java

示例9: keySet

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Override
public CompletableFuture<Set<K>> keySet() {
    Set<K> allKeys = Sets.newConcurrentHashSet();
    return CompletableFuture.allOf(getMaps().stream()
                                            .map(map -> map.keySet().thenAccept(allKeys::addAll))
                                            .toArray(CompletableFuture[]::new))
                            .thenApply(v -> allKeys);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:PartitionedAsyncConsistentMap.java

示例10: clientStreaming_async

import com.google.common.collect.Sets; //导入方法依赖的package包/类
@Test
public void clientStreaming_async() throws Exception {
  PublishSubject<Integer> publishSubject = PublishSubject.create();
  Set<Integer> resultsHolder = Sets.newConcurrentHashSet();
  Set<Throwable> exceptionsHolder = Sets.newConcurrentHashSet();
  AtomicBoolean complete = new AtomicBoolean(false);
  Disposable disposable = publishSubject
      .observeOn(Schedulers.io())
      .doOnNext(num->resultsHolder.add(num*2))
      .doOnError(t->exceptionsHolder.add(t))
      .doOnComplete(()->complete.compareAndSet(false,true))
      .subscribe();

  assertThat(disposable.isDisposed()).isFalse();
  RxStreamObserver<Integer> rxStreamObserver = new RxStreamObserver<>(publishSubject);

  IntStream.range(1,5).forEach(num->rxStreamObserver.onNext(num));
  rxStreamObserver.onCompleted();
  while(resultsHolder.size() < 4){
    Thread.sleep(500);
  }

  assertThat(disposable.isDisposed()).isTrue();
  assertThat(resultsHolder).containsExactly(2,4,6,8);
  assertThat(exceptionsHolder).isEmpty();
  assertThat(complete).isTrue();
}
 
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:28,代码来源:RxStreamObserverTest.java

示例11: addTable

import com.google.common.collect.Sets; //导入方法依赖的package包/类
public void addTable(Datasource ds, Table t) {
	addDatasource(ds);
	t.setDatasource(ds);
	t.setProject(getProject());
	
	if(dsTables.containsKey(ds)) {
		dsTables.get(ds).add(t);
	}else {
		Set<Table> n = Sets.newConcurrentHashSet();
		n.add(t);
		dsTables.put(ds, n);
	}
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:14,代码来源:Schema.java

示例12: addFailedSubscribed

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private void addFailedSubscribed(GrpcURL url, NotifyListener.NotifyServiceListener listener) {
  Set<NotifyListener.NotifyServiceListener> listeners = failedSubscribed.get(url);
  if (listeners == null) {
    listeners = Sets.newConcurrentHashSet();
    listeners = failedSubscribed.putIfAbsent(url, listeners);
  }
  listeners.add(listener);
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:9,代码来源:FailbackRegistry.java

示例13: createOrUpdateLinkProviders

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<ProviderId> createOrUpdateLinkProviders(Set<ProviderId> current, ProviderId providerId) {
    if (current == null) {
        current = Sets.newConcurrentHashSet();
    }
    current.add(providerId);
    return current;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:ECLinkStore.java

示例14: addEdgePort

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private void addEdgePort(ConnectPoint point) {
    if (!topologyService.isInfrastructure(topology, point) && !point.port().isLogical()) {
        Set<ConnectPoint> set = connectionPoints.get(point.deviceId());
        if (set == null) {
            set = Sets.newConcurrentHashSet();
            connectionPoints.put(point.deviceId(), set);
        }
        if (set.add(point)) {
            post(new EdgePortEvent(EDGE_PORT_ADDED, point));
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:EdgeManager.java

示例15: createControlMessages

import com.google.common.collect.Sets; //导入方法依赖的package包/类
private Set<ControlMessage> createControlMessages() {
    final DeviceId deviceId = DeviceId.deviceId("of:0000000000000001");
    Set<ControlMessage> controlMessages = Sets.newConcurrentHashSet();
    controlMessages.add(createControlMessage(INBOUND_PACKET, deviceId));
    controlMessages.add(createControlMessage(OUTBOUND_PACKET, deviceId));
    return controlMessages;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:ControlMessageEventTest.java


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