use of org.apache.commons.configuration2.Configuration in project hadoop by apache.
the class AzureBlobStorageTestAccount method createOutOfBandStore.
public static AzureBlobStorageTestAccount createOutOfBandStore(int uploadBlockSize, int downloadBlockSize) throws Exception {
saveMetricsConfigFile();
CloudBlobContainer container = null;
Configuration conf = createTestConfiguration();
CloudStorageAccount account = createTestAccount(conf);
if (null == account) {
return null;
}
String containerName = String.format("wasbtests-%s-%tQ", System.getProperty("user.name"), new Date());
// Create the container.
container = account.createCloudBlobClient().getContainerReference(containerName);
container.create();
String accountName = conf.get(TEST_ACCOUNT_NAME_PROPERTY_NAME);
// Ensure that custom throttling is disabled and tolerate concurrent
// out-of-band appends.
conf.setBoolean(KEY_DISABLE_THROTTLING, true);
conf.setBoolean(KEY_READ_TOLERATE_CONCURRENT_APPEND, true);
configureSecureModeTestSettings(conf);
// Set account URI and initialize Azure file system.
URI accountUri = createAccountUri(accountName, containerName);
// Set up instrumentation.
//
AzureFileSystemMetricsSystem.fileSystemStarted();
String sourceName = NativeAzureFileSystem.newMetricsSourceName();
String sourceDesc = "Azure Storage Volume File System metrics";
AzureFileSystemInstrumentation instrumentation = new AzureFileSystemInstrumentation(conf);
AzureFileSystemMetricsSystem.registerSource(sourceName, sourceDesc, instrumentation);
// Create a new AzureNativeFileSystemStore object.
AzureNativeFileSystemStore testStorage = new AzureNativeFileSystemStore();
// Initialize the store with the throttling feedback interfaces.
testStorage.initialize(accountUri, conf, instrumentation);
// Create test account initializing the appropriate member variables.
//
AzureBlobStorageTestAccount testAcct = new AzureBlobStorageTestAccount(testStorage, account, container);
return testAcct;
}
use of org.apache.commons.configuration2.Configuration in project hadoop by apache.
the class AzureBlobStorageTestAccount method create.
public static AzureBlobStorageTestAccount create(String containerNameSuffix, EnumSet<CreateOptions> createOptions, Configuration initialConfiguration) throws Exception {
saveMetricsConfigFile();
NativeAzureFileSystem fs = null;
CloudBlobContainer container = null;
Configuration conf = createTestConfiguration(initialConfiguration);
configurePageBlobDir(conf);
configureAtomicRenameDir(conf);
CloudStorageAccount account = createTestAccount(conf);
if (account == null) {
return null;
}
fs = new NativeAzureFileSystem();
String containerName = String.format("wasbtests-%s-%tQ%s", System.getProperty("user.name"), new Date(), containerNameSuffix);
container = account.createCloudBlobClient().getContainerReference(containerName);
if (createOptions.contains(CreateOptions.CreateContainer)) {
container.create();
}
String accountName = conf.get(TEST_ACCOUNT_NAME_PROPERTY_NAME);
if (createOptions.contains(CreateOptions.UseSas)) {
String sas = generateSAS(container, createOptions.contains(CreateOptions.Readonly));
if (!createOptions.contains(CreateOptions.CreateContainer)) {
// The caller doesn't want the container to be pre-created,
// so delete it now that we have generated the SAS.
container.delete();
}
// Remove the account key from the configuration to make sure we don't
// cheat and use that.
conf.set(ACCOUNT_KEY_PROPERTY_NAME + accountName, "");
// Set the SAS key.
conf.set(SAS_PROPERTY_NAME + containerName + "." + accountName, sas);
}
// appropriately.
if (createOptions.contains(CreateOptions.useThrottling)) {
conf.setBoolean(KEY_DISABLE_THROTTLING, false);
} else {
conf.setBoolean(KEY_DISABLE_THROTTLING, true);
}
configureSecureModeTestSettings(conf);
// Set account URI and initialize Azure file system.
URI accountUri = createAccountUri(accountName, containerName);
fs.initialize(accountUri, conf);
// Create test account initializing the appropriate member variables.
//
AzureBlobStorageTestAccount testAcct = new AzureBlobStorageTestAccount(fs, account, container);
return testAcct;
}
use of org.apache.commons.configuration2.Configuration in project cas by apereo.
the class CasConfigurationPropertiesEnvironmentManager method savePropertyForStandaloneProfile.
/**
* Save property for standalone profile.
*
* @param pair the pair
*/
public void savePropertyForStandaloneProfile(final Pair<String, String> pair) {
try {
final File file = getStandaloneProfileConfigurationDirectory();
final Parameters params = new Parameters();
final FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class).configure(params.properties().setFile(new File(file, getApplicationName() + ".properties")));
final Configuration config = builder.getConfiguration();
config.setProperty(pair.getKey(), pair.getValue());
builder.save();
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
use of org.apache.commons.configuration2.Configuration in project graylog2-server by Graylog2.
the class SearchesTest method setUp.
@Before
public void setUp() throws Exception {
when(indexRangeService.find(any(DateTime.class), any(DateTime.class))).thenReturn(INDEX_RANGES);
metricRegistry = new MetricRegistry();
searches = new Searches(new Configuration(), indexRangeService, client, metricRegistry, streamService, mock(Indices.class));
}
use of org.apache.commons.configuration2.Configuration in project graylog2-server by Graylog2.
the class ExposedConfigurationTest method testCreateWithConfiguration.
@Test
public void testCreateWithConfiguration() throws Exception {
final Configuration configuration = new Configuration();
final ExposedConfiguration c = ExposedConfiguration.create(configuration);
assertThat(c.inputBufferProcessors()).isEqualTo(configuration.getInputbufferProcessors());
assertThat(c.processBufferProcessors()).isEqualTo(configuration.getProcessBufferProcessors());
assertThat(c.outputBufferProcessors()).isEqualTo(configuration.getOutputBufferProcessors());
assertThat(c.processorWaitStrategy()).isEqualTo(configuration.getProcessorWaitStrategy().getClass().getName());
assertThat(c.inputBufferWaitStrategy()).isEqualTo(configuration.getInputBufferWaitStrategy().getClass().getName());
assertThat(c.inputBufferRingSize()).isEqualTo(configuration.getInputBufferRingSize());
assertThat(c.ringSize()).isEqualTo(configuration.getRingSize());
assertThat(c.pluginDir()).isEqualTo(configuration.getPluginDir());
assertThat(c.nodeIdFile()).isEqualTo(configuration.getNodeIdFile());
assertThat(c.allowHighlighting()).isEqualTo(configuration.isAllowHighlighting());
assertThat(c.allowLeadingWildcardSearches()).isEqualTo(configuration.isAllowLeadingWildcardSearches());
assertThat(c.streamProcessingTimeout()).isEqualTo(configuration.getStreamProcessingTimeout());
assertThat(c.streamProcessingMaxFaults()).isEqualTo(configuration.getStreamProcessingMaxFaults());
assertThat(c.outputModuleTimeout()).isEqualTo(configuration.getOutputModuleTimeout());
assertThat(c.staleMasterTimeout()).isEqualTo(configuration.getStaleMasterTimeout());
assertThat(c.gcWarningThreshold()).isEqualTo(configuration.getGcWarningThreshold().toString());
}
Aggregations