StoreFileReference(String regionName) { this.regionName = Objects.requireNonNull(regionName); familyToFiles = HashMultimap.create(); }
public void processFileArchivals(FileArchiveNotificationRequest request, Connection conn, Configuration conf, FileSystem fs) throws IOException { final HashMultimap<TableName,Entry<String,Long>> archivedFilesByTable = HashMultimap.create(); // Group the archived files by table for (FileWithSize fileWithSize : request.getArchivedFilesList()) { TableName tn = ProtobufUtil.toTableName(fileWithSize.getTableName()); archivedFilesByTable.put( tn, Maps.immutableEntry(fileWithSize.getName(), fileWithSize.getSize())); } if (LOG.isTraceEnabled()) { LOG.trace("Grouped archived files by table: " + archivedFilesByTable); } // Report each set of files to the appropriate object for (TableName tn : archivedFilesByTable.keySet()) { final Set<Entry<String,Long>> filesWithSize = archivedFilesByTable.get(tn); final FileArchiverNotifier notifier = FileArchiverNotifierFactoryImpl.getInstance().get( conn, conf, fs, tn); notifier.addArchivedFiles(filesWithSize); } } }
/** * Creates a new, empty {@code HashMultimap} with the default initial capacities. * * <p>This method will soon be deprecated in favor of {@code * MultimapBuilder.hashKeys().hashSetValues().build()}. */ public static <K, V> HashMultimap<K, V> create() { return new HashMultimap<K, V>(); }
private HashMultimap(Multimap<? extends K, ? extends V> multimap) { super(Maps.<K, Collection<V>>newHashMapWithExpectedSize(multimap.keySet().size())); putAll(multimap); }
@GwtIncompatible // java.io.ObjectInputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); expectedValuesPerKey = DEFAULT_VALUES_PER_KEY; int distinctKeys = Serialization.readCount(stream); Map<K, Collection<V>> map = Maps.newHashMap(); setMap(map); Serialization.populateMultimap(this, stream, distinctKeys); }
/** * Constructs a {@code HashMultimap} with the same mappings as the specified multimap. If a * key-value mapping appears multiple times in the input multimap, it only appears once in the * constructed multimap. * * <p>This method will soon be deprecated in favor of {@code * MultimapBuilder.hashKeys().hashSetValues().build(multimap)}. * * @param multimap the multimap whose contents are copied to this multimap */ public static <K, V> HashMultimap<K, V> create(Multimap<? extends K, ? extends V> multimap) { return new HashMultimap<K, V>(multimap); }
/** * Returns a view of all tables that reside in a namespace with a namespace * quota, grouped by the namespace itself. */ public Multimap<String,TableName> getTablesByNamespace() { Multimap<String,TableName> tablesByNS = HashMultimap.create(); for (TableName tn : tablesWithNamespaceQuotas) { tablesByNS.put(tn.getNamespaceAsString(), tn); } return tablesByNS; }
/** * Constructs an empty {@code HashMultimap} with enough capacity to hold the specified numbers of * keys and values without rehashing. * * <p>This method will soon be deprecated in favor of {@code * MultimapBuilder.hashKeys(expectedKeys).hashSetValues(expectedValuesPerKey).build()}. * * @param expectedKeys the expected number of distinct keys * @param expectedValuesPerKey the expected average number of values per key * @throws IllegalArgumentException if {@code expectedKeys} or {@code expectedValuesPerKey} is * negative */ public static <K, V> HashMultimap<K, V> create(int expectedKeys, int expectedValuesPerKey) { return new HashMultimap<K, V>(expectedKeys, expectedValuesPerKey); }
Multimap<ByteBuffer, LoadQueueItem> rgs = HashMultimap.create(); final Multimap<ByteBuffer, LoadQueueItem> regionGroups = Multimaps.synchronizedMultimap(rgs); Set<String> missingHFiles = new HashSet<>();
/** * Computes a mapping of originating {@code TableName} to snapshots, when the {@code TableName} * exists in the provided {@code Set}. */ Multimap<TableName,String> getSnapshotsFromTables( Admin admin, Set<TableName> tablesToFetchSnapshotsFrom) throws IOException { Multimap<TableName,String> snapshotsToCompute = HashMultimap.create(); for (org.apache.hadoop.hbase.client.SnapshotDescription sd : admin.listSnapshots()) { TableName tn = sd.getTableName(); if (tablesToFetchSnapshotsFrom.contains(tn)) { snapshotsToCompute.put(tn, sd.getName()); } } return snapshotsToCompute; }
FileArchiverNotifierFactoryImpl.setInstance(test); Multimap<TableName,String> snapshotsToCompute = HashMultimap.create(); snapshotsToCompute.put(tn1, ""); snapshotsToCompute.put(tn2, "");
Multimap<TableName, QuotaSettings> createTablesWithSpaceQuotas() throws Exception { final Admin admin = testUtil.getAdmin(); final Multimap<TableName, QuotaSettings> tablesWithQuotas = HashMultimap.create();
/** * Returns all subscribers for the given listener grouped by the type of event they subscribe to. */ private Multimap<Class<?>, Subscriber> findAllSubscribers(Object listener) { Multimap<Class<?>, Subscriber> methodsInListener = HashMultimap.create(); Class<?> clazz = listener.getClass(); for (Method method : getAnnotatedMethods(clazz)) { Class<?>[] parameterTypes = method.getParameterTypes(); Class<?> eventType = parameterTypes[0]; methodsInListener.put(eventType, Subscriber.create(bus, listener, method)); } return methodsInListener; }
@Test public void testPersistingSnapshotsForNamespaces() throws Exception { Multimap<TableName,SnapshotWithSize> snapshotsWithSizes = HashMultimap.create(); TableName tn1 = TableName.valueOf("ns1:tn1"); TableName tn2 = TableName.valueOf("ns1:tn2"); TableName tn3 = TableName.valueOf("ns2:tn1"); TableName tn4 = TableName.valueOf("ns2:tn2"); TableName tn5 = TableName.valueOf("tn1"); snapshotsWithSizes.put(tn1, new SnapshotWithSize("", 1024L)); snapshotsWithSizes.put(tn2, new SnapshotWithSize("", 1024L)); snapshotsWithSizes.put(tn3, new SnapshotWithSize("", 512L)); snapshotsWithSizes.put(tn4, new SnapshotWithSize("", 1024L)); snapshotsWithSizes.put(tn5, new SnapshotWithSize("", 3072L)); Map<String,Long> nsSizes = testChore.groupSnapshotSizesByNamespace(snapshotsWithSizes); assertEquals(3, nsSizes.size()); assertEquals(2048L, (long) nsSizes.get("ns1")); assertEquals(1536L, (long) nsSizes.get("ns2")); assertEquals(3072L, (long) nsSizes.get(NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR)); }
admin.createTable(desc); Multimap<TableName,SnapshotWithSize> snapshotsWithSizes = HashMultimap.create(); try (Table table = conn.getTable(tn)) {
Multimap<TableName, QuotaSettings> createTablesWithSpaceQuotas() throws Exception { final Admin admin = testUtil.getAdmin(); final Multimap<TableName, QuotaSettings> tablesWithQuotas = HashMultimap.create();