com.google.common.collect.Sets#newConcurrentHashSet ( )源码实例Demo

下面列出了com.google.common.collect.Sets#newConcurrentHashSet ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DrivingAgency   文件: AgentManageServiceImpl.java
@Override
public List<AgentVo> listAllUnExamineAgents() {
    Agent agent = SecurityContextHolder.getAgent();
    Set<Agent> agents= Sets.newConcurrentHashSet();
    findChildrenAgents(agents,agent.getId());
    List<AgentVo> lists= Lists.newArrayList();

    agents.stream().filter(agent1 -> agent1.getStatus().equals(AgentStatus.UNEXAMINED.getCode()))
            .sorted(Comparator.comparing(Agent::getAgentAchieve).reversed()).forEach(agent1->{
        AgentVo agentVo=new AgentVo();
        BeanUtils.copyProperties(agent1,agentVo);
        lists.add(agentVo);
    });

    return lists;
}
 
源代码2 项目: incubator-gobblin   文件: MetricContext.java
protected MetricContext(String name, MetricContext parent, List<Tag<?>> tags, boolean isRoot) throws NameConflictException {
  Preconditions.checkArgument(!Strings.isNullOrEmpty(name));

  this.closer = Closer.create();

  try {
    this.innerMetricContext = this.closer.register(new InnerMetricContext(this, name, parent, tags));
  } catch(ExecutionException ee) {
    throw Throwables.propagate(ee);
  }

  this.contextAwareMetricsSet = Sets.newConcurrentHashSet();

  this.notificationTargets = Maps.newConcurrentMap();
  this.executorServiceOptional = Optional.absent();

  this.notificationTimer = new ContextAwareTimer(this, GOBBLIN_METRICS_NOTIFICATIONS_TIMER_NAME);
  register(this.notificationTimer);

  if (!isRoot) {
    RootMetricContext.get().addMetricContext(this);
  }
}
 
源代码3 项目: Valkyrien-Skies   文件: PhysicsObject.java
public PhysicsObject(PhysicsWrapperEntity host) {
    this.wrapperEntity = host;
    if (host.world.isRemote) {
        this.shipRenderer = new PhysObjectRenderManager(this);
    }
    // We need safe access to this across multiple threads.
    this.blockPositions = ConcurrentHashMap.newKeySet();
    this.shipBoundingBox = Entity.ZERO_AABB;
    this.watchingPlayers = new ArrayList<>();
    this.shipSubspace = new ImplSubspace(this);
    this.physicsControllers = Sets.newConcurrentHashSet();
    this.physicsControllersImmutable = Collections.unmodifiableSet(this.physicsControllers);
    this.blockPositionsGameTick = new TIntArrayList();
    this.cachedSurroundingChunks = new SurroundingChunkCacheController(this);
    this.voxelFieldAABBMaker = null;
}
 
源代码4 项目: saluki   文件: FailbackRegistry.java
@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);
  }
}
 
源代码5 项目: airpal   文件: Job.java
public Job(final String user,
        final String query,
        final UUID uuid,
        final PersistentJobOutput output,
        final QueryStats stats,
        final JobState state,
        final List<Column> columns,
        final QueryError error,
        final DateTime queryFinished)
{
    this(user,
         query,
         uuid,
         output,
         stats,
         state,
         columns,
         Sets.<Table>newConcurrentHashSet(),
         new DateTime(),
         error,
         queryFinished
    );
}
 
