Search in sources :

Example 1 with VolumeChooserEnvironment

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);
}
Also used : VolumeChooserEnvironment(org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment) VolumeChooserEnvironmentImpl(org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl) SiteConfiguration(org.apache.accumulo.core.conf.SiteConfiguration) Text(org.apache.hadoop.io.Text)

Example 2 with VolumeChooserEnvironment

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));
    }
}
Also used : TableId(org.apache.accumulo.core.data.TableId) ConfigurationCopy(org.apache.accumulo.core.conf.ConfigurationCopy) VolumeChooserEnvironment(org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment) VolumeChooserEnvironment(org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment) Test(org.junit.Test)

Example 3 with VolumeChooserEnvironment

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;
}
Also used : Path(org.apache.hadoop.fs.Path) VolumeChooserEnvironment(org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment) VolumeChooserEnvironmentImpl(org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl)

Example 4 with VolumeChooserEnvironment

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);
        }
    }
}
Also used : RecoveryPath(org.apache.accumulo.server.manager.recovery.RecoveryPath) Path(org.apache.hadoop.fs.Path) VolumeChooserEnvironment(org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment) VolumeChooserEnvironmentImpl(org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl)

Aggregations

VolumeChooserEnvironment (org.apache.accumulo.core.spi.fs.VolumeChooserEnvironment)4 VolumeChooserEnvironmentImpl (org.apache.accumulo.server.fs.VolumeChooserEnvironmentImpl)3 Path (org.apache.hadoop.fs.Path)2 ConfigurationCopy (org.apache.accumulo.core.conf.ConfigurationCopy)1 SiteConfiguration (org.apache.accumulo.core.conf.SiteConfiguration)1 TableId (org.apache.accumulo.core.data.TableId)1 RecoveryPath (org.apache.accumulo.server.manager.recovery.RecoveryPath)1 Text (org.apache.hadoop.io.Text)1 Test (org.junit.Test)1