List of usage examples for com.google.common.collect ArrayListMultimap create
public static <K, V> ArrayListMultimap<K, V> create()
From source file:org.apache.cassandra.service.BatchlogEndpointSelector.java
/** * @param endpoints nodes in the local datacenter, grouped by rack name * @return list of candidates for batchlog hosting. if possible these will be two nodes from different racks. *///from w w w.j a v a 2s .c o m public Collection<InetAddress> chooseEndpoints(Multimap<String, InetAddress> endpoints) { // strip out dead endpoints and localhost ListMultimap<String, InetAddress> validated = ArrayListMultimap.create(); for (Map.Entry<String, InetAddress> entry : endpoints.entries()) { if (isValid(entry.getValue())) validated.put(entry.getKey(), entry.getValue()); } if (validated.size() <= 2) return validated.values(); if ((validated.size() - validated.get(localRack).size()) >= 2) { // we have enough endpoints in other racks validated.removeAll(localRack); } if (validated.keySet().size() == 1) { // we have only 1 `other` rack Collection<InetAddress> otherRack = Iterables.getOnlyElement(validated.asMap().values()); return Lists.newArrayList(Iterables.limit(otherRack, 2)); } // randomize which racks we pick from if more than 2 remaining Collection<String> racks; if (validated.keySet().size() == 2) { racks = validated.keySet(); } else { racks = Lists.newArrayList(validated.keySet()); Collections.shuffle((List) racks); } // grab a random member of up to two racks List<InetAddress> result = new ArrayList<>(2); for (String rack : Iterables.limit(racks, 2)) { List<InetAddress> rackMembers = validated.get(rack); result.add(rackMembers.get(getRandomInt(rackMembers.size()))); } return result; }
From source file:com.kurtraschke.ctatt.gtfsrealtime.services.GtfsDaoService.java
public GtfsDaoService() { scheduledTripMapping = ArrayListMultimap.create(); }
From source file:org.eclipse.incquery.tooling.core.generator.fragments.ExtensionBasedGenerationFragmentProvider.java
protected void initializeFragments() { fragments = ArrayListMultimap.create(); final IConfigurationElement[] config = Platform.getExtensionRegistry() .getConfigurationElementsFor(EXTENSIONID); for (IConfigurationElement e : config) { final String annotationName = e.getAttribute("annotation") != null ? e.getAttribute("annotation") : GENERIC_ATTRIBUTE;/*from www. j a v a 2 s . c o m*/ try { IGenerationFragment fragment = (IGenerationFragment) e.createExecutableExtension("fragment"); fragments.put(annotationName, fragment); } catch (CoreException e1) { logger.warn("Cannot load generator fragment from " + e.getContributor().getName(), e1); } } }
From source file:com.streamsets.pipeline.lib.el.ELUtils.java
public static Multimap<String, Record> partitionBatchByExpression(ELEval elEvaluator, ELVars variables, String expression, Batch batch) { Multimap<String, Record> partitions = ArrayListMultimap.create(); Iterator<Record> batchIterator = batch.getRecords(); while (batchIterator.hasNext()) { Record record = batchIterator.next(); RecordEL.setRecordInContext(variables, record); try {//from ww w . ja v a2 s. c o m String partitionName = elEvaluator.eval(variables, expression, String.class); LOG.debug("Expression '{}' is evaluated to '{}' : ", expression, partitionName); partitions.put(partitionName, record); } catch (ELEvalException e) { LOG.error("Failed to evaluate expression '{}' : ", expression, e.toString(), e); } } return partitions; }
From source file:prm4j.indexing.model.ParametricPropertyModel.java
public ParametricPropertyModel(ParametricProperty pp) { super();//www . j ava 2s .c o m this.pp = pp; maxArgs = ArrayListMultimap.create(); joinArgs = ArrayListMultimap.create(); updateChainingArgs = HashMultimap.create(); monitorSetSpecs = HashMultimap.create(); initialize(); }
From source file:com.onboard.service.websocket.impl.WebSocketServiceImpl.java
@PostConstruct public void init() { userPagesMap = ArrayListMultimap.create(); }
From source file:com.griddynamics.jagger.engine.e1.sessioncomparation.ConfigurableSessionComparator.java
@Override @SuppressWarnings("unchecked") public SessionVerdict compare(String currentSession, String baselineSession) { log.info("Comparing of sessions requested"); log.info("Feature comparators chain {}", comparatorChain); Multimap<String, Verdict> details = ArrayListMultimap.create(); for (FeatureComparator featureComparator : comparatorChain) { String feature = featureComparator.getDescription(); log.debug("Going to compare feature {}", feature); List<Verdict> verdicts = featureComparator.compare(currentSession, baselineSession); log.debug("Verdicts for feature {} are {}", feature, verdicts); details.putAll(feature, verdicts); }/* w ww .j a v a2s . c o m*/ Decision decision = decisionMaker.makeDecision(details); log.info("Sessions compared. Decision {}", decision); return new SessionVerdict(decision, details); }
From source file:org.apache.mailet.PerRecipientHeaders.java
public PerRecipientHeaders() { headersByRecipient = ArrayListMultimap.create(); }
From source file:io.datakernel.datagraph.graph.DataGraph.java
private ListMultimap<Partition, Node> getNodesByPartition() { ListMultimap<Partition, Node> listMultimap = ArrayListMultimap.create(); for (Map.Entry<Node, Partition> entry : nodePartitions.entrySet()) { listMultimap.put(entry.getValue(), entry.getKey()); }/*from ww w .j a v a 2 s . c om*/ return listMultimap; }
From source file:org.sonar.batch.bootstrap.BatchExtensionInstaller.java
public void install(Module module) { ListMultimap<PluginMetadata, Object> installedExtensionsByPlugin = ArrayListMultimap.create(); for (Map.Entry<PluginMetadata, Plugin> entry : pluginRepository.getPluginsByMetadata().entrySet()) { PluginMetadata metadata = entry.getKey(); Plugin plugin = entry.getValue(); module.addExtension(metadata, plugin); for (Object extension : plugin.getExtensions()) { if (installExtension(module, metadata, extension)) { installedExtensionsByPlugin.put(metadata, extension); } else { module.declareExtension(metadata, extension); }//www . ja v a2 s . c o m } } for (Map.Entry<PluginMetadata, Object> entry : installedExtensionsByPlugin.entries()) { PluginMetadata plugin = entry.getKey(); Object extension = entry.getValue(); if (isExtensionProvider(extension)) { ExtensionProvider provider = (ExtensionProvider) module.getComponentByKey(extension); installProvider(module, plugin, provider); } } installMetrics(module); }