Examples of CounterValue


Examples of net.floodlightcontroller.counter.CounterValue

    @Get("json")
    public Map<String, Object> retrieve() {
        String counterTitle =
            (String) getRequestAttributes().get("counterTitle");
        Map<String, Object> model = new HashMap<String,Object>();
        CounterValue v;
        if (counterTitle.equalsIgnoreCase("all")) {
            Map<String, ICounter> counters = this.counterStore.getAll();
            if (counters != null) {
                Iterator<Map.Entry<String, ICounter>> it =
                    counters.entrySet().iterator();
                while (it.hasNext()) {
                    Entry<String, ICounter> entry = it.next();
                    String counterName = entry.getKey();
                    v = entry.getValue().getCounterValue();

                    if (CounterValue.CounterType.LONG == v.getType()) {
                        model.put(counterName, v.getLong());
                    } else if (v.getType() == CounterValue.CounterType.DOUBLE) {
                        model.put(counterName, v.getDouble());
                    }  
                }  
            }  
        } else {
            ICounter counter = this.counterStore.getCounter(counterTitle);
            if (counter != null) {
                v = counter.getCounterValue();
            } else {
                v = new CounterValue(CounterValue.CounterType.LONG);
            }  

            if (CounterValue.CounterType.LONG == v.getType()) {
                model.put(counterTitle, v.getLong());
            } else if (v.getType() == CounterValue.CounterType.DOUBLE) {
                model.put(counterTitle, v.getDouble());
            }  
        }
        return model;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.