Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration#containsKey()

The following examples show how to use org.apache.commons.configuration.PropertiesConfiguration#containsKey() . 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: TestJNDIInitialization.java    From sqlg with MIT License 6 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    configuration = new PropertiesConfiguration(sqlProperties);
    if (!configuration.containsKey("jdbc.url")) {
        throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));
    }

    ds = C3P0DataSource.create(configuration).getDatasource();

    //change the connection url to be a JNDI one
    configuration.setProperty("jdbc.url", "jndi:testConnection");

    //set up the initial context
    NamingManager.setInitialContextFactoryBuilder(environment -> {
        InitialContextFactory mockFactory = mock(InitialContextFactory.class);
        Context mockContext = mock(Context.class);
        when(mockFactory.getInitialContext(any())).thenReturn(mockContext);

        when(mockContext.lookup("testConnection")).thenReturn(ds);

        return mockFactory;
    });
}
 
Example 2
Source File: TestUserSuppliedPKTopology.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        if (isPostgres()) {
            configuration.addProperty(SqlgGraph.DISTRIBUTED, true);
            if (!configuration.containsKey(SqlgGraph.JDBC_URL))
                throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", SqlgGraph.JDBC_URL));
        }
    } catch (ConfigurationException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 3
Source File: DocTests.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.setProperty("implement.foreign.keys", false);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 4
Source File: TestMultipleThreadMultipleJvm.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
    public static void beforeClass() {
        URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
        try {
            configuration = new PropertiesConfiguration(sqlProperties);
            Assume.assumeTrue(isPostgres());
            configuration.addProperty("distributed", true);
//            configuration.addProperty("maxPoolSize", 3);
            if (!configuration.containsKey("jdbc.url"))
                throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

        } catch (ConfigurationException e) {
            throw new RuntimeException(e);
        }
    }
 
Example 5
Source File: TestNotifyJson.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 6
Source File: TestLoadSchemaViaNotify.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 7
Source File: TestTopologyDelete.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty(SqlgGraph.DISTRIBUTED, true);
        if (!configuration.containsKey(SqlgGraph.JDBC_URL))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", SqlgGraph.JDBC_URL));

    } catch (ConfigurationException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 8
Source File: TestTopologyMultipleGraphs.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 9
Source File: TestTopologySchemaDeleteMultipleGraphs.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 10
Source File: TestPartitionMultipleGraphs.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 11
Source File: TestSubSubPartition.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 12
Source File: TestVertexCache.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        configuration.setProperty("cache.vertices", true);
        if (!configuration.containsKey("jdbc.url")) {
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));
        }
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 13
Source File: BaseTest.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        if (!configuration.containsKey("jdbc.url")) {
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));
        }
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 14
Source File: TestSharding.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 15
Source File: TestShardingGremlin.java    From sqlg with MIT License 5 votes vote down vote up
@SuppressWarnings("Duplicates")
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        Assume.assumeTrue(isPostgres());
        configuration.addProperty("distributed", true);
        if (!configuration.containsKey("jdbc.url"))
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));

    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 16
Source File: TestTinkerPopEvent.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        configuration.setProperty("cache.vertices", true);
        if (!configuration.containsKey("jdbc.url")) {
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));
        }
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 17
Source File: NetAggregateTest.java    From sqlg with MIT License 5 votes vote down vote up
@BeforeClass
public static void beforeClass() {
    URL sqlProperties = Thread.currentThread().getContextClassLoader().getResource("sqlg.properties");
    try {
        configuration = new PropertiesConfiguration(sqlProperties);
        configuration.setProperty("cache.vertices", true);
        if (!configuration.containsKey("jdbc.url")) {
            throw new IllegalArgumentException(String.format("SqlGraph configuration requires that the %s be set", "jdbc.url"));
        }
    } catch (ConfigurationException e) {
        throw new RuntimeException(e);
    }
}
 
