Search in sources :

Example 1 with PropertyStore

use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.

the class FF4jConfiguration method subset.

/**
 * {@inheritDoc}
 */
@Override
public Configuration subset(String prefix) {
    Map<String, Property<?>> myProps = ff4jStore().readAllProperties();
    PropertyStore ps = new InMemoryPropertyStore();
    for (Map.Entry<String, Property<?>> prop : myProps.entrySet()) {
        if (prop.getKey().startsWith(prefix)) {
            ps.createProperty(prop.getValue());
        }
    }
    return new FF4jConfiguration(ps);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) Property(org.ff4j.property.Property) Map(java.util.Map) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore)

Example 2 with PropertyStore

use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.

the class PropertyStoreArchaiusCommonsConfTest method testInitPropertyStore2.

/**
 * {@inheritDoc}
 */
@Test
public void testInitPropertyStore2() {
    PropertyStore sourceStore = new InMemoryPropertyStore("ff4j-properties.xml");
    PropertyStore archaiusStore = new PropertyStoreArchaius(sourceStore);
    Assert.assertTrue(archaiusStore.existProperty("a"));
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) Test(org.junit.Test)

Example 3 with PropertyStore

use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.

the class PropertyStoreAsArchaiusInputTest method initArchauisWithFF4j.

@BeforeClass
public static void initArchauisWithFF4j() throws InterruptedException {
    // Sample FF4J Store
    PropertyStore ff4jStore = new InMemoryPropertyStore("ff4j-properties.xml");
    // FF4Store as polling Source for Archiaus
    PolledConfigurationSource ff4jSource = new FF4jPolledConfigurationSource(ff4jStore);
    // Working Thread (polling from ff4j => Archaius)
    AbstractPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 100, true);
    // Define configuration with polling and source
    DynamicConfiguration configuration = new DynamicConfiguration(ff4jSource, scheduler);
    // Init configuration
    ConfigurationManager.install(configuration);
    // Other initialization mechanism
    FF4jPolledConfigurationSource conf2 = new FF4jPolledConfigurationSource();
    conf2.setFf4jStore(ff4jStore);
    // Must invoke poll
    Thread.sleep(100);
}
Also used : InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) DynamicConfiguration(com.netflix.config.DynamicConfiguration) AbstractPollingScheduler(com.netflix.config.AbstractPollingScheduler) FixedDelayPollingScheduler(com.netflix.config.FixedDelayPollingScheduler) PolledConfigurationSource(com.netflix.config.PolledConfigurationSource) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) BeforeClass(org.junit.BeforeClass)

Example 4 with PropertyStore

use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.

the class PropertyStoreAuditProxyTest method initPropertyStore.

/**
 * {@inheritDoc}
 */
@Override
protected PropertyStore initPropertyStore() {
    FF4j ff4j = new FF4j();
    PropertyStore ps = new InMemoryPropertyStore("ff4j.xml");
    ff4j.setPropertiesStore(ps);
    return new PropertyStoreAuditProxy(ff4j, ps);
}
Also used : PropertyStoreAuditProxy(org.ff4j.audit.proxy.PropertyStoreAuditProxy) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) FF4j(org.ff4j.FF4j) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore)

Example 5 with PropertyStore

use of org.ff4j.property.store.PropertyStore in project ff4j by ff4j.

the class CacheProxyWithPollingTest method testCacheProxyManagerProperty.

@Test
public void testCacheProxyManagerProperty() throws InterruptedException {
    // When
    FeatureStore fs = new InMemoryFeatureStore("ff4j.xml");
    PropertyStore ps = new InMemoryPropertyStore("ff4j.xml");
    FF4JCacheManager cm = new InMemoryCacheManager();
    FF4jCacheProxy proxy = new FF4jCacheProxy(fs, ps, cm);
    // Start polling on 100ms basis
    proxy.startPolling(100);
    proxy.createSchema();
    Thread.sleep(200);
    // When (Remove something)
    fs.delete("AwesomeFeature");
    // Then (Proxy is not yet refresh)
    Assert.assertTrue(proxy.exist("AwesomeFeature"));
    // When (wait for cache refresh)
    Thread.sleep(200);
    // Then (also delete in cache si Cache is refreshed)
    Assert.assertFalse(proxy.exist("AwesomeFeature"));
    Store2CachePollingScheduler scheduler = proxy.getStore2CachePoller();
    scheduler.setInitialDelay(scheduler.getInitialDelay());
    scheduler.setPollingDelay(scheduler.getPollingDelay());
    proxy.stopPolling();
    proxy.setStore2CachePoller(new Store2CachePollingScheduler(fs, ps, cm));
}
Also used : FF4JCacheManager(org.ff4j.cache.FF4JCacheManager) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) InMemoryCacheManager(org.ff4j.cache.InMemoryCacheManager) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FF4jCacheProxy(org.ff4j.cache.FF4jCacheProxy) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FeatureStore(org.ff4j.core.FeatureStore) Store2CachePollingScheduler(org.ff4j.cache.Store2CachePollingScheduler) InMemoryPropertyStore(org.ff4j.property.store.InMemoryPropertyStore) PropertyStore(org.ff4j.property.store.PropertyStore) Test(org.junit.Test)

Aggregations

PropertyStore (org.ff4j.property.store.PropertyStore)8 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)6 FeatureStore (org.ff4j.core.FeatureStore)3 AbstractPollingScheduler (com.netflix.config.AbstractPollingScheduler)2 DynamicConfiguration (com.netflix.config.DynamicConfiguration)2 FixedDelayPollingScheduler (com.netflix.config.FixedDelayPollingScheduler)2 PolledConfigurationSource (com.netflix.config.PolledConfigurationSource)2 Map (java.util.Map)2 FF4j (org.ff4j.FF4j)2 Property (org.ff4j.property.Property)2 BeforeClass (org.junit.BeforeClass)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 PropertyStoreAuditProxy (org.ff4j.audit.proxy.PropertyStoreAuditProxy)1 FF4JCacheManager (org.ff4j.cache.FF4JCacheManager)1 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)1 InMemoryCacheManager (org.ff4j.cache.InMemoryCacheManager)1 Store2CachePollingScheduler (org.ff4j.cache.Store2CachePollingScheduler)1 XmlConfig (org.ff4j.conf.XmlConfig)1 XmlParser (org.ff4j.conf.XmlParser)1