Example usage for javax.management RuntimeOperationsException RuntimeOperationsException

List of usage examples for javax.management RuntimeOperationsException RuntimeOperationsException

Introduction

In this page you can find the example usage for javax.management RuntimeOperationsException RuntimeOperationsException.

Prototype

public RuntimeOperationsException(java.lang.RuntimeException e, String message) 

Source Link

Document

Creates a RuntimeOperationsException that wraps the actual java.lang.RuntimeException with a detailed message.

Usage

From source file:org.archive.crawler.admin.CrawlJob.java

public Object getAttribute(String attribute_name) throws AttributeNotFoundException {
    if (attribute_name == null) {
        throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name cannot be null"),
                "Cannot call getAttribute with null attribute name");
    }//from w w w. j ava 2 s  . c o m

    // If no controller, we can't do any work in here.
    if (this.controller == null) {
        throw new RuntimeOperationsException(new NullPointerException("Controller is null"),
                "Controller is null");
    }

    // Is it a bdbje attribute?
    if (this.bdbjeAttributeNameList.contains(attribute_name)) {
        try {
            return this.bdbjeMBeanHelper.getAttribute(this.controller.getBdbEnvironment(), attribute_name);
        } catch (MBeanException e) {
            throw new RuntimeOperationsException(new RuntimeException(e));
        }
    }

    // Is it a crawl-order attribute?
    if (attribute_name.startsWith(this.controller.getOrder().getAbsoluteName())) {
        return getCrawlOrderAttribute(attribute_name);
    }

    if (!ATTRIBUTE_LIST.contains(attribute_name)) {
        throw new AttributeNotFoundException("Attribute " + attribute_name + " is unimplemented.");
    }

    // The pattern in the below is to match an attribute and when found
    // do a return out of if clause.  Doing it this way, I can fall
    // on to the AttributeNotFoundException for case where we've an
    // attribute but no handler.
    if (attribute_name.equals(STATUS_ATTR)) {
        return getCrawlStatus();
    }
    if (attribute_name.equals(NAME_ATTR)) {
        return getJobName();
    }
    if (attribute_name.equals(UID_ATTR)) {
        return getUID();
    }
    if (attribute_name.equals(TOTAL_DATA_ATTR)) {
        return new Long(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().totalBytesCrawled());
    }
    if (attribute_name.equals(CRAWL_TIME_ATTR)) {
        return new Long(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().getCrawlerTotalElapsedTime() / 1000);
    }
    if (attribute_name.equals(CURRENT_DOC_RATE_ATTR)) {
        return new Double(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().currentProcessedDocsPerSec());
    }
    if (attribute_name.equals(DOC_RATE_ATTR)) {
        return new Double(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().processedDocsPerSec());
    }
    if (attribute_name.equals(KB_RATE_ATTR)) {
        return new Long(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().currentProcessedKBPerSec());
    }
    if (attribute_name.equals(CURRENT_KB_RATE_ATTR)) {
        return new Long(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().processedKBPerSec());
    }
    if (attribute_name.equals(THREAD_COUNT_ATTR)) {
        return new Integer(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().activeThreadCount());
    }
    if (attribute_name.equals(FRONTIER_SHORT_REPORT_ATTR)) {
        return getFrontierOneLine();
    }
    if (attribute_name.equals(THREADS_SHORT_REPORT_ATTR)) {
        return getThreadOneLine();
    }
    if (attribute_name.equals(DISCOVERED_COUNT_ATTR)) {
        return new Long(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().totalCount());
    }
    if (attribute_name.equals(DOWNLOAD_COUNT_ATTR)) {
        return new Long(this.controller == null && this.controller.getStatistics() != null ? 0
                : this.controller.getStatistics().successfullyFetchedCount());
    }

    throw new AttributeNotFoundException("Attribute " + attribute_name + " not found.");
}

From source file:org.archive.crawler.admin.CrawlJob.java

public AttributeList setAttributes(AttributeList attributes) {
    if (attributes == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("attributeNames[] cannot be " + "null"),
                "Cannot call getAttributes with null attribute " + "names");
    }//from w  w  w  . jav  a 2s. c o m

    AttributeList resultList = new AttributeList();
    if (attributes.size() == 0) {
        return resultList;
    }
    for (int i = 0; i < attributes.size(); i++) {
        try {
            Attribute attr = (Attribute) attributes.get(i);
            setAttributeInternal(attr);
            String an = attr.getName();
            Object newValue = getAttribute(an);
            resultList.add(new Attribute(an, newValue));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // prompt updating of settings-sensitive components
    kickUpdate();
    return resultList;
}

From source file:org.eclipse.smila.management.jmx.AgentMBean.java

/**
 * {@inheritDoc}// w  ww  .j av a2s  . c o m
 * 
 * @see javax.management.DynamicMBean#getAttributes(java.lang.String[])
 */
public AttributeList getAttributes(final String[] attributes) {
    if (attributes == null) {
        throw new RuntimeOperationsException(new IllegalArgumentException("attributeNames must not be null"),
                "Exception occured trying to get attributes of a " + "LocalMBean");
    }
    final AttributeList attributeList = new AttributeList();
    String attributeName;
    for (int i = 0; i < attributes.length; i++) {
        attributeName = attributes[i];
        try {
            attributeList.add(new Attribute(attributeName, getAttribute(attributeName)));
        } catch (final Throwable e) {
            _log.error("getAttributes(String[]), failed to get \"" + attributeName + "\"", e);
        }
    }
    return attributeList;
}

From source file:org.eclipse.smila.management.jmx.AgentMBean.java

/**
 * {@inheritDoc}//from w  ww  .j  a v a  2  s. c om
 * 
 * @see javax.management.DynamicMBean#setAttributes(javax.management.AttributeList)
 */
public AttributeList setAttributes(final AttributeList attributes) {
    if (attributes == null) {
        throw new RuntimeOperationsException(new IllegalArgumentException("attributes must not be null"),
                "Exception occured trying to set attributes of a " + "LocalMBean");
    }
    final AttributeList attributeList = new AttributeList();
    for (final Iterator i = attributes.iterator(); i.hasNext();) {
        final Attribute attribute = (Attribute) i.next();
        try {
            setAttribute(attribute);
            attributeList.add(attribute);
        } catch (final Exception e) {
            i.remove();
        }
    }
    return attributeList;
}