Exemple #1
0
  @BeforeClass
  public void setup() throws Exception {
    TableDataManagerProvider.setServerMetrics(new ServerMetrics(new MetricsRegistry()));

    File confDir = new File(QueryExecutorTest.class.getClassLoader().getResource("conf").toURI());
    setupSegmentList(2);
    // ServerBuilder serverBuilder = new ServerBuilder(confDir.getAbsolutePath());
    String configFilePath = confDir.getAbsolutePath();

    // build _serverConf
    PropertiesConfiguration serverConf = new PropertiesConfiguration();
    serverConf.setDelimiterParsingDisabled(false);
    serverConf.load(new File(configFilePath, PINOT_PROPERTIES));

    FileBasedInstanceDataManager instanceDataManager =
        FileBasedInstanceDataManager.getInstanceDataManager();
    instanceDataManager.init(
        new FileBasedInstanceDataManagerConfig(serverConf.subset("pinot.server.instance")));
    instanceDataManager.start();

    for (int i = 0; i < 2; ++i) {
      instanceDataManager.getTableDataManager("midas");
      instanceDataManager.getTableDataManager("midas").addSegment(_indexSegmentList.get(i));
    }
    _queryExecutor = new ServerQueryExecutorV1Impl();
    _queryExecutor.init(
        serverConf.subset("pinot.server.query.executor"),
        instanceDataManager,
        new ServerMetrics(new MetricsRegistry()));
  }
 private static void showStartupInfo(
     PropertiesConfiguration buildConfiguration, boolean enableTLS, int appPort) {
   StringBuilder buffer = new StringBuilder();
   buffer.append("\n############################################");
   buffer.append("############################################");
   buffer.append("\n                               Atlas Server (STARTUP)");
   buffer.append("\n");
   try {
     final Iterator<String> keys = buildConfiguration.getKeys();
     while (keys.hasNext()) {
       String key = keys.next();
       buffer
           .append('\n')
           .append('\t')
           .append(key)
           .append(":\t")
           .append(buildConfiguration.getProperty(key));
     }
   } catch (Throwable e) {
     buffer.append("*** Unable to get build info ***");
   }
   buffer.append("\n############################################");
   buffer.append("############################################");
   LOG.info(buffer.toString());
   LOG.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
   LOG.info("Server starting with TLS ? {} on port {}", enableTLS, appPort);
   LOG.info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
 }
  /** Load the config parameters from fortress.properties file. */
  private void loadLocalConfig() {
    try {
      // Load the system config file.
      URL fUrl = Config.class.getClassLoader().getResource(PROP_FILE);
      config.setDelimiterParsingDisabled(true);
      if (fUrl == null) {
        String error = "static init: Error, null cfg file: " + PROP_FILE;
        LOG.warn(error);
      } else {
        LOG.info("static init: found from: {} path: {}", PROP_FILE, fUrl.getPath());
        config.load(fUrl);
        LOG.info("static init: loading from: {}", PROP_FILE);
      }

      URL fUserUrl = Config.class.getClassLoader().getResource(USER_PROP_FILE);
      if (fUserUrl != null) {
        LOG.info(
            "static init: found user properties from: {} path: {}",
            USER_PROP_FILE,
            fUserUrl.getPath());
        config.load(fUserUrl);
      }
    } catch (org.apache.commons.configuration.ConfigurationException ex) {
      String error =
          "static init: Error loading from cfg file: ["
              + PROP_FILE
              + "] ConfigurationException="
              + ex;
      LOG.error(error);
      throw new CfgRuntimeException(GlobalErrIds.FT_CONFIG_BOOTSTRAP_FAILED, error, ex);
    }
  }
  public static void persistSSLClientConfiguration(PropertiesConfiguration clientConfig)
      throws AtlasException, IOException {
    // trust settings
    Configuration configuration = new Configuration(false);
    File sslClientFile = getSSLClientFile();
    if (!sslClientFile.exists()) {
      configuration.set("ssl.client.truststore.type", "jks");
      configuration.set(
          "ssl.client.truststore.location", clientConfig.getString(TRUSTSTORE_FILE_KEY));
      if (clientConfig.getBoolean(CLIENT_AUTH_KEY, false)) {
        // need to get client key properties
        configuration.set(
            "ssl.client.keystore.location", clientConfig.getString(KEYSTORE_FILE_KEY));
        configuration.set("ssl.client.keystore.type", "jks");
      }
      // add the configured credential provider
      configuration.set(
          CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
          clientConfig.getString(CERT_STORES_CREDENTIAL_PROVIDER_PATH));
      String hostnameVerifier = clientConfig.getString(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY);
      if (hostnameVerifier != null) {
        configuration.set(SSLFactory.SSL_HOSTNAME_VERIFIER_KEY, hostnameVerifier);
      }

      configuration.writeXml(new FileWriter(sslClientFile));
    }
  }
