List of usage examples for com.google.common.collect Maps newConcurrentMap
public static <K, V> ConcurrentMap<K, V> newConcurrentMap()
From source file:com.google.gerrit.sshd.DispatchCommandProvider.java
@SuppressWarnings("unchecked") private ConcurrentMap<String, CommandProvider> createMap() { ConcurrentMap<String, CommandProvider> m = Maps.newConcurrentMap(); for (final Binding<?> b : allCommands()) { final Annotation annotation = b.getKey().getAnnotation(); if (annotation instanceof CommandName) { final CommandName n = (CommandName) annotation; if (!Commands.CMD_ROOT.equals(n) && Commands.isChild(parent, n)) { String descr = null; if (annotation instanceof Commands.NestedCommandNameImpl) { Commands.NestedCommandNameImpl impl = ((Commands.NestedCommandNameImpl) annotation); descr = impl.descr(); }//from w ww .j a va2 s. co m m.put(n.value(), new CommandProvider((Provider<Command>) b.getProvider(), descr)); } } } return m; }
From source file:com.continuuity.weave.internal.kafka.client.KafkaBrokerCache.java
KafkaBrokerCache(ZKClient zkClient) { this.zkClient = zkClient; this.brokers = Maps.newConcurrentMap(); this.topicBrokers = Maps.newConcurrentMap(); }
From source file:org.apache.gobblin.metrics.reporter.util.SchemaRegistryVersionWriter.java
public SchemaRegistryVersionWriter(KafkaAvroSchemaRegistry registry, Optional<String> overrideName, Optional<Schema> singleSchema) throws IOException { this.registry = registry; this.registrySchemaIds = Maps.newConcurrentMap(); this.overrideName = overrideName; this.schema = singleSchema; this.schemaIdLengthBytes = registry.getSchemaIdLengthByte(); if (this.schema.isPresent()) { try {//from ww w .j ava 2s. c o m this.schemaId = this.overrideName.isPresent() ? Optional.of(this.registry.register(this.schema.get(), this.overrideName.get())) : Optional.of(this.registry.register(this.schema.get())); } catch (SchemaRegistryException e) { throw Throwables.propagate(e); } } else { this.schemaId = Optional.absent(); } }
From source file:com.enonic.cms.core.structure.page.template.PageTemplateEntity.java
/** * Copy constructor. clones contained references for portlets, regions... * * @param source// w ww .ja v a 2s . c o m */ public PageTemplateEntity(final PageTemplateEntity source) { this.key = source.key; this.name = source.name; this.description = source.description; this.timestamp = source.timestamp == null ? null : new Date(source.timestamp.getTime()); this.xmlData = (LazyInitializedJDOMDocument) source.xmlData.clone(); this.styleKey = source.styleKey; this.site = source.site; this.cssKey = source.cssKey; this.type = source.type; this.runAs = source.runAs; final Map<Integer, PageTemplateRegionEntity> templateRegionTable = Maps.newConcurrentMap(); // clone page template regions for (PageTemplateRegionEntity region : source.pageTemplateRegions) { final PageTemplateRegionEntity regionClone = new PageTemplateRegionEntity(region); regionClone.setPageTemplate(this); this.pageTemplateRegions.add(regionClone); templateRegionTable.put(regionClone.getKey(), regionClone); } // clone page template portlets for (PageTemplatePortletEntity pageTemplatePortlet : source.pageTemplatePortlets) { final PageTemplatePortletEntity pageTemplatePortletClone = new PageTemplatePortletEntity( pageTemplatePortlet); pageTemplatePortletClone.setPageTemplate(this); // make reference pointing to region in cloned portlet, point to cloned region instance final PageTemplateRegionEntity pageTemplateRegionClone = templateRegionTable .get(pageTemplatePortlet.getPageTemplateRegion().getKey()); pageTemplatePortletClone.setPageTemplateRegion(pageTemplateRegionClone); this.pageTemplatePortlets.add(pageTemplatePortletClone); } // fix references to portlets in cloned regions for (PageTemplateRegionEntity region : this.pageTemplateRegions) { final Set<PageTemplatePortletEntity> clonedPortlets = Sets.newHashSet(); for (PageTemplatePortletEntity portlet : region.getPortlets()) { clonedPortlets.add(this.pageTemplatePortlets.get(this.pageTemplatePortlets.indexOf(portlet))); } region.setPortlets(clonedPortlets); } this.contentTypes = Sets.newHashSet(source.contentTypes); this.datasources = source.datasources == null ? null : new DataSourcesElement(source.datasources); }
From source file:co.cask.cdap.common.metrics.CMetrics.java
/** * Constructor specifying the type of metric as specified by * the {@link MetricType} and the group the metrics belong to. * * @param metricType collected//from w w w. ja v a 2 s .c o m * @param metricGroup the metrics being collected belong to. */ public CMetrics(MetricType metricType, String metricGroup) throws IllegalArgumentException { // if a metric type is user or system flow metric then metric // group has be valid. if (metricType == MetricType.FlowSystem || metricType == MetricType.FlowUser) { if (metricGroup == null || metricGroup.isEmpty()) { throw new IllegalArgumentException("Metric group cannot be empty or null " + "for a flow metric."); } } this.metricType = metricType; this.metricGroup = metricGroup; this.counters = Maps.newConcurrentMap(); this.gauges = Maps.newConcurrentMap(); this.meters = Maps.newConcurrentMap(); this.histograms = Maps.newConcurrentMap(); }
From source file:org.apache.tajo.worker.TaskExecutor.java
public TaskExecutor(TajoWorker.WorkerContext workerContext) { super(TaskExecutor.class.getName()); this.workerContext = workerContext; this.allocatedResourceMap = Maps.newConcurrentMap(); this.runningTasks = new AtomicInteger(); this.taskQueue = new LinkedBlockingQueue<>(); this.fetcherThreadPoolList = Lists.newArrayList(); }
From source file:org.onosproject.store.primitives.impl.PartitionedAsyncLeaderElector.java
@Override public CompletableFuture<Map<String, Leadership>> getLeaderships() { Map<String, Leadership> leaderships = Maps.newConcurrentMap(); return CompletableFuture.allOf( getLeaderElectors().stream().map(le -> le.getLeaderships().thenAccept(m -> leaderships.putAll(m))) .toArray(CompletableFuture[]::new)) .thenApply(v -> leaderships); }
From source file:org.sakaiproject.nakamura.resource.lite.servlet.post.operations.MoveOperation.java
public MoveOperation() { moveCleaners = Maps.newConcurrentMap(); }
From source file:com.viadeo.kasper.core.interceptor.InterceptorChainRegistry.java
public InterceptorChainRegistry(final List<InterceptorFactory<INPUT, OUTPUT>> interceptorFactories) { this.interceptorFactories = Lists.newArrayList(checkNotNull(interceptorFactories)); this.chains = Maps.newConcurrentMap(); }
From source file:org.ros.internal.message.StringFileProvider.java
public StringFileProvider(IOFileFilter ioFileFilter) { directories = Lists.newArrayList();/* w w w. j av a2 s.c o m*/ strings = Maps.newConcurrentMap(); IOFileFilter directoryFilter = FileFilterUtils.directoryFileFilter(); FileFilter fileFilter = FileFilterUtils.orFileFilter(directoryFilter, ioFileFilter); stringFileDirectoryWalker = new StringFileDirectoryWalker(fileFilter, -1); }