use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method cemb.
static Map<String, Map<KeyExtent, List<String>>> cemb(Object[]... ols) {
Map<String, Map<KeyExtent, List<String>>> emb = new HashMap<>();
for (Object[] ol : ols) {
String row = (String) ol[0];
String server = (String) ol[1];
KeyExtent ke = (KeyExtent) ol[2];
emb.computeIfAbsent(server, k -> new HashMap<>()).computeIfAbsent(ke, k -> new ArrayList<>()).add(row);
}
return emb;
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method testBinMutations4.
@Test
public void testBinMutations4() throws Exception {
// three table with hole
KeyExtent ke1 = nke("foo", "h", null);
KeyExtent ke3 = nke("foo", null, "t");
TabletLocatorImpl metaCache = createLocators("foo", ke1, "l1", ke3, "l3");
List<Mutation> ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("i", "cf1:cq1=v3", "cf1:cq2=v4"));
Map<String, Map<KeyExtent, List<String>>> emb = cemb(nol("a", "l1", ke1));
runTest(metaCache, ml, emb, "i");
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);
ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("w", "cf1:cq3=v3"));
emb = cemb(nol("a", "l1", ke1), nol("w", "l3", ke3));
runTest(metaCache, ml, emb);
ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("w", "cf1:cq3=v3"), nm("z", "cf1:cq4=v4"));
emb = cemb(nol("a", "l1", ke1), nol("w", "l3", ke3), nol("z", "l3", ke3));
runTest(metaCache, ml, emb);
ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("w", "cf1:cq3=v3"), nm("z", "cf1:cq4=v4"), nm("t", "cf1:cq5=v5"));
emb = cemb(nol("a", "l1", ke1), nol("w", "l3", ke3), nol("z", "l3", ke3));
runTest(metaCache, ml, emb, "t");
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method test2.
@Test
public void test2() throws Exception {
TServers tservers = new TServers();
TabletLocatorImpl metaCache = createLocators(tservers, "tserver1", "tserver2", "foo");
KeyExtent ke1 = nke("foo", "m", null);
KeyExtent ke2 = nke("foo", null, "m");
setLocation(tservers, "tserver2", MTE, ke1, null);
setLocation(tservers, "tserver2", MTE, ke2, "L1");
locateTabletTest(metaCache, "a", null, null);
locateTabletTest(metaCache, "r", ke2, "L1");
setLocation(tservers, "tserver2", MTE, ke1, "L2");
locateTabletTest(metaCache, "a", ke1, "L2");
locateTabletTest(metaCache, "r", ke2, "L1");
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method testLostLock.
@Test
public void testLostLock() throws Exception {
final HashSet<String> activeLocks = new HashSet<>();
TServers tservers = new TServers();
TabletLocatorImpl metaCache = createLocators(tservers, "tserver1", "tserver2", "foo", new TabletServerLockChecker() {
@Override
public boolean isLockHeld(String tserver, String session) {
return activeLocks.contains(tserver + ":" + session);
}
@Override
public void invalidateCache(String server) {
}
});
KeyExtent ke1 = nke("foo", null, null);
setLocation(tservers, "tserver2", MTE, ke1, "L1", "5");
activeLocks.add("L1:5");
locateTabletTest(metaCache, "a", ke1, "L1");
locateTabletTest(metaCache, "a", ke1, "L1");
activeLocks.clear();
locateTabletTest(metaCache, "a", null, null);
locateTabletTest(metaCache, "a", null, null);
locateTabletTest(metaCache, "a", null, null);
clearLocation(tservers, "tserver2", MTE, ke1, "5");
setLocation(tservers, "tserver2", MTE, ke1, "L2", "6");
activeLocks.add("L2:6");
locateTabletTest(metaCache, "a", ke1, "L2");
locateTabletTest(metaCache, "a", ke1, "L2");
clearLocation(tservers, "tserver2", MTE, ke1, "6");
locateTabletTest(metaCache, "a", ke1, "L2");
setLocation(tservers, "tserver2", MTE, ke1, "L3", "7");
locateTabletTest(metaCache, "a", ke1, "L2");
activeLocks.clear();
locateTabletTest(metaCache, "a", null, null);
locateTabletTest(metaCache, "a", null, null);
activeLocks.add("L3:7");
locateTabletTest(metaCache, "a", ke1, "L3");
locateTabletTest(metaCache, "a", ke1, "L3");
List<Mutation> ml = nml(nm("a", "cf1:cq1=v1", "cf1:cq2=v2"), nm("w", "cf1:cq3=v3"));
Map<String, Map<KeyExtent, List<String>>> emb = cemb(nol("a", "L3", ke1), nol("w", "L3", ke1));
runTest(metaCache, ml, emb);
clearLocation(tservers, "tserver2", MTE, ke1, "7");
runTest(metaCache, ml, emb);
activeLocks.clear();
emb.clear();
runTest(metaCache, ml, emb, "a", "w");
runTest(metaCache, ml, emb, "a", "w");
KeyExtent ke11 = nke("foo", "m", null);
KeyExtent ke12 = nke("foo", null, "m");
setLocation(tservers, "tserver2", MTE, ke11, "L1", "8");
setLocation(tservers, "tserver2", MTE, ke12, "L2", "9");
runTest(metaCache, ml, emb, "a", "w");
activeLocks.add("L1:8");
emb = cemb(nol("a", "L1", ke11));
runTest(metaCache, ml, emb, "w");
activeLocks.add("L2:9");
emb = cemb(nol("a", "L1", ke11), nol("w", "L2", ke12));
runTest(metaCache, ml, emb);
List<Range> ranges = nrl(new Range("a"), nr("b", "o"), nr("r", "z"));
Map<String, Map<KeyExtent, List<Range>>> expected = createExpectedBinnings("L1", nol(ke11, nrl(new Range("a"), nr("b", "o"))), "L2", nol(ke12, nrl(nr("b", "o"), nr("r", "z"))));
runTest(ranges, metaCache, expected);
activeLocks.remove("L2:9");
expected = createExpectedBinnings("L1", nol(ke11, nrl(new Range("a"))));
runTest(ranges, metaCache, expected, nrl(nr("b", "o"), nr("r", "z")));
activeLocks.clear();
expected = createExpectedBinnings();
runTest(ranges, metaCache, expected, nrl(new Range("a"), nr("b", "o"), nr("r", "z")));
clearLocation(tservers, "tserver2", MTE, ke11, "8");
clearLocation(tservers, "tserver2", MTE, ke12, "9");
setLocation(tservers, "tserver2", MTE, ke11, "L3", "10");
setLocation(tservers, "tserver2", MTE, ke12, "L4", "11");
runTest(ranges, metaCache, expected, nrl(new Range("a"), nr("b", "o"), nr("r", "z")));
activeLocks.add("L3:10");
expected = createExpectedBinnings("L3", nol(ke11, nrl(new Range("a"))));
runTest(ranges, metaCache, expected, nrl(nr("b", "o"), nr("r", "z")));
activeLocks.add("L4:11");
expected = createExpectedBinnings("L3", nol(ke11, nrl(new Range("a"), nr("b", "o"))), "L4", nol(ke12, nrl(nr("b", "o"), nr("r", "z"))));
runTest(ranges, metaCache, expected);
}
use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.
the class BulkImportTest method addMapping.
private void addMapping(SortedMap<KeyExtent, Files> mappings, String prevRow, String endRow, String... fileNames) {
KeyExtent ke = new KeyExtent(TableId.of("42"), endRow == null ? null : new Text(endRow), prevRow == null ? null : new Text(prevRow));
Files files = new Files();
for (String name : fileNames) {
files.add(new FileInfo(name, 2, 2));
}
mappings.put(ke, files);
}
Aggregations