List of usage examples for com.google.common.collect Sets newConcurrentHashSet
public static <E> Set<E> newConcurrentHashSet()
From source file:com.facebook.buck.distributed.build_slave.MinionHealthTracker.java
public MinionHealthTracker(Clock clock, long maxMinionSilenceMillis, int maxConsecutiveSlowDeadMinionChecks, long expectedHeartbeatIntervalMillis, long slowHeartbeatWarningThresholdMillis, HealthCheckStatsTracker healthCheckStatsTracker) { this.healthCheckStatsTracker = healthCheckStatsTracker; Preconditions.checkArgument(slowHeartbeatWarningThresholdMillis > expectedHeartbeatIntervalMillis, "slow_heartbeat_warning_threshold_millis must be higher than heartbeat_service_interval_millis"); Preconditions.checkArgument(maxMinionSilenceMillis > 0, "The maxMinionSilenceMillis value needs to be positive. Found [%d] instead.", maxMinionSilenceMillis);/* w w w . jav a 2 s . c o m*/ this.maxMinionSilenceMillis = maxMinionSilenceMillis; this.maxConsecutiveSlowDeadMinionChecks = maxConsecutiveSlowDeadMinionChecks; this.slowHeartbeatWarningThresholdMillis = slowHeartbeatWarningThresholdMillis; this.minions = Maps.newConcurrentMap(); this.untrackedMinions = Sets.newConcurrentHashSet(); this.clock = clock; }
From source file:oims.dataBase.tables.SyncerTable.java
public Set<String> compareSyncerTable(ResultSet lrs, ResultSet rrs) { Set<String> result = Sets.newConcurrentHashSet(); Map<String, String> serializedrrs = Maps.newHashMap(); Map<String, String> serializedlrs = Maps.newHashMap(); try {//w w w . ja v a2 s. c o m if (rrs.first()) { do { serializedrrs.put(rrs.getString("TableName"), rrs.getString("versionTag")); } while (rrs.next()); } if (lrs.first()) { do { serializedlrs.put(lrs.getString("TableName"), lrs.getString("versionTag")); } while (rrs.next()); } } catch (SQLException ex) { Logger.getLogger(SyncerTable.class.getName()).log(Level.SEVERE, null, ex); } for (Entry<String, String> entry : serializedrrs.entrySet()) { if (serializedlrs.containsKey(entry.getKey())) { if (serializedlrs.get(entry.getKey()).equals(entry.getValue())) { continue; } } result.add(entry.getKey()); } return result; }
From source file:com.palantir.lock.client.LockRefreshingRemoteLockService.java
private LockRefreshingRemoteLockService(RemoteLockService delegate) { this.delegate = delegate; toRefresh = Sets.newConcurrentHashSet(); exec = PTExecutors.newScheduledThreadPool(1, PTExecutors.newNamedThreadFactory(true)); }
From source file:com.facebook.buck.util.cache.impl.LoadingCacheFileHashCache.java
private void updateParent(Path path) { Path parent = path.getParent(); if (parent != null) { Set<Path> children = parentToChildCache.computeIfAbsent(parent, key -> Sets.newConcurrentHashSet()); children.add(path);/*from www . j a v a 2 s.com*/ } }
From source file:ru.runa.wfe.commons.cache.sm.CachingLogic.java
/** * Register listener. Listener will be notified on events, according to implemented interfaces. * * @param listener/*from w w w . j a v a2s . com*/ * Listener, which must receive events. */ public static synchronized void registerChangeListener(ChangeListener listener) { ChangeListenerGuard guarded = new ChangeListenerGuard(listener); for (Class<?> clazz : listener.getListenObjectTypes()) { Set<ChangeListener> listeners = objectTypeToListenersRegistered.get(clazz); if (listeners == null) { listeners = Sets.newConcurrentHashSet(); objectTypeToListenersRegistered.put(clazz, listeners); } listeners.add(guarded); } objectTypeToListenersAll.clear(); }
From source file:se.svt.helios.serviceregistration.consul.ConsulServiceRegistrar.java
public ConsulServiceRegistrar(final ConsulClient consulClient, final String serviceCheckScript, final String serviceCheckInterval) { this.consulClient = consulClient; this.serviceCheckScript = serviceCheckScript; this.serviceCheckInterval = serviceCheckInterval; this.handles = Maps.newConcurrentMap(); this.endpoints = Sets.newConcurrentHashSet(); this.executor = MoreExecutors.getExitingScheduledExecutorService( (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("consul-registrar-%d").build()), 0, TimeUnit.SECONDS); // If the Consul agent is restarted, all services will forgotten. Therefore we sync the // state between services known by this plugin and services registered in Consul. Runnable registrationRunnable = new Runnable() { @Override//w w w .ja v a 2 s . c o m public void run() { syncState(); } }; this.executor.scheduleAtFixedRate(registrationRunnable, CONSUL_UPDATE_INTERVAL, CONSUL_UPDATE_INTERVAL, TimeUnit.SECONDS); }
From source file:com.navercorp.pinpoint.web.service.map.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); }//w w w .j a v a 2 s .co m logger.debug("depth search. callerDepth : {}, calleeDepth : {}", linkSelectContext.getCallerDepth(), linkSelectContext.getCalleeDepth()); return resultMap; }
From source file:com.palantir.lock.client.LockRefreshingLockService.java
private LockRefreshingLockService(LockService delegate) { this.delegate = delegate; toRefresh = Sets.newConcurrentHashSet(); exec = PTExecutors.newScheduledThreadPool(1, PTExecutors.newNamedThreadFactory(true)); }
From source file:org.gradle.tooling.composite.internal.CompositeModelBuilder.java
@Override public void get(ResultHandler<? super Set<T>> handler) throws IllegalStateException { final Set<T> results = Sets.newConcurrentHashSet(); final AtomicReference<Throwable> firstFailure = new AtomicReference<Throwable>(); final ResultHandlerVersion1<Set<T>> adaptedHandler = new HierarchialResultAdapter( new ResultHandlerAdapter(handler)); final CyclicBarrier barrier = new CyclicBarrier(participants.size(), new Runnable() { @Override//from w ww .j a v a 2 s. co m public void run() { if (firstFailure.get() == null) { adaptedHandler.onComplete(results); } else { adaptedHandler.onFailure(firstFailure.get()); } } }); for (GradleParticipantBuild participant : participants) { participant.getConnection().getModel(modelType, new ResultHandler<T>() { @Override public void onComplete(T result) { results.add(result); waitForFinish(); } private void waitForFinish() { try { barrier.await(); } catch (InterruptedException e) { e.printStackTrace(); } catch (BrokenBarrierException e) { e.printStackTrace(); } } @Override public void onFailure(GradleConnectionException failure) { firstFailure.compareAndSet(null, failure); waitForFinish(); } }); } }
From source file:org.onosproject.provider.nil.NullFlowRuleProvider.java
@Override public void executeBatch(FlowRuleBatchOperation batch) { // TODO: consider checking mastership Set<FlowEntry> entries = flowTable.getOrDefault(batch.deviceId(), Sets.newConcurrentHashSet()); for (FlowRuleBatchEntry fbe : batch.getOperations()) { switch (fbe.operator()) { case ADD: entries.add(new DefaultFlowEntry(fbe.target())); break; case REMOVE: entries.remove(new DefaultFlowEntry(fbe.target())); break; case MODIFY: FlowEntry entry = new DefaultFlowEntry(fbe.target()); entries.remove(entry);/* ww w. ja v a 2 s . co m*/ entries.add(entry); break; default: log.error("Unknown flow operation: {}", fbe); } } flowTable.put(batch.deviceId(), entries); CompletedBatchOperation op = new CompletedBatchOperation(true, Collections.emptySet(), batch.deviceId()); providerService.batchOperationCompleted(batch.id(), op); }