当前位置: 首页>>代码示例>>Java>>正文


Java Maps.newConcurrentMap方法代码示例

本文整理汇总了Java中com.google.common.collect.Maps.newConcurrentMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newConcurrentMap方法的具体用法?Java Maps.newConcurrentMap怎么用?Java Maps.newConcurrentMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Maps的用法示例。


在下文中一共展示了Maps.newConcurrentMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerProperties

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public void registerProperties(Class<?> componentClass) {
    checkPermission(CONFIG_WRITE);

    String componentName = componentClass.getName();
    String resourceName = componentClass.getSimpleName() + RESOURCE_EXT;
    try (InputStream ris = componentClass.getResourceAsStream(resourceName)) {
        checkArgument(ris != null, "Property definitions not found at resource %s",
                      resourceName);

        // Read the definitions
        Set<ConfigProperty> defs = ConfigPropertyDefinitions.read(ris);

        // Produce a new map of the properties and register it.
        Map<String, ConfigProperty> map = Maps.newConcurrentMap();
        defs.forEach(p -> map.put(p.name(), p));

        properties.put(componentName, map);
        loadExistingValues(componentName);
    } catch (IOException e) {
        log.error("Unable to read property definitions from resource " + resourceName, e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:ComponentConfigManager.java

示例2: jsonNodeToHostRoutes

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Changes hostRoutes JsonNode to a collection of the hostRoutes.
 *
 * @param hostRoutes the hostRoutes json node
 * @return a collection of hostRoutes
 */
public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
    checkNotNull(hostRoutes, JSON_NOT_NULL);
    ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
            .newConcurrentMap();
    Integer i = 0;
    for (JsonNode node : hostRoutes) {
        IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
        IpPrefix destination = IpPrefix.valueOf(node.get("destination")
                .asText());
        HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
        hostRouteMaps.putIfAbsent(i, hostRoute);
        i++;
    }
    return Collections.unmodifiableCollection(hostRouteMaps.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:22,代码来源:SubnetWebResource.java

示例3: buildFields

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Build content field
 * 
 * @param ddmStructure
 * @param serviceContext
 * @return
 * @throws Exception
 */
public String buildFields(long groupId, DDMStructure ddmStructure, String[] locales) throws Exception {
	
	Map<String, Serializable> fieldsMap = Maps.newConcurrentMap();
	Set<String> fieldNames = ddmStructure.getFieldNames();

	for(String fieldName : fieldNames ) {
		fieldsMap.put(fieldName, "");
	}
	
	Fields fields = _ddmLocalUtil.toFields(
			ddmStructure.getStructureId(), 
			fieldsMap, 
			locales,
			LocaleUtil.getDefault());

	return _journalConverter.getContent(ddmStructure, fields);
}
 
开发者ID:yasuflatland-lf,项目名称:liferay-dummy-factory,代码行数:26,代码来源:JournalUtils.java

示例4: jsonNodeToAllowedAddressPair

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Returns a Object of the currently known infrastructure virtualPort.
 *
 * @param allowedAddressPairs the allowedAddressPairs json node
 * @return a collection of allowedAddressPair
 */
public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
    checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
    ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
            .newConcurrentMap();
    int i = 0;
    for (JsonNode node : allowedAddressPairs) {
        IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
        MacAddress mac = MacAddress.valueOf(node.get("mac_address")
                .asText());
        AllowedAddressPair allows = AllowedAddressPair
                .allowedAddressPair(ip, mac);
        allowMaps.put(i, allows);
        i++;
    }
    log.debug("The jsonNode of allowedAddressPairallow is {}"
            + allowedAddressPairs.toString());
    return Collections.unmodifiableCollection(allowMaps.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:25,代码来源:VirtualPortWebResource.java

示例5: FinalizerThread

import com.google.common.collect.Maps; //导入方法依赖的package包/类
public FinalizerThread(Map<ClassPath, CacheEntry> cacheEntries, Lock lock) {
    this.setName("Classloader cache reference queue poller");
    this.setDaemon(true);
    this.referenceQueue = new ReferenceQueue<CachedClassLoader>();
    this.cacheEntries = cacheEntries;
    this.cleanups = Maps.newConcurrentMap();
    this.lock = lock;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:FinalizerThread.java

示例6: lookupServiceUpdate

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private Map<String, List<GrpcURL>> lookupServiceUpdate(String group) {
  Long lastConsulIndexId =
      lookupGroupServices.get(group) == null ? 0L : lookupGroupServices.get(group);
  String serviceName = GrpcURLUtils.toServiceName(group);
  ConsulServiceResp consulResp = client.lookupHealthService(serviceName, lastConsulIndexId);
  if (consulResp != null) {
    List<ConsulService> consulServcies = consulResp.getSalukiConsulServices();
    boolean updated = consulServcies != null && !consulServcies.isEmpty()
        && consulResp.getConsulIndex() > lastConsulIndexId;
    if (updated) {
      Map<String, List<GrpcURL>> groupProviderUrls = Maps.newConcurrentMap();
      for (ConsulService service : consulServcies) {
        GrpcURL providerUrl = buildURL(service);
        String serviceKey = providerUrl.getServiceKey();
        List<GrpcURL> urlList = groupProviderUrls.get(serviceKey);
        if (urlList == null) {
          urlList = Lists.newArrayList();
          groupProviderUrls.put(serviceKey, urlList);
        }
        urlList.add(providerUrl);
      }
      lookupGroupServices.put(group, consulResp.getConsulIndex());
      return groupProviderUrls;
    }
  }
  return null;
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:28,代码来源:ConsulRegistry.java

示例7: testGet

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Test
public void testGet() {
    ExtendedSet<TestValue> set = new ExtendedSet<>(Maps.newConcurrentMap());
    TestValue e1 = new TestValue("foo", 1);
    set.add(e1);
    TestValue lookupValue = new TestValue("foo", 2);
    TestValue setEntry = set.get(lookupValue);
    assertEquals(e1, setEntry);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:ExtendedSetTest.java

示例8: jsonNodeToSecurityGroup

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Returns a collection of virtualPorts.
 *
 * @param securityGroups the virtualPort jsonnode
 * @return a collection of securityGroups
 */
public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {
    checkNotNull(securityGroups, JSON_NOT_NULL);
    ConcurrentMap<Integer, SecurityGroup> securMaps = Maps
            .newConcurrentMap();
    int i = 0;
    for (JsonNode node : securityGroups) {
        SecurityGroup securityGroup = SecurityGroup
                .securityGroup(node.asText());
        securMaps.put(i, securityGroup);
        i++;
    }
    return Collections.unmodifiableCollection(securMaps.values());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:VirtualPortWebResource.java

示例9: init

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void init() throws DrillbitStartupException {
  final DrillConfig config = context.getConfig();
  final Collection<Class<? extends StoragePlugin>> pluginClasses =
      PathScanner.scanForImplementations(
          StoragePlugin.class,
          config.getStringList(ExecConstants.STORAGE_ENGINE_SCAN_PACKAGES));
  final String lineBrokenList =
      pluginClasses.size() == 0
      ? "" : "\n\t- " + Joiner.on("\n\t- ").join(pluginClasses);
  logger.debug("Found {} storage plugin configuration classes: {}.",
               pluginClasses.size(), lineBrokenList);
  for (Class<? extends StoragePlugin> plugin : pluginClasses) {
    int i = 0;
    for (Constructor<?> c : plugin.getConstructors()) {
      Class<?>[] params = c.getParameterTypes();
      if(params.length != 3
          || params[1] != DrillbitContext.class
          || !StoragePluginConfig.class.isAssignableFrom(params[0])
          || params[2] != String.class) {
        logger.info("Skipping StoragePlugin constructor {} for plugin class {} since it doesn't implement a [constructor(StoragePluginConfig, DrillbitContext, String)]", c, plugin);
        continue;
      }
      availablePlugins.put(params[0], (Constructor<? extends StoragePlugin>) c);
      i++;
    }
    if (i == 0) {
      logger.debug("Skipping registration of StoragePlugin {} as it doesn't have a constructor with the parameters of (StorangePluginConfig, Config)", plugin.getCanonicalName());
    }
  }

  // create registered plugins defined in "storage-plugins.json"
  this.plugins = Maps.newConcurrentMap();
  this.plugins.putAll(createPlugins());

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:37,代码来源:StoragePluginRegistry.java

示例10: getCounters

import com.google.common.collect.Maps; //导入方法依赖的package包/类
@Override
public Map<String, Long> getCounters() {
    Map<String, Long> counters = Maps.newConcurrentMap();
    federatedPrimitiveCreator.getAsyncAtomicCounterNames()
           .forEach(name -> counters.put(name,
                   federatedPrimitiveCreator.newAsyncCounter(name).asAtomicCounter().get()));
    return counters;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:StorageManager.java

示例11: init

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private void init() {

        // Reset any previous state
        synchronized (this) {
            flowRuleGenerated = Boolean.FALSE;
            leafSwitches = Sets.newHashSet();
            spineSwitches = Sets.newHashSet();
            deviceFlowRules = Maps.newConcurrentMap();
            ruleFlags = Maps.newConcurrentMap();
            contextFlags = Maps.newConcurrentMap();
        }

        // Start flow rules generator...
        spawnTask(() -> generateFlowRules(topologyService.currentTopology(), Sets.newHashSet(hostService.getHosts())));
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:AbstractUpgradableFabricApp.java

示例12: ReactiveRoutingFib

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Class constructor.
 *
 * @param appId application ID to use to generate intents
 * @param hostService host service
 * @param interfaceService interface service
 * @param intentSynchronizer intent synchronization service
 */
public ReactiveRoutingFib(ApplicationId appId, HostService hostService,
                          InterfaceService interfaceService,
                          IntentSynchronizationService intentSynchronizer) {
    this.appId = appId;
    this.hostService = hostService;
    this.interfaceService = interfaceService;
    this.intentSynchronizer = intentSynchronizer;

    routeIntents = Maps.newConcurrentMap();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:ReactiveRoutingFib.java

示例13: initialize

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private void initialize() {
  maxIdScanned = 0;
  publicAppNamespaceCache = new CaseInsensitiveMapWrapper<>(Maps.newConcurrentMap());
  appNamespaceCache = new CaseInsensitiveMapWrapper<>(Maps.newConcurrentMap());
  appNamespaceIdCache = Maps.newConcurrentMap();
  scheduledExecutorService = Executors.newScheduledThreadPool(1, ApolloThreadFactory
      .create("AppNamespaceServiceWithCache", true));
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:9,代码来源:AppNamespaceServiceWithCache.java

示例14: testBehaviorOfIteratorsCycleConcurrentlyModifyingUnderlyingMap

import com.google.common.collect.Maps; //导入方法依赖的package包/类
/**
 * Just a sanity test of java behaviors.
 *  - Create a concurrent hashmap with 4 entries
 *  - Create a new thread that runs forever cycling over the keys
 *  - In main thread add/remove a bunch of keys
 *  - See that nothing bad happens
 */
@Test
public void testBehaviorOfIteratorsCycleConcurrentlyModifyingUnderlyingMap() throws ExecutionException, InterruptedException {
    final Map<String, String> myMap = Maps.newConcurrentMap();
    myMap.put("Key1", "Value1");
    myMap.put("Key2", "Value2");
    myMap.put("Key3", "Value3");
    myMap.put("Key4", "Value4");

    final Set<String> foundKeys = Sets.newConcurrentHashSet();

    // Create new Thread
    final CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
        Iterator<String> keyIterator = Iterators.cycle(myMap.keySet());
        while (keyIterator.hasNext()) {
            final String keyValue = keyIterator.next();
            if (!foundKeys.contains(keyValue)) {
                foundKeys.add(keyValue);
            }
        }
        return false;
    });

    // Wait for a few iterations in the other thread have completed.
    Thread.sleep(200L);

    // Add keys
    for (int x = 5; x < 100; x++) {
        myMap.put("Key" + x, "Value" + x);
    }

    // Sleep for a few
    await()
        .atMost(5, TimeUnit.SECONDS)
        .until(() -> {
            return foundKeys.size();
        }, equalTo(myMap.size()));


    // See that we found all of our keys
    assertEquals("Found all keys", myMap.size(), foundKeys.size());

    // Now remove some keys
    for (int x = 5; x < 100; x++) {
        myMap.remove("Key" + x);
    }

    // Make sure nothing bad happened
    assertFalse("No exceptions thrown", future.isCompletedExceptionally());
    future.cancel(true);
    try {
        future.get();
    } catch (CancellationException e) {
        // We expect an exception because we cancelled it. swallow.
    }
}
 
开发者ID:salesforce,项目名称:storm-dynamic-spout,代码行数:63,代码来源:RoundRobinBufferTest.java

示例15: Builder

import com.google.common.collect.Maps; //导入方法依赖的package包/类
private Builder(final ResultMap res) {
    this.res = res;
    this.map = Maps.newConcurrentMap();
}
 
开发者ID:Zigin,项目名称:MonitorPlatform,代码行数:5,代码来源:ResultMap.java


注:本文中的com.google.common.collect.Maps.newConcurrentMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。