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


Java Multimaps.synchronizedMultimap方法代码示例

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


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

示例1: sendMessage

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public void sendMessage(String userEmail, String message) {

        Multimap<String, WebSocketSession> syncMap = Multimaps.synchronizedMultimap(userPagesMap);
        Collection<WebSocketSession> mis = syncMap.get(userEmail);
        synchronized (syncMap) {
            if (mis != null) {
                Iterator<WebSocketSession> it = mis.iterator();
                while (it.hasNext()) {
                    WebSocketSession session = it.next();
                    try {
                        session.sendMessage(new TextMessage(message));
                    } catch (Exception e) {
                        logger.info("The WebSocket connection has been closed: " + session.toString());
                    }

                }
            }
        }

    }
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:21,代码来源:WebsocketHandler.java

示例2: broadcastOne

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Override
public void broadcastOne(String user, String message) {
    Multimap<String, MessageInbound> syncMap = Multimaps.synchronizedMultimap(userPagesMap);
    Collection<MessageInbound> mis = syncMap.get(user);
    synchronized (syncMap) {
        if (mis != null) {
            Iterator<MessageInbound> it = mis.iterator();
            while (it.hasNext()) {
                MessageInbound inbound = it.next();
                try {
                    sendToPage(inbound, message);
                } catch (IOException e) {
                    // userPagesMap.remove(user, inbound);
                    logger.info("The WebSocket connection has been closed: " + inbound.toString());
                }

            }
        }
    }
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:21,代码来源:WebSocketServiceImpl.java

示例3: lazyInitCacheIfNeeded

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
private void lazyInitCacheIfNeeded() {
    if (!initialized) {
        synchronized (this) {
            if (!initialized) {
                if (watchersCache == null) {
                    watchersCache = HashMultimap.create();
                    watchersCache = Multimaps.synchronizedMultimap(watchersCache);
                }

                try {
                    //TODO: [by YS] consider using single query to get watch + repo path
                    List<Watch> nodeWatches = watchesDao.getWatches();
                    for (Watch nodeWatch : nodeWatches) {
                        RepoPath repoPath = fileService.loadItem(nodeWatch.getNodeId()).getRepoPath();
                        watchersCache.put(repoPath, nodeWatch);
                    }
                    initialized = true;
                } catch (SQLException e) {
                    throw new StorageException("Failed to load watches", e);
                }
            }
        }
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:25,代码来源:WatchesServiceImpl.java

示例4: train

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public TrainingResults train(String name, int numberOfTrees, List<LabeledItem<Integer>> trainingData, List<String> attributes, int defaultLabel) {
    int featuresToUse = (int) Math.sqrt(attributes.size());

    Multimap<LabeledItem<Integer>, Tree<Integer>> treesForItem = Multimaps.synchronizedMultimap(ArrayListMultimap.create());
    Matrix itemProximities = new Basic2DMatrix(trainingData.size(), trainingData.size());
    IdentityHashMap<Tree<Integer>, Set<LabeledItem<Integer>>> outOfBagItemsByTree = new IdentityHashMap<>();
    Collection<Tree<Integer>> trees = Functional.timesParallel(numberOfTrees, () -> {
        List<LabeledItem<Integer>> bootstrappedData = pickTrainingData(trainingData);
        Set<LabeledItem<Integer>> outOfBagItems = Sets.difference(new HashSet<>(trainingData), new HashSet<>(bootstrappedData));
        Tree<Integer> tree = decisionTreeTrainer.train(name, bootstrappedData, attributes, featuresToUse, defaultLabel);
        outOfBagItems.forEach(item -> treesForItem.put(item, tree));
        outOfBagItemsByTree.put(tree, outOfBagItems);
        System.out.print(".");
        return tree;
    });

    System.out.println("\n calculating proximities...");
    calculateProximities(trainingData, itemProximities, trees);

    return new TrainingResults(new RandomForest(trees, defaultLabel), treesForItem, itemProximities, trainingData, outOfBagItemsByTree);
}
 
开发者ID:flightstats,项目名称:learning,代码行数:22,代码来源:RandomForestTrainer.java

示例5: DynamicPartitionObserver

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Instantiates a new Dynamic partition observer.
 */
public DynamicPartitionObserver() {
  mapping = Collections.synchronizedMap(new HashMap<>());
  mappingReverse = Multimaps.synchronizedMultimap(ArrayListMultimap.create());
  filters = Collections.synchronizedSet(new LinkedHashSet<>());
  listeners = Collections.synchronizedSet(new HashSet<>());
  listenerExecutor = Executors.newSingleThreadExecutor();
}
 
开发者ID:aguther,项目名称:dds-examples,代码行数:11,代码来源:DynamicPartitionObserver.java

示例6:

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/********************** constructors **********************************/

	DatarouterNodes(){
		this.topLevelNodes = new ConcurrentSkipListSet<>();
		this.nodeByName = new ConcurrentSkipListMap<>();
		this.topLevelNodesByRouterName = Multimaps.synchronizedMultimap(TreeMultimap.create());
		this.routerNameByNode = new ConcurrentSkipListMap<>();
		this.clientIdsByRouterName = new ConcurrentSkipListMap<>();
		this.physicalNodeByTableNameByClientName = new ConcurrentSkipListMap<>();
	}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:11,代码来源:DatarouterNodes.java

示例7: PackageInventory

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * No argument constructor.
 */
PackageInventory(){
	packagesByIdMap = new ConcurrentHashMap<PID, MovingCodePackage>();
	
	// multimap for packageName -> packageId LUT
	Multimap<String, MovingCodePackage> delegate1 = ArrayListMultimap.create();
	packagesByNameMap = Multimaps.synchronizedMultimap(delegate1);
	
	// multimap for functionId -> packageId LUT
	Multimap<String, MovingCodePackage> delegate2 = ArrayListMultimap.create();
	packagesByFunctionIdMap = Multimaps.synchronizedMultimap(delegate2);
}
 
开发者ID:52North,项目名称:movingcode,代码行数:15,代码来源:PackageInventory.java

示例8: TopologyImpl

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
/**
 * Create an empty Topology.
 */
public TopologyImpl() {
    mastership = new HashMap<>();
    // TODO: Does these object need to be stored in Concurrent Collection?
    switches = new ConcurrentHashMap<>();
    ports = new ConcurrentHashMap<>();
    hosts = Multimaps.synchronizedMultimap(
            HashMultimap.<SwitchPort, HostData>create());
    mac2Host = new ConcurrentHashMap<>();
    outgoingLinks = new ConcurrentHashMap<>();
    incomingLinks = new ConcurrentHashMap<>();
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:15,代码来源:TopologyImpl.java

示例9: ConfigurationManager

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
@Inject
public ConfigurationManager(ServiceProperties props) {
    this.serviceProps = props;
    this.callbackListeners = Multimaps.synchronizedMultimap(ArrayListMultimap.create());
    this.lastProperties = new HashMap<>(props.getAllProperties());
}
 
开发者ID:Sixt,项目名称:ja-micro,代码行数:7,代码来源:ConfigurationManager.java

示例10: ElectionRegistry

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public ElectionRegistry(ZKClient zkClient) {
  this.zkClient = zkClient;
  Multimap<String, LeaderElection> multimap = HashMultimap.create();
  this.registry = Multimaps.synchronizedMultimap(multimap);
}
 
开发者ID:apache,项目名称:twill,代码行数:6,代码来源:ElectionRegistry.java

示例11: WebSocketRegistryImpl

import com.google.common.collect.Multimaps; //导入方法依赖的package包/类
public WebSocketRegistryImpl()
{
    this.idToSession = Maps.newConcurrentMap();
    this.groupToId = Multimaps.synchronizedMultimap( HashMultimap.create() );
}
 
开发者ID:purplejs,项目名称:purplejs,代码行数:6,代码来源:WebSocketRegistryImpl.java


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