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));
}
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);
}
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);
}
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()));
}
}
};
}
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());
}
}
Aggregations