Example usage for javax.management.openmbean SimpleType DOUBLE

List of usage examples for javax.management.openmbean SimpleType DOUBLE

Introduction

In this page you can find the example usage for javax.management.openmbean SimpleType DOUBLE.

Prototype

SimpleType DOUBLE

To view the source code for javax.management.openmbean SimpleType DOUBLE.

Click Source Link

Document

The SimpleType instance describing values whose Java class name is java.lang.Double.

Usage

From source file:org.jolokia.converter.object.StringToOpenTypeConverterTest.java

@Test
public void simpleType() {
    assertTrue(converter.canConvert(SimpleType.STRING));
    assertEquals(converter.convertToObject(SimpleType.STRING, "bla"), "bla");
    assertEquals(converter.convertToObject(SimpleType.BOOLEAN, "true"), true);
    assertEquals(converter.convertToObject(SimpleType.BOOLEAN, false), false);
    assertEquals(converter.convertToObject(SimpleType.DOUBLE, 4.52), 4.52);
    assertEquals(converter.convertToObject(SimpleType.DOUBLE, "4.52"), 4.52);
    assertEquals(converter.convertToObject(SimpleType.INTEGER, "9876"), 9876);
}

From source file:org.eclipse.gyrex.monitoring.internal.mbeans.MetricSetMBean.java

private OpenType detectType(final Class type) {
    if ((Long.class == type) || (Long.TYPE == type)) {
        return SimpleType.LONG;
    } else if ((Integer.class == type) || (Integer.TYPE == type)) {
        return SimpleType.INTEGER;
    } else if ((Double.class == type) || (Double.TYPE == type)) {
        return SimpleType.DOUBLE;
    } else if ((Float.class == type) || (Float.TYPE == type)) {
        return SimpleType.FLOAT;
    } else if ((Byte.class == type) || (Byte.TYPE == type)) {
        return SimpleType.BYTE;
    } else if ((Short.class == type) || (Short.TYPE == type)) {
        return SimpleType.SHORT;
    } else if ((Boolean.class == type) || (Boolean.TYPE == type)) {
        return SimpleType.BOOLEAN;
    } else if (BigDecimal.class == type) {
        return SimpleType.BIGDECIMAL;
    } else if (BigInteger.class == type) {
        return SimpleType.BIGINTEGER;
    } else if ((Character.class == type) || (Character.TYPE == type)) {
        return SimpleType.CHARACTER;
    }//from w ww . j a  v  a  2s  . c  o m

    // last fallback to strings
    if (isConvertibleToString(type)) {
        return SimpleType.STRING;
    }

    // give up
    return null;
}

From source file:com.cyberway.issue.crawler.admin.CrawlJob.java

/**
 * Build up the MBean info for Heritrix main.
 * @return Return created mbean info instance.
 * @throws InitializationException // w w w.ja  v  a  2  s .c  o m
 */