源代码6 项目: onos   文件: K8sNetworkPolicyHandler.java
private Set<Pod> podsFromPolicyPeer(NetworkPolicyPeer peer, String namespace) {
    Set<Pod> pods = Sets.newConcurrentHashSet();
    if (peer.getPodSelector() != null) {
        Map<String, String> podLabels = peer.getPodSelector().getMatchLabels();
        List<LabelSelectorRequirement> matchExps = peer.getPodSelector().getMatchExpressions();

        if (podLabels == null && matchExps.size() == 0) {
            k8sPodService.pods().stream()
                    .filter(pod -> pod.getMetadata().getNamespace().equals(
                            namespace))
                    .forEach(pods::add);
        } else {
            k8sPodService.pods().stream()
                    .filter(pod -> pod.getMetadata().getNamespace().equals(
                            namespace))
                    .forEach(pod -> {
                        pod.getMetadata().getLabels().forEach((k, v) -> {
                            if (podLabels != null && podLabels.get(k) != null &&
                                    podLabels.get(k).equals(v)) {
                                pods.add(pod);
                            }
                        });
                    });
        }
    }
    return pods;
}
 
源代码7 项目: DDMQ   文件: CarreraConsumer.java
public void start() throws CarreraClientException {
    LogUtils.logMainInfo("CarreraConsumer.start, group:{}, brokerCluster:{}.",
            config.getGroup(), config.getBrokerCluster());
    workingJobs = Sets.newConcurrentHashSet();
    buildActionMap();

    //rocketmq
    if (config.getcProxyConfig().getRocketmqConfigs().containsKey(config.getBrokerCluster())) {
        RocketmqConfiguration rocketmqConfiguration = config.getcProxyConfig()
                .getRocketmqConfigs().get(config.getBrokerCluster());

        if (ConfigUtils.satisfyNewRmqConsumer(config.getGroupConfig())) {
            LOGGER.debug("open a CarreraNewRocketMqConsumer client. group:{}.", config.getGroup());
            consumer = new CarreraNewRocketMqConsumer(config.getBrokerCluster(),
                    config.getGroup(), config.getGroupConfig(), config.getcProxyConfig(),
                    rocketmqConfiguration, this, config.getMaxConsumeLagMap(), config.getTotalThreads());
        } else {
            consumer = new CarreraRocketMqConsumer(config.getBrokerCluster(),
                    config.getGroup(), config.getGroupConfig(), config.getcProxyConfig(),
                    rocketmqConfiguration, this, config.getMaxConsumeLagMap(), config.getTotalThreads());
        }
    }

    //kafka
    if (config.getcProxyConfig().getKafkaConfigs().containsKey(config.getBrokerCluster())) {
        KafkaConfiguration kafkaConfiguration = config.getcProxyConfig().getKafkaConfigs().get(config.getBrokerCluster());
        consumer = new CarreraKafkaConsumer(config.getBrokerCluster(),
                config.getGroup(), config.getGroupConfig(), config.getcProxyConfig(),
                kafkaConfiguration, this, config.getMaxConsumeLagMap(), config.getTopicCount(), config.getTopicMap());
    }

    consumer.enableOffsetAutoCommit(CarreraOffsetManager.getInstance().getScheduler());
    consumer.startConsume();
}
 
源代码8 项目: buck   文件: CachingBuildEngine.java
@Override
public int getNumRulesToBuild(Iterable<BuildRule> rules) {
  Set<BuildRule> seen = Sets.newConcurrentHashSet();
  ImmutableList.Builder<ListenableFuture<?>> results = ImmutableList.builder();
  for (BuildRule rule : rules) {
    if (seen.add(rule)) {
      results.add(walkRule(rule, seen));
    }
  }
  Futures.getUnchecked(Futures.allAsList(results.build()));
  return seen.size();
}
 
源代码9 项目: bazel   文件: NinjaPipelineImpl.java
/**
 * @param basePath base path for resolving include and subninja paths.
 * @param service service to use for scheduling tasks in parallel.
 * @param includedOrSubninjaFiles Ninja files expected in include/subninja statements
 * @param ownerTargetName name of the owner ninja_graph target
 */
