use of org.apache.accumulo.server.metadata.RootGcCandidates in project accumulo by apache.
the class ZooKeeperInitializer method initialize.
void initialize(ZooReaderWriter zoo, boolean clearInstanceName, InstanceId iid, String instanceNamePath, String rootTabletDirName, String rootTabletFileUri) throws KeeperException, InterruptedException {
// setup basic data in zookeeper
zoo.putPersistentData(Constants.ZROOT, new byte[0], ZooUtil.NodeExistsPolicy.SKIP, ZooDefs.Ids.OPEN_ACL_UNSAFE);
zoo.putPersistentData(Constants.ZROOT + Constants.ZINSTANCES, new byte[0], ZooUtil.NodeExistsPolicy.SKIP, ZooDefs.Ids.OPEN_ACL_UNSAFE);
// setup instance name
if (clearInstanceName) {
zoo.recursiveDelete(instanceNamePath, ZooUtil.NodeMissingPolicy.SKIP);
}
zoo.putPersistentData(instanceNamePath, iid.canonical().getBytes(UTF_8), ZooUtil.NodeExistsPolicy.FAIL);
final byte[] EMPTY_BYTE_ARRAY = new byte[0];
final byte[] ZERO_CHAR_ARRAY = { '0' };
// setup the instance
String zkInstanceRoot = Constants.ZROOT + "/" + iid;
zoo.putPersistentData(zkInstanceRoot, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZTABLES, Constants.ZTABLES_INITIAL_ID, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZNAMESPACES, new byte[0], ZooUtil.NodeExistsPolicy.FAIL);
TableManager.prepareNewNamespaceState(zoo, iid, Namespace.DEFAULT.id(), Namespace.DEFAULT.name(), ZooUtil.NodeExistsPolicy.FAIL);
TableManager.prepareNewNamespaceState(zoo, iid, Namespace.ACCUMULO.id(), Namespace.ACCUMULO.name(), ZooUtil.NodeExistsPolicy.FAIL);
TableManager.prepareNewTableState(zoo, iid, RootTable.ID, Namespace.ACCUMULO.id(), RootTable.NAME, TableState.ONLINE, ZooUtil.NodeExistsPolicy.FAIL);
TableManager.prepareNewTableState(zoo, iid, MetadataTable.ID, Namespace.ACCUMULO.id(), MetadataTable.NAME, TableState.ONLINE, ZooUtil.NodeExistsPolicy.FAIL);
@SuppressWarnings("deprecation") String replicationTableName = org.apache.accumulo.core.replication.ReplicationTable.NAME;
TableManager.prepareNewTableState(zoo, iid, REPL_TABLE_ID, Namespace.ACCUMULO.id(), replicationTableName, TableState.OFFLINE, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZTSERVERS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZPROBLEMS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + RootTable.ZROOT_TABLET, RootTabletMetadata.getInitialJson(rootTabletDirName, rootTabletFileUri), ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + RootTable.ZROOT_TABLET_GC_CANDIDATES, new RootGcCandidates().toJson().getBytes(UTF_8), ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZMANAGERS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZMANAGER_LOCK, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZMANAGER_GOAL_STATE, ManagerGoalState.NORMAL.toString().getBytes(UTF_8), ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZGC, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZGC_LOCK, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZCONFIG, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZTABLE_LOCKS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZHDFS_RESERVATIONS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZNEXT_FILE, ZERO_CHAR_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZRECOVERY, ZERO_CHAR_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZMONITOR, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZMONITOR_LOCK, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
@SuppressWarnings("deprecation") String replicationZBase = org.apache.accumulo.core.replication.ReplicationConstants.ZOO_BASE;
zoo.putPersistentData(zkInstanceRoot + replicationZBase, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
@SuppressWarnings("deprecation") String replicationZServers = org.apache.accumulo.core.replication.ReplicationConstants.ZOO_TSERVERS;
zoo.putPersistentData(zkInstanceRoot + replicationZServers, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + WalStateManager.ZWALS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZCOORDINATOR, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZCOORDINATOR_LOCK, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
zoo.putPersistentData(zkInstanceRoot + Constants.ZCOMPACTORS, EMPTY_BYTE_ARRAY, ZooUtil.NodeExistsPolicy.FAIL);
}
use of org.apache.accumulo.server.metadata.RootGcCandidates in project accumulo by apache.
the class Upgrader9to10 method upgradeRootTabletMetadata.
/**
* Improvements to the metadata and root tables were made in this version. See pull request
* <a href="https://github.com/apache/accumulo/pull/1174">#1174</a> for more details.
*/
private void upgradeRootTabletMetadata(ServerContext context) {
String rootMetaSer = getFromZK(context, ZROOT_TABLET);
if (rootMetaSer == null || rootMetaSer.isEmpty()) {
String dir = getFromZK(context, ZROOT_TABLET_PATH);
List<LogEntry> logs = getRootLogEntries(context);
TServerInstance last = getLocation(context, ZROOT_TABLET_LAST_LOCATION);
TServerInstance future = getLocation(context, ZROOT_TABLET_FUTURE_LOCATION);
TServerInstance current = getLocation(context, ZROOT_TABLET_LOCATION);
UpgradeMutator tabletMutator = new UpgradeMutator(context);
tabletMutator.putPrevEndRow(RootTable.EXTENT.prevEndRow());
tabletMutator.putDirName(upgradeDirColumn(dir));
if (last != null)
tabletMutator.putLocation(last, LocationType.LAST);
if (future != null)
tabletMutator.putLocation(future, LocationType.FUTURE);
if (current != null)
tabletMutator.putLocation(current, LocationType.CURRENT);
logs.forEach(tabletMutator::putWal);
Map<String, DataFileValue> files = cleanupRootTabletFiles(context.getVolumeManager(), dir);
files.forEach((path, dfv) -> tabletMutator.putFile(new TabletFile(new Path(path)), dfv));
tabletMutator.putTime(computeRootTabletTime(context, files.keySet()));
tabletMutator.mutate();
}
try {
context.getZooReaderWriter().putPersistentData(context.getZooKeeperRoot() + ZROOT_TABLET_GC_CANDIDATES, new RootGcCandidates().toJson().getBytes(UTF_8), NodeExistsPolicy.SKIP);
} catch (KeeperException | InterruptedException e) {
throw new RuntimeException(e);
}
// this operation must be idempotent, so deleting after updating is very important
delete(context, ZROOT_TABLET_CURRENT_LOGS);
delete(context, ZROOT_TABLET_FUTURE_LOCATION);
delete(context, ZROOT_TABLET_LAST_LOCATION);
delete(context, ZROOT_TABLET_LOCATION);
delete(context, ZROOT_TABLET_WALOGS);
delete(context, ZROOT_TABLET_PATH);
}
Aggregations