Search in sources :

Example 11 with ConfigurationSource

use of org.apache.hadoop.hdds.conf.ConfigurationSource in project ozone by apache.

the class TestKeyValueContainer method testContainersShareColumnFamilyOptions.

@Test
public void testContainersShareColumnFamilyOptions() {
    ConfigurationSource conf = new OzoneConfiguration();
    // Make sure ColumnFamilyOptions are same for a particular db profile
    for (Supplier<DatanodeDBProfile> dbProfileSupplier : new Supplier[] { DatanodeDBProfile.Disk::new, DatanodeDBProfile.SSD::new }) {
        // ColumnFamilyOptions should be same across configurations
        ColumnFamilyOptions columnFamilyOptions1 = dbProfileSupplier.get().getColumnFamilyOptions(new OzoneConfiguration());
        ColumnFamilyOptions columnFamilyOptions2 = dbProfileSupplier.get().getColumnFamilyOptions(new OzoneConfiguration());
        Assert.assertEquals(columnFamilyOptions1, columnFamilyOptions2);
        // ColumnFamilyOptions should be same when queried multiple times
        // for a particulat configuration
        columnFamilyOptions1 = dbProfileSupplier.get().getColumnFamilyOptions(conf);
        columnFamilyOptions2 = dbProfileSupplier.get().getColumnFamilyOptions(conf);
        Assert.assertEquals(columnFamilyOptions1, columnFamilyOptions2);
    }
    // Make sure ColumnFamilyOptions are different for different db profile
    DatanodeDBProfile diskProfile = new DatanodeDBProfile.Disk();
    DatanodeDBProfile ssdProfile = new DatanodeDBProfile.SSD();
    Assert.assertNotEquals(diskProfile.getColumnFamilyOptions(new OzoneConfiguration()), ssdProfile.getColumnFamilyOptions(new OzoneConfiguration()));
    Assert.assertNotEquals(diskProfile.getColumnFamilyOptions(conf), ssdProfile.getColumnFamilyOptions(conf));
}
Also used : ColumnFamilyOptions(org.rocksdb.ColumnFamilyOptions) DatanodeDBProfile(org.apache.hadoop.ozone.container.common.utils.db.DatanodeDBProfile) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Supplier(java.util.function.Supplier) Test(org.junit.Test)

Example 12 with ConfigurationSource

use of org.apache.hadoop.hdds.conf.ConfigurationSource in project ozone by apache.

the class HttpServer2 method constructSecretProvider.

private static SignerSecretProvider constructSecretProvider(final Builder b, ServletContext ctx) throws Exception {
    final ConfigurationSource conf = b.conf;
    Properties config = getFilterProperties(conf, b.authFilterConfigurationPrefix);
    return AuthenticationFilter.constructSecretProvider(ctx, config, b.disallowFallbackToRandomSignerSecretProvider);
}
Also used : LegacyHadoopConfigurationSource(org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) MutableConfigurationSource(org.apache.hadoop.hdds.conf.MutableConfigurationSource) Properties(java.util.Properties)

Example 13 with ConfigurationSource

use of org.apache.hadoop.hdds.conf.ConfigurationSource in project ozone by apache.

the class TestReplicationConfig method testAdjustReplication.

@Test
public void testAdjustReplication() {
    ConfigurationSource conf = new OzoneConfiguration();
    ReplicationConfig replicationConfig = ReplicationConfig.parse(org.apache.hadoop.hdds.client.ReplicationType.valueOf(type), factor, conf);
    validate(ReplicationConfig.adjustReplication(replicationConfig, (short) 3, conf), org.apache.hadoop.hdds.client.ReplicationType.valueOf(type), org.apache.hadoop.hdds.client.ReplicationFactor.THREE);
    validate(ReplicationConfig.adjustReplication(replicationConfig, (short) 1, conf), org.apache.hadoop.hdds.client.ReplicationType.valueOf(type), org.apache.hadoop.hdds.client.ReplicationFactor.ONE);
}
Also used : ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) Test(org.junit.Test)

Example 14 with ConfigurationSource

use of org.apache.hadoop.hdds.conf.ConfigurationSource in project ozone by apache.

the class TestSimpleContainerDownloader method createDownloaderWithPredefinedFailures.

/**
 * Creates downloader which fails with datanodes in the arguments.
 *
 * @param directException if false the exception will be wrapped in the
 *                        returning future.
 */
