Package org.rioproject.impl.watch

Examples of org.rioproject.impl.watch.StopWatch


     * invocation takes
     *
     * @param watchRegistry The WatchRegistry to register the StopWatch
     */
    public void createWatch(WatchDataSourceRegistry watchRegistry) {
        responseWatch = new StopWatch(RESPONSE_WATCH + descriptor.toString());
        if(watchRegistry == null)
            return;
        this.watchRegistry = watchRegistry;
        watchRegistry.register(responseWatch);
    }
View Full Code Here


     *
     * @throws RemoteException if the test fails
     */
    @Test
    public void testGetSetStartTime() throws RemoteException {
        StopWatch watch = new StopWatch("watch");
        Assert.assertEquals(0, watch.getStartTime());

        for (int i = 0; i < 10; i++) {
            long value = Math.round(Math.random() * 100);
            watch.setStartTime(value);
            Assert.assertEquals(value, watch.getStartTime());
        }

        checkData(0, watch);

        for (int i = 0; i < 10; i++) {
            watch.setStartTime(System.currentTimeMillis());
            watch.stopTiming();
            checkData(i + 1, watch);
        }

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

     *
     * @throws RemoteException if the test fails
     */
    @Test
    public void testSetElapsedTime1() throws RemoteException {
        StopWatch watch = new StopWatch("watch");

        List<Long> expected = new ArrayList<Long>();
        checkData(expected, watch);

        for (int i = 0; i < 10; i++) {
            long value = Math.round(Math.random() * 100);
            watch.setElapsedTime(value);
            expected.add(value);
            checkData(expected, watch);
        }

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

     *
     * @throws RemoteException if the test fails
     */
    @Test
    public void testSetElapsedTime2() throws RemoteException {
        StopWatch watch = new StopWatch("watch");

        List<Long> expectedValues = new ArrayList<Long>();
        List<Long> expectedStamps = new ArrayList<Long>();
        checkData(expectedValues, expectedStamps, watch);

        for (int i = 0; i < 10; i++) {
            long value = Math.round(Math.random() * 100);
            long stamp = Math.round(Math.random() * 100);
            watch.setElapsedTime(value, stamp);
            expectedValues.add(value);
            expectedStamps.add(stamp);
            checkData(expectedValues, expectedStamps, watch);
        }

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

     *
     * @throws RemoteException if the test fails
     */
    @Test
    public void testStartTiming() throws RemoteException {
        StopWatch watch = new StopWatch("watch");

        Assert.assertEquals(0, watch.getStartTime());

        long prevStartTime = -1;
        for (int i = 0; i < 10; i++) {
            Utils.sleep(100);
            watch.startTiming();
            long startTime = watch.getStartTime();
            Assert.assertTrue(startTime >= 0);
            if (prevStartTime != -1) {
                Assert.assertTrue(startTime > prevStartTime);
            }
            prevStartTime = startTime;
        }

        checkData(0, watch);

        for (int i = 0; i < 10; i++) {
            watch.startTiming();
            Utils.sleep(100);
            watch.stopTiming();
            checkData(i + 1, watch);
        }

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

     *
     * @throws RemoteException if the test fails
     */
    @Test
    public void testStopTiming() throws RemoteException {
        StopWatch watch = new StopWatch("watch");
        DataSourceMonitor mon = new DataSourceMonitor(watch);

        checkData(0, watch);

        for (int i = 0; i < 10; i++) {
            Utils.sleep(100);
            watch.stopTiming();
            mon.waitFor(i + 1);
            Calculable[] calcs = watch.getWatchDataSource().getCalculable();
            Assert.assertEquals(i + 1, calcs.length);
            Assert.assertTrue(calcs[0].getValue() > 0);
            for (int j = 1; j < calcs.length; j++) {
                Assert.assertTrue(calcs[j].getValue()
                                  >= calcs[j - 1].getValue());
            }
        }

        for (int i = 0; i < 10; i++) {
            watch.startTiming();
            Utils.sleep(100);
            watch.stopTiming();
            checkData(10 + i + 1, watch);
        }

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

    public Watch createWatch(final WatchDataSourceRegistry watchRegistry) {
        if(watchRegistry == null)
            throw new IllegalArgumentException("watchRegistry is null");
        if(responseWatch!=null)
            return responseWatch;
        responseWatch = new StopWatch(RESPONSE_WATCH, config);
        this.watchRegistry = watchRegistry;
        watchRegistry.register(responseWatch);
        return responseWatch;
    }
View Full Code Here

        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);
        service.submit(new SpaceProcessor());
        context.getWatchRegistry().register(rate);
View Full Code Here

        notification = new GaugeWatch("notification");

        /*
        * Create the stop watch, and register the stop watch */
        watch = new StopWatch("HelloWatch");
        context.getWatchRegistry().register(watch, notification);

        logger.debug("Initialized HelloImpl");
    }
View Full Code Here

    public void setServiceBeanContext(ServiceBeanContext context) throws Exception {
        /**
         * Create the stop watch, and register the stop watch with the
         * WatchDataRegistry
         */
        watch = new StopWatch("Hello Consumer");
        context.getWatchRegistry().register(watch);
        localConsumer = new LocalEventConsumer();
        consumer = new BasicEventConsumer(HelloEvent.getEventDescriptor(),
                                          localConsumer);
        logger.info("Initialized HelloEvent Consumer");
View Full Code Here

TOP

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

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.