Search in sources :

Example 16 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class PropertyStoreHBase method readAllProperties.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Property<?>> readAllProperties() {
    Map<String, Property<?>> mapOfProperty = new HashMap<>();
    try (Connection hbConn = ConnectionFactory.createConnection(conn.getConfig())) {
        try (Table table = hbConn.getTable(PROPERTIES_TABLENAME)) {
            Scan scan = new Scan();
            scan.setCaching(100);
            scan.setBatch(100);
            scan.addFamily(B_FEATURES_CF_PROPERTIES);
            try (ResultScanner resultScanner = table.getScanner(scan)) {
                Iterator<Result> iterator = resultScanner.iterator();
                while (iterator.hasNext()) {
                    Property<?> p = MAPPER.fromStore(iterator.next());
                    mapOfProperty.put(p.getName(), p);
                }
            }
        }
    } catch (IOException e) {
        throw new PropertyAccessException("Cannot read all property", e);
    }
    return mapOfProperty;
}
Also used : Table(org.apache.hadoop.hbase.client.Table) ResultScanner(org.apache.hadoop.hbase.client.ResultScanner) HashMap(java.util.HashMap) HBaseConnection(org.ff4j.hbase.HBaseConnection) Connection(org.apache.hadoop.hbase.client.Connection) PropertyAccessException(org.ff4j.exception.PropertyAccessException) IOException(java.io.IOException) Result(org.apache.hadoop.hbase.client.Result) Scan(org.apache.hadoop.hbase.client.Scan) Property(org.ff4j.property.Property)

Example 17 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class PropertyStoreJCacheTest method clear.

/**
 * TDD.
 */
@Test
public void clear() {
    // Given
    Assert.assertNotNull(testedStore);
    Map<String, Property<?>> before = testedStore.readAllProperties();
    Assert.assertFalse(before.isEmpty());
    // When
    testedStore.clear();
    // Then
    Assert.assertTrue(testedStore.readAllProperties().isEmpty());
    // / Reinit
    for (String pName : before.keySet()) {
        testedStore.createProperty(before.get(pName));
    }
}
Also used : PropertyString(org.ff4j.property.PropertyString) Property(org.ff4j.property.Property) Test(org.junit.Test)

Example 18 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class PropertyStoreCassandra method readAllProperties.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Property<?>> readAllProperties() {
    Map<String, Property<?>> properties = new HashMap<String, Property<?>>();
    ResultSet rs = cqlSession.execute(STMT_PROPERTY_READ_ALL);
    for (Row row : rs.all()) {
        Property<?> p = mapPropertyRow(row);
        properties.put(p.getName(), p);
    }
    return properties;
}
Also used : HashMap(java.util.HashMap) ResultSet(com.datastax.oss.driver.api.core.cql.ResultSet) Row(com.datastax.oss.driver.api.core.cql.Row) Property(org.ff4j.property.Property)

Example 19 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class PropertyStoreCouchbase method readAllProperties.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Property<?>> readAllProperties() {
    N1qlQuery queryFeatures = N1qlQuery.simple("SELECT * FROM " + couchBaseConnection.getFf4jPropertyBucketName());
    N1qlQueryResult queryResult = getPropertyBucket().query(queryFeatures);
    Map<String, Property<?>> allProperties = new HashMap<>();
    for (N1qlQueryRow row : queryResult.allRows()) {
        Property<?> p = PropertyJsonParser.parseProperty(row.value().get(couchBaseConnection.getFf4jPropertyBucketName()).toString());
        allProperties.put(p.getName(), p);
    }
    return allProperties;
}
Also used : N1qlQueryRow(com.couchbase.client.java.query.N1qlQueryRow) N1qlQuery(com.couchbase.client.java.query.N1qlQuery) HashMap(java.util.HashMap) N1qlQueryResult(com.couchbase.client.java.query.N1qlQueryResult) Property(org.ff4j.property.Property)

Example 20 with Property

use of org.ff4j.property.Property in project ff4j by ff4j.

the class PropertyStoreCommonsConfig method readAllProperties.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, Property<?>> readAllProperties() {
    Map<String, Property<?>> props = new HashMap<String, Property<?>>();
    Iterator<String> iterKeys = conf().getKeys();
    while (iterKeys.hasNext()) {
        String currentKey = iterKeys.next();
        props.put(currentKey, readProperty(currentKey));
    }
    return props;
}
Also used : HashMap(java.util.HashMap) PropertyString(org.ff4j.property.PropertyString) Property(org.ff4j.property.Property)

Aggregations

Property (org.ff4j.property.Property)56 HashMap (java.util.HashMap)20 PropertyString (org.ff4j.property.PropertyString)20 Test (org.junit.Test)20 Feature (org.ff4j.core.Feature)16 Map (java.util.Map)11 InputStream (java.io.InputStream)9 XmlParser (org.ff4j.conf.XmlParser)7 InMemoryPropertyStore (org.ff4j.property.store.InMemoryPropertyStore)7 LinkedHashMap (java.util.LinkedHashMap)6 XmlConfig (org.ff4j.conf.XmlConfig)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 FeatureStore (org.ff4j.core.FeatureStore)4 PropertyAccessException (org.ff4j.exception.PropertyAccessException)4 PropertyStore (org.ff4j.property.store.PropertyStore)4 IOException (java.io.IOException)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3 FF4jCacheProxy (org.ff4j.cache.FF4jCacheProxy)3