private SimpleContainerDownloader createDownloaderWithPredefinedFailures(boolean directException, DatanodeDetails... failedDatanodes) {
    ConfigurationSource conf = new OzoneConfiguration();
    final List<DatanodeDetails> datanodes = Arrays.asList(failedDatanodes);
    return new SimpleContainerDownloader(conf, null) {

        // for retry testing we use predictable list of datanodes.
        @Override
        protected List<DatanodeDetails> shuffleDatanodes(List<DatanodeDetails> sourceDatanodes) {
            // turn off randomization
            return sourceDatanodes;
        }

        @Override
        protected CompletableFuture<Path> downloadContainer(long containerId, DatanodeDetails datanode) {
            if (datanodes.contains(datanode)) {
                if (directException) {
                    throw new RuntimeException("Unavailable datanode");
                } else {
                    return CompletableFuture.supplyAsync(() -> {
                        throw new RuntimeException("Unavailable datanode");
                    });
                }
            } else {
                // path includes the dn id to make it possible to assert.
                return CompletableFuture.completedFuture(Paths.get(datanode.getUuidString()));
            }
        }
    };
}
Also used : Path(java.nio.file.Path) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) MockDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) ArrayList(java.util.ArrayList) List(java.util.List)

Example 15 with ConfigurationSource

use of org.apache.hadoop.hdds.conf.ConfigurationSource in project ozone by apache.

the class ContainerPlacementPolicyFactory method getPolicy.

public static PlacementPolicy getPolicy(ConfigurationSource conf, final NodeManager nodeManager, NetworkTopology clusterMap, final boolean fallback, SCMContainerPlacementMetrics metrics) throws SCMException {
    final Class<? extends PlacementPolicy> placementClass = conf.getClass(ScmConfigKeys.OZONE_SCM_CONTAINER_PLACEMENT_IMPL_KEY, OZONE_SCM_CONTAINER_PLACEMENT_IMPL_DEFAULT, PlacementPolicy.class);
    Constructor<? extends PlacementPolicy> constructor;
    try {
        constructor = placementClass.getDeclaredConstructor(NodeManager.class, ConfigurationSource.class, NetworkTopology.class, boolean.class, SCMContainerPlacementMetrics.class);
        LOG.info("Create container placement policy of type {}", placementClass.getCanonicalName());
    } catch (NoSuchMethodException e) {
        String msg = "Failed to find constructor(NodeManager, Configuration, " + "NetworkTopology, boolean) for class " + placementClass.getCanonicalName();
        LOG.error(msg);
        throw new SCMException(msg, SCMException.ResultCodes.FAILED_TO_INIT_CONTAINER_PLACEMENT_POLICY);
    }
    try {
        return constructor.newInstance(nodeManager, conf, clusterMap, fallback, metrics);
    } catch (Exception e) {
        throw new RuntimeException("Failed to instantiate class " + placementClass.getCanonicalName() + " for " + e.getMessage());
    }
}
Also used : NodeManager(org.apache.hadoop.hdds.scm.node.NodeManager) ConfigurationSource(org.apache.hadoop.hdds.conf.ConfigurationSource) NetworkTopology(org.apache.hadoop.hdds.scm.net.NetworkTopology) SCMException(org.apache.hadoop.hdds.scm.exceptions.SCMException) SCMException(org.apache.hadoop.hdds.scm.exceptions.SCMException)

Aggregations

ConfigurationSource (org.apache.hadoop.hdds.conf.ConfigurationSource)19 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)8 LegacyHadoopConfigurationSource (org.apache.hadoop.hdds.utils.LegacyHadoopConfigurationSource)8 Test (org.junit.Test)5 IOException (java.io.IOException)4 MutableConfigurationSource (org.apache.hadoop.hdds.conf.MutableConfigurationSource)4 Before (org.junit.Before)3 URISyntaxException (java.net.URISyntaxException)2 List (java.util.List)2 Configuration (org.apache.hadoop.conf.Configuration)2 Path (org.apache.hadoop.fs.Path)2 InMemoryConfiguration (org.apache.hadoop.hdds.conf.InMemoryConfiguration)2 RpcClient (org.apache.hadoop.ozone.client.rpc.RpcClient)2 URIBuilder (org.apache.http.client.utils.URIBuilder)2 File (java.io.File)1 URI (java.net.URI)1 Path (java.nio.file.Path)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1