Package org.apache.sirona.counters

Examples of org.apache.sirona.counters.Unit


    @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);

        final Map<String, Collection<String>> counters = new TreeMap<String, Collection<String>>();
        if (AggregatedCounter.class.isInstance(counter)) {
            for (final Map.Entry<String, ? extends Counter> marker : AggregatedCounter.class.cast(counter).aggregated().entrySet()) {
View Full Code Here


    private static final String SEPARATOR = Configuration.getProperty(Configuration.CONFIG_PROPERTY_PREFIX + "csv.separator", ";");
    public static final String HEADER = "Counter" + SEPARATOR + "Role" + SEPARATOR + toCsv(ATTRIBUTES_ORDERED_LIST);

    @Override
    public Template render(final Map<String, ?> params) {
        final Unit timeUnit = timeUnit(params);
        return new Template("/templates/report/report-csv.vm",
                        new MapBuilder<String, Object>()
                        .set("headers", HEADER)
                        .set("separator", SEPARATOR)
                        .set("lines", snapshot(timeUnit, format(params, null)))
View Full Code Here

        }

        final Object u = params.get("unit");
        if (u != null) {
            if (String.class.isInstance(u)) {
                final Unit unit = Unit.get(String.class.cast(u).toLowerCase());
                if (unit != null) {
                    return unit;
                }
            }
            if (String[].class.isInstance(u)) {
                final String[] array = String[].class.cast(u);
                if (array.length > 0) {
                    final Unit unit = Unit.get(array[0].toLowerCase());
                    if (unit != null) {
                        return unit;
                    }
                }
            }
View Full Code Here

        }
        return data;
    }

    public static Collection<String> generateLine(final Counter counter, final Unit timeUnit, final String format) {
        final Unit counterUnit = counter.getKey().getRole().getUnit();
        final boolean compatible = timeUnit.isCompatible(counterUnit);

        final Collection<String> line = new ArrayList<String>();

        line.add(counter.getKey().getName());

        if (compatible) {
            line.add(counter.getKey().getRole().getName() + " (" + timeUnit.getName() + ")");
        } else {
            line.add(counter.getKey().getRole().getName() + " (" + counterUnit.getName() + ")");
        }

        final DecimalFormat formatter;
        if (format != null) {
            formatter = new DecimalFormat(format);
View Full Code Here

public class HTMLFormat extends MapFormat implements Format {
    public static final String NUMBER_FORMAT = "###,###,###,##0.00"; // DecimalFormat is not thread safe so don't init it statically

    @Override
    public Template render(final Map<String, ?> params) {
        final Unit timeUnit = timeUnit(params);
        return new Template("report/report.vm",
            new MapBuilder<String, Object>()
                .set(Map.class.cast(params))
                .set("headers", ATTRIBUTES_ORDERED_LIST)
                .set("data", snapshotByPath(timeUnit, format(params, NUMBER_FORMAT)))
View Full Code Here

    @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);

        final Map<String, Collection<String>> counters = new TreeMap<String, Collection<String>>();
        if (AggregatedCounter.class.isInstance(counter)) {
            for (final Map.Entry<String, ? extends Counter> marker : AggregatedCounter.class.cast(counter).aggregated().entrySet()) {
View Full Code Here

    private static final String SEPARATOR = Configuration.getProperty(Configuration.CONFIG_PROPERTY_PREFIX + "csv.separator", ";");
    public static final String HEADER = "Monitor" + SEPARATOR + "Role" + SEPARATOR + toCsv(ATTRIBUTES_ORDERED_LIST);

    @Override
    public Template render(final Map<String, ?> params) {
        final Unit timeUnit = timeUnit(params);
        return new Template("/templates/report/report-csv.vm",
                        new MapBuilder<String, Object>()
                        .set("headers", HEADER)
                        .set("separator", SEPARATOR)
                        .set("lines", snapshot(timeUnit, format(params, null)))
View Full Code Here

TOP

Related Classes of org.apache.sirona.counters.Unit

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.