當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。