Search in sources :

Example 6 with Configuration

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;
}
Also used : AzureFileSystemInstrumentation(org.apache.hadoop.fs.azure.metrics.AzureFileSystemInstrumentation) SubsetConfiguration(org.apache.commons.configuration2.SubsetConfiguration) Configuration(org.apache.hadoop.conf.Configuration) URI(java.net.URI)

Example 7 with Configuration

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;
}
Also used : SubsetConfiguration(org.apache.commons.configuration2.SubsetConfiguration) Configuration(org.apache.hadoop.conf.Configuration) URI(java.net.URI)

Example 8 with Configuration

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);
    }
}
Also used : Parameters(org.apache.commons.configuration2.builder.fluent.Parameters) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) FileBasedConfiguration(org.apache.commons.configuration2.FileBasedConfiguration) Configuration(org.apache.commons.configuration2.Configuration) FileBasedConfiguration(org.apache.commons.configuration2.FileBasedConfiguration) File(java.io.File) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration)

Example 9 with Configuration

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));
}
Also used : Configuration(org.graylog2.Configuration) MetricRegistry(com.codahale.metrics.MetricRegistry) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Example 10 with Configuration

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());
}
Also used : Configuration(org.graylog2.Configuration) Test(org.junit.Test)

Aggregations

SubsetConfiguration (org.apache.commons.configuration2.SubsetConfiguration)10 Configuration (org.graylog2.Configuration)10 Test (org.junit.Test)9 Configuration (org.apache.hadoop.conf.Configuration)8 URI (java.net.URI)7 Configuration (org.apache.commons.configuration2.Configuration)5 Before (org.junit.Before)5 PropertiesConfiguration (org.apache.commons.configuration2.PropertiesConfiguration)4 MetricRegistry (com.codahale.metrics.MetricRegistry)2 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 Parameters (org.apache.commons.configuration2.builder.fluent.Parameters)2 ConfigurationException (org.apache.commons.configuration2.ex.ConfigurationException)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 Path (org.apache.hadoop.fs.Path)2 Role (org.graylog2.shared.users.Role)2 UserService (org.graylog2.shared.users.UserService)2 EventBus (com.google.common.eventbus.EventBus)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1