@Override public ServerName randomAssignment(RegionInfo region, List<ServerName> servers) throws HBaseIOException { ListMultimap<String,RegionInfo> regionMap = LinkedListMultimap.create(); ListMultimap<String,ServerName> serverMap = LinkedListMultimap.create(); generateGroupMaps(Lists.newArrayList(region), servers, regionMap, serverMap); List<ServerName> filteredServers = serverMap.get(regionMap.keySet().iterator().next()); return this.internalBalancer.randomAssignment(region, filteredServers); }
/** * {@inheritDoc} * * <p>The returned list is immutable and implements * {@link java.util.RandomAccess}. */ @CanIgnoreReturnValue @Override public List<V> removeAll(@Nullable Object key) { List<V> oldValues = getCopy(key); removeAllNodes(key); return oldValues; }
/** * @serialData the number of distinct keys, and then for each distinct key: * the first key, the number of values for that key, and the key's values, * followed by successive keys and values from the entries() ordering */ @GwtIncompatible // java.io.ObjectOutputStream private void writeObject(ObjectOutputStream stream) throws IOException { stream.defaultWriteObject(); stream.writeInt(size()); for (Entry<K, V> entry : entries()) { stream.writeObject(entry.getKey()); stream.writeObject(entry.getValue()); } }
/** * Constructs a {@code LinkedListMultimap} with the same mappings as the * specified {@code Multimap}. The new multimap has the same * {@link Multimap#entries()} iteration order as the input multimap. * * @param multimap the multimap whose contents are copied to this multimap */ public static <K, V> LinkedListMultimap<K, V> create( Multimap<? extends K, ? extends V> multimap) { return new LinkedListMultimap<K, V>(multimap); }
@Override public boolean containsValue(@Nullable Object value) { return values().contains(value); }
private LinkedListMultimap(Multimap<? extends K, ? extends V> multimap) { this(multimap.keySet().size()); putAll(multimap); }
/** * Stores a key-value pair in the multimap. * * @param key key to store in the multimap * @param value value to store in the multimap * @return {@code true} always */ @CanIgnoreReturnValue @Override public boolean put(@Nullable K key, @Nullable V value) { addNode(key, value, null); return true; }
@GwtIncompatible // java.io.ObjectInputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); keyToKeyList = Maps.newLinkedHashMap(); int size = stream.readInt(); for (int i = 0; i < size; i++) { @SuppressWarnings("unchecked") // reading data stored by writeObject K key = (K) stream.readObject(); @SuppressWarnings("unchecked") // reading data stored by writeObject V value = (V) stream.readObject(); put(key, value); } }
@Override public List<V> replaceValues(@Nullable K key, Iterable<? extends V> values) { List<V> oldValues = getCopy(key); ListIterator<V> keyValues = new ValueForKeyIterator(key); Iterator<? extends V> newValues = values.iterator();
/** * Creates a new, empty {@code LinkedListMultimap} with the default initial * capacity. */ public static <K, V> LinkedListMultimap<K, V> create() { return new LinkedListMultimap<K, V>(); }
@Override public ServerName randomAssignment(RegionInfo region, List<ServerName> servers) throws HBaseIOException { ListMultimap<String,RegionInfo> regionMap = LinkedListMultimap.create(); ListMultimap<String,ServerName> serverMap = LinkedListMultimap.create(); generateGroupMaps(Lists.newArrayList(region), servers, regionMap, serverMap); List<ServerName> filteredServers = serverMap.get(regionMap.keySet().iterator().next()); return this.internalBalancer.randomAssignment(region, filteredServers); }
/** * Constructs an empty {@code LinkedListMultimap} with enough capacity to hold * the specified number of keys without rehashing. * * @param expectedKeys the expected number of distinct keys * @throws IllegalArgumentException if {@code expectedKeys} is negative */ public static <K, V> LinkedListMultimap<K, V> create(int expectedKeys) { return new LinkedListMultimap<K, V>(expectedKeys); }
@Override public ServerName randomAssignment(RegionInfo region, List<ServerName> servers) throws HBaseIOException { ListMultimap<String,RegionInfo> regionMap = LinkedListMultimap.create(); ListMultimap<String,ServerName> serverMap = LinkedListMultimap.create(); generateGroupMaps(Lists.newArrayList(region), servers, regionMap, serverMap); List<ServerName> filteredServers = serverMap.get(regionMap.keySet().iterator().next()); return this.internalBalancer.randomAssignment(region, filteredServers); }