org.apache.commons.configuration.Configuration Java Examples

The following examples show how to use org.apache.commons.configuration.Configuration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: S3PinotFS.java    From incubator-pinot with Apache License 2.0 7 votes vote down vote up
@Override
public void init(Configuration config) {
  Preconditions.checkArgument(!isNullOrEmpty(config.getString(REGION)));
  String region = config.getString(REGION);

  AwsCredentialsProvider awsCredentialsProvider;
  try {

    if (!isNullOrEmpty(config.getString(ACCESS_KEY)) && !isNullOrEmpty(config.getString(SECRET_KEY))) {
      String accessKey = config.getString(ACCESS_KEY);
      String secretKey = config.getString(SECRET_KEY);
      AwsBasicCredentials awsBasicCredentials = AwsBasicCredentials.create(accessKey, secretKey);
      awsCredentialsProvider = StaticCredentialsProvider.create(awsBasicCredentials);
    } else {
      awsCredentialsProvider =
          AwsCredentialsProviderChain.builder().addCredentialsProvider(SystemPropertyCredentialsProvider.create())
              .addCredentialsProvider(EnvironmentVariableCredentialsProvider.create()).build();
    }

    _s3Client = S3Client.builder().region(Region.of(region)).credentialsProvider(awsCredentialsProvider).build();
  } catch (S3Exception e) {
    throw new RuntimeException("Could not initialize S3PinotFS", e);
  }
}
 
Example #2
Source File: CustomBenchmark.java    From ldbc_graphalytics with Apache License 2.0 6 votes vote down vote up
public CustomBenchmark(String type, String platformName,
                       Path baseReportDir, Path baseOutputDir, Path baseValidationDir,
                       Map<String, Graph> foundGraphs, Map<String, Map<Algorithm, AlgorithmParameters>> algorithmParameters) {

    super(platformName, true, true,
            baseReportDir, baseOutputDir, baseValidationDir,
            foundGraphs, algorithmParameters);
    this.baseReportDir = formatReportDirectory(baseReportDir, platformName, type);
    this.type = type;

    Configuration benchmarkConfiguration = ConfigurationUtil.loadConfiguration(BENCHMARK_PROPERTIES_FILE);
    this.timeout = ConfigurationUtil.getInteger(benchmarkConfiguration, BENCHMARK_RUN_TIMEOUT_KEY);

    this.validationRequired = ConfigurationUtil.getBoolean(benchmarkConfiguration, BENCHMARK_RUN_VALIDATION_REQUIRED_KEY);
    this.outputRequired = ConfigurationUtil.getBoolean(benchmarkConfiguration, BENCHMARK_RUN_OUTPUT_REQUIRED_KEY);
    this.isWriteResultsDirectlyEnabled = ConfigurationUtil.getBooleanIfExists(benchmarkConfiguration, BENCHMARK_WRITE_RESULT_AFTER_EACH_JOB);

    if (this.validationRequired && !this.outputRequired) {
        LOG.warn("Validation can only be enabled if output is generated. "
                + "Please enable the key " + BENCHMARK_RUN_OUTPUT_REQUIRED_KEY + " in your configuration.");
        LOG.info("Validation will be disabled for all benchmarks.");
        this.validationRequired = false;
    }

}
 
Example #3
Source File: ConfigurationMapEntryUtils.java    From cognition with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts map entries from configuration.
 *
 * @param conf
 * @param mappingEntry
 * @param fields       first field should be unique and exist in all entries, other fields are optional from map
 * @return
 */
public static Map<String, Map<String, String>> extractMapList(
    final Configuration conf,
    final String mappingEntry,
    final String... fields) {
  String keyField = fields[0];
  List<Object> keys = conf.getList(mappingEntry + "." + keyField);
  Map<String, Map<String, String>> maps = new HashMap<>(keys.size());

  for (int i = 0; i < keys.size(); i++) {
    Map<String, String> map = new HashMap<>();
    Object key = keys.get(i);
    map.put(keyField, key.toString());

    for (int j = 1; j < fields.length; j++) {
      String field = fields[j];
      String fieldPath = String.format("%s(%s).%s", mappingEntry, i, field);
      String value = conf.getString(fieldPath);
      if (value != null)
        map.put(field, value);
    }

    maps.put(key.toString(), map);
  }
  return maps;
}
 
