Search in sources :

Example 81 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class BasicCompactionStrategyTest method testDefaultCompaction.

@Test
public void testDefaultCompaction() {
    ttcs.init(opts);
    conf = DefaultConfiguration.getInstance();
    KeyExtent ke = new KeyExtent(TableId.of("0"), null, null);
    mcr = new MajorCompactionRequest(ke, MajorCompactionReason.NORMAL, conf, InMemoryMapTest.getServerContext());
    Map<StoredTabletFile, DataFileValue> fileMap = createFileMap("f1", "10M", "f2", "10M", "f3", "10M", "f4", "10M", "f5", "100M", "f6", "100M", "f7", "100M", "f8", "100M");
    mcr.setFiles(fileMap);
    assertTrue(ttcs.shouldCompact(mcr));
    assertEquals(8, mcr.getFiles().size());
    List<StoredTabletFile> filesToCompact = ttcs.getCompactionPlan(mcr).inputFiles;
    assertEquals(fileMap.keySet(), new HashSet<>(filesToCompact));
    assertEquals(8, filesToCompact.size());
    assertNull(ttcs.getCompactionPlan(mcr).writeParameters);
}
Also used : DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) MajorCompactionRequest(org.apache.accumulo.tserver.compaction.MajorCompactionRequest) Test(org.junit.Test) InMemoryMapTest(org.apache.accumulo.tserver.InMemoryMapTest) SizeLimitCompactionStrategyTest(org.apache.accumulo.tserver.compaction.SizeLimitCompactionStrategyTest)

Example 82 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class TabletStateChangeIteratorIT method test.

@Test
public void test() throws AccumuloException, AccumuloSecurityException, TableExistsException, TableNotFoundException {
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        String[] tables = getUniqueNames(6);
        final String t1 = tables[0];
        final String t2 = tables[1];
        final String t3 = tables[2];
        final String metaCopy1 = tables[3];
        final String metaCopy2 = tables[4];
        final String metaCopy3 = tables[5];
        // create some metadata
        createTable(client, t1, true);
        createTable(client, t2, false);
        createTable(client, t3, true);
        // examine a clone of the metadata table, so we can manipulate it
        copyTable(client, MetadataTable.NAME, metaCopy1);
        State state = new State(client);
        int tabletsInFlux = findTabletsNeedingAttention(client, metaCopy1, state);
        while (tabletsInFlux > 0) {
            log.debug("Waiting for {} tablets for {}", tabletsInFlux, metaCopy1);
            UtilWaitThread.sleep(500);
            copyTable(client, MetadataTable.NAME, metaCopy1);
            tabletsInFlux = findTabletsNeedingAttention(client, metaCopy1, state);
        }
        assertEquals("No tables should need attention", 0, findTabletsNeedingAttention(client, metaCopy1, state));
        // The metadata table stabilized and metaCopy1 contains a copy suitable for testing. Before
        // metaCopy1 is modified, copy it for subsequent test.
        copyTable(client, metaCopy1, metaCopy2);
        copyTable(client, metaCopy1, metaCopy3);
        // test the assigned case (no location)
        removeLocation(client, metaCopy1, t3);
        assertEquals("Should have two tablets without a loc", 2, findTabletsNeedingAttention(client, metaCopy1, state));
        // test the cases where the assignment is to a dead tserver
        reassignLocation(client, metaCopy2, t3);
        assertEquals("Should have one tablet that needs to be unassigned", 1, findTabletsNeedingAttention(client, metaCopy2, state));
        // test the cases where there is ongoing merges
        state = new State(client) {

            @Override
            public Collection<MergeInfo> merges() {
                TableId tableIdToModify = TableId.of(client.tableOperations().tableIdMap().get(t3));
                return Collections.singletonList(new MergeInfo(new KeyExtent(tableIdToModify, null, null), MergeInfo.Operation.MERGE));
            }
        };
        assertEquals("Should have 2 tablets that need to be chopped or unassigned", 1, findTabletsNeedingAttention(client, metaCopy2, state));
        // test the bad tablet location state case (inconsistent metadata)
        state = new State(client);
        addDuplicateLocation(client, metaCopy3, t3);
        assertEquals("Should have 1 tablet that needs a metadata repair", 1, findTabletsNeedingAttention(client, metaCopy3, state));
        // clean up
        dropTables(client, t1, t2, t3, metaCopy1, metaCopy2, metaCopy3);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) TableId(org.apache.accumulo.core.data.TableId) MergeInfo(org.apache.accumulo.server.manager.state.MergeInfo) TableState(org.apache.accumulo.core.manager.state.tables.TableState) ManagerState(org.apache.accumulo.core.manager.thrift.ManagerState) CurrentState(org.apache.accumulo.server.manager.state.CurrentState) Collection(java.util.Collection) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Test(org.junit.Test)

