Package org.apache.sirona

Examples of org.apache.sirona.Role


        return renderFormat(request, response, Format.Defaults.HTML);
    }

    @Regex("/counter/([^/]*)/([^/]*)\\?name=(.*)")
    public Template counterDetail(final String role, final String unit, final String name, final HttpServletRequest request) {
        final Counter counter = Repository.INSTANCE.getCounter(new Counter.Key(new Role(decode(role), Unit.get(unit)), name)); // name is already decoded by servlet container

        final Map<String, String[]> params = request.getParameterMap();
        final Unit timeUnit = timeUnit(params);
        final String format = format(params, HTMLFormat.NUMBER_FORMAT);

View Full Code Here


            }
            doPost(events2);
        }

        final CollectorCounterStore store = IoCs.getInstance(CollectorCounterStore.class);
        final Counter counter1 = store.getOrCreateCounter(new Counter.Key(new Role("role1", Unit.UNARY), "counter1"));
        final Counter counter1Client1 = store.getOrCreateCounter(new Counter.Key(new Role("role1", Unit.UNARY), "counter1"), "client1");
        final Counter counter1Client2 = store.getOrCreateCounter(new Counter.Key(new Role("role1", Unit.UNARY), "counter1"), "client2");
        assertCounter(counter1, 200, 4, 612, 3.59, 12.24785, 150.01005, 718);
        assertCounter(counter1Client1, 10, 4, 12, 8, 2.64575, 7, 64);
        assertCounter(counter1Client2, 190, 46, 612, 64, 8.83176, 78, 654);
    }
View Full Code Here

            }
            doPost(events2);
        }

        final CollectorGaugeDataStore store = IoCs.getInstance(CollectorGaugeDataStore.class);
        final GaugeValuesRequest gaugeValuesRequest = new GaugeValuesRequest(0, System.currentTimeMillis() + 1000, new Role("event-role", Unit.UNARY));
        final Map<Long, Double> aggregated = store.getGaugeValues(gaugeValuesRequest);
        final Map<Long, Double> node1 = store.getGaugeValues(gaugeValuesRequest, "node1");
        final Map<Long, Double> node2 = store.getGaugeValues(gaugeValuesRequest, "node2");
        assertEquals(1, aggregated.size());
        assertTrue(aggregated.containsValue(20.));
View Full Code Here

    @Test
    public void cubeMe() {
        new SeeMyProtectedStuffStore().doPush();

        final CollectorCounterStore store = IoCs.getInstance(CollectorCounterStore.class);
        final Counter counter1 = store.getOrCreateCounter(new Counter.Key(new Role("cube", Unit.UNARY), "client"));
        final Counter counter1Client1 = store.getOrCreateCounter(new Counter.Key(new Role("cube", Unit.UNARY), "client"), "local");

        assertEquals(50, counter1.getHits());
        assertEquals(counter1.getHits(), counter1Client1.getHits());
    }
View Full Code Here

    }

    private static class SeeMyProtectedStuffStore extends CubeCounterDataStore {
        public void doPush() {
            pushCountersByBatch(Arrays.<Counter>asList(
                new DefaultCounter(new Counter.Key(new Role("cube", Unit.UNARY), "client"), null) {
                    @Override
                    public long getHits() {
                        return 50;
                    }
                })
View Full Code Here

        }
        return data;
    }

    public static String generateCounterKeyString(final Counter.Key key) {
        final Role role = key.getRole();
        try {
            return encode(role.getName()) + '/' + role.getUnit().getName() + "?name=" + encode(key.getName());
        } catch (final UnsupportedEncodingException e) {
            throw new IllegalStateException(e);
        }
    }
View Full Code Here

            Number.class.cast(data.get("concurrency")).intValue());
    }

    private Role role(final Map<String, Object> data) {
        final String name = String.class.cast(data.get("role"));
        final Role existing = roles.get(name);
        if (existing != null) {
            return existing;
        }

        final Role created = new Role(name, Unit.get(String.class.cast(data.get("unit"))));
        roles.put(name, created);
        return created;
    }
View Full Code Here

            return counters;
        }

        for (final HColumn<String, String> colum : qResult.get().getColumns()) {
            final String[] segments = colum.getName().split(cassandra.keySeparator());
            final Counter.Key ckey = new Counter.Key(new Role(segments[0], Unit.get(segments[1])), segments[2]);
            counters.add(findByKey(ckey, marker));
        }

        return counters;
    }
View Full Code Here

        return renderFormat(request, response, Format.Defaults.HTML);
    }

    @Regex("/counter/([^/]*)/([^/]*)\\?name=(.*)")
    public Template counterDetail(final String role, final String unit, final String name, final HttpServletRequest request) {
        final Counter counter = Repository.INSTANCE.getCounter(new Counter.Key(new Role(decode(role), Unit.get(unit)), name)); // name is already decoded by servlet container

        final Map<String, String[]> params = request.getParameterMap();
        final Unit timeUnit = timeUnit(params);
        final String format = format(params, HTMLFormat.NUMBER_FORMAT);

View Full Code Here

    }

    @Override
    protected void pushGauges(final Map<Role, Measure> gauges) {
        for (final Map.Entry<Role, Measure> entry : gauges.entrySet()) {
            final Role role = entry.getKey();
            final Measure measure = entry.getValue();

            delegate.createOrNoopGauge(role, marker);
            delegate.addToGauge(role, measure.getTime(), measure.getValue(), marker);
        }
View Full Code Here

TOP

Related Classes of org.apache.sirona.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.