Example #4
Source File: ValidatePublish.java    From juddi with Apache License 2.0 6 votes vote down vote up
public void validateBindingTemplates(EntityManager em, org.uddi.api_v3.BindingTemplates bindingTemplates,
        org.uddi.api_v3.BusinessService parent, Configuration config, UddiEntityPublisher publisher)
        throws DispositionReportFaultMessage {
        // Binding templates is optional
        if (bindingTemplates == null) {
                return;
        }

        List<org.uddi.api_v3.BindingTemplate> bindingTemplateList = bindingTemplates.getBindingTemplate();
        if (bindingTemplateList == null || bindingTemplateList.size() == 0) {
                throw new ValueNotAllowedException(new ErrorMessage("errors.bindingtemplates.NoInput"));
        }

        for (org.uddi.api_v3.BindingTemplate bindingTemplate : bindingTemplateList) {
                validateBindingTemplate(em, bindingTemplate, parent, config, publisher);
        }

}
 
Example #5
Source File: ValidatePublish.java    From juddi with Apache License 2.0 6 votes vote down vote up
public void validateCategoryBag(org.uddi.api_v3.CategoryBag categories, Configuration config, boolean isRoot) throws DispositionReportFaultMessage {

                // Category bag is optional
                if (categories == null) {
                        return;
                }

                // If category bag does exist, it must have at least one element
                List<KeyedReference> elems = categories.getKeyedReference();
                List<KeyedReferenceGroup> groups = categories.getKeyedReferenceGroup();
                if (groups.size() == 0 && elems.size() == 0) {
                        throw new ValueNotAllowedException(new ErrorMessage("errors.categorybag.NoInput"));
                }

                for (KeyedReferenceGroup group : groups) {
                        validateKeyedReferenceGroup(group, config, isRoot);
                }

                for (KeyedReference elem : elems) {
                        validateKeyedReference(elem, config, isRoot);
                }
        }
 
Example #6
Source File: TestConfigurePropertyUtils.java    From servicecomb-java-chassis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetPropertiesWithPrefix() {
  ClassLoaderScopeContext.clearClassLoaderScopeProperty();
  Configuration configuration = ConfigUtil.createLocalConfig();

  String prefix = "service_description.properties";
  Map<String, String> expectedMap = new HashMap<>();
  expectedMap.put("key1", "value1");
  expectedMap.put("key2", "value2");
  Assert.assertEquals(expectedMap, ConfigurePropertyUtils.getPropertiesWithPrefix(configuration, prefix));

  List<BasePath> paths = ConfigurePropertyUtils.getMicroservicePaths(configuration);
  Assert.assertEquals(2, paths.size());
  Assert.assertEquals(paths.get(0).getPath(), "/test1/testpath");
  Assert.assertEquals(paths.get(0).getProperty().get("checksession"), false);

  ClassLoaderScopeContext.setClassLoaderScopeProperty(DefinitionConst.URL_PREFIX, "/webroot");
  paths = ConfigurePropertyUtils.getMicroservicePaths(configuration);
  Assert.assertEquals(2, paths.size());
  Assert.assertEquals(paths.get(0).getPath(), "/webroot/test1/testpath");
  Assert.assertEquals(paths.get(0).getProperty().get("checksession"), false);
  ClassLoaderScopeContext.clearClassLoaderScopeProperty();
}
 
Example #7
Source File: ResourceManager.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
/**
 * @param config configuration for initializing resource manager
 */
public ResourceManager(Configuration config) {
  numQueryRunnerThreads = config.getInt(QUERY_RUNNER_CONFIG_KEY, DEFAULT_QUERY_RUNNER_THREADS);
  numQueryWorkerThreads = config.getInt(QUERY_WORKER_CONFIG_KEY, DEFAULT_QUERY_WORKER_THREADS);

  LOGGER.info("Initializing with {} query runner threads and {} worker threads", numQueryRunnerThreads,
      numQueryWorkerThreads);
  // pqr -> pinot query runner (to give short names)
  ThreadFactory queryRunnerFactory =
      new ThreadFactoryBuilder().setDaemon(false).setPriority(QUERY_RUNNER_THREAD_PRIORITY).setNameFormat("pqr-%d")
          .build();
  queryRunners =
      MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(numQueryRunnerThreads, queryRunnerFactory));

  // pqw -> pinot query workers
  ThreadFactory queryWorkersFactory =
      new ThreadFactoryBuilder().setDaemon(false).setPriority(Thread.NORM_PRIORITY).setNameFormat("pqw-%d").build();
  queryWorkers =
      MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(numQueryWorkerThreads, queryWorkersFactory));
}
 
