/** * This dumps data in a visually reasonable way for visual debugging * * @param splits * @param regions */ void dump(SortedSet<byte[]> splits, Multimap<byte[], HbckInfo> regions) { // we display this way because the last end key should be displayed as well. StringBuilder sb = new StringBuilder(); for (byte[] k : splits) { sb.setLength(0); // clear out existing buffer, if any. sb.append(Bytes.toStringBinary(k) + ":\t"); for (HbckInfo r : regions.get(k)) { sb.append("[ "+ r.toString() + ", " + Bytes.toStringBinary(r.getEndKey())+ "]\t"); } errors.print(sb.toString()); } } }
/** * This dumps data in a visually reasonable way for visual debugging. It has * the basic iteration structure. */ String dump(SortedSet<byte[]> splits, Multimap<byte[], SimpleRange> regions) { // we display this way because the last end key should be displayed as well. StringBuilder sb = new StringBuilder(); for (byte[] k : splits) { sb.append(Bytes.toString(k)).append(":\t"); for (SimpleRange r : regions.get(k)) { sb.append(r.toString()).append("\t"); } sb.append("\n"); } String s = sb.toString(); LOG.info("\n" + s); return s; }
/** * Check the "depth" (number of regions included at a split) of a generated * split calculation */ void checkDepths(SortedSet<byte[]> splits, Multimap<byte[], SimpleRange> regions, Integer... depths) { assertEquals(splits.size(), depths.length); int i = 0; for (byte[] k : splits) { Collection<SimpleRange> rs = regions.get(k); int sz = rs == null ? 0 : rs.size(); assertEquals((int) depths[i], sz); i++; } }
@Test public void testGetTablesByNamespace() { final TablesWithQuotas tables = new TablesWithQuotas(conn, conf); tables.addTableQuotaTable(TableName.valueOf("ignored1")); tables.addTableQuotaTable(TableName.valueOf("ignored2")); tables.addNamespaceQuotaTable(TableName.valueOf("ns1", "t1")); tables.addNamespaceQuotaTable(TableName.valueOf("ns1", "t2")); tables.addNamespaceQuotaTable(TableName.valueOf("ns1", "t3")); tables.addNamespaceQuotaTable(TableName.valueOf("ns2", "t1")); tables.addNamespaceQuotaTable(TableName.valueOf("ns2", "t2")); Multimap<String,TableName> tablesByNamespace = tables.getTablesByNamespace(); Collection<TableName> tablesInNs = tablesByNamespace.get("ns1"); assertEquals(3, tablesInNs.size()); assertTrue("Unexpected results for ns1: " + tablesInNs, tablesInNs.containsAll(Arrays.asList( TableName.valueOf("ns1", "t1"), TableName.valueOf("ns1", "t2"), TableName.valueOf("ns1", "t3")))); tablesInNs = tablesByNamespace.get("ns2"); assertEquals(2, tablesInNs.size()); assertTrue("Unexpected results for ns2: " + tablesInNs, tablesInNs.containsAll(Arrays.asList( TableName.valueOf("ns2", "t1"), TableName.valueOf("ns2", "t2")))); }
public void dumpOverlapProblems(Multimap<byte[], HbckInfo> regions) { // we display this way because the last end key should be displayed as // well. for (byte[] k : regions.keySet()) { errors.print(Bytes.toStringBinary(k) + ":"); for (HbckInfo r : regions.get(k)) { errors.print("[ " + r.toString() + ", " + Bytes.toStringBinary(r.getEndKey()) + "]"); } errors.print("----"); } }
@Test public void testSnapshotsFromTables() throws Exception { TableName tn1 = helper.createTableWithRegions(1); TableName tn2 = helper.createTableWithRegions(1); TableName tn3 = helper.createTableWithRegions(1); // Set a space quota on table 1 and 2 (but not 3) admin.setQuota(QuotaSettingsFactory.limitTableSpace( tn1, SpaceQuotaHelperForTests.ONE_GIGABYTE, SpaceViolationPolicy.NO_INSERTS)); admin.setQuota(QuotaSettingsFactory.limitTableSpace( tn2, SpaceQuotaHelperForTests.ONE_GIGABYTE, SpaceViolationPolicy.NO_INSERTS)); // Create snapshots on each table (we didn't write any data, so just skipflush) admin.snapshot(new SnapshotDescription(tn1 + "snapshot", tn1, SnapshotType.SKIPFLUSH)); admin.snapshot(new SnapshotDescription(tn2 + "snapshot", tn2, SnapshotType.SKIPFLUSH)); admin.snapshot(new SnapshotDescription(tn3 + "snapshot", tn3, SnapshotType.SKIPFLUSH)); Multimap<TableName,String> mapping = testChore.getSnapshotsToComputeSize(); assertEquals(2, mapping.size()); assertEquals(1, mapping.get(tn1).size()); assertEquals(tn1 + "snapshot", mapping.get(tn1).iterator().next()); assertEquals(1, mapping.get(tn2).size()); assertEquals(tn2 + "snapshot", mapping.get(tn2).iterator().next()); admin.snapshot(new SnapshotDescription(tn2 + "snapshot1", tn2, SnapshotType.SKIPFLUSH)); admin.snapshot(new SnapshotDescription(tn3 + "snapshot1", tn3, SnapshotType.SKIPFLUSH)); mapping = testChore.getSnapshotsToComputeSize(); assertEquals(3, mapping.size()); assertEquals(1, mapping.get(tn1).size()); assertEquals(tn1 + "snapshot", mapping.get(tn1).iterator().next()); assertEquals(2, mapping.get(tn2).size()); assertEquals( new HashSet<String>(Arrays.asList(tn2 + "snapshot", tn2 + "snapshot1")), mapping.get(tn2)); }
Collection<HbckInfo> ranges = regions.get(key); if (prevKey == null && !Bytes.equals(key, HConstants.EMPTY_BYTE_ARRAY)) { for (HbckInfo rng : ranges) {
assertEquals(1, mapping.get(tn1).size()); assertEquals(tn1.getQualifierAsString() + "snapshot", mapping.get(tn1).iterator().next()); assertEquals(1, mapping.get(tn2).size()); assertEquals(tn2.getQualifierAsString() + "snapshot", mapping.get(tn2).iterator().next()); assertEquals(1, mapping.get(tn1).size()); assertEquals(tn1.getQualifierAsString() + "snapshot", mapping.get(tn1).iterator().next()); assertEquals(2, mapping.get(tn2).size()); assertEquals( new HashSet<String>(Arrays.asList(tn2.getQualifierAsString() + "snapshot", tn2.getQualifierAsString() + "snapshot1")), mapping.get(tn2));
@Override public Collection<V> get(K key) { return unmodifiableValueCollection(delegate.get(key)); }
@Override public Collection<V2> get(final K key) { return transform(key, fromMultimap.get(key)); }
@Override public Collection<V> get(K key) { synchronized (mutex) { return typePreservingCollection(delegate().get(key), mutex); } }
@SuppressWarnings("unchecked") @Override public Collection<V> get(Object key) { return containsKey(key) ? multimap.get((K) key) : null; }
@Override public List<V2> get(K key) { return transform(key, fromMultimap.get(key)); }
@Override public Collection<V> get(@Nullable K key) { return delegate().get(key); }
@Override public Collection<V> get(final K key) { return filterCollection(unfiltered.get(key), new ValuePredicate(key)); }
@CanIgnoreReturnValue @Override public Builder<K, V> putAll(K key, Iterable<? extends V> values) { Collection<V> collection = builderMultimap.get(checkNotNull(key)); for (V value : values) { collection.add(checkNotNull(value)); } return this; }
@Override public Collection<V> get(K key) { if (keyPredicate.apply(key)) { return unfiltered.get(key); } else if (unfiltered instanceof SetMultimap) { return new AddRejectingSet<K, V>(key); } else { return new AddRejectingList<K, V>(key); } }
/** * This dumps data in a visually reasonable way for visual debugging. It has * the basic iteration structure. */ String dump(SortedSet<byte[]> splits, Multimap<byte[], SimpleRange> regions) { // we display this way because the last end key should be displayed as well. StringBuilder sb = new StringBuilder(); for (byte[] k : splits) { sb.append(Bytes.toString(k)).append(":\t"); for (SimpleRange r : regions.get(k)) { sb.append(r.toString()).append("\t"); } sb.append("\n"); } String s = sb.toString(); LOG.info("\n" + s); return s; }
/** * Check the "depth" (number of regions included at a split) of a generated * split calculation */ void checkDepths(SortedSet<byte[]> splits, Multimap<byte[], SimpleRange> regions, Integer... depths) { assertEquals(splits.size(), depths.length); int i = 0; for (byte[] k : splits) { Collection<SimpleRange> rs = regions.get(k); int sz = rs == null ? 0 : rs.size(); assertEquals((int) depths[i], sz); i++; } }