public NinjaPipelineImpl(
    Path basePath,
    ListeningExecutorService service,
    Collection<Path> includedOrSubninjaFiles,
    String ownerTargetName) {
  this.basePath = basePath;
  this.service = service;
  this.includedOrSubninjaFiles = includedOrSubninjaFiles;
  this.ownerTargetName = ownerTargetName;
  this.childPaths = Sets.newConcurrentHashSet();
}
 
源代码10 项目: joyqueue   文件: ConsumerConnectionState.java
protected Set<String> getOrCreateAddedTopicSet(String app) {
    Set<String> topicSet = consumerMap.get(app);
    if (topicSet == null) {
        topicSet = Sets.newConcurrentHashSet();
        Set<String> oldTopicSet = consumerMap.putIfAbsent(app, topicSet);
        if (oldTopicSet != null) {
            topicSet = oldTopicSet;
        }
    }
    return topicSet;
}
 
源代码11 项目: pinpoint   文件: DefaultApplicationsMapCreator.java
private LinkDataDuplexMap createParallel(List<Application> applications, LinkSelectContext linkSelectContext) {
    final Set<LinkDataDuplexMap> searchResults = Sets.newConcurrentHashSet();
    CompletableFuture[] futures = getLinkDataMapFutures(searchResults, applications, linkSelectContext);
    CompletableFuture.allOf(futures).join();
    LinkDataDuplexMap resultMap = new LinkDataDuplexMap();
    for (LinkDataDuplexMap searchResult : searchResults) {
        resultMap.addLinkDataDuplexMap(searchResult);
    }
    logger.debug("depth search. callerDepth : {}, calleeDepth : {}", linkSelectContext.getCallerDepth(), linkSelectContext.getCalleeDepth());
    return resultMap;
}
 
源代码12 项目: apollo   文件: ReleaseKeyGeneratorTest.java
@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());
}
 
源代码13 项目: DDMQ   文件: CarreraConsumer.java
public void start() throws CarreraClientException {
    LogUtils.logMainInfo("CarreraConsumer.start, group:{}, brokerCluster:{}.",
            config.getGroup(), config.getBrokerCluster());
    workingJobs = Sets.newConcurrentHashSet();
    buildActionMap();

    //rocketmq
    if (config.getcProxyConfig().getRocketmqConfigs().containsKey(config.getBrokerCluster())) {
        RocketmqConfiguration rocketmqConfiguration = config.getcProxyConfig()
                .getRocketmqConfigs().get(config.getBrokerCluster());

        if (ConfigUtils.satisfyNewRmqConsumer(config.getGroupConfig())) {
            LOGGER.debug("open a CarreraNewRocketMqConsumer client. group:{}.", config.getGroup());
            consumer = new CarreraNewRocketMqConsumer(config.getBrokerCluster(),
                    config.getGroup(), config.getGroupConfig(), config.getcProxyConfig(),
                    rocketmqConfiguration, this, config.getMaxConsumeLagMap(), config.getTotalThreads());
        } else {
            consumer = new CarreraRocketMqConsumer(config.getBrokerCluster(),
                    config.getGroup(), config.getGroupConfig(), config.getcProxyConfig(),
                    rocketmqConfiguration, this, config.getMaxConsumeLagMap(), config.getTotalThreads());
        }
    }

    //kafka
    if (config.getcProxyConfig().getKafkaConfigs().containsKey(config.getBrokerCluster())) {
        KafkaConfiguration kafkaConfiguration = config.getcProxyConfig().getKafkaConfigs().get(config.getBrokerCluster());
        consumer = new CarreraKafkaConsumer(config.getBrokerCluster(),
                config.getGroup(), config.getGroupConfig(), config.getcProxyConfig(),
                kafkaConfiguration, this, config.getMaxConsumeLagMap(), config.getTopicCount(), config.getTopicMap());
    }

    consumer.enableOffsetAutoCommit(CarreraOffsetManager.getInstance().getScheduler());
    consumer.startConsume();
}
 