Example #8
Source File: AtlasKeycloakAuthenticationProvider.java    From atlas with Apache License 2.0 5 votes vote down vote up
public AtlasKeycloakAuthenticationProvider() throws Exception {
  this.keycloakAuthenticationProvider = new KeycloakAuthenticationProvider();

  Configuration configuration = ApplicationProperties.get();
  this.groupsFromUGI = configuration.getBoolean("atlas.authentication.method.keycloak.ugi-groups", true);
  this.groupsClaim = configuration.getString("atlas.authentication.method.keycloak.groups_claim");
}
 
Example #9
Source File: Install.java    From juddi with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if there is a database with a root publisher. If it is not
 * found an
 *
 * @param config
 * @return true if it finds a database with the root publisher in it.
 * @throws ConfigurationException
 */
protected static boolean alreadyInstalled(Configuration config) throws ConfigurationException {

        String rootPublisherStr = config.getString(Property.JUDDI_ROOT_PUBLISHER);
        log.info("Checking if jUDDI is seeded by searching for root publisher " + rootPublisherStr);
        org.apache.juddi.model.Publisher publisher = null;
        int numberOfTries = 0;
        while (numberOfTries++ < 100) {
                EntityManager em = PersistenceManager.getEntityManager();
                EntityTransaction tx = em.getTransaction();
                try {
                        tx.begin();
                        publisher = em.find(org.apache.juddi.model.Publisher.class, rootPublisherStr);
                        tx.commit();
                } finally {
                        if (tx.isActive()) {
                                tx.rollback();
                        }
                        em.close();
                }
                if (publisher != null) {
                        return true;
                }

                if (config.getBoolean(Property.JUDDI_LOAD_INSTALL_DATA, Property.DEFAULT_LOAD_INSTALL_DATA)) {
                        log.debug("Install data not yet installed.");
                        return false;
                } else {
                        try {
                                log.info("Install data not yet installed.");
                                log.info("Going to sleep and retry...");
                                Thread.sleep(1000l);
                        } catch (InterruptedException e) {
                                log.error(e.getMessage(), e);
                        }
                }
        }
        throw new ConfigurationException("Could not load the Root node data. Please check for errors.");
}
 
Example #10
Source File: ServerStarterIntegrationTest.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetInstanceIdToHostname()
    throws Exception {
  Configuration serverConf = new BaseConfiguration();
  serverConf.addProperty(SET_INSTANCE_ID_TO_HOSTNAME_KEY, true);
  String expectedHost = NetUtil.getHostnameOrAddress();
  String expectedInstanceId = PREFIX_OF_SERVER_INSTANCE + expectedHost + "_" + DEFAULT_SERVER_NETTY_PORT;
  verifyInstanceConfig(serverConf, expectedInstanceId, expectedHost, DEFAULT_SERVER_NETTY_PORT);
}
 
Example #11
Source File: ConfigurationProvider.java    From googleads-java-lib with Apache License 2.0 5 votes vote down vote up
@Override
public Configuration get() {
  try {
    return configurationHelper.createCombinedConfiguration(propertyFilePaths, propertyUrls);
  } catch (ConfigurationLoadException e) {
    throw new IllegalArgumentException("Configuration could be loaded.", e);
  }
}
 
Example #12
Source File: AtlasBaseClient.java    From atlas with Apache License 2.0 5 votes vote down vote up
void initializeState(Configuration configuration, String[] baseUrls, UserGroupInformation ugi, String doAsUser) {
    this.configuration = configuration;
    Client client = getClient(configuration, ugi, doAsUser);

    if ((!AuthenticationUtil.isKerberosAuthenticationEnabled()) && basicAuthUser != null && basicAuthPassword != null) {
        final HTTPBasicAuthFilter authFilter = new HTTPBasicAuthFilter(basicAuthUser, basicAuthPassword);
        client.addFilter(authFilter);
    }

    String activeServiceUrl = determineActiveServiceURL(baseUrls, client);
    atlasClientContext = new AtlasClientContext(baseUrls, client, ugi, doAsUser);
    service = client.resource(UriBuilder.fromUri(activeServiceUrl).build());
}
 
