use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class DatafileManager method bringMajorCompactionOnline.
StoredTabletFile bringMajorCompactionOnline(Set<StoredTabletFile> oldDatafiles, TabletFile tmpDatafile, Long compactionId, Set<StoredTabletFile> selectedFiles, DataFileValue dfv, Optional<ExternalCompactionId> ecid) throws IOException {
final KeyExtent extent = tablet.getExtent();
VolumeManager vm = tablet.getTabletServer().getContext().getVolumeManager();
long t1, t2;
TabletFile newDatafile = CompactableUtils.computeCompactionFileDest(tmpDatafile);
if (vm.exists(newDatafile.getPath())) {
log.error("Target map file already exist " + newDatafile, new Exception());
throw new IllegalStateException("Target map file already exist " + newDatafile);
}
if (dfv.getNumEntries() == 0) {
vm.deleteRecursively(tmpDatafile.getPath());
} else {
// rename before putting in metadata table, so files in metadata table should
// always exist
rename(vm, tmpDatafile.getPath(), newDatafile.getPath());
}
TServerInstance lastLocation = null;
// calling insert to get the new file before inserting into the metadata
StoredTabletFile newFile = newDatafile.insert();
Long compactionIdToWrite = null;
synchronized (tablet) {
t1 = System.currentTimeMillis();
Preconditions.checkState(datafileSizes.keySet().containsAll(oldDatafiles), "Compacted files %s are not a subset of tablet files %s", oldDatafiles, datafileSizes.keySet());
if (dfv.getNumEntries() > 0) {
Preconditions.checkState(!datafileSizes.containsKey(newFile), "New compaction file %s already exist in tablet files %s", newFile, datafileSizes.keySet());
}
tablet.incrementDataSourceDeletions();
datafileSizes.keySet().removeAll(oldDatafiles);
if (dfv.getNumEntries() > 0) {
datafileSizes.put(newFile, dfv);
// could be used by a follow on compaction in a multipass compaction
}
updateCount++;
tablet.computeNumEntries();
lastLocation = tablet.resetLastLocation();
if (compactionId != null && Collections.disjoint(selectedFiles, datafileSizes.keySet())) {
compactionIdToWrite = compactionId;
}
t2 = System.currentTimeMillis();
}
// known consistency issue between minor and major compactions - see ACCUMULO-18
Set<StoredTabletFile> filesInUseByScans = waitForScansToFinish(oldDatafiles);
if (!filesInUseByScans.isEmpty())
log.debug("Adding scan refs to metadata {} {}", extent, filesInUseByScans);
ManagerMetadataUtil.replaceDatafiles(tablet.getContext(), extent, oldDatafiles, filesInUseByScans, newFile, compactionIdToWrite, dfv, tablet.getTabletServer().getClientAddressString(), lastLocation, tablet.getTabletServer().getLock(), ecid);
tablet.setLastCompactionID(compactionIdToWrite);
removeFilesAfterScan(filesInUseByScans);
if (log.isTraceEnabled()) {
log.trace(String.format("MajC finish lock %.2f secs", (t2 - t1) / 1000.0));
}
return newFile;
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class CheckTabletMetadataTest method testBadTabletMetadata.
@Test
public void testBadTabletMetadata() throws Exception {
KeyExtent ke = new KeyExtent(TableId.of("1"), null, null);
TreeMap<Key, Value> tabletMeta = new TreeMap<>();
put(tabletMeta, "1<", TabletColumnFamily.PREV_ROW_COLUMN, TabletColumnFamily.encodePrevEndRow(null).get());
put(tabletMeta, "1<", ServerColumnFamily.DIRECTORY_COLUMN, "t1".getBytes());
put(tabletMeta, "1<", ServerColumnFamily.TIME_COLUMN, "M0".getBytes());
put(tabletMeta, "1<", FutureLocationColumnFamily.NAME, "4", "127.0.0.1:9997");
TServerInstance tsi = new TServerInstance("127.0.0.1:9997", 4);
TabletMetadata tm = TabletMetadata.convertRow(tabletMeta.entrySet().iterator(), EnumSet.allOf(ColumnType.class), true);
assertTrue(checkTabletMetadata(ke, tsi, tm));
assertFail(tabletMeta, ke, new TServerInstance("127.0.0.1:9998", 4));
assertFail(tabletMeta, ke, new TServerInstance("127.0.0.1:9998", 5));
assertFail(tabletMeta, ke, new TServerInstance("127.0.0.1:9997", 5));
assertFail(tabletMeta, ke, new TServerInstance("127.0.0.2:9997", 4));
assertFail(tabletMeta, ke, new TServerInstance("127.0.0.2:9997", 5));
assertFail(tabletMeta, new KeyExtent(TableId.of("1"), null, new Text("m")), tsi);
assertFail(tabletMeta, new KeyExtent(TableId.of("1"), new Text("r"), new Text("m")), tsi);
assertFail(tabletMeta, ke, tsi, newKey("1<", TabletColumnFamily.PREV_ROW_COLUMN));
assertFail(tabletMeta, ke, tsi, newKey("1<", ServerColumnFamily.DIRECTORY_COLUMN));
assertFail(tabletMeta, ke, tsi, newKey("1<", ServerColumnFamily.TIME_COLUMN));
assertFail(tabletMeta, ke, tsi, newKey("1<", FutureLocationColumnFamily.NAME, "4"));
TreeMap<Key, Value> copy = new TreeMap<>(tabletMeta);
put(copy, "1<", CurrentLocationColumnFamily.NAME, "4", "127.0.0.1:9997");
assertFail(copy, ke, tsi);
assertFail(copy, ke, tsi, newKey("1<", FutureLocationColumnFamily.NAME, "4"));
copy = new TreeMap<>(tabletMeta);
put(copy, "1<", CurrentLocationColumnFamily.NAME, "5", "127.0.0.1:9998");
assertFail(copy, ke, tsi);
put(copy, "1<", CurrentLocationColumnFamily.NAME, "6", "127.0.0.1:9999");
assertFail(copy, ke, tsi);
copy = new TreeMap<>(tabletMeta);
put(copy, "1<", FutureLocationColumnFamily.NAME, "5", "127.0.0.1:9998");
assertFail(copy, ke, tsi);
assertFail(new TreeMap<>(), ke, tsi);
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class ListTabletsCommand method getMetadataInfo.
protected List<TabletRowInfo> getMetadataInfo(Shell shellState, TableInfo tableInfo) throws Exception {
List<TabletRowInfo> results = new ArrayList<>();
final ClientContext context = shellState.getContext();
Set<TServerInstance> liveTserverSet = TabletMetadata.getLiveTServers(context);
try (var tabletsMetadata = TabletsMetadata.builder(context).forTable(tableInfo.id).build()) {
for (var md : tabletsMetadata) {
TabletRowInfo.Factory factory = new TabletRowInfo.Factory(tableInfo.name, md.getExtent());
var fileMap = md.getFilesMap();
factory.numFiles(fileMap.size());
long entries = 0L;
long size = 0L;
for (DataFileValue dfv : fileMap.values()) {
entries += dfv.getNumEntries();
size += dfv.getSize();
}
factory.numEntries(entries);
factory.size(size);
factory.numWalLogs(md.getLogs().size());
factory.dir(md.getDirName());
factory.location(md.getLocation());
factory.status(md.getTabletState(liveTserverSet).toString());
results.add(factory.build());
}
}
return results;
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class Tablet method resetLastLocation.
public TServerInstance resetLastLocation() {
TServerInstance result = lastLocation;
lastLocation = null;
return result;
}
Aggregations