Example 18
Source File: ColumnMetadata.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
public static ColumnMetadata fromPropertiesConfiguration(String column, PropertiesConfiguration config) {
  Builder builder = new Builder();

  builder.setColumnName(column);
  builder.setCardinality(config.getInt(getKeyFor(column, CARDINALITY)));
  int totalDocs = config.getInt(getKeyFor(column, TOTAL_DOCS));
  builder.setTotalDocs(totalDocs);
  DataType dataType = DataType.valueOf(config.getString(getKeyFor(column, DATA_TYPE)).toUpperCase());
  builder.setDataType(dataType);
  builder.setBitsPerElement(config.getInt(getKeyFor(column, BITS_PER_ELEMENT)));
  builder.setColumnMaxLength(config.getInt(getKeyFor(column, DICTIONARY_ELEMENT_SIZE)));
  builder.setFieldType(FieldType.valueOf(config.getString(getKeyFor(column, COLUMN_TYPE)).toUpperCase()));
  builder.setIsSorted(config.getBoolean(getKeyFor(column, IS_SORTED)));
  builder.setContainsNulls(config.getBoolean(getKeyFor(column, HAS_NULL_VALUE)));
  builder.setHasDictionary(config.getBoolean(getKeyFor(column, HAS_DICTIONARY), true));
  builder.setHasInvertedIndex(config.getBoolean(getKeyFor(column, HAS_INVERTED_INDEX)));
  builder.setSingleValue(config.getBoolean(getKeyFor(column, IS_SINGLE_VALUED)));
  builder.setMaxNumberOfMultiValues(config.getInt(getKeyFor(column, MAX_MULTI_VALUE_ELEMTS)));
  builder.setTotalNumberOfEntries(config.getInt(getKeyFor(column, TOTAL_NUMBER_OF_ENTRIES)));
  builder.setAutoGenerated(config.getBoolean(getKeyFor(column, IS_AUTO_GENERATED), false));
  builder.setDefaultNullValueString(config.getString(getKeyFor(column, DEFAULT_NULL_VALUE), null));
  builder.setTimeUnit(TimeUnit.valueOf(config.getString(TIME_UNIT, "DAYS").toUpperCase()));
  builder.setTextIndexType(config.getString(getKeyFor(column, TEXT_INDEX_TYPE), TextIndexType.NONE.name()));

  char paddingCharacter = V1Constants.Str.LEGACY_STRING_PAD_CHAR;
  if (config.containsKey(SEGMENT_PADDING_CHARACTER)) {
    String padding = config.getString(SEGMENT_PADDING_CHARACTER);
    paddingCharacter = StringEscapeUtils.unescapeJava(padding).charAt(0);
  }
  builder.setPaddingCharacter(paddingCharacter);

  String dateTimeFormat = config.getString(getKeyFor(column, DATETIME_FORMAT), null);
  if (dateTimeFormat != null) {
    builder.setDateTimeFormat(dateTimeFormat);
  }

  String dateTimeGranularity = config.getString(getKeyFor(column, DATETIME_GRANULARITY), null);
  if (dateTimeGranularity != null) {
    builder.setDateTimeGranularity(dateTimeGranularity);
  }

  // Set min/max value if available.
  String minString = config.getString(getKeyFor(column, MIN_VALUE), null);
  String maxString = config.getString(getKeyFor(column, MAX_VALUE), null);
  if ((minString != null) && (maxString != null)) {
    switch (dataType) {
      case INT:
        builder.setMinValue(Integer.valueOf(minString));
        builder.setMaxValue(Integer.valueOf(maxString));
        break;
      case LONG:
        builder.setMinValue(Long.valueOf(minString));
        builder.setMaxValue(Long.valueOf(maxString));
        break;
      case FLOAT:
        builder.setMinValue(Float.valueOf(minString));
        builder.setMaxValue(Float.valueOf(maxString));
        break;
      case DOUBLE:
        builder.setMinValue(Double.valueOf(minString));
        builder.setMaxValue(Double.valueOf(maxString));
        break;
      case STRING:
        builder.setMinValue(minString);
        builder.setMaxValue(maxString);
        break;
      default:
        throw new IllegalStateException("Unsupported data type: " + dataType + " for column: " + column);
    }
  }

  String partitionFunctionName =
      config.getString(getKeyFor(column, V1Constants.MetadataKeys.Column.PARTITION_FUNCTION));
  if (partitionFunctionName != null) {
    int numPartitions = config.getInt(getKeyFor(column, V1Constants.MetadataKeys.Column.NUM_PARTITIONS));
    PartitionFunction partitionFunction =
        PartitionFunctionFactory.getPartitionFunction(partitionFunctionName, numPartitions);
    builder.setPartitionFunction(partitionFunction);
    builder.setNumPartitions(numPartitions);
    builder.setPartitions(ColumnPartitionMetadata
        .extractPartitions(config.getList(getKeyFor(column, V1Constants.MetadataKeys.Column.PARTITION_VALUES))));
  }

  return builder.build();
}
 
