Package org.rioproject.impl.watch

Examples of org.rioproject.impl.watch.GaugeWatch


                super.initialize(context);
            }
            Configuration config = context.getConfiguration();
            deploymentVerifier = new DeploymentVerifier(config, context.getDiscoveryManagement());
            ProvisionMonitorEventProcessor eventProcessor = new ProvisionMonitorEventProcessor(config);
            provisionWatch = new GaugeWatch("Provision Clock", config);
            getWatchRegistry().register(provisionWatch);

            /* Wire up event handlers for the ProvisionMonitorEvent and the ProvisionFailureEvent */
            EventDescriptor clientEventDesc = ProvisionMonitorEvent.getEventDescriptor();
            getEventTable().put(clientEventDesc.eventID, eventProcessor.getMonitorEventHandler());
View Full Code Here


    /**
     * Is overridden to setup the load watch.
     */
    public void initialize(ServiceBeanContext context) throws Exception {
        super.initialize(context);
        loadWatch = new GaugeWatch("load");
        getWatchRegistry().register(loadWatch);
        loadWatch.addValue(0);
    }
View Full Code Here

     * @throws RemoteException if watch data source causes problems
     */
    @Test
    public void testAddValue1() throws RemoteException {
        String id = "watch";
        GaugeWatch watch = new GaugeWatch(id);
        DataSourceMonitor mon = new DataSourceMonitor(watch);

        final int checkpoints[] = new int[] {0, 1, 50, 1000, 1001, 2000, 10000};
        final int collectionSize = 1000;
        List<Double> added = new ArrayList<Double>();

        // Go through the checkpoints
        for (int checkpoint : checkpoints) {
            if(watch.getWatchDataSource().getMaxSize()<checkpoint) {
                watch.getWatchDataSource().setMaxSize(1000);
            }
            // Generate samples to reach the checkpoint
            while (added.size() < checkpoint) {
                double d = Math.random();
                added.add(d);
                watch.addValue(d);
            }
            //mon.waitFor(added.size());
            mon.waitFor(Math.min(collectionSize, checkpoint));

            // Verify that the data has been added correctly
            Calculable[] calcs = watch.getWatchDataSource().getCalculable();
            int offset = Math.max(added.size() - collectionSize, 0);
            List<Double> expected = added.subList(offset, added.size());
            List<Double> actual = new ArrayList<Double>();
            for (Calculable calc : calcs) {
                Assert.assertEquals(id, calc.getId());
                actual.add(calc.getValue());
            }
            Assert.assertEquals(expected, actual);
        }

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

     * @throws RemoteException if watch data source causes problems
     */
    @Test
    public void testAddValue2() throws RemoteException {
        String id = "watch";
        GaugeWatch watch = new GaugeWatch(id);
        DataSourceMonitor mon = new DataSourceMonitor(watch);

        final int checkpoints[] = new int[] {0, 1, 50, 1000, 1001, 2000, 10000};
        final int collectionSize = 1000;
        List<Long> added = new ArrayList<Long>();

        // Go through the checkpoints
        for (int checkpoint : checkpoints) {
            if(watch.getWatchDataSource().getMaxSize()<checkpoint) {
                watch.getWatchDataSource().setMaxSize(1000);
            }

            // Generate samples to reach the checkpoint
            while (added.size() < checkpoint) {
                long l = (long) (Math.random() * 1000);
                added.add(l);
                watch.addValue(l);
            }
            mon.waitFor(Math.min(collectionSize, checkpoint));

            // Verify that the data has been added correctly
            Calculable[] calcs = watch.getWatchDataSource().getCalculable();
            int offset = Math.max(added.size() - collectionSize, 0);
            List<Long> expected = added.subList(offset, added.size());
            List<Long> actual = new ArrayList<Long>();
            for (Calculable calc : calcs) {
                Assert.assertEquals(id, calc.getId());
                actual.add((long) calc.getValue());
            }
            Assert.assertEquals(expected, actual);
        }

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

    public void setServiceBeanContext(ServiceBeanContext context) throws Exception {
        /* Create and register the event producer */
        eventHandler = new DispatchEventHandler(HelloEvent.getEventDescriptor());
        context.registerEventHandler(HelloEvent.getEventDescriptor(), eventHandler);

        notification = new GaugeWatch("notification");

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

    private AtomicInteger rhsExecutedCount = new AtomicInteger();
    private GaugeWatch notification;
    private Logger logger = LoggerFactory.getLogger(TestServiceImpl.class.getName());

    public void setServiceBeanContext(ServiceBeanContext context) {
        loadWatch = new GaugeWatch("load");
        context.getWatchRegistry().register(loadWatch);
        instanceID = context.getServiceBeanConfig().getInstanceID();
        name = context.getServiceElement().getName();

        notification = new GaugeWatch("notification");
        context.getWatchRegistry().register(notification);
    }
View Full Code Here

            }
        }
        Random random = new Random();
        int room = random.nextInt(numRooms)+1;
        roomNumber = Integer.toString(room);
        temperature = new GaugeWatch("temperature");
        pulse = new GaugeWatch("pulse");
        context.getWatchRegistry().register(temperature, pulse);
        logger.debug("Created Bed:%{} in room #{}", context.getServiceBeanConfig().getInstanceID(),roomNumber);
    }
View Full Code Here

                                                                     String.class,
                                                                     null,
                                                                     name);
        logger.debug("Status for {} is {}", name, sStatus);
        this.status = Status.valueOf(sStatus);
        numPatients = new GaugeWatch("numPatients");
        context.getWatchRegistry().register(numPatients);
    }   
View Full Code Here

TOP

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

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.