Exemple #5
0
  public SenseiServerBuilder(File confDir, Map<String, Object> properties) throws Exception {
    if (properties != null) {
      _senseiConfFile = null;
      _senseiConf = new MapConfiguration(properties);
      ((MapConfiguration) _senseiConf).setDelimiterParsingDisabled(true);
    } else {
      _senseiConfFile = new File(confDir, SENSEI_PROPERTIES);
      if (!_senseiConfFile.exists()) {
        throw new ConfigurationException(
            "configuration file: " + _senseiConfFile.getAbsolutePath() + " does not exist.");
      }
      _senseiConf = new PropertiesConfiguration();
      ((PropertiesConfiguration) _senseiConf).setDelimiterParsingDisabled(true);
      ((PropertiesConfiguration) _senseiConf).load(_senseiConfFile);
    }

    pluginRegistry = SenseiPluginRegistry.build(_senseiConf);
    pluginRegistry.start();

    processRelevanceFunctionPlugins(pluginRegistry);
    processRelevanceExternalObjectPlugins(pluginRegistry);

    _gateway = pluginRegistry.getBeanByFullPrefix(SENSEI_GATEWAY, SenseiGateway.class);
    _schemaDoc = loadSchema(confDir);
    _senseiSchema = SenseiSchema.build(_schemaDoc);
  }
  public static Configuration instance() {
    if (config == null) {
      try {
        // Default values build into war file, this is last prio used if no of the other sources
        // override this
        boolean allowexternal =
            Boolean.getBoolean(
                new PropertiesConfiguration(
                        ExtraConfiguration.class.getResource("/" + PROPERTY_FILENAME))
                    .getString(CONFIGALLOWEXTERNAL, "false"));

        config = new CompositeConfiguration();

        PropertiesConfiguration pc;
        // Only add these config sources if we allow external configuration
        if (allowexternal) {
          // Override with system properties, this is prio 1 if it exists (java -Dscep.test=foo)
          config.addConfiguration(new SystemConfiguration());
          log.info("Added system properties to configuration source (java -Dfoo.prop=bar).");

          // Override with file in "application server home directory"/conf, this is prio 2
          File f1 = new File("conf/" + PROPERTY_FILENAME);
          pc = new PropertiesConfiguration(f1);
          pc.setReloadingStrategy(new FileChangedReloadingStrategy());
          config.addConfiguration(pc);
          log.info("Added file to configuration source: " + f1.getAbsolutePath());

          // Override with file in "/etc/ejbca/conf/extra, this is prio 3
          File f2 = new File("/etc/ejbca/conf/extra/" + PROPERTY_FILENAME);
          pc = new PropertiesConfiguration(f2);
          pc.setReloadingStrategy(new FileChangedReloadingStrategy());
          config.addConfiguration(pc);
          log.info("Added file to configuration source: " + f2.getAbsolutePath());
        }

        // Default values build into war file, this is last prio used if no of the other sources
        // override this
        URL url = ExtraConfiguration.class.getResource("/" + PROPERTY_FILENAME);
        pc = new PropertiesConfiguration(url);
        config.addConfiguration(pc);
        log.info("Added url to configuration source: " + url);

        log.info("Allow external re-configuration: " + allowexternal);
        // Test
        log.debug("Using keystore path (1): " + config.getString(SCEPKEYSTOREPATH + ".1"));
        // log.debug("Using keystore pwd (1): "+config.getString(SCEPKEYSTOREPWD+".1"));
        // log.debug("Using authPwd: "+config.getString(SCEPAUTHPWD));
        log.debug("Using certificate profile: " + config.getString(SCEPCERTPROFILEKEY));
        log.debug("Using entity profile: " + config.getString(SCEPENTITYPROFILEKEY));
        log.debug("Using default CA: " + config.getString(SCEPDEFAULTCA));
        log.debug("Create or edit user: "******"Mapping for CN=Scep CA,O=EJBCA Sample,C=SE: "
                + config.getString("CN=Scep CA,O=EJBCA Sample,C=SE"));
      } catch (ConfigurationException e) {
        log.error("Error intializing ExtRA Configuration: ", e);
      }
    }
    return config;
  }
 private static Project newProject(String key, String language) {
   PropertiesConfiguration configuration = new PropertiesConfiguration();
   configuration.setProperty("sonar.language", language);
   return new Project(key)
       .setConfiguration(configuration)
       .setAnalysisType(Project.AnalysisType.DYNAMIC);
 }
  /**
   * Converts the properties object into a JSON string.
   *
   * @param properties The properties object to convert.
   * @param envelope Envelope for resulting JSON object. Null if not needed.
   * @return A JSON string representing the object.
   */
  public static String toJson(PropertiesConfiguration properties, String envelope) {
    JsonObject json = new JsonObject();
    Iterator<String> i = properties.getKeys();

    while (i.hasNext()) {
      final String key = i.next();
      final String value = properties.getString(key);
      if (value.equals("true") || value.equals("false")) {
        json.addProperty(key.toString(), Boolean.parseBoolean(value));
      } else if (PATTERN_INTEGER.matcher(value).matches()) {
        json.addProperty(key.toString(), Integer.parseInt(value));
      } else if (PATTERN_FLOAT.matcher(value).matches()) {
        json.addProperty(key.toString(), Float.parseFloat(value));
      } else {
        json.addProperty(key.toString(), value);
      }
    }

    GsonBuilder gsonBuilder = new GsonBuilder().disableHtmlEscaping();
    Gson gson = gsonBuilder.create();
    String _json = gson.toJson(json);
    if (envelope != null && !envelope.isEmpty()) {
      _json = envelope(_json, envelope);
    }
    return _json;
  }
  @BeforeClass
  public void setup() throws Exception {
    CONFIG_BUILDER = new TestingServerPropertiesBuilder("testTable");

    setupSegmentFor("testTable");
    setUpTestQueries("testTable");

    final PropertiesConfiguration serverConf = CONFIG_BUILDER.build();
    serverConf.setDelimiterParsingDisabled(false);

    final FileBasedInstanceDataManager instanceDataManager =
        FileBasedInstanceDataManager.getInstanceDataManager();
    instanceDataManager.init(
        new FileBasedInstanceDataManagerConfig(serverConf.subset("pinot.server.instance")));
    instanceDataManager.start();

    System.out.println(
        "************************** : " + new File(INDEX_DIR, "segment").getAbsolutePath());
    File segmentFile = new File(INDEX_DIR, "segment").listFiles()[0];
    segmentName = segmentFile.getName();
    final IndexSegment indexSegment = ColumnarSegmentLoader.load(segmentFile, ReadMode.heap);
    instanceDataManager.getTableDataManager("testTable");
    instanceDataManager.getTableDataManager("testTable").addSegment(indexSegment);

    QUERY_EXECUTOR = new ServerQueryExecutorV1Impl(false);
    QUERY_EXECUTOR.init(
        serverConf.subset("pinot.server.query.executor"),
        instanceDataManager,
        new ServerMetrics(new MetricsRegistry()));
  }
 public static void setProperties(PropertiesConfiguration configuration) {
   configuration.getProperty("");
   getMailProperties()
       .setMailLogin(configuration.getString(MailProperties.getMailType() + ".login"));
   getMailProperties()
       .setMailPass(configuration.getString(MailProperties.getMailType() + ".password"));
   getMailProperties().setMailUrl(configuration.getString(MailProperties.getMailType() + ".url"));
 }
  @Test
  public void shouldGetPropertyValue() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty("sonar.timemachine.period1", "5");

    assertThat(PastSnapshotFinder.getPropertyValue(conf, 1), is("5"));
    assertThat(PastSnapshotFinder.getPropertyValue(conf, 999), nullValue());
  }
 /**
  * Get an SQL statement for the appropriate vendor from the bundle
  *
  * @param key
  * @return statement or null if none found.
  */
 private String getStatement(String key) {
   try {
     return statements.getString(key);
   } catch (NoSuchElementException e) {
     log.error("Statement: '" + key + "' could not be found in: " + statements.getFileName(), e);
     return null;
   }
 }
