Search in sources :

Example 1 with Stats

use of org.infinispan.stats.Stats in project camel by apache.

the class InfinispanProducerTest method statsOperation.

@Test
public void statsOperation() throws Exception {
    ((Cache) currentCache()).getAdvancedCache().getStats().setStatisticsEnabled(true);
    template.send("direct:start", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(InfinispanConstants.KEY, KEY_ONE);
            exchange.getIn().setHeader(InfinispanConstants.VALUE, VALUE_ONE);
            exchange.getIn().setHeader(InfinispanConstants.OPERATION, InfinispanConstants.PUT);
        }
    });
    Object value = currentCache().get(KEY_ONE);
    assertEquals(VALUE_ONE, value.toString());
    template.send("direct:start", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
            exchange.getIn().setHeader(InfinispanConstants.KEY, KEY_TWO);
            exchange.getIn().setHeader(InfinispanConstants.VALUE, VALUE_TWO);
            exchange.getIn().setHeader(InfinispanConstants.OPERATION, InfinispanConstants.PUT);
        }
    });
    value = currentCache().get(KEY_TWO);
    assertEquals(VALUE_TWO, value.toString());
    Exchange exchange;
    exchange = template.send("direct:stats", new Processor() {

        @Override
        public void process(Exchange exchange) throws Exception {
        }
    });
    Stats resultStats = exchange.getIn().getHeader(InfinispanConstants.RESULT, Stats.class);
    assertEquals(2L, resultStats.getTotalNumberOfEntries());
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) Stats(org.infinispan.stats.Stats) Cache(org.infinispan.Cache) Test(org.junit.Test)

Aggregations

Exchange (org.apache.camel.Exchange)1 Processor (org.apache.camel.Processor)1 Cache (org.infinispan.Cache)1 Stats (org.infinispan.stats.Stats)1 Test (org.junit.Test)1