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);
}
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);
}
}
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();
}
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);
}
}
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);
}
Aggregations