use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method verify.
private void verify(Map<String, Map<KeyExtent, List<String>>> expected, Map<String, TabletServerMutations<Mutation>> actual) {
assertEquals(expected.keySet(), actual.keySet());
for (String server : actual.keySet()) {
TabletServerMutations<Mutation> atb = actual.get(server);
Map<KeyExtent, List<String>> etb = expected.get(server);
assertEquals(etb.keySet(), atb.getMutations().keySet());
for (KeyExtent ke : etb.keySet()) {
ArrayList<String> eRows = new ArrayList<>(etb.get(ke));
ArrayList<String> aRows = new ArrayList<>();
for (Mutation m : atb.getMutations().get(ke)) {
aRows.add(new String(m.getRow()));
}
Collections.sort(eRows);
Collections.sort(aRows);
assertEquals(eRows, aRows);
}
}
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method testBug2.
@Test
public void testBug2() throws Exception {
// a bug that occurred while running a functional test
KeyExtent mte1 = new KeyExtent(MetadataTable.ID, new Text("~"), RTE.getEndRow());
KeyExtent mte2 = new KeyExtent(MetadataTable.ID, null, new Text("~"));
TServers tservers = new TServers();
TestTabletLocationObtainer ttlo = new TestTabletLocationObtainer(tservers);
RootTabletLocator rtl = new TestRootTabletLocator();
TabletLocatorImpl rootTabletCache = new TabletLocatorImpl(MetadataTable.ID, rtl, ttlo, new YesLockChecker());
TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl(Table.ID.of("0"), rootTabletCache, ttlo, new YesLockChecker());
setLocation(tservers, "tserver1", RTE, mte1, "tserver2");
setLocation(tservers, "tserver1", RTE, mte2, "tserver3");
// create the ~ tablet so it exists
Map<KeyExtent, SortedMap<Key, Value>> ts3 = new HashMap<>();
ts3.put(mte2, new TreeMap<>());
tservers.tservers.put("tserver3", ts3);
assertNull(tab0TabletCache.locateTablet(context, new Text("row_0000000000"), false, false));
}
use of org.apache.accumulo.core.data.impl.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.data.impl.KeyExtent in project accumulo by apache.
the class TabletLocatorImplTest method testBug3.
// this test reproduces a problem where empty metadata tablets, that were created by user tablets being merged away, caused locating tablets to fail
@Test
public void testBug3() throws Exception {
KeyExtent mte1 = new KeyExtent(MetadataTable.ID, new Text("1;c"), RTE.getEndRow());
KeyExtent mte2 = new KeyExtent(MetadataTable.ID, new Text("1;f"), new Text("1;c"));
KeyExtent mte3 = new KeyExtent(MetadataTable.ID, new Text("1;j"), new Text("1;f"));
KeyExtent mte4 = new KeyExtent(MetadataTable.ID, new Text("1;r"), new Text("1;j"));
KeyExtent mte5 = new KeyExtent(MetadataTable.ID, null, new Text("1;r"));
KeyExtent ke1 = new KeyExtent(Table.ID.of("1"), null, null);
TServers tservers = new TServers();
TestTabletLocationObtainer ttlo = new TestTabletLocationObtainer(tservers);
RootTabletLocator rtl = new TestRootTabletLocator();
TabletLocatorImpl rootTabletCache = new TabletLocatorImpl(MetadataTable.ID, rtl, ttlo, new YesLockChecker());
TabletLocatorImpl tab0TabletCache = new TabletLocatorImpl(Table.ID.of("1"), rootTabletCache, ttlo, new YesLockChecker());
setLocation(tservers, "tserver1", RTE, mte1, "tserver2");
setLocation(tservers, "tserver1", RTE, mte2, "tserver3");
setLocation(tservers, "tserver1", RTE, mte3, "tserver4");
setLocation(tservers, "tserver1", RTE, mte4, "tserver5");
setLocation(tservers, "tserver1", RTE, mte5, "tserver6");
createEmptyTablet(tservers, "tserver2", mte1);
createEmptyTablet(tservers, "tserver3", mte2);
createEmptyTablet(tservers, "tserver4", mte3);
createEmptyTablet(tservers, "tserver5", mte4);
setLocation(tservers, "tserver6", mte5, ke1, "tserver7");
locateTabletTest(tab0TabletCache, "a", ke1, "tserver7");
}
use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.
the class TabletGroupWatcher method deleteTablets.
private void deleteTablets(MergeInfo info) throws AccumuloException {
KeyExtent extent = info.getExtent();
String targetSystemTable = extent.isMeta() ? RootTable.NAME : MetadataTable.NAME;
Master.log.debug("Deleting tablets for {}", extent);
char timeType = '\0';
KeyExtent followingTablet = null;
if (extent.getEndRow() != null) {
Key nextExtent = new Key(extent.getEndRow()).followingKey(PartialKey.ROW);
followingTablet = getHighTablet(new KeyExtent(extent.getTableId(), nextExtent.getRow(), extent.getEndRow()));
Master.log.debug("Found following tablet {}", followingTablet);
}
try {
Connector conn = this.master.getConnector();
Text start = extent.getPrevEndRow();
if (start == null) {
start = new Text();
}
Master.log.debug("Making file deletion entries for {}", extent);
Range deleteRange = new Range(KeyExtent.getMetadataEntry(extent.getTableId(), start), false, KeyExtent.getMetadataEntry(extent.getTableId(), extent.getEndRow()), true);
Scanner scanner = conn.createScanner(targetSystemTable, Authorizations.EMPTY);
scanner.setRange(deleteRange);
TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.fetch(scanner);
TabletsSection.ServerColumnFamily.TIME_COLUMN.fetch(scanner);
scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
Set<FileRef> datafiles = new TreeSet<>();
for (Entry<Key, Value> entry : scanner) {
Key key = entry.getKey();
if (key.compareColumnFamily(DataFileColumnFamily.NAME) == 0) {
datafiles.add(new FileRef(this.master.fs, key));
if (datafiles.size() > 1000) {
MetadataTableUtil.addDeleteEntries(extent, datafiles, master);
datafiles.clear();
}
} else if (TabletsSection.ServerColumnFamily.TIME_COLUMN.hasColumns(key)) {
timeType = entry.getValue().toString().charAt(0);
} else if (key.compareColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME) == 0) {
throw new IllegalStateException("Tablet " + key.getRow() + " is assigned during a merge!");
} else if (TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.hasColumns(key)) {
// ACCUMULO-2974 Need to include the TableID when converting a relative path to an absolute path.
// The value has the leading path separator already included so it doesn't need it included.
String path = entry.getValue().toString();
if (path.contains(":")) {
datafiles.add(new FileRef(path));
} else {
datafiles.add(new FileRef(path, this.master.fs.getFullPath(FileType.TABLE, Path.SEPARATOR + extent.getTableId() + path)));
}
if (datafiles.size() > 1000) {
MetadataTableUtil.addDeleteEntries(extent, datafiles, master);
datafiles.clear();
}
}
}
MetadataTableUtil.addDeleteEntries(extent, datafiles, master);
BatchWriter bw = conn.createBatchWriter(targetSystemTable, new BatchWriterConfig());
try {
deleteTablets(info, deleteRange, bw, conn);
} finally {
bw.close();
}
if (followingTablet != null) {
Master.log.debug("Updating prevRow of {} to {}", followingTablet, extent.getPrevEndRow());
bw = conn.createBatchWriter(targetSystemTable, new BatchWriterConfig());
try {
Mutation m = new Mutation(followingTablet.getMetadataEntry());
TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.put(m, KeyExtent.encodePrevEndRow(extent.getPrevEndRow()));
ChoppedColumnFamily.CHOPPED_COLUMN.putDelete(m);
bw.addMutation(m);
bw.flush();
} finally {
bw.close();
}
} else {
// Recreate the default tablet to hold the end of the table
Master.log.debug("Recreating the last tablet to point to {}", extent.getPrevEndRow());
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(extent.getTableId());
String tdir = master.getFileSystem().choose(chooserEnv, ServerConstants.getBaseUris()) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + extent.getTableId() + Constants.DEFAULT_TABLET_LOCATION;
MetadataTableUtil.addTablet(new KeyExtent(extent.getTableId(), null, extent.getPrevEndRow()), tdir, master, timeType, this.master.masterLock);
}
} catch (RuntimeException | IOException | TableNotFoundException | AccumuloSecurityException ex) {
throw new AccumuloException(ex);
}
}
Aggregations