Java Code Examples for org.apache.commons.configuration.PropertiesConfiguration#addProperty()
The following examples show how to use
org.apache.commons.configuration.PropertiesConfiguration#addProperty() .
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: StarTreeIndexMapUtils.java From incubator-pinot with Apache License 2.0 | 6 votes |
/** * Stores the index maps for multiple star-trees into a file. */ public static void storeToFile(List<Map<IndexKey, IndexValue>> indexMaps, File indexMapFile) throws ConfigurationException { Preconditions.checkState(!indexMapFile.exists(), "Star-tree index map file already exists"); PropertiesConfiguration configuration = new PropertiesConfiguration(indexMapFile); int numStarTrees = indexMaps.size(); for (int i = 0; i < numStarTrees; i++) { Map<IndexKey, IndexValue> indexMap = indexMaps.get(i); for (Map.Entry<IndexKey, IndexValue> entry : indexMap.entrySet()) { IndexKey key = entry.getKey(); IndexValue value = entry.getValue(); configuration.addProperty(key.getPropertyName(i, OFFSET_SUFFIX), value._offset); configuration.addProperty(key.getPropertyName(i, SIZE_SUFFIX), value._size); } } configuration.save(); }
Example 2
Source File: PacketHandlerImplTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void initNoAnalyses() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(CONFKEY_ANALYSIS_COG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SOG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_TYPESIZE_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_DRIFT_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_CLOSEENCOUNTER_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_FREEFLOW_ENABLED, false); final JUnit4Mockery context = new JUnit4Mockery(); Injector injectorMock = context.mock(Injector.class); context.checking(new Expectations() {{ }}); PacketHandlerImpl sut = new PacketHandlerImpl(configuration, injectorMock, null, null, null, null); Set<Analysis> analyses = sut.getAnalyses(); assertEquals(0, analyses.size()); }
Example 3
Source File: TestShardingGremlin.java From sqlg with MIT License | 5 votes |
@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 4
Source File: PinotCrypterFactoryTest.java From incubator-pinot with Apache License 2.0 | 5 votes |
@Test public void testConfiguredPinotCrypter() { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.addProperty("class.testpinotcrypter", TestPinotCrypter.class.getName()); propertiesConfiguration.addProperty("testpinotcrypter" + "." + CONFIG_SUBSET_KEY, SAMPLE_KEYMAP_VAL); PinotCrypterFactory.init(propertiesConfiguration); Assert.assertTrue(PinotCrypterFactory.create(NoOpPinotCrypter.class.getSimpleName()) instanceof NoOpPinotCrypter); PinotCrypter testPinotCrypter = PinotCrypterFactory.create(TestPinotCrypter.class.getSimpleName()); Assert.assertTrue(testPinotCrypter instanceof TestPinotCrypter); testPinotCrypter.encrypt(null, null); }
Example 5
Source File: SegmentMetadataImpl.java From incubator-pinot with Apache License 2.0 | 5 votes |
/** * For REALTIME consuming segments. */ public SegmentMetadataImpl(RealtimeSegmentZKMetadata segmentMetadata, Schema schema) { _indexDir = null; PropertiesConfiguration segmentMetadataPropertiesConfiguration = new PropertiesConfiguration(); segmentMetadataPropertiesConfiguration.addProperty(SEGMENT_CREATOR_VERSION, null); segmentMetadataPropertiesConfiguration .addProperty(SEGMENT_PADDING_CHARACTER, V1Constants.Str.DEFAULT_STRING_PAD_CHAR); segmentMetadataPropertiesConfiguration .addProperty(SEGMENT_START_TIME, Long.toString(segmentMetadata.getStartTime())); segmentMetadataPropertiesConfiguration.addProperty(SEGMENT_END_TIME, Long.toString(segmentMetadata.getEndTime())); segmentMetadataPropertiesConfiguration.addProperty(TABLE_NAME, segmentMetadata.getTableName()); TimeUnit timeUnit = segmentMetadata.getTimeUnit(); if (timeUnit != null) { segmentMetadataPropertiesConfiguration.addProperty(TIME_UNIT, timeUnit.toString()); } else { segmentMetadataPropertiesConfiguration.addProperty(TIME_UNIT, null); } segmentMetadataPropertiesConfiguration.addProperty(SEGMENT_TOTAL_DOCS, segmentMetadata.getTotalDocs()); _crc = segmentMetadata.getCrc(); _creationTime = segmentMetadata.getCreationTime(); setTimeInfo(segmentMetadataPropertiesConfiguration); _columnMetadataMap = null; _tableName = segmentMetadata.getTableName(); _segmentName = segmentMetadata.getSegmentName(); _allColumns = schema.getColumnNames(); _schema = schema; _totalDocs = segmentMetadataPropertiesConfiguration.getInt(SEGMENT_TOTAL_DOCS); }
Example 6
Source File: FileRegistryTest.java From secor with Apache License 2.0 | 5 votes |
public void setUp() throws Exception { super.setUp(); PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("secor.file.reader.writer.factory", "com.pinterest.secor.io.impl.SequenceFileReaderWriterFactory"); properties.addProperty("secor.file.age.youngest", true); SecorConfig secorConfig = new SecorConfig(properties); mRegistry = new FileRegistry(secorConfig); mLogFilePath = new LogFilePath("/some_parent_dir", PATH); mTopicPartition = new TopicPartition("some_topic", 0); mLogFilePathGz = new LogFilePath("/some_parent_dir", PATH_GZ); }
Example 7
Source File: ReflectionUtilTest.java From secor with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("message.timestamp.name", ""); properties.addProperty("message.timestamp.name.separator", ""); properties.addProperty("secor.offsets.prefix", "offset="); mSecorConfig = new SecorConfig(properties); mLogFilePath = new LogFilePath("/foo", "/foo/bar/baz/1_1_1"); }
Example 8
Source File: TestMultipleThreadMultipleJvm.java From sqlg with MIT License | 5 votes |
@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 9
Source File: TestLoadSchemaViaNotify.java From sqlg with MIT License | 5 votes |
@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: TestTopologyDelete.java From sqlg with MIT License | 5 votes |
@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 11
Source File: TestTopologyMultipleGraphs.java From sqlg with MIT License | 5 votes |
@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: PacketHandlerImplTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void initSelectedAnalyses() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(CONFKEY_ANALYSIS_COG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SOG_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_TYPESIZE_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_DRIFT_ENABLED, false); configuration.addProperty(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_ENABLED, true); configuration.addProperty(CONFKEY_ANALYSIS_CLOSEENCOUNTER_ENABLED, true); configuration.addProperty(CONFKEY_ANALYSIS_FREEFLOW_ENABLED, false); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH, 2.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH, 3.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND, 0.25); final JUnit4Mockery context = new JUnit4Mockery(); Injector injectorMock = context.mock(Injector.class); EventEmittingTracker trackingServiceMock = context.mock(EventEmittingTracker.class); SafetyZoneService safetyZoneService = new SafetyZoneService(configuration); context.checking(new Expectations() {{ ignoring(trackingServiceMock); oneOf(injectorMock).getInstance(with(SuddenSpeedChangeAnalysis.class)); will(returnValue(new SuddenSpeedChangeAnalysis(configuration, null, trackingServiceMock, null))); oneOf(injectorMock).getInstance(with(CloseEncounterAnalysis.class)); will(returnValue(new CloseEncounterAnalysis(configuration, null, trackingServiceMock, null, safetyZoneService))); }}); PacketHandlerImpl sut = new PacketHandlerImpl(configuration, injectorMock, null, null, null, null); Set<Analysis> analyses = sut.getAnalyses(); assertEquals(2, analyses.size()); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof CourseOverGroundAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof SpeedOverGroundAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof ShipTypeAndSizeAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof DriftAnalysis)); assertEquals(true, analyses.stream().anyMatch(a -> a instanceof SuddenSpeedChangeAnalysis)); assertEquals(true, analyses.stream().anyMatch(a -> a instanceof CloseEncounterAnalysis)); assertEquals(false, analyses.stream().anyMatch(a -> a instanceof FreeFlowAnalysis)); }
Example 13
Source File: TestPartitionMultipleGraphs.java From sqlg with MIT License | 5 votes |
@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 14
Source File: TestSubSubPartition.java From sqlg with MIT License | 5 votes |
@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: TestSharding.java From sqlg with MIT License | 5 votes |
@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: TestUserSuppliedPKTopology.java From sqlg with MIT License | 5 votes |
@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 17
Source File: CloseEncounterAnalysisTest.java From AisAbnormal with GNU Lesser General Public License v3.0 | 4 votes |
@Before public void setUp() throws Exception { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH, 2.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH, 3.0); configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND, 0.25); context = new JUnit4Mockery(); trackingService = context.mock(EventEmittingTracker.class); statisticsService = context.mock(AppStatisticsService.class); eventRepository = context.mock(EventRepository.class); safetyZoneService = new SafetyZoneService(configuration); analysis = new CloseEncounterAnalysis(new PropertiesConfiguration(), statisticsService, trackingService, eventRepository, safetyZoneService); long timestamp = System.currentTimeMillis(); long tooOld = timestamp - maxTimestampDeviationMillis - 1; long old = timestamp - maxTimestampDeviationMillis + 1; long tooNew = timestamp + maxTimestampDeviationMillis + 1; long nyw = timestamp + maxTimestampDeviationMillis - 1; Position position = Position.create(56, 12); Position tooFarAway = Position.create(56.1, 12.1); assertTrue(position.distanceTo(tooFarAway, CoordinateSystem.CARTESIAN) > maxDistanceDeviationMeters); Position farAway = Position.create(56.014, 12.014); assertTrue(position.distanceTo(farAway, CoordinateSystem.CARTESIAN) < maxDistanceDeviationMeters); track = new Track(219000606); track.update(vessel1StaticPacket); track.update(timestamp, position, 90.0f, 10.0f, 90.0f); closeTrack = new Track(219002827); closeTrack.update(vessel2StaticPacket); closeTrack.update(timestamp - 40000, Position.create(56.1000, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp - 30000, Position.create(56.0800, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp - 20000, Position.create(56.0600, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp - 10000, Position.create(56.0400, 12.0010), 180.0f, 10.0f, 180.0f); closeTrack.update(timestamp, Position.create(56.00001, 12.0000), 180.0f, 10.0f, 180.0f); closeTrack.getTrackingReports().forEach( tr -> { tr.setProperty("event-certainty-CloseEncounterEvent", EventCertainty.LOWERED);}); assertTrue(closeTrack.getPosition().equals(Position.create(56.00001, 12.0000))); assertTrue(track.getPosition().distanceTo(closeTrack.getPosition(), CoordinateSystem.CARTESIAN) < 200); distantTrack = new Track(219000606); distantTrack.update(vessel1StaticPacket); distantTrack.update(timestamp, Position.create(57, 13), 90.0f, 10.0f, 90.0f); Track track1 = new Track(1); track1.update(tooOld, position, 90.0f, 10.0f, 90.0f); oldNearbyTrack = new Track(2); oldNearbyTrack.update(old, position, 90.0f, 10.0f, 90.0f); Track track3 = new Track(3); track3.update(tooNew, position, 90.0f, 10.0f, 90.0f); newNearbyTrack = new Track(3); newNearbyTrack.update(nyw, position, 90.0f, 10.0f, 90.0f); Track track4 = new Track(4); track4.update(timestamp, tooFarAway, 90.0f, 10.0f, 90.0f); distantNearbyTrack = new Track(5); distantNearbyTrack.update(timestamp, farAway, 90.0f, 10.0f, 90.0f); tracks = new HashSet<>(); tracks.add(track); tracks.add(track1); tracks.add(oldNearbyTrack); tracks.add(track3); tracks.add(track4); tracks.add(distantNearbyTrack); tracks.add(newNearbyTrack); }
Example 18
Source File: FileReaderWriterFactoryTest.java From secor with Apache License 2.0 | 4 votes |
private void setupSequenceFileReaderConfig() { PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("secor.file.reader.writer.factory", "com.pinterest.secor.io.impl.SequenceFileReaderWriterFactory"); mConfig = new SecorConfig(properties); }
Example 19
Source File: FileReaderWriterFactoryTest.java From secor with Apache License 2.0 | 4 votes |
private void setupDelimitedTextFileWriterConfig() { PropertiesConfiguration properties = new PropertiesConfiguration(); properties.addProperty("secor.file.reader.writer.factory", "com.pinterest.secor.io.impl.DelimitedTextFileReaderWriterFactory"); mConfig = new SecorConfig(properties); }
Example 20
Source File: SegmentDeletionManagerTest.java From incubator-pinot with Apache License 2.0 | 4 votes |
@Test public void testRemoveDeletedSegments() throws Exception { PropertiesConfiguration pinotFSConfig = new PropertiesConfiguration(); pinotFSConfig.addProperty(CommonConstants.Controller.PREFIX_OF_CONFIG_OF_PINOT_FS_FACTORY + ".class", LocalPinotFS.class.getName()); PinotFSFactory.init(pinotFSConfig); HelixAdmin helixAdmin = makeHelixAdmin(); ZkHelixPropertyStore<ZNRecord> propertyStore = makePropertyStore(); File tempDir = Files.createTempDir(); tempDir.deleteOnExit(); FakeDeletionManager deletionManager = new FakeDeletionManager(tempDir.getAbsolutePath(), helixAdmin, propertyStore); // Test delete when deleted segments directory does not exists deletionManager.removeAgedDeletedSegments(1); // Create deleted directory String deletedDirectoryPath = tempDir + File.separator + "Deleted_Segments"; File deletedDirectory = new File(deletedDirectoryPath); deletedDirectory.mkdir(); // Test delete when deleted segments directory is empty deletionManager.removeAgedDeletedSegments(1); // Create dummy directories and files File dummyDir1 = new File(deletedDirectoryPath + File.separator + "dummy1"); dummyDir1.mkdir(); File dummyDir2 = new File(deletedDirectoryPath + File.separator + "dummy2"); dummyDir2.mkdir(); // Test delete when there is no files but some directories exist deletionManager.removeAgedDeletedSegments(1); Assert.assertEquals(dummyDir1.exists(), false); Assert.assertEquals(dummyDir2.exists(), false); // Create dummy directories and files dummyDir1.mkdir(); dummyDir2.mkdir(); // Create dummy files for (int i = 0; i < 3; i++) { createTestFileWithAge(dummyDir1.getAbsolutePath() + File.separator + "file" + i, i); } for (int i = 2; i < 5; i++) { createTestFileWithAge(dummyDir2.getAbsolutePath() + File.separator + "file" + i, i); } // Check that dummy directories and files are successfully created. Assert.assertEquals(dummyDir1.list().length, 3); Assert.assertEquals(dummyDir2.list().length, 3); // Try to remove files with the retention of 3 days. deletionManager.removeAgedDeletedSegments(3); Assert.assertEquals(dummyDir1.list().length, 3); Assert.assertEquals(dummyDir2.list().length, 1); // Try to further remove files with the retention of 1 days. deletionManager.removeAgedDeletedSegments(1); Assert.assertEquals(dummyDir1.list().length, 1); // Check that empty directory has successfully been removed. Assert.assertEquals(dummyDir2.exists(), false); }