Search in sources :

Example 6 with KeyExtent

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;
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) TableId(org.apache.accumulo.core.data.TableId) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) TabletLocation(org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocation) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Text(org.apache.hadoop.io.Text) HashMap(java.util.HashMap) MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) Mutation(org.apache.accumulo.core.data.Mutation) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) CurrentLocationColumnFamily(org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.CurrentLocationColumnFamily) MetadataLocationObtainer(org.apache.accumulo.core.metadata.MetadataLocationObtainer) Map(java.util.Map) Key(org.apache.accumulo.core.data.Key) RootTable(org.apache.accumulo.core.metadata.RootTable) EasyMock.replay(org.easymock.EasyMock.replay) Value(org.apache.accumulo.core.data.Value) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) InstanceId(org.apache.accumulo.core.data.InstanceId) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Set(java.util.Set) TabletServerMutations(org.apache.accumulo.core.clientImpl.TabletLocator.TabletServerMutations) EasyMock(org.easymock.EasyMock) Range(org.apache.accumulo.core.data.Range) Test(org.junit.jupiter.api.Test) List(java.util.List) TabletLocationObtainer(org.apache.accumulo.core.clientImpl.TabletLocatorImpl.TabletLocationObtainer) TreeMap(java.util.TreeMap) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Entry(java.util.Map.Entry) TabletLocations(org.apache.accumulo.core.clientImpl.TabletLocator.TabletLocations) TabletServerLockChecker(org.apache.accumulo.core.clientImpl.TabletLocatorImpl.TabletServerLockChecker) TabletColumnFamily(org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.TabletColumnFamily) PartialKey(org.apache.accumulo.core.data.PartialKey) Collections(java.util.Collections) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent)

Example 7 with KeyExtent

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");
}
Also used : Mutation(org.apache.accumulo.core.data.Mutation) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) Test(org.junit.jupiter.api.Test)

Example 8 with KeyExtent

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");
}
Also used : KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Test(org.junit.jupiter.api.Test)

Example 9 with KeyExtent

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);
}
Also used : Range(org.apache.accumulo.core.data.Range) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Mutation(org.apache.accumulo.core.data.Mutation) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) TabletServerLockChecker(org.apache.accumulo.core.clientImpl.TabletLocatorImpl.TabletServerLockChecker) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 10 with KeyExtent

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);
}
Also used : FileInfo(org.apache.accumulo.core.clientImpl.bulk.Bulk.FileInfo) Text(org.apache.hadoop.io.Text) Files(org.apache.accumulo.core.clientImpl.bulk.Bulk.Files) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent)

Aggregations

KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)239 Text (org.apache.hadoop.io.Text)98 ArrayList (java.util.ArrayList)72 HashMap (java.util.HashMap)60 Value (org.apache.accumulo.core.data.Value)57 Key (org.apache.accumulo.core.data.Key)56 TableId (org.apache.accumulo.core.data.TableId)53 Test (org.junit.Test)52 Mutation (org.apache.accumulo.core.data.Mutation)47 IOException (java.io.IOException)40 List (java.util.List)40 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)39 HashSet (java.util.HashSet)38 TreeMap (java.util.TreeMap)38 Range (org.apache.accumulo.core.data.Range)38 Map (java.util.Map)33 Scanner (org.apache.accumulo.core.client.Scanner)31 Entry (java.util.Map.Entry)30 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)30 Test (org.junit.jupiter.api.Test)30