Exemple #13
0
  /**
   * Sets a property to rhqctl.properties. Note that calling this will eventually cause
   * rhqctl.properties file to be created later.
   *
   * @param key
   * @param value
   */
  private void putProperty(String key, String value) {
    if (rhqctlConfig == null) {
      rhqctlConfig = new PropertiesConfiguration();
      rhqctlConfig.setPath(getRhqCtlPropertiesPath());
    }

    rhqctlConfig.setProperty(key, value);
  }
 public void save() {
   if (properties != null) {
     try {
       properties.save();
     } catch (ConfigurationException e) {
       logger.error("Coud not save properties on " + properties.getFileName());
     }
   }
 }
  @Test
  public void shouldGetDefaultPropertyValue() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty("sonar.timemachine.period1", "5");

    assertThat(
        PastSnapshotFinder.getPropertyValue(conf, 2),
        is(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2));
  }
  @Test
  public void hasJavaSourceFiles() {
    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);
    assertThat(fs.hasJavaSourceFiles(), is(true));

    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.java");
    project.setConfiguration(conf);
    assertThat(fs.hasJavaSourceFiles(), is(false));
  }
  @Test
  public void doNotApplyExclusionPatternsToTestFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getTestFiles(Java.INSTANCE).size(), is(1));
    assertThat(fs.getTestFiles(Java.INSTANCE), hasItem(named("BarTest.java")));
  }
  @Test
  public void applyExclusionPatternsToSourceFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/B*.java");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getJavaSourceFiles().size(), is(1));
    assertThat(fs.getJavaSourceFiles(), hasItem(named("Whizz.java")));
  }