Example 19
Source File: SegmentMetadataImpl.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
private void init(PropertiesConfiguration segmentMetadataPropertiesConfiguration) {
  if (segmentMetadataPropertiesConfiguration.containsKey(SEGMENT_CREATOR_VERSION)) {
    _creatorName = segmentMetadataPropertiesConfiguration.getString(SEGMENT_CREATOR_VERSION);
  }

  if (segmentMetadataPropertiesConfiguration.containsKey(SEGMENT_PADDING_CHARACTER)) {
    String padding = segmentMetadataPropertiesConfiguration.getString(SEGMENT_PADDING_CHARACTER);
    _paddingCharacter = StringEscapeUtils.unescapeJava(padding).charAt(0);
  }

  String versionString =
      segmentMetadataPropertiesConfiguration.getString(SEGMENT_VERSION, SegmentVersion.v1.toString());
  _segmentVersion = SegmentVersion.valueOf(versionString);

  // NOTE: here we only add physical columns as virtual columns should not be loaded from metadata file
  // NOTE: getList() will always return an non-null List with trimmed strings:
  // - If key does not exist, it will return an empty list
  // - If key exists but value is missing, it will return a singleton list with an empty string
  addPhysicalColumns(segmentMetadataPropertiesConfiguration.getList(DIMENSIONS), _allColumns);
  addPhysicalColumns(segmentMetadataPropertiesConfiguration.getList(METRICS), _allColumns);
  addPhysicalColumns(segmentMetadataPropertiesConfiguration.getList(TIME_COLUMN_NAME), _allColumns);
  addPhysicalColumns(segmentMetadataPropertiesConfiguration.getList(DATETIME_COLUMNS), _allColumns);

  //set the table name
  _tableName = segmentMetadataPropertiesConfiguration.getString(TABLE_NAME);

  // Set segment name.
  _segmentName = segmentMetadataPropertiesConfiguration.getString(SEGMENT_NAME);

  // Build column metadata map, schema and hll derived column map.
  for (String column : _allColumns) {
    ColumnMetadata columnMetadata =
        ColumnMetadata.fromPropertiesConfiguration(column, segmentMetadataPropertiesConfiguration);
    _columnMetadataMap.put(column, columnMetadata);
    _schema.addField(columnMetadata.getFieldSpec());
  }

  // Build star-tree v2 metadata
  int starTreeV2Count =
      segmentMetadataPropertiesConfiguration.getInt(StarTreeV2Constants.MetadataKey.STAR_TREE_COUNT, 0);
  if (starTreeV2Count > 0) {
    _starTreeV2MetadataList = new ArrayList<>(starTreeV2Count);
    for (int i = 0; i < starTreeV2Count; i++) {
      _starTreeV2MetadataList.add(new StarTreeV2Metadata(
          segmentMetadataPropertiesConfiguration.subset(StarTreeV2Constants.MetadataKey.getStarTreePrefix(i))));
    }
  }
}