Example #13
Source File: DefaultMetadataService.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@Inject
public DefaultMetadataService(final MetadataRepository repository, final ITypeStore typeStore,
                              final Set<TypesChangeListener> typesChangeListeners,
                              final Set<EntityChangeListener> entityChangeListeners,
                              final TypeSystem typeSystem,
                              final Configuration configuration,
                              TypeCache typeCache,
                              EntityAuditRepository auditRepository) throws AtlasException {
    this.typeStore = typeStore;
    this.typeSystem = typeSystem;
    /**
     * Ideally a TypeCache implementation should have been injected in the TypeSystemProvider,
     * but a singleton of TypeSystem is constructed privately within the class so that
     * clients of TypeSystem would never instantiate a TypeSystem object directly in
     * their code. As soon as a client makes a call to TypeSystem.getInstance(), they
     * should have the singleton ready for consumption. Manually inject TypeSystem with
     * the Guice-instantiated type cache here, before types are restored.
     * This allows cache implementations to participate in Guice dependency injection.
     */
    this.typeSystem.setTypeCache(typeCache);

    this.repository = repository;

    this.typeChangeListeners.addAll(typesChangeListeners);

    this.entityChangeListeners.addAll(entityChangeListeners);

    if (!HAConfiguration.isHAEnabled(configuration)) {
        restoreTypeSystem();
    }

    maxAuditResults = configuration.getShort(CONFIG_MAX_AUDIT_RESULTS, DEFAULT_MAX_AUDIT_RESULTS);

    this.auditRepository = auditRepository;
}
 
Example #14
Source File: Parallelized.java    From es6draft with MIT License 5 votes vote down vote up
protected int numberOfThreads(Class<?> klass) {
    Concurrency concurrency = klass.getAnnotation(Concurrency.class);
    int threads;
    int maxThreads;
    float factor;
    if (concurrency != null) {
        threads = concurrency.threads();
        maxThreads = concurrency.maxThreads();
        factor = concurrency.factor();
    } else {
        threads = getDefaultValue(Concurrency.class, "threads", Integer.class);
        maxThreads = getDefaultValue(Concurrency.class, "maxThreads", Integer.class);
        factor = getDefaultValue(Concurrency.class, "factor", Float.class);
    }

    TestConfiguration testConfiguration = klass.getAnnotation(TestConfiguration.class);
    if (testConfiguration != null) {
        Configuration configuration = Resources.loadConfiguration(testConfiguration);
        int configThreads = configuration.getInt("concurrency.threads", -1);
        if (configThreads > 0) {
            threads = configThreads;
        }
        int configMaxThreads = configuration.getInt("concurrency.maxThreads", -1);
        if (configMaxThreads > 0) {
            factor = configMaxThreads;
        }
        float configFactor = configuration.getFloat("concurrency.factor", -1f);
        if (configFactor > 0) {
            factor = configFactor;
        }
    }

    threads = threads > 0 ? threads : Runtime.getRuntime().availableProcessors();
    maxThreads = Math.max(maxThreads, 1);
    factor = Math.max(factor, 0);
    return Math.min(Math.max((int) Math.round(threads * factor), 1), maxThreads);
}
 
Example #15
Source File: BlurIndex.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
public BlurIndex(Configuration config) {
  _tableNamePrefix = config.getString(BLUR_TABLE_PREFIX, DEFAULT_TABLE_NAME_PREFIX);
  _defaultShardCount = config.getInt(BLUR_TABLE_DEFAULT_SHARD_COUNT, DEFAULT_SHARD_COUNT);
  _controllerConnectionString = config.getString(BLUR_CONTROLLER_CONNECTION, "");
  _family = config.getString(BLUR_FAMILY_DEFAULT, TITAN);
  _waitToBeVisible = config.getBoolean(BLUR_WAIT_TO_BE_VISIBLE, DEFAULT_BLUR_WAIT_TO_BE_VISIBLE);
  _wal = config.getBoolean(BLUR_WRITE_AHEAD_LOG, DEFAULT_BLUR_WRITE_AHEAD_LOG);
  Preconditions.checkArgument(StringUtils.isNotBlank(_controllerConnectionString),
      "Need to configure connection string for Blur (" + BLUR_CONTROLLER_CONNECTION + ")");
  LOG.info("Blur using connection [" + _controllerConnectionString + "] with table prefix of [" + _tableNamePrefix
      + "]");
}
 
Example #16
Source File: HelixServerStarter.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * This method is for reference purpose only.
 */
