Java Code Examples for com.google.common.collect.Sets#newConcurrentHashSet()
The following examples show how to use
com.google.common.collect.Sets#newConcurrentHashSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Job.java From airpal with Apache License 2.0 | 6 votes |
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 ); }
Example 2
Source File: AgentManageServiceImpl.java From DrivingAgency with MIT License | 6 votes |
@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; }
Example 3
Source File: MetricContext.java From incubator-gobblin with Apache License 2.0 | 6 votes |
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); } }
Example 4
Source File: PhysicsObject.java From Valkyrien-Skies with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: FailbackRegistry.java From saluki with Apache License 2.0 | 6 votes |
@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); } }
Example 6
Source File: ConsumerConnectionState.java From joyqueue with Apache License 2.0 | 5 votes |
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; }
Example 7
Source File: CarreraConsumer.java From DDMQ with Apache License 2.0 | 5 votes |
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(); }
Example 8
Source File: ReleaseKeyGeneratorTest.java From apollo with Apache License 2.0 | 5 votes |
@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()); }
Example 9
Source File: DefaultApplicationsMapCreator.java From pinpoint with Apache License 2.0 | 5 votes |
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; }
Example 10
Source File: K8sNetworkPolicyHandler.java From onos with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: NinjaPipelineImpl.java From bazel with Apache License 2.0 | 5 votes |
/** * @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(); }
Example 12
Source File: CachingBuildEngine.java From buck with Apache License 2.0 | 5 votes |
@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(); }
Example 13
Source File: CarreraConsumer.java From DDMQ with Apache License 2.0 | 5 votes |
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(); }
Example 14
Source File: StatsFlowRuleManager.java From onos with Apache License 2.0 | 4 votes |
@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; }
Example 15
Source File: TestDistributedSet.java From onos with Apache License 2.0 | 4 votes |
/** * Public constructor. * * @param setName name to be assigned to this set */ public TestDistributedSet(String setName) { set = Sets.newConcurrentHashSet(); listeners = new LinkedList<>(); this.setName = setName; }
Example 16
Source File: StatsFlowRuleManager.java From onos with Apache License 2.0 | 4 votes |
@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); } }
Example 17
Source File: ArtemisConfig.java From onos with Apache License 2.0 | 4 votes |
public MoasInfo() { moasAddresses = Sets.newConcurrentHashSet(); tunnelPoints = Sets.newConcurrentHashSet(); }
Example 18
Source File: DefaultOvsdbClient.java From onos with Apache License 2.0 | 4 votes |
@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; }
Example 19
Source File: DefaultDistributedSetService.java From atomix with Apache License 2.0 | 4 votes |
public DefaultDistributedSetService() { super(DistributedSetType.instance(), Sets.newConcurrentHashSet()); }
Example 20
Source File: BrokeredDeviceExportedPropertyRecorder.java From android-test with Apache License 2.0 | 2 votes |
/** * 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(); }