List of usage examples for com.google.common.collect Maps newConcurrentMap
public static <K, V> ConcurrentMap<K, V> newConcurrentMap()
From source file:org.apache.giraph.comm.messages.out_of_core.DiskBackedMessageStore.java
/** * Constructor/*from w ww .j a va2s.com*/ * * @param messageValueFactory Factory for creating message values * @param service Service worker * @param maxNumberOfMessagesInMemory Number of messages to keep in memory * @param partitionStoreFactory Factory for creating stores for a * partition */ public DiskBackedMessageStore(MessageValueFactory<M> messageValueFactory, CentralizedServiceWorker<I, V, E> service, int maxNumberOfMessagesInMemory, MessageStoreFactory<I, M, PartitionDiskBackedMessageStore<I, M>> partitionStoreFactory) { this.messageValueFactory = messageValueFactory; this.service = service; this.maxNumberOfMessagesInMemory = maxNumberOfMessagesInMemory; this.partitionStoreFactory = partitionStoreFactory; partitionMessageStores = Maps.newConcurrentMap(); }
From source file:io.joynr.dispatching.subscription.SubscriptionManagerImpl.java
@Inject public SubscriptionManagerImpl(@Named(JOYNR_SCHEDULER_CLEANUP) ScheduledExecutorService cleanupScheduler, Dispatcher dispatcher) {// w w w . ja va 2 s . c o m super(); this.cleanupScheduler = cleanupScheduler; this.dispatcher = dispatcher; this.subscriptionListenerDirectory = Maps.newConcurrentMap(); this.broadcastSubscriptionListenerDirectory = Maps.newConcurrentMap(); this.subscriptionStates = Maps.newConcurrentMap(); this.missedPublicationTimers = Maps.newConcurrentMap(); this.subscriptionEndFutures = Maps.newConcurrentMap(); this.subscriptionTypes = Maps.newConcurrentMap(); this.subscriptionBroadcastTypes = Maps.newConcurrentMap(); this.subscriptionFutureMap = Maps.newConcurrentMap(); }
From source file:uk.ac.cam.cl.dtg.segue.dao.content.ContentMapper.java
/** * Creates a new content mapper without type information. * //from w w w .ja va 2s.co m * Note: Type information must be provided by using the register type methods. * */ @Inject public ContentMapper() { jsonTypes = Maps.newConcurrentMap(); mapOfDOsToDTOs = Maps.newConcurrentMap(); }
From source file:com.netflix.astyanax.thrift.ThriftClusterImpl.java
public ThriftClusterImpl(AstyanaxConfiguration config, ConnectionPool<Cassandra.Client> connectionPool, KeyspaceTracerFactory tracerFactory) { this.config = config; this.connectionPool = connectionPool; this.tracerFactory = tracerFactory; this.keyspaces = Maps.newConcurrentMap(); }
From source file:com.intellij.lang.jsgraphql.endpoint.ide.project.JSGraphQLEndpointNamedTypeRegistry.java
private Map<String, JSGraphQLNamedType> computeNamedTypes() { return endpointTypesByName.computeIfAbsent(project, p -> { final Map<String, JSGraphQLNamedType> result = Maps.newConcurrentMap(); final PsiFile entryPsiFile = getEndpointEntryPsiFile(); if (entryPsiFile != null) { Collection<JSGraphQLEndpointNamedTypeDefinition> endpointNamedTypeDefinitions = JSGraphQLEndpointPsiUtil .getKnownDefinitions(entryPsiFile, JSGraphQLEndpointNamedTypeDefinition.class, true, null); for (JSGraphQLEndpointNamedTypeDefinition typeDefinition : endpointNamedTypeDefinitions) { if (typeDefinition.getNamedTypeDef() != null) { final String typeName = typeDefinition.getNamedTypeDef().getText(); final JSGraphQLNamedType namedType = new JSGraphQLNamedType(typeDefinition, typeDefinition.getNamedTypeDef()); final JSGraphQLEndpointFieldDefinitionSet fieldDefinitionSet = PsiTreeUtil .findChildOfType(typeDefinition, JSGraphQLEndpointFieldDefinitionSet.class); if (fieldDefinitionSet != null) { final JSGraphQLEndpointFieldDefinition[] fields = PsiTreeUtil .getChildrenOfType(fieldDefinitionSet, JSGraphQLEndpointFieldDefinition.class); if (fields != null) { for (JSGraphQLEndpointFieldDefinition field : fields) { final JSGraphQLEndpointCompositeType propertyValueType = field .getCompositeType(); if (propertyValueType != null) { String propertyValueTypeName = null; if (propertyValueType.getListType() != null) { final JSGraphQLEndpointNamedType listItemType = propertyValueType .getListType().getNamedType(); if (listItemType != null) { propertyValueTypeName = listItemType.getText(); } } else if (propertyValueType.getNamedType() != null) { propertyValueTypeName = propertyValueType.getNamedType().getText(); }/*from ww w . j av a 2 s.c om*/ if (propertyValueTypeName != null) { namedType.properties.put(field.getProperty().getText(), new JSGraphQLPropertyType(field.getProperty(), namedType, propertyValueTypeName)); } } } } } result.put(typeName, namedType); if (JSGraphQLElementType.QUERY_KIND.equals(typeName)) { // also use Query for anonymous queries that are selection sets result.put(JSGraphQLElementType.SELECTION_SET_KIND, namedType); } } } } return result; }); }
From source file:com.eharmony.matching.seeking.executor.mongodb.MongoQueryExecutor.java
public MongoQueryExecutor(DB db, WriteConcern writeConcern, MongoQueryTranslator queryTranslator, EntityResolver entityResolver, final int batchSize) { if (null == db) { throw new IllegalArgumentException("null database"); }/*www. j a v a 2s .c om*/ this.db = db; /* Keep reference rather than making defensive copy: write concern * can be (and is) subclassed. */ if (null == writeConcern) { throw new IllegalArgumentException("null write concern"); } this.writeConcern = writeConcern; if (null == queryTranslator) { throw new IllegalArgumentException("null query translator"); } this.queryTranslator = queryTranslator; if (null == entityResolver) { throw new IllegalArgumentException("null entity resolver"); } this.entityResolver = entityResolver; this.mapper = new Mapper(); this.collections = Maps.newConcurrentMap(); // TODO: fix the entity cache? this.cache = new NonFunctionalEntityCache(); this.batchSize = batchSize; }
From source file:org.onosproject.aaa.StateMachine.java
public static void initializeMaps() { sessionIdMap = Maps.newConcurrentMap(); identifierMap = Maps.newConcurrentMap(); }
From source file:com.google.code.jgntp.internal.io.NioTcpGntpClient.java
public NioTcpGntpClient(GntpApplicationInfo applicationInfo, SocketAddress growlAddress, Executor executor, GntpListener listener, GntpPassword password, boolean encrypted, long retryTime, TimeUnit retryTimeUnit, int notificationRetryCount) { super(applicationInfo, growlAddress, password, encrypted); Preconditions.checkNotNull(executor, "Executor must not be null"); if (retryTime > 0) { Preconditions.checkNotNull(retryTimeUnit, "Retry time unit must not be null"); }//from w w w .j a v a 2 s . c o m Preconditions.checkArgument(notificationRetryCount >= 0, "Notification retries must be equal or greater than zero"); this.retryTime = retryTime; this.retryTimeUnit = retryTimeUnit; this.notificationRetryCount = notificationRetryCount; if (retryTime > 0) { retryExecutorService = Executors.newSingleThreadScheduledExecutor(); } else { retryExecutorService = null; } bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(executor, executor)); bootstrap.setPipelineFactory(new GntpChannelPipelineFactory(new GntpChannelHandler(this, listener))); bootstrap.setOption("tcpNoDelay", true); bootstrap.setOption("remoteAddress", growlAddress); bootstrap.setOption("soTimeout", 60 * 1000); bootstrap.setOption("receiveBufferSizePredictor", new AdaptiveReceiveBufferSizePredictor()); channelGroup = new DefaultChannelGroup("jgntp"); notificationIdGenerator = new AtomicLong(); // no need to sync on this map because notificationIdGenerator guarantees ID uniqueness // and there is only one way for alterations to this map occur for any notification // see GntpChannelHandler for details notificationsSent = HashBiMap.create(); notificationRetries = Maps.newConcurrentMap(); }
From source file:com.palantir.atlasdb.keyvalue.impl.KeyValueServices.java
public static Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> getFirstBatchForRangesUsingGetRangeConcurrent( ExecutorService executor, final KeyValueService kv, final String tableName, Iterable<RangeRequest> rangeRequests, final long timestamp, int maxConcurrentRequests) { final Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> ret = Maps .newConcurrentMap();/* ww w. j a v a2 s . c o m*/ BlockingWorkerPool pool = new BlockingWorkerPool(executor, maxConcurrentRequests); try { for (final RangeRequest request : rangeRequests) { pool.submitTask(new Runnable() { @Override public void run() { getFirstBatchForRangeUsingGetRange(kv, tableName, request, timestamp, ret); } }); } pool.waitForSubmittedTasks(); return ret; } catch (InterruptedException e) { throw Throwables.rewrapAndThrowUncheckedException(e); } }
From source file:org.ow2.proactive.resourcemanager.nodesource.infrastructure.OpenstackInfrastructure.java
/** * Default constructor */ public OpenstackInfrastructure() { nodesPerInstances = Maps.newConcurrentMap(); }