源代码14 项目: atomix   文件: DefaultDistributedSetService.java
public DefaultDistributedSetService() {
  super(DistributedSetType.instance(), Sets.newConcurrentHashSet());
}
 
源代码15 项目: onos   文件: StatsFlowRuleManager.java
@Override
public void run() {
    Set<FlowInfo> filteredOverlayFlowInfos = Sets.newConcurrentHashSet();
    Set<FlowInfo> filteredUnderlayFlowInfos = Sets.newConcurrentHashSet();

    // we only let the master controller of the device where the
    // stats flow rules are installed send stats message
    if (monitorOverlay) {
        getOverlayFlowInfos().forEach(f -> {
            if (checkSrcDstLocalMaster(f)) {
                filteredOverlayFlowInfos.add(f);
            }
        });
    }
    if (monitorUnderlay) {
        getUnderlayFlowInfos().forEach(f -> {
            if (checkSrcDstLocalMaster(f)) {
                filteredUnderlayFlowInfos.add(f);
            }
        });
    }

    // we only let the master controller of the device where the port
    // is located to send stats message
    if (portStats) {
        if (monitorOverlay) {
            getOverlayDstPortBasedFlowInfos().forEach(f -> {
                if (checkSrcDstLocalMaster(f)) {
                    filteredOverlayFlowInfos.add(f);
                }
            });
        }

        if (monitorUnderlay) {
            getUnderlayDstPortBasedFlowInfos().forEach(f -> {
                if (checkSrcDstLocalMaster(f)) {
                    filteredUnderlayFlowInfos.add(f);
                }
            });
        }
    }


    if (monitorOverlay) {
        telemetryService.publish(filteredOverlayFlowInfos);

        // TODO: Refactor the following code to "TelemetryService" style.
        filteredOverlayFlowInfos.forEach(StatsFlowRuleManager.this::enqFlowInfo);
    }

    if (monitorUnderlay) {
        telemetryService.publish(filteredUnderlayFlowInfos);
    }
}
 
源代码16 项目: onos   文件: StatsFlowRuleManager.java
@Override
public Set<FlowInfo> getUnderlayFlowInfos() {

    Set<FlowInfo> flowInfos = Sets.newConcurrentHashSet();

    for (Device device : getUnderlayDevices()) {

        if (!isEdgeSwitch(device.id())) {
            continue;
        }

        for (FlowEntry entry : flowRuleService.getFlowEntries(device.id())) {
            FlowInfo.Builder fBuilder = new DefaultFlowInfo.DefaultBuilder();
            TrafficSelector selector = entry.selector();
            Criterion inPort = selector.getCriterion(Criterion.Type.IN_PORT);
            Criterion dstIpCriterion = selector.getCriterion(Criterion.Type.IPV4_DST);
            if (inPort != null && dstIpCriterion != null) {
                IpAddress srcIp = getIpAddress(device, (PortCriterion) inPort);
                IpAddress dstIp = ((IPCriterion) dstIpCriterion).ip().address();

                if (srcIp == null) {
                    continue;
                }

                fBuilder.withFlowType(FLOW_TYPE_SONA)
                        .withSrcIp(IpPrefix.valueOf(srcIp, ARBITRARY_LENGTH))
                        .withDstIp(IpPrefix.valueOf(dstIp, ARBITRARY_LENGTH))
                        .withSrcMac(getMacAddress(srcIp))
                        .withDstMac(getMacAddress(dstIp))
                        .withInputInterfaceId(getInterfaceId(srcIp))
                        .withOutputInterfaceId(getInterfaceId(dstIp))
                        .withDeviceId(entry.deviceId());

                StatsInfo.Builder sBuilder = new DefaultStatsInfo.DefaultBuilder();

                sBuilder.withStartupTime(System.currentTimeMillis())
                        .withFstPktArrTime(System.currentTimeMillis())
                        .withLstPktOffset((int) (REFRESH_INTERVAL * MILLISECONDS))
                        .withCurrAccPkts((int) entry.packets())
                        .withCurrAccBytes(entry.bytes())
                        .withErrorPkts((short) 0)
                        .withDropPkts((short) 0);

                fBuilder.withStatsInfo(sBuilder.build());

                FlowInfo flowInfo = mergeFlowInfo(fBuilder.build(), fBuilder, sBuilder);

                flowInfos.add(flowInfo);
            }
        }
    }

    return flowInfos;
}
 
