Package org.rioproject.impl.watch

Examples of org.rioproject.impl.watch.CounterWatch


     * Tests the <code>getCounter</code> and <code>setCounter</code>
     * methods.
     */
    @Test
    public void testGetSetCounter() {
        CounterWatch watch = new CounterWatch("watch");
        Assert.assertEquals(0, watch.getCounter());
        for (int i = 0; i < 10; i++) {
            long value = Math.round(Math.random() * 100);
            watch.setCounter(value);
            Assert.assertEquals(value, watch.getCounter());
        }
        Utils.close(watch.getWatchDataSource());
    }
View Full Code Here


     *
     * @throws RemoteException if the test fails
     */
    @Test
    public void testModificatorMethods() throws RemoteException {
        CounterWatch watch = new CounterWatch("watch");
        checkData(new double[] {}, watch);

        watch.decrement();
        checkData(new double[] {-1}, watch);

        watch.decrement(10);
        checkData(new double[] {-1, -11}, watch);

        watch.setCounter(-100);
        checkData(new double[] {-1, -11, -100}, watch);

        watch.setCounter(1);
        checkData(new double[] {-1, -11, -100, 1}, watch);

        watch.increment();
        checkData(new double[] {-1, -11, -100, 1, 2}, watch);

        watch.increment(10);
        checkData(new double[] {-1, -11, -100, 1, 2, 12}, watch);

        watch.decrement(13);
        checkData(new double[] {-1, -11, -100, 1, 2, 12, -1}, watch);

        Utils.close(watch.getWatchDataSource());
    }
View Full Code Here

    @PreAdvertise
    public void startup() {
        if(space==null)
            throw new IllegalStateException("The JavaSpace should have been injected prior to this method being called");
        logger.info("PRE_ADVERTISE {}", context.getServiceElement().getName());
        rate = new CounterWatch("rate");
        throughput = new ThroughputWatch("throughput");
        meanTime = new StopWatch("meanTime");
        timeout = 1000*10;
        int workerTasks = 1;
        service = Executors.newFixedThreadPool(workerTasks);
View Full Code Here

    private Long instanceID;

    public void setServiceBeanContext(ServiceBeanContext context) {
        instanceID = context.getServiceBeanConfig().getInstanceID();
        //loadWatch = new GaugeWatch("load");
        kSessionCounter = new CounterWatch("kSessionCounter");
        // context.getWatchRegistry().register(loadWatch);
        context.getWatchRegistry().register(kSessionCounter);
        instanceID = context.getServiceBeanConfig().getInstanceID();
    }
View Full Code Here

    private final static Logger logger = LoggerFactory.getLogger(HospitalImpl.class.getName());

    @SuppressWarnings("unused") /* Injection point for Rio */
    public void setServiceBeanContext(final ServiceBeanContext context) {
        this.context = context;
        availableBeds = new CounterWatch("availableBeds");
        context.getWatchRegistry().register(availableBeds);
    }
View Full Code Here

TOP

Related Classes of org.rioproject.impl.watch.CounterWatch

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.