Example 83 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class TabletStateChangeIteratorIT method removeLocation.

private void removeLocation(AccumuloClient client, String table, String tableNameToModify) throws TableNotFoundException, MutationsRejectedException {
    TableId tableIdToModify = TableId.of(client.tableOperations().tableIdMap().get(tableNameToModify));
    BatchDeleter deleter = client.createBatchDeleter(table, Authorizations.EMPTY, 1);
    deleter.setRanges(Collections.singleton(new KeyExtent(tableIdToModify, null, null).toMetaRange()));
    deleter.fetchColumnFamily(CurrentLocationColumnFamily.NAME);
    deleter.delete();
    deleter.close();
}
Also used : TableId(org.apache.accumulo.core.data.TableId) BatchDeleter(org.apache.accumulo.core.client.BatchDeleter) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent)

Example 84 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class TabletStateChangeIteratorIT method addDuplicateLocation.

private void addDuplicateLocation(AccumuloClient client, String table, String tableNameToModify) throws TableNotFoundException, MutationsRejectedException {
    TableId tableIdToModify = TableId.of(client.tableOperations().tableIdMap().get(tableNameToModify));
    Mutation m = new Mutation(new KeyExtent(tableIdToModify, null, null).toMetaRow());
    m.put(CurrentLocationColumnFamily.NAME, new Text("1234567"), new Value("fake:9005"));
    try (BatchWriter bw = client.createBatchWriter(table)) {
        bw.addMutation(m);
    }
}
Also used : TableId(org.apache.accumulo.core.data.TableId) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) Mutation(org.apache.accumulo.core.data.Mutation) BatchWriter(org.apache.accumulo.core.client.BatchWriter) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent)

Example 85 with KeyExtent

use of org.apache.accumulo.core.dataImpl.KeyExtent in project accumulo by apache.

the class SplitRecoveryIT method runSplitRecoveryTest.

private void runSplitRecoveryTest(ServerContext context, int failPoint, String mr, int extentToSplit, ServiceLock zl, KeyExtent... extents) throws Exception {
    Text midRow = new Text(mr);
    SortedMap<StoredTabletFile, DataFileValue> splitMapFiles = null;
    for (int i = 0; i < extents.length; i++) {
        KeyExtent extent = extents[i];
        String dirName = "dir_" + i;
        String tdir = context.getTablesDirs().iterator().next() + "/" + extent.tableId() + "/" + dirName;
        MetadataTableUtil.addTablet(extent, dirName, context, TimeType.LOGICAL, zl);
        SortedMap<TabletFile, DataFileValue> mapFiles = new TreeMap<>();
        mapFiles.put(new TabletFile(new Path(tdir + "/" + RFile.EXTENSION + "_000_000")), new DataFileValue(1000017 + i, 10000 + i));
        int tid = 0;
        TransactionWatcher.ZooArbitrator.start(context, Constants.BULK_ARBITRATOR_TYPE, tid);
        SortedMap<StoredTabletFile, DataFileValue> storedFiles = new TreeMap<>(MetadataTableUtil.updateTabletDataFile(tid, extent, mapFiles, new MetadataTime(0, TimeType.LOGICAL), context, zl));
        if (i == extentToSplit) {
            splitMapFiles = storedFiles;
        }
    }
    KeyExtent extent = extents[extentToSplit];
    KeyExtent high = new KeyExtent(extent.tableId(), extent.endRow(), midRow);
    KeyExtent low = new KeyExtent(extent.tableId(), midRow, extent.prevEndRow());
    splitPartiallyAndRecover(context, extent, high, low, .4, splitMapFiles, midRow, "localhost:1234", failPoint, zl);
}
Also used : Path(org.apache.hadoop.fs.Path) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) Text(org.apache.hadoop.io.Text) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) TabletFile(org.apache.accumulo.core.metadata.TabletFile) TreeMap(java.util.TreeMap) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) MetadataTime(org.apache.accumulo.core.metadata.schema.MetadataTime)

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