Package org.rioproject.watch

Examples of org.rioproject.watch.WatchDataSource


        Assert.assertNotNull(testManager);
        SettableLoadService service = (SettableLoadService)testManager.waitForService(SettableLoadService.class);
        Assert.assertNotNull(service);
        Throwable thrown = null;
        try {           
            WatchDataSource systemCPU = service.fetch(SystemWatchID.SYSTEM_CPU);
            Assert.assertNotNull(systemCPU);
            WatchDataSource load = service.fetch("load");
            Assert.assertNotNull(load);
        } catch (RemoteException e) {
            thrown = e;
            e.printStackTrace();
        }
View Full Code Here


            throw new IllegalArgumentException("config is null");
        this.id = id;
        this.config = config;
        dataLogger = LoggerFactory.getLogger("watch."+id);
        try {
            WatchDataSource wds = (WatchDataSource) config.getEntry(COMPONENT,
                                                                    "watchDataSource",
                                                                    WatchDataSource.class,
                                                                    null);
            if(wds==null)
                wds = new WatchDataSourceImpl();
View Full Code Here

        // id
        final String ids[] = new String[]{"1-2", "watch", "aBcde"};
        for (String id : ids) {
            //WatchDataSource wds = new WatchDataSourceImpl(
            //        id, null, EmptyConfiguration.INSTANCE).export();
            WatchDataSource wds = new WatchDataSourceImpl();
            wds.setConfiguration(EmptyConfiguration.INSTANCE);
            wds.initialize();
            //wds.setID(id);
            //wds.initialize();

            Watch watch = construct4(wds, id);
            Assert.assertEquals(id, watch.getId());
            testInstance(watch);
            Utils.close(watch.getWatchDataSource());
        }

        // Illegal id
        try {
            String id = null;
            WatchDataSourceImpl wdsi = new WatchDataSourceImpl();
            wdsi.setID("");
            wdsi.setConfiguration(EmptyConfiguration.INSTANCE);
            WatchDataSource wds = wdsi.export();

            construct4(wds, id);
            Assert.fail("IllegalArgumentException expected but not thrown");
        } catch (IllegalArgumentException e) {
        }
        try {
            String id = "";
            construct1(id);
            Assert.fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
        }

        // watchDataSource
        final int collectionSizes[] = new int[]{1, 1000, 5000};
        for (int collectionSize : collectionSizes) {
            DynamicConfiguration config = new DynamicConfiguration();
            config.setEntry("org.rioproject.watch", "collectionSize",
                            collectionSize);
            //WatchDataSource wds = new WatchDataSourceImpl("", null,
            //                                              config).export();
            WatchDataSource wds = new WatchDataSourceImpl();
            wds.setConfiguration(config);

            Watch watch = construct4(wds, "watch");
            Assert.assertSame(wds, watch.getWatchDataSource());
            checkInstance(watch, collectionSize, false);
            Utils.close(watch.getWatchDataSource());
        }

        // Illegal watchDataSource
        try {
            WatchDataSource wds = null;
            construct4(wds, "watch");
            Assert.fail("IllegalArgumentException expected but not thrown");
        } catch (IllegalArgumentException e) {
        }
    }
View Full Code Here

    @Test
    public void testGetSetWatchDataSource() throws Exception {
        WatchDataSourceImpl wdsi = new WatchDataSourceImpl();
        wdsi.setID("wds");
        wdsi.setConfiguration(EmptyConfiguration.INSTANCE);
        WatchDataSource wds = wdsi.export();
        Watch watch = construct4(wds, "watch");
        Assert.assertSame(wds, watch.getWatchDataSource());

        WatchDataSourceImpl wdsi2 = new WatchDataSourceImpl();
        wdsi2.setID("otherWds");
        wdsi2.setConfiguration(EmptyConfiguration.INSTANCE);
        WatchDataSource otherWds = wdsi2.export();
               
        watch.setWatchDataSource(otherWds);
        Assert.assertSame(otherWds, watch.getWatchDataSource());

        watch.setWatchDataSource(null);
View Full Code Here

        for(Watch w : watches) {
            unregisterJMX(w);
            if(w instanceof PeriodicWatch)
                ((PeriodicWatch)w).stop();
            try {
                WatchDataSource wd = w.getWatchDataSource();
                if (wd != null)
                    wd.close();
            } catch (Throwable t) {
                logger.warn("Closing WatchDataSource", t);
            }
        }       
    }
View Full Code Here

    /**
     * @see WatchRegistry#fetch(String)
     */
    public WatchDataSource fetch(String id) {
        WatchDataSource wds = null;
        Watch watch = findWatch(id);
        if(watch != null) {
            wds = watch.getWatchDataSource();
        } else {
            boolean isSystemWatch = false;
View Full Code Here

        }
        return watchDataSources.toArray(new WatchDataSource[watchDataSources.size()]);
    }

    public WatchDataSource fetch(final String id) {
        WatchDataSource watchDataSource = null;
        for(MeasurableCapability mCap : computeResource.getMeasurableCapabilities()) {
            if(mCap.getId().equals(id)) {
                watchDataSource = mCap.getWatchDataSource();
                break;
            }
View Full Code Here

    /**
     @see org.rioproject.watch.Watchable#fetch(String)
     */
    public WatchDataSource fetch(String id) {
        WatchDataSource wds = null;
        if(watchRegistry!=null) {
            wds = watchRegistry.fetch(id);
        } else {
            logger.warn("WatchRegistry is null");
        }
View Full Code Here

        }
        patientLabel.setText(getLabelText(p));
        service = (Service)p.getBed();
        try {
            pulseTimeSeries.clear();
            WatchDataSource pulse = service.fetch("pulse");
            for(Calculable c : pulse.getCalculable()) {
                lastPulse = (CalculablePatient)c;
                pulseTimeSeries.addOrUpdate(new FixedMillisecond(c.getWhen()), c.getValue());
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        try {
            temperatureTimeSeries.clear();
            WatchDataSource temperature = service.fetch("temperature");
            for(Calculable c : temperature.getCalculable()) {
                lastTemperature = c;
                temperatureTimeSeries.add(new FixedMillisecond(c.getWhen()), c.getValue());
            }
        } catch (RemoteException e) {
            e.printStackTrace();
View Full Code Here

            }
        }

        private CalculablePatient checkAdd(Service s, String watch, Calculable lastOne) throws
                                                                              RemoteException {
            WatchDataSource wds = s.fetch(watch);
            CalculablePatient c = (CalculablePatient)wds.getLastCalculable();
            Date lastMeasurement = new Date(lastOne.getWhen());
            Date currentMeasurement = new Date(c.getWhen());
            return currentMeasurement.after(lastMeasurement)?c:null;
        }
View Full Code Here

TOP

Related Classes of org.rioproject.watch.WatchDataSource

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.