Exemple #19
0
  @Override
  public void updateConfiguration(PropertiesConfiguration configuration) {
    if (configuration.getProperty("database").equals("derby")) {
      String url = (String) configuration.getProperty("database.url");

      if (!StringUtils.contains(url, ";upgrade=")) {
        url += ";upgrade=true";
      }

      configuration.setProperty("database.url", url);
    }
  }
  /** See http://jira.codehaus.org/browse/SONAR-1449 */
  @Test
  public void exclusionPatternOnAjFiles() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*.aj");
    project.setConfiguration(conf);

    final DefaultProjectFileSystem fs = newDefaultProjectFileSystem(project);

    assertThat(fs.getSourceFiles(Java.INSTANCE).size(), is(2));
    assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Whizz.java")));
    assertThat(fs.getSourceFiles(Java.INSTANCE), hasItem(named("Bar.java")));
  }
Exemple #21
0
  // Saves the settings to config file.
  public static void saveSettings(Settings settings) {
    config.setProperty("vlclocation", settings.getVlcLocation());
    config.setProperty("thumbnailcount", settings.getThumbnailCount());
    config.setProperty("thumbnailwidth", settings.getThumbnailWidth());
    config.setProperty("thumbnailhighlightcolor", settings.getThumbnailHighlightColor());
    config.setProperty("folders", String.join("|", settings.getFolders()));

    try {
      config.save("vidor.config");
    } catch (ConfigurationException ex) {
      ex.printStackTrace();
    }
  }
  @Override
  public SystemConfiguration getSystemConfiguration() {

    // Create a new SystemConfiguration by reading out the parameters in the config file
    logger.trace("Loading System Configuration");
    SystemConfiguration systemConfiguration = new SystemConfiguration();
    systemConfiguration.setThreadPoolSize(
        propertiesConfiguration.getInt(PropertiesConfigurationEntries.THREAD_POOL_SIZE));
    systemConfiguration.setDaemonThreadTimer(
        propertiesConfiguration.getInt(PropertiesConfigurationEntries.SYSTEM_DAEMON_TIMER));

    return systemConfiguration;
  }
 /**
  * Converts a JSON string into the properties object.
  *
  * @param properties The properties object to convert.
  * @return A JSON string representing the object. Null if conversion fails.
  */
 public static PropertiesConfiguration toProperties(String json) {
   try {
     Properties src = JsonPropertiesConverter.toProperties(json);
     if (src != null) {
       PropertiesConfiguration dest = new PropertiesConfiguration();
       for (String key : src.stringPropertyNames()) {
         dest.setProperty(key, src.getProperty(key));
       }
       return dest;
     }
   } catch (Exception e) {
   }
   return null;
 }
  @Override
  public void initliaze(InputStream input, WebApplicationConfiguration configuration)
      throws Exception {
    PropertiesConfiguration pc = new PropertiesConfiguration();
    pc.load(input);

    BeanUtilsBean bu = retrieveBeanUtilsBean();
    Iterator<String> keys = pc.getKeys();
    while (keys.hasNext()) {
      String key = keys.next();
      String value = pc.getString(key);
      fillConfiguration(configuration, bu, key, value);
    }
  }
 private static org.apache.commons.configuration.Configuration init() {
   PropertiesConfiguration config = null;
   try {
     config = new PropertiesConfiguration();
     config.setListDelimiter('\0');
     config.load(ERR_CODE_FILE);
   } catch (ConfigurationException ex) {
     // error out if the configuration file is not there
     String message = "Failed to load serengeti error message file.";
     Logger.getLogger(RestResource.class).fatal(message, ex);
     throw BddException.APP_INIT_ERROR(ex, message);
   }
   return config;
 }
  public UserStore(String nombre, PropertiesConfiguration configuration) {
    BasicDataSource ds = null;
    String driver = configuration.getString("userstore.driver");
    if (driver != null) {
      ds = new BasicDataSource();
      ds.setDriverClassName(driver);
      ds.setUrl(configuration.getString("userstore.url"));
      ds.setUsername(configuration.getString("userstore.username"));
      ds.setPassword(configuration.getString("userstore.password"));
      ds.setMaxActive(configuration.getInt("userstore.maxActive"));
      ds.setMinIdle(configuration.getInt("userstore.minIdle"));
      ds.setMaxWait(configuration.getInt("userstore.maxWait"));
    }
    this.dataSource = ds;
    System.out.println(ds);
    this.selectUser = configuration.getString("userstore.selectUser");
    this.encoding = configuration.getString("userstore.encoding");
    String algorithm = configuration.getString("userstore.algorithm");
    if (algorithm != null && !algorithm.isEmpty()) {
      try {
        messageDigest = MessageDigest.getInstance(algorithm);
      } catch (NoSuchAlgorithmException algorithmException) {

        System.out.println(
            "Algoritmo " + algorithm + "no encontrado... no se cifrararan los passwords");
        messageDigest = null;
      }
      this.nombre = nombre;
    }
  }
  @Override
  public BluetoothConfiguration getBluetoothConfiguration() {

    // Create a new BluetoothConfiguration by reading out the parameters in the config file
    logger.trace("Loading Bluetooth Configuration");
    BluetoothConfiguration bluetoothConfiguration = new BluetoothConfiguration();
    bluetoothConfiguration.setServerName(
        propertiesConfiguration.getString(PropertiesConfigurationEntries.BLUETOOTH_SERVER));
    bluetoothConfiguration.setServiceName(
        propertiesConfiguration.getString(PropertiesConfigurationEntries.BLUETOOTH_SERVICE));
    bluetoothConfiguration.setServiceUUID(
        propertiesConfiguration.getString(PropertiesConfigurationEntries.BLUETOOTH_UUID));

    return bluetoothConfiguration;
  }
  /** @see Plugin#init() */
  public void init() throws PluginException {
    try {
      if (System.getProperty("roda.home") != null) {
        RODA_HOME = System.getProperty("roda.home");
      } else if (System.getenv("RODA_HOME") != null) {
        RODA_HOME = System.getenv("RODA_HOME");
      } else {
        RODA_HOME = null;
      }
      if (StringUtils.isBlank(RODA_HOME)) {
        throw new PluginException(
            "RODA_HOME enviroment variable and ${roda.home} system property are not set.");
      }
      final File pluginsConfigDirectory = new File(new File(RODA_HOME, "config"), "plugins");

      final File configFile = new File(pluginsConfigDirectory, CONFIGURATION_FILENAME);
      final PropertiesConfiguration configuration = new PropertiesConfiguration();

      if (configFile.isFile()) {
        configuration.load(configFile);
        logger.info("Loading configuration file from " + configFile);
      } else {
        configuration.load(getClass().getResourceAsStream("/" + CONFIGURATION_FILENAME));
        logger.info("Loading default configuration file from resources");
      }

      taverna_bin = configuration.getString("taverna_bin");
      logger.debug("taverna_bin=" + taverna_bin);

      xpathSelectIDs = configuration.getString("xpathSelectIDs");
      logger.debug("xpathSelectIDs=" + xpathSelectIDs);

      xpathSelectWorkflow = configuration.getString("xpathSelectWorkflow");
      logger.debug("xpathSelectWorkflow=" + xpathSelectWorkflow);

      workflowInputPort = configuration.getString("workflowInputPort");
      logger.debug("workflowInputPort=" + workflowInputPort);

      workflowOutputPort = configuration.getString("workflowOutputPort");
      logger.debug("workflowOutputPort=" + workflowOutputPort);

      workflowExtraPorts = configuration.getStringArray("workflowExtraPorts");
      logger.debug("workflowExtraPorts=" + Arrays.asList(workflowExtraPorts));

    } catch (ConfigurationException ex) {
      logger.debug("Error reading plugin configuration - " + ex.getMessage(), ex);
      throw new PluginException("Error reading plugin configuration - " + ex.getMessage(), ex);
    }

    planFile = new File(new File(RODA_HOME, "data"), PLAN_FILENAME);

    logger.debug("init() OK");
  }
Exemple #29
0
  public int exec(String[] args) {
    Options options = getOptions();
    int rValue = RHQControl.EXIT_CODE_OK;
    try {
      CommandLineParser parser = new RHQPosixParser(false);
      CommandLine cmdLine = parser.parse(options, args, true);
      if (!cmdLine.getArgList().isEmpty()) {
        // there were some unrecognized args
        System.out.println("Unrecognized arguments: " + cmdLine.getArgList());
        printUsage();
        return RHQControl.EXIT_CODE_INVALID_ARGUMENT;
      }
      rValue = exec(cmdLine);

      if (rhqctlConfig != null) {
        rhqctlConfig.save();
      }
    } catch (ParseException e) {
      printUsage();
      rValue = RHQControl.EXIT_CODE_INVALID_ARGUMENT;
    } catch (ConfigurationException e) {
      throw new RHQControlException("Failed to update " + getRhqCtlProperties(), e);
    }
    return rValue;
  }
 static void saveConfiguration() {
   try {
     configuration.save();
   } catch (ConfigurationException ce) {
     log.error("Could not save Configuration.", ce);
   }
 }