List of usage examples for com.google.common.collect Maps newConcurrentMap
public static <K, V> ConcurrentMap<K, V> newConcurrentMap()
From source file:com.viadeo.kasper.common.exposition.query.DefaultQueryFactory.java
public DefaultQueryFactory(final FeatureConfiguration features, final Map<Type, TypeAdapter> adapters, final Map<Type, BeanAdapter> beanAdapters, final List<? extends TypeAdapterFactory> factories, final VisibilityFilter visibilityFilter) { this.features = checkNotNull(features); this.visibilityFilter = checkNotNull(visibilityFilter); this.factories = Lists.newArrayList(checkNotNull(factories)); this.beanAdapters = Maps.newHashMap(checkNotNull(beanAdapters)); this.adapters = Maps.newConcurrentMap(); this.adapters.putAll(checkNotNull(adapters)); }
From source file:com.datatorrent.lib.bucket.AbstractBucketManager.java
public AbstractBucketManager() { eventQueue = new LinkedBlockingQueue<Long>(); evictionCandidates = Sets.newHashSet(); dirtyBuckets = Maps.newConcurrentMap(); bucketHeap = MinMaxPriorityQueue.orderedBy(new Comparator<AbstractBucket<T>>() { @Override//w w w .j a v a 2 s . c o m public int compare(AbstractBucket<T> bucket1, AbstractBucket<T> bucket2) { if (bucket1.lastUpdateTime() < bucket2.lastUpdateTime()) { return -1; } if (bucket1.lastUpdateTime() > bucket2.lastUpdateTime()) { return 1; } return 0; } }).create(); lock = new Lock(); committedWindow = -1; noOfBuckets = DEF_NUM_BUCKETS; noOfBucketsInMemory = DEF_NUM_BUCKETS_MEM; maxNoOfBucketsInMemory = DEF_NUM_BUCKETS_MEM + 100; millisPreventingBucketEviction = DEF_MILLIS_PREVENTING_EVICTION; writeEventKeysOnly = true; bucketsToDelete = Sets.newHashSet(); }
From source file:org.haiku.haikudepotserver.naturallanguage.NaturalLanguageServiceImpl.java
private Map<String, Boolean> assembleNaturalLanguageCodeUseMap(Query codeQuery) { ObjectContext context = serverRuntime.newContext(); Map<String, Boolean> result = Maps.newConcurrentMap(); List<String> usedCodes = context.performQuery(codeQuery); for (String naturalLanguageCode : NaturalLanguage.getAllCodes(context)) { result.put(naturalLanguageCode, usedCodes.contains(naturalLanguageCode)); }/*w w w. jav a 2 s. c o m*/ return result; }
From source file:edu.berkeley.sparrow.daemon.scheduler.Scheduler.java
public void initialize(Configuration conf, InetSocketAddress socket) throws IOException { address = Network.socketAddressToThrift(socket); String mode = conf.getString(SparrowConf.DEPLYOMENT_MODE, "unspecified"); this.conf = conf; if (mode.equals("standalone")) { state = new StandaloneSchedulerState(); } else if (mode.equals("configbased")) { state = new ConfigSchedulerState(); } else {//w w w .ja va2 s . c om throw new RuntimeException("Unsupported deployment mode: " + mode); } state.initialize(conf); defaultProbeRatioUnconstrained = conf.getDouble(SparrowConf.SAMPLE_RATIO, SparrowConf.DEFAULT_SAMPLE_RATIO); defaultProbeRatioConstrained = conf.getDouble(SparrowConf.SAMPLE_RATIO_CONSTRAINED, SparrowConf.DEFAULT_SAMPLE_RATIO_CONSTRAINED); requestTaskPlacers = Maps.newConcurrentMap(); useCancellation = conf.getBoolean(SparrowConf.CANCELLATION, SparrowConf.DEFAULT_CANCELLATION); if (useCancellation) { LOG.debug("Initializing cancellation service"); cancellationService = new CancellationService(nodeMonitorClientPool); new Thread(cancellationService).start(); } else { LOG.debug("Not using cancellation"); } spreadEvenlyTaskSetSize = conf.getInt(SparrowConf.SPREAD_EVENLY_TASK_SET_SIZE, SparrowConf.DEFAULT_SPREAD_EVENLY_TASK_SET_SIZE); }
From source file:org.apache.drill.exec.cache.infinispan.ICache.java
@Override public void run() throws DrillbitStartupException { try {/*from ww w . ja v a 2s. c o m*/ if (local) { localCounters = Maps.newConcurrentMap(); manager.start(); } else { cacheChannel.connect("c1"); } } catch (Exception e) { throw new DrillbitStartupException("Failure while trying to set up JGroups."); } }
From source file:org.apache.tez.runtime.InputReadyTracker.java
public void setGroupedInputs(Collection<MergedLogicalInput> inputGroups) { lock.lock();/*from w w w. jav a 2 s . c om*/ try { if (inputGroups != null) { inputToGroupMap = Maps.newConcurrentMap(); for (MergedLogicalInput mergedInput : inputGroups) { for (Input dest : mergedInput.getInputs()) { // Check already ready Inputs - may have become ready during initialize if (readyInputs.containsKey(dest)) { mergedInput.setConstituentInputIsReady(dest); } List<MergedLogicalInput> mergedList = inputToGroupMap.get(dest); if (mergedList == null) { mergedList = Lists.newArrayList(); inputToGroupMap.put(dest, mergedList); } mergedList.add(mergedInput); } } } } finally { lock.unlock(); } }
From source file:co.cask.cdap.internal.app.services.ServiceHttpServer.java
public ServiceHttpServer(String host, Program program, ServiceSpecification spec, RunId runId, Arguments runtimeArgs, int instanceId, int instanceCount, ServiceAnnouncer serviceAnnouncer, MetricsCollectionService metricsCollectionService, DatasetFramework datasetFramework, DataFabricFacadeFactory dataFabricFacadeFactory, TransactionSystemClient txClient, DiscoveryServiceClient discoveryServiceClient) { this.host = host; this.program = program; this.spec = spec; this.runId = runId; this.runtimeArgs = runtimeArgs; this.instanceId = instanceId; this.instanceCount = new AtomicInteger(instanceCount); this.serviceAnnouncer = serviceAnnouncer; this.metricsCollectionService = metricsCollectionService; this.datasetFramework = datasetFramework; this.dataFabricFacadeFactory = dataFabricFacadeFactory; this.txClient = txClient; this.discoveryServiceClient = discoveryServiceClient; this.contextFactory = createHttpServiceContextFactory(); this.handlerReferences = Maps.newConcurrentMap(); this.handlerReferenceQueue = new ReferenceQueue<>(); constructNettyHttpService(runId, metricsCollectionService); }
From source file:org.glowroot.plugin.servlet.ServletMessageSupplier.java
void putSessionAttributeChangedValue(String name, @Nullable String value) { if (sessionAttributeUpdatedValueMap == null) { sessionAttributeUpdatedValueMap = Maps.newConcurrentMap(); }/*from w w w. ja v a 2s.c om*/ sessionAttributeUpdatedValueMap.put(name, Optional.fromNullable(value)); }
From source file:org.apache.zeppelin.interpreter.InterpreterSettingManager.java
public InterpreterSettingManager(ZeppelinConfiguration zeppelinConfiguration, DependencyResolver dependencyResolver, InterpreterOption interpreterOption) throws IOException, RepositoryException { this.zeppelinConfiguration = zeppelinConfiguration; this.interpreterDirPath = Paths.get(zeppelinConfiguration.getInterpreterDir()); logger.debug("InterpreterRootPath: {}", interpreterDirPath); this.interpreterBindingPath = Paths.get(zeppelinConfiguration.getInterpreterSettingPath()); logger.debug("InterpreterBindingPath: {}", interpreterBindingPath); this.interpreterSettingsRef = Maps.newConcurrentMap(); this.interpreterSettings = Maps.newConcurrentMap(); this.interpreterBindings = Maps.newConcurrentMap(); this.dependencyResolver = dependencyResolver; this.interpreterRepositories = dependencyResolver.getRepos(); this.defaultOption = interpreterOption; this.cleanCl = Collections.synchronizedMap(new HashMap<String, URLClassLoader>()); String replsConf = zeppelinConfiguration.getString(ConfVars.ZEPPELIN_INTERPRETERS); this.interpreterClassList = replsConf.split(","); String groupOrder = zeppelinConfiguration.getString(ConfVars.ZEPPELIN_INTERPRETER_GROUP_ORDER); this.interpreterGroupOrderList = groupOrder.split(","); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setPrettyPrinting();/*from w w w. ja v a 2 s.co m*/ this.gson = gsonBuilder.create(); init(); }
From source file:org.eclipse.emf.compare.ui2.viewers.EMFCompareEditor.java
@Override public void doSave(IProgressMonitor monitor) { fireDirtyPropertyChange(false);// w w w. j av a 2s . c o m if (fIsRightDirty) { if (((EMFCompareInput) getEditorInput()).getRight() instanceof Resource) { Resource rightResource = (Resource) ((EMFCompareInput) getEditorInput()).getRight(); try { rightResource.save(Maps.newConcurrentMap()); } catch (IOException e) { e.printStackTrace(); } } } }