源代码17 项目: onos   文件: TestDistributedSet.java
/**
 * Public constructor.
 *
 * @param setName name to be assigned to this set
 */
public TestDistributedSet(String setName) {
    set = Sets.newConcurrentHashSet();
    listeners = new LinkedList<>();
    this.setName = setName;
}
 
源代码18 项目: onos   文件: ArtemisConfig.java
public MoasInfo() {
    moasAddresses = Sets.newConcurrentHashSet();
    tunnelPoints = Sets.newConcurrentHashSet();
}
 
源代码19 项目: onos   文件: DefaultOvsdbClient.java
@Override
public boolean createInterface(String bridgeName, OvsdbInterface ovsdbIface) {
    String bridgeUuid  = getBridgeUuid(bridgeName);
    if (bridgeUuid == null) {
        log.warn("Couldn't find bridge {} in {}", bridgeName, nodeId.getIpAddress());
        return false;
    }

    if (getPortUuid(ovsdbIface.name(), bridgeUuid) != null) {
        log.warn("Interface {} already exists", ovsdbIface.name());
        return false;
    }

    ArrayList<Operation> operations = Lists.newArrayList();
    DatabaseSchema dbSchema = schema.get(DATABASENAME);

    // insert a new port with the interface name
    Port port = (Port) TableGenerator.createTable(dbSchema, OvsdbTable.PORT);
    port.setName(ovsdbIface.name());
    Insert portInsert = new Insert(dbSchema.getTableSchema(PORT), PORT, port.getRow());
    portInsert.getRow().put(INTERFACES, Uuid.uuid(INTERFACE));
    operations.add(portInsert);

    // update the bridge table with the new port
    Condition condition = ConditionUtil.isEqual(UUID, Uuid.uuid(bridgeUuid));
    Mutation mutation = MutationUtil.insert(PORTS, Uuid.uuid(PORT));
    List<Condition> conditions = Lists.newArrayList(condition);
    List<Mutation> mutations = Lists.newArrayList(mutation);
    operations.add(new Mutate(dbSchema.getTableSchema(BRIDGE), conditions, mutations));

    Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
    intf.setName(ovsdbIface.name());

    if (ovsdbIface.type() != null) {
        intf.setType(ovsdbIface.typeToString());
    }

    if (ovsdbIface.mtu().isPresent()) {
        Set<Long> mtuSet = Sets.newConcurrentHashSet();
        mtuSet.add(ovsdbIface.mtu().get());
        intf.setMtu(mtuSet);
        intf.setMtuRequest(mtuSet);
    }

    intf.setOptions(ovsdbIface.options());

    ovsdbIface.data().forEach((k, v) -> {
        if (k == Interface.InterfaceColumn.EXTERNALIDS) {
            intf.setExternalIds(v);
        }
    });

    Insert intfInsert = new Insert(dbSchema.getTableSchema(INTERFACE), INTERFACE, intf.getRow());
    operations.add(intfInsert);

    transactConfig(DATABASENAME, operations);
    log.info("Created interface {}", ovsdbIface);
    return true;
}
 
/**
 * Decorates a device broker to record the properties of every device it creates.
 *
 * @param delegate the (non-null) broker to delegate to.
 */
public BrokeredDeviceExportedPropertyRecorder(DeviceBroker delegate) {
  this.delegate = checkNotNull(delegate);
  exportedProperties = Sets.newConcurrentHashSet();
}