Search in sources :

Example 1 with MutableHitCount

use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.

the class EventRepositoryCassandra method getHostHitCount.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, MutableHitCount> getHostHitCount(EventQueryDefinition query) {
    String cqlQuery = getBuilder().cqlHostHitCount(query);
    LOGGER.debug("Query " + cqlQuery);
    ResultSet rs = conn.getSession().execute(cqlQuery);
    Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
    for (Row row : rs.all()) {
        String hostName = row.getString(COL_EVENT_HOSTNAME);
        if (hitCount.containsKey(hostName)) {
            hitCount.get(hostName).inc();
        } else {
            hitCount.put(hostName, new MutableHitCount(1));
        }
    }
    return hitCount;
}
Also used : HashMap(java.util.HashMap) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) MutableHitCount(org.ff4j.audit.MutableHitCount)

Example 2 with MutableHitCount

use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.

the class EventRepositoryCassandra method getSourceHitCount.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, MutableHitCount> getSourceHitCount(EventQueryDefinition query) {
    String cqlQuery = getBuilder().cqlSourceHitCount(query);
    LOGGER.debug("Query " + cqlQuery);
    ResultSet rs = conn.getSession().execute(cqlQuery);
    Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
    for (Row row : rs.all()) {
        String source = row.getString(COL_EVENT_SOURCE);
        if (hitCount.containsKey(source)) {
            hitCount.get(source).inc();
        } else {
            hitCount.put(source, new MutableHitCount(1));
        }
    }
    return hitCount;
}
Also used : HashMap(java.util.HashMap) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) MutableHitCount(org.ff4j.audit.MutableHitCount)

Example 3 with MutableHitCount

use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.

the class EventRepositoryCassandra method getUserHitCount.

/**
 * {@inheritDoc}
 */
@Override
public Map<String, MutableHitCount> getUserHitCount(EventQueryDefinition query) {
    String cqlQuery = getBuilder().cqlUserHitCount(query);
    LOGGER.debug("Query " + cqlQuery);
    ResultSet rs = conn.getSession().execute(cqlQuery);
    Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
    for (Row row : rs.all()) {
        String user = row.getString(COL_EVENT_USER);
        if (hitCount.containsKey(user)) {
            hitCount.get(user).inc();
        } else {
            hitCount.put(user, new MutableHitCount(1));
        }
    }
    return hitCount;
}
Also used : HashMap(java.util.HashMap) ResultSet(com.datastax.driver.core.ResultSet) Row(com.datastax.driver.core.Row) MutableHitCount(org.ff4j.audit.MutableHitCount)

Example 4 with MutableHitCount

use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.

the class EventRepositoryElastic method getFeatureUsageHitCount.

@Override
public Map<String, MutableHitCount> getFeatureUsageHitCount(EventQueryDefinition query) {
    JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query, EventConstants.ACTION_CHECK_OK));
    List<Event> events = result.getSourceAsObjectList(Event.class);
    Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
    for (Event event : events) {
        String name = event.getName();
        if (hitCount.containsKey(name)) {
            hitCount.get(name).inc();
        } else {
            hitCount.put(name, new MutableHitCount(1));
        }
    }
    return hitCount;
}
Also used : HashMap(java.util.HashMap) Event(org.ff4j.audit.Event) JestResult(io.searchbox.client.JestResult) MutableHitCount(org.ff4j.audit.MutableHitCount)

Example 5 with MutableHitCount

use of org.ff4j.audit.MutableHitCount in project ff4j by ff4j.

the class EventRepositoryElastic method getUserHitCount.

@Override
public Map<String, MutableHitCount> getUserHitCount(EventQueryDefinition query) {
    JestResult result = getConnection().execute(getBuilder().queryGetEventQueryDefinition(query, EventConstants.ACTION_CHECK_OK));
    List<Event> events = result.getSourceAsObjectList(Event.class);
    Map<String, MutableHitCount> hitCount = new HashMap<String, MutableHitCount>();
    for (Event event : events) {
        String user = event.getUser();
        if (hitCount.containsKey(user)) {
            hitCount.get(user).inc();
        } else {
            hitCount.put(user, new MutableHitCount(1));
        }
    }
    return hitCount;
}
Also used : HashMap(java.util.HashMap) Event(org.ff4j.audit.Event) JestResult(io.searchbox.client.JestResult) MutableHitCount(org.ff4j.audit.MutableHitCount)

Aggregations

MutableHitCount (org.ff4j.audit.MutableHitCount)27 Event (org.ff4j.audit.Event)15 HashMap (java.util.HashMap)14 Test (org.junit.Test)10 EventQueryDefinition (org.ff4j.audit.EventQueryDefinition)8 ResultSet (com.datastax.driver.core.ResultSet)4 Row (com.datastax.driver.core.Row)4 JestResult (io.searchbox.client.JestResult)4 Map (java.util.Map)3 Timestamp (java.sql.Timestamp)2 Date (java.util.Date)2 TreeMap (java.util.TreeMap)2 Serie (org.ff4j.audit.chart.Serie)2 TimeSeriesChart (org.ff4j.audit.chart.TimeSeriesChart)2 IOException (java.io.IOException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 SimpleDateFormat (java.text.SimpleDateFormat)1