protected OpenMBeanInfoSupport buildMBeanInfo() throws InitializationException {
    // Start adding my attributes.
    List<OpenMBeanAttributeInfo> attributes = new ArrayList<OpenMBeanAttributeInfo>();

    // Attributes.
    attributes.add(new OpenMBeanAttributeInfoSupport(NAME_ATTR, "Crawl job name", SimpleType.STRING, true,
            false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(STATUS_ATTR, "Short basic status message",
            SimpleType.STRING, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(FRONTIER_SHORT_REPORT_ATTR, "Short frontier report",
            SimpleType.STRING, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(THREADS_SHORT_REPORT_ATTR, "Short threads report",
            SimpleType.STRING, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(UID_ATTR, "Crawl job UID", SimpleType.STRING, true, false,
            false));
    attributes.add(new OpenMBeanAttributeInfoSupport(TOTAL_DATA_ATTR, "Total data received", SimpleType.LONG,
            true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(CRAWL_TIME_ATTR, "Crawl time", SimpleType.LONG, true,
            false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(CURRENT_DOC_RATE_ATTR, "Current crawling rate (Docs/sec)",
            SimpleType.DOUBLE, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(CURRENT_KB_RATE_ATTR, "Current crawling rate (Kb/sec)",
            SimpleType.LONG, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(THREAD_COUNT_ATTR, "Active thread count",
            SimpleType.INTEGER, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(DOC_RATE_ATTR, "Crawling rate (Docs/sec)",
            SimpleType.DOUBLE, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(KB_RATE_ATTR, "Current crawling rate (Kb/sec)",
            SimpleType.LONG, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(DOWNLOAD_COUNT_ATTR, "Count of downloaded documents",
            SimpleType.LONG, true, false, false));
    attributes.add(new OpenMBeanAttributeInfoSupport(DISCOVERED_COUNT_ATTR, "Count of discovered documents",
            SimpleType.LONG, true, false, false));

    // Add in the crawl order attributes.
    addCrawlOrderAttributes(this.getController().getOrder(), attributes);

    // Add the bdbje attributes.  Convert to open mbean attributes.
    // First do bdbeje setup.  Then add a subset of the bdbje attributes.
    // Keep around the list of names as a convenience for when it comes
    // time to test if attribute is supported.
    Environment env = this.controller.getBdbEnvironment();
    try {
        this.bdbjeMBeanHelper = new JEMBeanHelper(env.getConfig(), env.getHome(), true);
    } catch (DatabaseException e) {
        e.printStackTrace();
        InitializationException ie = new InitializationException(e.getMessage());
        ie.setStackTrace(e.getStackTrace());
        throw ie;
    }
    this.bdbjeAttributeNameList = Arrays.asList(new String[] { JEMBeanHelper.ATT_ENV_HOME,
            JEMBeanHelper.ATT_OPEN, JEMBeanHelper.ATT_IS_READ_ONLY, JEMBeanHelper.ATT_IS_TRANSACTIONAL,
            JEMBeanHelper.ATT_CACHE_SIZE, JEMBeanHelper.ATT_CACHE_PERCENT, JEMBeanHelper.ATT_LOCK_TIMEOUT,
            JEMBeanHelper.ATT_IS_SERIALIZABLE, JEMBeanHelper.ATT_SET_READ_ONLY, });
    addBdbjeAttributes(attributes, this.bdbjeMBeanHelper.getAttributeList(env), this.bdbjeAttributeNameList);

    // Operations.
    List<OpenMBeanOperationInfo> operations = new ArrayList<OpenMBeanOperationInfo>();
    OpenMBeanParameterInfo[] args = new OpenMBeanParameterInfoSupport[3];
    args[0] = new OpenMBeanParameterInfoSupport("url", "URL to add to the frontier", SimpleType.STRING);
    args[1] = new OpenMBeanParameterInfoSupport("forceFetch", "True if URL is to be force fetched",
            SimpleType.BOOLEAN);
    args[2] = new OpenMBeanParameterInfoSupport("seed", "True if URL is a seed", SimpleType.BOOLEAN);
    operations.add(new OpenMBeanOperationInfoSupport(IMPORT_URI_OPER, "Add passed URL to the frontier", args,
            SimpleType.VOID, MBeanOperationInfo.ACTION));

    args = new OpenMBeanParameterInfoSupport[4];
    args[0] = new OpenMBeanParameterInfoSupport("pathOrUrl", "Path or URL to file of URLs", SimpleType.STRING);
    args[1] = new OpenMBeanParameterInfoSupport("style", "Format format:default|crawlLog|recoveryJournal",
            SimpleType.STRING);
    args[2] = new OpenMBeanParameterInfoSupport("forceFetch", "True if URLs are to be force fetched",
            SimpleType.BOOLEAN);
    args[3] = new OpenMBeanParameterInfoSupport("seed", "True if all content are seeds.", SimpleType.BOOLEAN);
    operations.add(new OpenMBeanOperationInfoSupport(IMPORT_URIS_OPER,
            "Add file of passed URLs to the frontier", args, SimpleType.STRING, MBeanOperationInfo.ACTION));

    args = new OpenMBeanParameterInfoSupport[4];
    args[0] = new OpenMBeanParameterInfoSupport("filename", "File to print to", SimpleType.STRING);
    args[1] = new OpenMBeanParameterInfoSupport("regexp", "Regular expression URLs must match",
            SimpleType.STRING);
    args[2] = new OpenMBeanParameterInfoSupport("numberOfMatches", "Maximum number of matches to return",
            SimpleType.INTEGER);
    args[3] = new OpenMBeanParameterInfoSupport("verbose", "Should they be verbose descriptions",
            SimpleType.BOOLEAN);
    operations.add(new OpenMBeanOperationInfoSupport(DUMP_URIS_OPER,
            "Dump pending URIs from frontier to a file", args, SimpleType.VOID, MBeanOperationInfo.ACTION));

    operations.add(new OpenMBeanOperationInfoSupport(PAUSE_OPER, "Pause crawling (noop if already paused)",
            null, SimpleType.VOID, MBeanOperationInfo.ACTION));

    operations.add(new OpenMBeanOperationInfoSupport(RESUME_OPER, "Resume crawling (noop if already resumed)",
            null, SimpleType.VOID, MBeanOperationInfo.ACTION));

    args = new OpenMBeanParameterInfoSupport[1];
    args[0] = new OpenMBeanParameterInfoSupport("name", "Name of report ('all', 'standard', etc.).",
            SimpleType.STRING);
    operations.add(new OpenMBeanOperationInfoSupport(FRONTIER_REPORT_OPER, "Full frontier report", args,
            SimpleType.STRING, MBeanOperationInfo.INFO));

    operations.add(new OpenMBeanOperationInfoSupport(THREADS_REPORT_OPER, "Full thread report", null,
            SimpleType.STRING, MBeanOperationInfo.INFO));

    operations.add(new OpenMBeanOperationInfoSupport(SEEDS_REPORT_OPER, "Seeds report", null, SimpleType.STRING,
            MBeanOperationInfo.INFO));

    operations.add(new OpenMBeanOperationInfoSupport(PROGRESS_STATISTICS_OPER,
            "Progress statistics at time of invocation", null, SimpleType.STRING, MBeanOperationInfo.INFO));

    operations.add(new OpenMBeanOperationInfoSupport(PROGRESS_STATISTICS_LEGEND_OPER,
            "Progress statistics legend", null, SimpleType.STRING, MBeanOperationInfo.INFO));

    operations.add(new OpenMBeanOperationInfoSupport(CHECKPOINT_OPER, "Start a checkpoint", null,
            SimpleType.VOID, MBeanOperationInfo.ACTION));

    // Add bdbje operations. Add subset only. Keep around the list so have
    // it to hand when figuring what operations are supported. Usual actual
    // Strings because not accessible from JEMBeanHelper.
    this.bdbjeOperationsNameList = Arrays.asList(new String[] { "cleanLog", "evictMemory", "checkpoint", "sync",
            "getEnvironmentStatsToString", "getLockStatsToString", "getDatabaseNames", OP_DB_STAT });
    addBdbjeOperations(operations, this.bdbjeMBeanHelper.getOperationList(env), this.bdbjeOperationsNameList);

    // Register notifications
    List<MBeanNotificationInfo> notifications = new ArrayList<MBeanNotificationInfo>();
    notifications.add(new MBeanNotificationInfo(
            new String[] { "crawlStarted", "crawlEnding", "crawlPaused", "crawlResuming", PROG_STATS },
            this.getClass().getName() + ".notifications",
            "CrawlStatusListener events and progress statistics as " + "notifications"));
    MBeanNotificationInfo[] notificationsArray = new MBeanNotificationInfo[notifications.size()];
    notifications.toArray(notificationsArray);

    // Build the info object.
    OpenMBeanAttributeInfoSupport[] attributesArray = new OpenMBeanAttributeInfoSupport[attributes.size()];
    attributes.toArray(attributesArray);
    OpenMBeanOperationInfoSupport[] operationsArray = new OpenMBeanOperationInfoSupport[operations.size()];
    operations.toArray(operationsArray);
    return new OpenMBeanInfoSupport(this.getClass().getName(), "Current Crawl Job as OpenMBean",
            attributesArray, new OpenMBeanConstructorInfoSupport[] {}, operationsArray, notificationsArray);
}