Package org.rioproject.watch

Examples of org.rioproject.watch.Calculable


        }
    }
    private List<Calculable> makeCalculables(int num) {
        List<Calculable> calcs = new ArrayList<Calculable>();
        for(int i=0; i<num; i++) {
            calcs.add(new Calculable("foo", i, System.currentTimeMillis()));
        }
        return calcs;
    }
View Full Code Here


         *   thresholdValues:   valid object, null
         *   type:              BREACHED, CLEARED, 0, 12345
         */

        final Object[] sources = new Object[] { new Object(), null};
        final Calculable[] calculables = new Calculable[] {new Calculable(), null};
        final ThresholdValues[] tvs = new ThresholdValues[] { new ThresholdValues(), null};
        final ThresholdType[] types = new ThresholdType[] {
                ThresholdType.BREACHED, ThresholdType.CLEARED};

        Object[][] combinations = ArrayUtils.combinations(new Object[][] {
                sources, calculables, tvs, types});
        for (Object[] combination : combinations) {
            Object source = combination[0];
            Calculable calculable = (Calculable) combination[1];
            ThresholdValues tv = (ThresholdValues) combination[2];
            ThresholdType type = (ThresholdType) combination[3];

            if (source == null) {
                try {
View Full Code Here

         */

        ThresholdEvent event = new ThresholdEvent(new Object());
        Assert.assertSame(null, event.getCalculable());

        Calculable c = new Calculable();
        event.setCalculable(c);
        Assert.assertSame(c, event.getCalculable());
    }
View Full Code Here

         *   calculable: valid alculable, null
         */

        ThresholdEvent event = new ThresholdEvent(new Object());

        Calculable c = new Calculable();
        event.setCalculable(c);
        Assert.assertSame(c, event.getCalculable());

        event.setCalculable(null);
        Assert.assertSame(null, event.getCalculable());
View Full Code Here

                return;
            } else {
                if(nullReturnCount.get()>0)
                    nullReturnCount.decrementAndGet();
            }
            Calculable metric;
            if(value instanceof Calculable) {
                metric = (Calculable)value;
            } else {
                Double d = new Double(value.toString());
                metric = new Calculable(getId(), d, System.currentTimeMillis());
            }
            addWatchRecord(metric);
           
        } catch(Throwable t) {
            logger.warn("SamplingWatch [{}], Invoking [{}={}()]",
View Full Code Here

    /**
     * @see org.rioproject.watch.WatchDataSource#getLastCalculable
     */
    public Calculable getLastCalculable() {
        Calculable c = null;
        try {
            synchronized(history) {
                c =  history.get(history.size() - 1);
            }
        } catch(IndexOutOfBoundsException ex) {
View Full Code Here

            logger.info("ThreadMXBean set, monitoring current JVM for thread deadlocks");
    }

    public Calculable getThreadDeadlockCalculable() {
        int deadlockCount = findDeadlockedThreads();
        Calculable metric = new Calculable(ID, deadlockCount, System.currentTimeMillis());
        if(deadlockCount>0) {
            String detail = formatDeadlockedThreadInfo();
            metric.setDetail(detail);
            if(logger.isTraceEnabled())
                logger.trace(detail);
        } else {
             if(logger.isTraceEnabled())
                logger.trace("No deadlocked threads");
View Full Code Here

     * Add a value
     *
     * @param value New value
     */
    public void addValue(long value) {
        addWatchRecord(new Calculable(id, (double)value, System.currentTimeMillis()));
    }
View Full Code Here

     * Add a value
     *
     * @param value New value
     */
    public void addValue(double value) {
        addWatchRecord(new Calculable(id, value, System.currentTimeMillis()));
    }
View Full Code Here

     * @param value New value.
     * @param detail Detail about the metric.
     */
    @SuppressWarnings("unused")
    public void addValue(double value, String detail) {
        Calculable calculable = new Calculable(id, value, System.currentTimeMillis());
        calculable.setDetail(detail);
        addWatchRecord(calculable);
    }
View Full Code Here

TOP

Related Classes of org.rioproject.watch.Calculable

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.