@SuppressWarnings("UnusedReturnValue")
public static HelixServerStarter startDefault()
    throws Exception {
  Configuration serverConf = new BaseConfiguration();
  int port = 8003;
  serverConf.addProperty(KEY_OF_SERVER_NETTY_PORT, port);
  serverConf.addProperty(CONFIG_OF_INSTANCE_DATA_DIR, "/tmp/PinotServer/test" + port + "/index");
  serverConf.addProperty(CONFIG_OF_INSTANCE_SEGMENT_TAR_DIR, "/tmp/PinotServer/test" + port + "/segmentTar");
  HelixServerStarter serverStarter = new HelixServerStarter("quickstart", "localhost:2191", serverConf);
  serverStarter.start();
  return serverStarter;
}
 
Example #17
Source File: RepairIndex.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static String[] getAtlasRESTUrl() {
    Configuration atlasConf = null;
    try {
        atlasConf = ApplicationProperties.get();
        return atlasConf.getStringArray(APPLICATION_PROPERTY_ATLAS_ENDPOINT);
    } catch (AtlasException e) {
        return new String[]{DEFAULT_ATLAS_URL};
    }
}
 
Example #18
Source File: NotificationHookConsumer.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
void startInternal(Configuration configuration, ExecutorService executorService) {
    if (consumers == null) {
        consumers = new ArrayList<>();
    }
    if (executorService != null) {
        executors = executorService;
    }
    if (!HAConfiguration.isHAEnabled(configuration)) {
        LOG.info("HA is disabled, starting consumers inline.");
        startConsumers(executorService);
    }
}
 
Example #19
Source File: SqoopHookIT.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public void setUp() throws Exception {
    //Set-up sqoop session
    Configuration configuration = ApplicationProperties.get();
    if (!AuthenticationUtil.isKerberosAuthenticationEnabled()) {
        atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT), new String[]{"admin", "admin"});
    } else {
        atlasClient = new AtlasClient(configuration.getStringArray(HiveMetaStoreBridge.ATLAS_ENDPOINT));
    }
}
 
Example #20
Source File: ConfigurationHelperTest.java    From googleads-java-lib with Apache License 2.0 5 votes vote down vote up
@Test
public void testFromFile_urlClasspathExists() throws Exception {
  Configuration configuration =
      configurationHelper.fromFile(ConfigurationHelperTest.class
          .getResource("props/test1.properties"));
  assertPropertiesEquals(test1Properties, configuration);
}
 
Example #21
Source File: PropertiesFileConfigurationWriter.java    From chassis with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Configuration configuration, Filter filter) {
    try (FileOutputStream fos = new FileOutputStream(outputFile)) {
        dump(Configurations.asMap(configuration), filter, new PrintStream(fos));
    } catch (Exception e) {
        LOGGER.error("Unable to write configs to file {}", outputFile);
    }
}
 
Example #22
Source File: TinkerFactory.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
/**
 * Create the "the crew" graph which is a TinkerPop 3.x toy graph showcasing many 3.x features like meta-properties,
 * multi-properties and graph variables.
 */
public static TinkerGraph createTheCrew() {
    final Configuration conf = getNumberIdManagerConfiguration();
    conf.setProperty(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name());
    final TinkerGraph g = TinkerGraph.open(conf);
    generateTheCrew(g);
    return g;
}
 
Example #23
Source File: BlazeGraphReadOnly.java    From tinkerpop3 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Never publicly instantiated - only by another {@link BlazeGraphEmbedded} 
 * instance.
 */
BlazeGraphReadOnly(final BigdataSailRepository repo,
        final BigdataSailRepositoryConnection cxn,
        final Configuration config) {
    super(repo, config);
    
    this.cxn = cxn;
}
 
Example #24
Source File: WorkflowOptions.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
public static WorkflowOptions getOptions(Configuration config) {
    WorkflowOptions options = new WorkflowOptions();

    String materialFolderRawScan = config.getString(PROP_MATERIAL_FOLDER_RAW_SCAN);
    if (materialFolderRawScan == null) {
        materialFolderRawScan = "";
    }
    options.setRawScan(materialFolderRawScan);

    String materialFolderMasterCopy = config.getString(PROP_MATERIAL_FOLDER_MASTER_COPY);
    if (materialFolderMasterCopy == null) {
        materialFolderMasterCopy = "";
    }
    options.setMasterCopy(materialFolderMasterCopy);

    String materialFolderOcr = config.getString(PROP_MATERIAL_FOLDER_OCR);
    if (materialFolderOcr == null) {
        materialFolderOcr = "";
    }
    options.setOcr(materialFolderOcr);

    String materialFolderOcrProcess = config.getString(PROP_MATERIAL_FOLDER_OCR_IMAGE);
    if (materialFolderOcrProcess == null) {
        materialFolderOcrProcess = "";
    }
    options.setOcrImage(materialFolderOcrProcess);

    return options;
}
 
