use of org.apache.accumulo.core.clientImpl.TabletLocatorImpl.TabletServerLockChecker 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);
}
Aggregations