List of usage examples for com.google.common.collect Maps newConcurrentMap
public static <K, V> ConcurrentMap<K, V> newConcurrentMap()
From source file:org.asoem.greyfish.core.environment.Generic2DEnvironment.java
protected Generic2DEnvironment(final Generic2DEnvironmentBuilder<?, ?, S, A, Z, P> builder) { this.parallelizationThreshold = builder.parallelizationThreshold; this.space = new AgentSpace<>(checkNotNull(builder.space)); this.addAgentMessages = checkNotNull( Collections.synchronizedList(Lists.<NewAgentEvent<P, A>>newArrayList())); this.removeAgentMessages = checkNotNull( Collections.synchronizedList(Lists.<RemoveAgentMessage<A>>newArrayList())); this.deliverAgentMessageMessages = checkNotNull( Collections.synchronizedList(Lists.<DeliverAgentMessageMessage<A>>newArrayList())); this.snapshotValues = Maps.newConcurrentMap(); this.executorService = builder.executionService; this.eventBus = builder.eventPublisher; }
From source file:org.ow2.proactive.resourcemanager.nodesource.infrastructure.AWSEC2Infrastructure.java
/** * Default constructor */ public AWSEC2Infrastructure() { nodesPerInstances = Maps.newConcurrentMap(); }
From source file:edu.umn.msi.tropix.proteomics.itraqquantitation.impl.ITraqMatcherImpl.java
public List<ITraqMatch> match(final Iterable<ReportEntry> reportEntries, final Function<ScanIndex, ITraqScanSummary> scanSummaries, final ITraqMatchBuilderOptions options) { final List<ITraqMatch> iTraqMatchs = Lists.newLinkedList(); // For each ScaffoldEntry find the matching Scan and if each of the iTraq intensities // is high enough add it to the result (dataEntries). int misMatches = 0; if (options.getThreads() == 1) { for (final ReportEntry reportEntry : reportEntries) { ITraqMatch match = match(reportEntry, scanSummaries, options); if (match != null) { iTraqMatchs.add(match);/*from w ww. j av a2 s .c om*/ } else { misMatches++; } } } else { final ConcurrentMap<ReportEntry, ITraqMatch> matchMap = Maps.newConcurrentMap(); final Closure<ReportEntry> matchClosure = new Closure<ReportEntry>() { public void apply(ReportEntry reportEntry) { ITraqMatch match = match(reportEntry, scanSummaries, options); if (match != null) { matchMap.put(reportEntry, match); } } }; if (!Concurrent.processInNThreads(options.getThreads(), matchClosure, reportEntries)) { throw new RuntimeException("Failed to build itraq matches"); } for (final ReportEntry reportEntry : reportEntries) { ITraqMatch match = matchMap.get(reportEntry); if (match != null) { iTraqMatchs.add(match); } else { misMatches++; } } } System.out.println( "Returning " + iTraqMatchs.size() + " matches, failed to match: " + misMatches + " entries."); return iTraqMatchs; }
From source file:com.android.build.gradle.shrinker.JavaSerializationShrinkerGraph.java
private JavaSerializationShrinkerGraph(File stateDir) { mStateDir = checkNotNull(stateDir);/* w ww . j a va2 s. c o m*/ mShrinkCounters = new Counters(Maps.<String, DependencyType>newConcurrentMap(), ImmutableMap.<String, Counter>of()); mMultidexCounters = new Counters(Maps.<String, DependencyType>newConcurrentMap(), ImmutableMap.<String, Counter>of()); mMembers = Multimaps.synchronizedSetMultimap(HashMultimap.<String, String>create()); mAnnotations = Multimaps.synchronizedSetMultimap(HashMultimap.<String, String>create()); mClasses = Maps.newConcurrentMap(); mModifiers = Maps.newConcurrentMap(); mDependencies = Multimaps.synchronizedSetMultimap(HashMultimap.<String, Dependency<String>>create()); }
From source file:org.terasology.world.chunks.store.ChunkStoreGZip.java
public void setup() { modifiedChunks = Maps.newConcurrentMap(); compressionQueue = Queues.newLinkedBlockingDeque(); setupThreads(); }
From source file:com.infinities.skyport.distributed.impl.local.LocalCache.java
@Override public void destroy() { this.e = new IllegalStateException("cache not initialized yet"); this.map = Maps.newConcurrentMap(); }
From source file:org.onosproject.segmentrouting.mcast.McastUtils.java
/** * Builds a new McastUtils object.//from w ww . j a v a 2 s. co m * * @param srManager the SR manager * @param coreAppId the core application id * @param log log reference of the McastHandler */ McastUtils(SegmentRoutingManager srManager, ApplicationId coreAppId, Logger log) { this.srManager = srManager; this.coreAppId = coreAppId; this.log = log; this.mcastLeaderCache = Maps.newConcurrentMap(); }
From source file:org.apache.bookkeeper.clients.impl.internal.StorageServerClientManagerImpl.java
public StorageServerClientManagerImpl(StorageClientSettings settings, Resource<OrderedScheduler> schedulerResource, Function<Endpoint, StorageServerChannel> channelFactory) { this.schedulerResource = schedulerResource; this.scheduler = SharedResourceManager.shared().get(schedulerResource); this.locationClient = new LocationClientImpl(settings, scheduler); this.channelManager = new StorageServerChannelManager(channelFactory); this.scChannelManager = new StorageContainerChannelManager(this.channelManager, this.locationClient, scheduler);/*from w w w . j a v a 2s . c o m*/ this.rootRangeClient = new RootRangeClientImplWithRetries( new RootRangeClientImpl(scheduler, scChannelManager), settings.backoffPolicy(), scheduler); this.streamMetadataCache = new StreamMetadataCache(rootRangeClient); this.metaRangeClients = Maps.newConcurrentMap(); }
From source file:org.ow2.proactive.resourcemanager.nodesource.infrastructure.VMWareInfrastructure.java
/** * Default constructor */ public VMWareInfrastructure() { nodesPerInstances = Maps.newConcurrentMap(); }
From source file:com.cloudera.livy.client.local.LocalClient.java
LocalClient(LocalClientFactory factory, LocalConf conf) throws IOException, SparkException { this.factory = factory; this.conf = conf; this.childIdGenerator = new AtomicInteger(); this.jobs = Maps.newConcurrentMap(); clientId = UUID.randomUUID().toString(); String secret = factory.getServer().createSecret(); this.driverThread = startDriver(factory.getServer(), clientId, secret); this.protocol = new ClientProtocol(); try {/* ww w .j a va 2s . com*/ // The RPC server will take care of timeouts here. this.driverRpc = factory.getServer().registerClient(clientId, secret, protocol).get(); } catch (Throwable e) { LOG.warn("Error while waiting for client to connect.", e); driverThread.interrupt(); try { driverThread.join(); } catch (InterruptedException ie) { // Give up. LOG.debug("Interrupted before driver thread was finished."); } throw Throwables.propagate(e); } driverRpc.addListener(new Rpc.Listener() { @Override public void rpcClosed(Rpc rpc) { if (isAlive) { LOG.warn("Client RPC channel closed unexpectedly."); isAlive = false; } } }); isAlive = true; }