Example #25
Source File: GhostConvert.java    From proarc with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<String> buildCmdLine(Configuration conf) {
    String inputFile = input.getAbsolutePath();
    String outputFile = output.getAbsolutePath();
    List<String> cmdLine = super.buildCmdLine(conf);
    //cmdLine.add("-i");
    cmdLine.add(inputFile);
    //cmdLine.add("-o");
    cmdLine.add(outputFile);
    return cmdLine;
}
 
Example #26
Source File: LocalStormDoTask.java    From incubator-samoa with Apache License 2.0 5 votes vote down vote up
/**
 * The main method.
 * 
 * @param args
 *          the arguments
 */
public static void main(String[] args) {

  List<String> tmpArgs = new ArrayList<String>(Arrays.asList(args));

  int numWorker = StormSamoaUtils.numWorkers(tmpArgs);

  args = tmpArgs.toArray(new String[0]);

  // convert the arguments into Storm topology
  StormTopology stormTopo = StormSamoaUtils.argsToTopology(args);
  String topologyName = stormTopo.getTopologyName();

  Config conf = new Config();
  // conf.putAll(Utils.readStormConfig());
  conf.setDebug(false);

  // local mode
  conf.setMaxTaskParallelism(numWorker);

  backtype.storm.LocalCluster cluster = new backtype.storm.LocalCluster();
  cluster.submitTopology(topologyName, conf, stormTopo.getStormBuilder().createTopology());

  // Read local mode execution duration from property file
  Configuration stormConfig = StormSamoaUtils.getPropertyConfig(LocalStormDoTask.SAMOA_STORM_PROPERTY_FILE_LOC);
  long executionDuration= stormConfig.getLong(LocalStormDoTask.EXECUTION_DURATION_KEY);
  backtype.storm.utils.Utils.sleep(executionDuration * 1000);

  cluster.killTopology(topologyName);
  cluster.shutdown();

}
 
Example #27
Source File: ConfigurePropertyUtils.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public static Map<String, String> getPropertiesWithPrefix(Configuration configuration, String prefix) {
  Map<String, String> propertiesMap = new HashMap<>();

  Iterator<String> keysIterator = configuration.getKeys(prefix);
  while (keysIterator.hasNext()) {
    String key = keysIterator.next();
    propertiesMap.put(key.substring(prefix.length() + 1), String.valueOf(configuration.getProperty(key)));
  }
  return propertiesMap;
}
 
Example #28
Source File: PrioritySchedulerTest.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
public static TestPriorityScheduler create(Configuration config) {
  ResourceManager rm = new PolicyBasedResourceManager(config);
  QueryExecutor qe = new TestQueryExecutor();
  groupFactory = new TestSchedulerGroupFactory();
  MultiLevelPriorityQueue queue =
      new MultiLevelPriorityQueue(config, rm, groupFactory, new TableBasedGroupMapper());
  latestQueryTime = new LongAccumulator(Long::max, 0);
  return new TestPriorityScheduler(config, rm, qe, queue, metrics, latestQueryTime);
}
 
Example #29
Source File: MetricsConfig.java    From hadoop with Apache License 2.0 5 votes vote down vote up
static String toString(Configuration c) {
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try {
    PrintStream ps = new PrintStream(buffer, false, "UTF-8");
    PropertiesConfiguration tmp = new PropertiesConfiguration();
    tmp.copy(c);
    tmp.save(ps);
    return buffer.toString("UTF-8");
  } catch (Exception e) {
    throw new MetricsConfigException(e);
  }
}
 
Example #30
Source File: ConfigurationHelperTest.java    From googleads-java-lib with Apache License 2.0 5 votes vote down vote up
/**
 * Asserts that reading list values from a properties file works properly when the default
 * list delimiter is modified.
 */
@Test
public void testFromFile_listValuesWithDefaultDelimiterChanged() throws Exception {
  AbstractConfiguration.setDefaultListDelimiter('|');
  Configuration configuration = configurationHelper.fromFile(
      ConfigurationHelperTest.class.getResource("props/test3.properties"));
  assertPropertiesEquals(test3Properties, configuration);
  String[] stringArray = configuration.getStringArray("i.j.k");
  assertArrayEquals(new String[] {"foo", "bar"}, stringArray);
}