use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TwoTierCompactionStrategyTest method testDefaultCompaction.
@Test
public void testDefaultCompaction() throws IOException {
ttcs.init(opts);
conf = DefaultConfiguration.getInstance();
KeyExtent ke = new KeyExtent(Table.ID.of("0"), null, null);
mcr = new MajorCompactionRequest(ke, MajorCompactionReason.NORMAL, conf);
Map<FileRef, DataFileValue> fileMap = createFileMap("f1", "10M", "f2", "10M", "f3", "10M", "f4", "10M", "f5", "100M", "f6", "100M", "f7", "100M", "f8", "100M");
mcr.setFiles(fileMap);
Assert.assertTrue(ttcs.shouldCompact(mcr));
Assert.assertEquals(8, mcr.getFiles().size());
List<FileRef> filesToCompact = ttcs.getCompactionPlan(mcr).inputFiles;
Assert.assertEquals(fileMap.keySet(), new HashSet<>(filesToCompact));
Assert.assertEquals(8, filesToCompact.size());
Assert.assertEquals(null, ttcs.getCompactionPlan(mcr).writeParameters.getCompressType());
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method createMetaCacheKE.
static TreeMap<KeyExtent, TabletLocation> createMetaCacheKE(Object... data) {
TreeMap<KeyExtent, TabletLocation> mcke = new TreeMap<>();
for (int i = 0; i < data.length; i += 2) {
KeyExtent ke = (KeyExtent) data[i];
String loc = (String) data[i + 1];
mcke.put(ke, new TabletLocation(ke, loc, "1"));
}
return mcke;
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method testBinSplit.
@Test
public void testBinSplit() throws Exception {
for (int i = 0; i < 3; i++) {
// when i == 0 only test binning mutations
// when i == 1 only test binning ranges
// when i == 2 test both
KeyExtent ke1 = nke("foo", null, null);
TServers tservers = new TServers();
TabletLocatorImpl metaCache = createLocators(tservers, "tserver1", "tserver2", "foo", ke1, "l1");
List<Mutation> ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("m", "cf1:cq1=v3", "cf1:cq2=v4"), nm("z", "cf1:cq1=v5"));
Map<String, Map<KeyExtent, List<String>>> emb = cemb(nol("a", "l1", ke1), nol("m", "l1", ke1), nol("z", "l1", ke1));
if (i == 0 || i == 2)
runTest(metaCache, ml, emb);
List<Range> ranges = nrl(new Range(new Text("a")), new Range(new Text("m")), new Range(new Text("z")));
Map<String, Map<KeyExtent, List<Range>>> expected1 = createExpectedBinnings("l1", nol(nke("foo", null, null), ranges));
if (i == 1 || i == 2)
runTest(new Text("foo"), ranges, metaCache, expected1);
KeyExtent ke11 = nke("foo", "n", null);
KeyExtent ke12 = nke("foo", null, "n");
setLocation(tservers, "tserver2", MTE, ke12, "l2");
metaCache.invalidateCache(ke1);
emb = cemb(nol("z", "l2", ke12));
if (i == 0 || i == 2)
runTest(metaCache, ml, emb, "a", "m");
Map<String, Map<KeyExtent, List<Range>>> expected2 = createExpectedBinnings("l2", nol(nke("foo", null, "n"), nrl(new Range(new Text("z")))));
if (i == 1 || i == 2)
runTest(new Text("foo"), ranges, metaCache, expected2, nrl(new Range(new Text("a")), new Range(new Text("m"))));
setLocation(tservers, "tserver2", MTE, ke11, "l3");
emb = cemb(nol("a", "l3", ke11), nol("m", "l3", ke11), nol("z", "l2", ke12));
if (i == 0 || i == 2)
runTest(metaCache, ml, emb);
Map<String, Map<KeyExtent, List<Range>>> expected3 = createExpectedBinnings("l2", nol(nke("foo", null, "n"), nrl(new Range(new Text("z")))), "l3", nol(nke("foo", "n", null), nrl(new Range(new Text("a")), new Range(new Text("m")))));
if (i == 1 || i == 2)
runTest(new Text("foo"), ranges, metaCache, expected3);
}
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method testBinMutations1.
@Test
public void testBinMutations1() throws Exception {
// one tablet table
KeyExtent ke1 = nke("foo", null, null);
TabletLocatorImpl metaCache = createLocators("foo", ke1, "l1");
List<Mutation> ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("c", "cf1:cq1=v3", "cf1:cq2=v4"));
Map<String, Map<KeyExtent, List<String>>> emb = cemb(nol("a", "l1", ke1), nol("c", "l1", ke1));
runTest(metaCache, ml, emb);
ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"));
emb = cemb(nol("a", "l1", ke1));
runTest(metaCache, ml, emb);
ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("a", "cf1:cq3=v3"));
emb = cemb(nol("a", "l1", ke1), nol("a", "l1", ke1));
runTest(metaCache, ml, emb);
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method verify.
private void verify(Map<String, Map<KeyExtent, List<String>>> expected, Map<String, TabletServerMutations<Mutation>> actual) {
assertEquals(expected.keySet(), actual.keySet());
for (String server : actual.keySet()) {
TabletServerMutations<Mutation> atb = actual.get(server);
Map<KeyExtent, List<String>> etb = expected.get(server);
assertEquals(etb.keySet(), atb.getMutations().keySet());
for (KeyExtent ke : etb.keySet()) {
ArrayList<String> eRows = new ArrayList<>(etb.get(ke));
ArrayList<String> aRows = new ArrayList<>();
for (Mutation m : atb.getMutations().get(ke)) {
aRows.add(new String(m.getRow()));
}
Collections.sort(eRows);
Collections.sort(aRows);
assertEquals(eRows, aRows);
}
}
}
Aggregations