use of org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment in project accumulo by apache.
the class FileSystemInitializer method initialize.
void initialize(VolumeManager fs, String rootTabletDirUri, String rootTabletFileUri, ServerContext context) throws IOException, InterruptedException, KeeperException {
SiteConfiguration siteConfig = initConfig.getSiteConf();
// initialize initial system tables config in zookeeper
initSystemTablesConfig();
Text splitPoint = MetadataSchema.TabletsSection.getRange().getEndKey().getRow();
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironmentImpl(VolumeChooserEnvironment.Scope.INIT, MetadataTable.ID, splitPoint, context);
String tableMetadataTabletDirName = TABLE_TABLETS_TABLET_DIR;
String tableMetadataTabletDirUri = fs.choose(chooserEnv, context.getBaseUris()) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + MetadataTable.ID + Path.SEPARATOR + tableMetadataTabletDirName;
chooserEnv = new VolumeChooserEnvironmentImpl(VolumeChooserEnvironment.Scope.INIT, REPL_TABLE_ID, null, context);
String replicationTableDefaultTabletDirName = MetadataSchema.TabletsSection.ServerColumnFamily.DEFAULT_TABLET_DIR_NAME;
String replicationTableDefaultTabletDirUri = fs.choose(chooserEnv, context.getBaseUris()) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + REPL_TABLE_ID + Path.SEPARATOR + replicationTableDefaultTabletDirName;
chooserEnv = new VolumeChooserEnvironmentImpl(VolumeChooserEnvironment.Scope.INIT, MetadataTable.ID, null, context);
String defaultMetadataTabletDirName = MetadataSchema.TabletsSection.ServerColumnFamily.DEFAULT_TABLET_DIR_NAME;
String defaultMetadataTabletDirUri = fs.choose(chooserEnv, context.getBaseUris()) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + MetadataTable.ID + Path.SEPARATOR + defaultMetadataTabletDirName;
// create table and default tablets directories
createDirectories(fs, rootTabletDirUri, tableMetadataTabletDirUri, defaultMetadataTabletDirUri, replicationTableDefaultTabletDirUri);
String ext = FileOperations.getNewFileExtension(DefaultConfiguration.getInstance());
// populate the metadata tablet with info about the replication tablet
String metadataFileName = tableMetadataTabletDirUri + Path.SEPARATOR + "0_1." + ext;
Tablet replicationTablet = new Tablet(REPL_TABLE_ID, replicationTableDefaultTabletDirName, null, null);
createMetadataFile(fs, metadataFileName, siteConfig, replicationTablet);
// populate the root tablet with info about the metadata table's two initial tablets
Tablet tablesTablet = new Tablet(MetadataTable.ID, tableMetadataTabletDirName, null, splitPoint, metadataFileName);
Tablet defaultTablet = new Tablet(MetadataTable.ID, defaultMetadataTabletDirName, splitPoint, null);
createMetadataFile(fs, rootTabletFileUri, siteConfig, tablesTablet, defaultTablet);
}
use of org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment in project accumulo by apache.
the class VolumeManagerImplTest method chooseFromOptions.
// Expected to throw a runtime exception when the WrongVolumeChooser picks an invalid volume.
@Test
public void chooseFromOptions() throws Exception {
Set<String> volumes = Set.of("file://one/", "file://two/", "file://three/");
ConfigurationCopy conf = new ConfigurationCopy();
conf.set(Property.INSTANCE_VOLUMES, String.join(",", volumes));
conf.set(Property.GENERAL_VOLUME_CHOOSER, WrongVolumeChooser.class.getName());
try (var vm = VolumeManagerImpl.get(conf, hadoopConf)) {
org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment() {
@Override
public Optional<TableId> getTable() {
throw new UnsupportedOperationException();
}
@Override
public ServiceEnvironment getServiceEnv() {
throw new UnsupportedOperationException();
}
@Override
public Text getEndRow() {
throw new UnsupportedOperationException();
}
@Override
public Scope getChooserScope() {
throw new UnsupportedOperationException();
}
};
assertThrows(RuntimeException.class, () -> vm.choose(chooserEnv, volumes));
}
}
use of org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment in project accumulo by apache.
the class Tablet method chooseTabletDir.
private String chooseTabletDir() throws IOException {
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironmentImpl(extent.tableId(), extent.endRow(), context);
String dirUri = tabletServer.getVolumeManager().choose(chooserEnv, context.getBaseUris()) + Constants.HDFS_TABLES_DIR + Path.SEPARATOR + extent.tableId() + Path.SEPARATOR + dirName;
checkTabletDir(new Path(dirUri));
return dirUri;
}
use of org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment in project accumulo by apache.
the class TabletServer method checkWalCanSync.
private static void checkWalCanSync(ServerContext context) {
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironmentImpl(VolumeChooserEnvironment.Scope.LOGGER, context);
Set<String> prefixes;
var options = context.getBaseUris();
try {
prefixes = context.getVolumeManager().choosable(chooserEnv, options);
} catch (RuntimeException e) {
log.warn("Unable to determine if WAL directories ({}) support sync or flush. " + "Data loss may occur.", Arrays.asList(options), e);
return;
}
boolean warned = false;
for (String prefix : prefixes) {
String logPath = prefix + Path.SEPARATOR + Constants.WAL_DIR;
if (!context.getVolumeManager().canSyncAndFlush(new Path(logPath))) {
// time to start so the warning will be more visible
if (!warned) {
UtilWaitThread.sleep(5000);
warned = true;
}
log.warn("WAL directory ({}) implementation does not support sync or flush." + " Data loss may occur.", logPath);
}
}
}
Aggregations