Search in sources :

Example 6 with JMException

use of javax.management.JMException in project OpenAM by OpenRock.

the class SsoServerLoggingSvcImpl method init.

private void init(SnmpMib myMib, MBeanServer server) {
    if (debug == null) {
        debug = Debug.getInstance("amMonitoring");
    }
    String classModule = "SsoServerLoggingServiceImpl.init:";
    if (isBogus) {
        int ind = 1;
        // DB Handler
        lg_dbh = new SsoServerLoggingHdlrEntryImpl(myMib);
        lg_dbh.LoggingHdlrName = DB_HANDLER_NAME;
        lg_dbh.LoggingHdlrIndex = new Integer(ind++);
        final ObjectName dbhName = lg_dbh.createSsoServerLoggingHdlrEntryObjectName(server);
        try {
            SsoServerLoggingHdlrTable.addEntry(lg_dbh, dbhName);
            if ((server != null) && (dbhName != null)) {
                server.registerMBean(lg_dbh, dbhName);
            }
            handlerMap.put(DB_HANDLER_NAME, lg_dbh);
        } catch (JMException ex) {
            debug.error(classModule + DB_HANDLER_NAME, ex);
        } catch (SnmpStatusException ex) {
            debug.error(classModule + DB_HANDLER_NAME, ex);
        }
        // File Handler
        lg_fh = new SsoServerLoggingHdlrEntryImpl(myMib);
        lg_fh.LoggingHdlrName = FILE_HANDLER_NAME;
        lg_fh.LoggingHdlrIndex = new Integer(ind++);
        final ObjectName fhName = lg_fh.createSsoServerLoggingHdlrEntryObjectName(server);
        try {
            SsoServerLoggingHdlrTable.addEntry(lg_fh, fhName);
            if ((server != null) && (fhName != null)) {
                server.registerMBean(lg_fh, fhName);
            }
            handlerMap.put(FILE_HANDLER_NAME, lg_fh);
        } catch (JMException ex) {
            debug.error(classModule + FILE_HANDLER_NAME, ex);
        } catch (SnmpStatusException ex) {
            debug.error(classModule + FILE_HANDLER_NAME, ex);
        }
        // Secure File Handler
        lg_sfh = new SsoServerLoggingHdlrEntryImpl(myMib);
        lg_sfh.LoggingHdlrName = SECURE_FILE_HANDLER_NAME;
        lg_sfh.LoggingHdlrIndex = new Integer(ind++);
        final ObjectName sfhName = lg_sfh.createSsoServerLoggingHdlrEntryObjectName(server);
        try {
            SsoServerLoggingHdlrTable.addEntry(lg_sfh, sfhName);
            if ((server != null) && (sfhName != null)) {
                server.registerMBean(lg_sfh, sfhName);
            }
            handlerMap.put(SECURE_FILE_HANDLER_NAME, lg_sfh);
        } catch (JMException ex) {
            debug.error(classModule + SECURE_FILE_HANDLER_NAME, ex);
        } catch (SnmpStatusException ex) {
            debug.error(classModule + SECURE_FILE_HANDLER_NAME, ex);
        }
        // Remote Handler
        lg_rh = new SsoServerLoggingHdlrEntryImpl(myMib);
        lg_rh.LoggingHdlrName = REMOTE_HANDLER_NAME;
        lg_rh.LoggingHdlrIndex = new Integer(ind++);
        final ObjectName rhName = lg_rh.createSsoServerLoggingHdlrEntryObjectName(server);
        try {
            SsoServerLoggingHdlrTable.addEntry(lg_rh, rhName);
            if ((server != null) && (rhName != null)) {
                server.registerMBean(lg_rh, rhName);
            }
            handlerMap.put(REMOTE_HANDLER_NAME, lg_rh);
        } catch (JMException ex) {
            debug.error(classModule + REMOTE_HANDLER_NAME, ex);
        } catch (SnmpStatusException ex) {
            debug.error(classModule + REMOTE_HANDLER_NAME, ex);
        }
    }
}
Also used : SnmpStatusException(com.sun.management.snmp.SnmpStatusException) JMException(javax.management.JMException) ObjectName(javax.management.ObjectName)

Example 7 with JMException

use of javax.management.JMException in project OpenAM by OpenRock.

the class Agent method realmConfigMonitoringAgent.

/**
     *  process configuration for a realm
     */
public static int realmConfigMonitoringAgent(SSOServerRealmInfo rlmInfo) {
    String classMethod = "Agent.realmConfigMonitoringAgent:";
    String realm = rlmInfo.realmName;
    Map<String, String> authMods = rlmInfo.authModules;
    Integer realmIndex = realm2Index.get(realm);
    if (realmIndex == null) {
        debug.error(classMethod + "could not find realm " + realm + " in realm2Index map");
        return -1;
    }
    SsoServerAuthSvcImpl sig = sunMib.getAuthSvcGroup();
    TableSsoServerAuthModulesTable atab = null;
    if (sig != null) {
        try {
            atab = sig.accessSsoServerAuthModulesTable();
        } catch (SnmpStatusException ex) {
            debug.error(classMethod + "getting auth table: ", ex);
            return -2;
        }
    }
    StringBuilder sb = new StringBuilder();
    if (debug.messageEnabled()) {
        sb.append("receiving config info for realm = ").append(realm).append(":\n  Authentication Modules:\n");
    }
    /*
         *  auth module table entries have realm index, and auth module index
         */
    int i = 1;
    for (Map.Entry<String, String> entry : authMods.entrySet()) {
        String modInst = entry.getKey();
        String modType = entry.getValue();
        if (debug.messageEnabled()) {
            sb.append("    instance = ").append(modInst).append(", value(type) = ").append(modType).append("\n");
        }
        SsoServerAuthModulesEntryImpl aei = new SsoServerAuthModulesEntryImpl(sunMib);
        aei.SsoServerRealmIndex = realmIndex;
        aei.AuthModuleIndex = new Integer(i++);
        aei.AuthModuleName = modInst;
        aei.AuthModuleType = getEscapedString(modType);
        aei.AuthModuleSuccessCount = 0L;
        aei.AuthModuleFailureCount = 0L;
        ObjectName aname = aei.createSsoServerAuthModulesEntryObjectName(server);
        if (aname == null) {
            debug.error(classMethod + "Error creating object for auth module name '" + modInst + "', type '" + modType + "'");
            continue;
        }
        try {
            atab.addEntry(aei, aname);
            if ((server != null) && (aei != null)) {
                server.registerMBean(aei, aname);
            }
            /* is a Map of realm/authmodule to index needed? */
            String rai = realm + "|" + modInst;
            // aei is this module's SsoServerAuthModulesEntryImpl instance
            realmAuthInst.put(rai, aei);
        } catch (JMException ex) {
            debug.error(classMethod + modInst, ex);
        } catch (SnmpStatusException ex) {
            debug.error(classMethod + modInst, ex);
        }
    }
    // if no realm info added because mbean not created...
    if (realmAuthInst.isEmpty()) {
        return -3;
    }
    if (debug.messageEnabled()) {
        debug.message(classMethod + sb.toString());
    }
    return 0;
}
Also used : SnmpStatusException(com.sun.management.snmp.SnmpStatusException) ObjectName(javax.management.ObjectName) JMException(javax.management.JMException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 8 with JMException

use of javax.management.JMException in project tdi-studio-se by Talend.

the class OverviewProperties method refreshPropertyValues.

/**
     * Refreshes the property values.
     */
private void refreshPropertyValues() {
    for (List<OverviewProperty> properties : overviewProperties.values()) {
        for (OverviewProperty property : properties) {
            try {
                ObjectName objectName = ObjectName.getInstance(property.getObjectName());
                String attributeName = property.getAttributeName();
                Object attribute = activeJvm.getMBeanServer().getAttribute(objectName, attributeName);
                property.setValue(attribute);
            } catch (JvmCoreException e) {
                Activator.log(Messages.getMBeanAttributeFailedMsg, e);
            } catch (JMException e) {
                Activator.log(IStatus.ERROR, Messages.getMBeanAttributeFailedMsg, e);
            }
        }
    }
}
Also used : JMException(javax.management.JMException) ObjectName(javax.management.ObjectName) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 9 with JMException

use of javax.management.JMException in project tdi-studio-se by Talend.

the class MBeanServer method getAttribute.

/*
     * @see IMBeanServer#getAttribute(ObjectName, String)
     */
@Override
public Object getAttribute(ObjectName objectName, String qualifiedAttributeName) throws JvmCoreException {
    Assert.isNotNull(objectName);
    Assert.isNotNull(qualifiedAttributeName);
    if (!checkReachability()) {
        return null;
    }
    String attributeName = qualifiedAttributeName;
    if (attributeName.contains(".")) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        attributeName = attributeName.split("\\.")[0];
    }
    try {
        return connection.getAttribute(objectName, attributeName);
    } catch (JMException e) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.getAttributeFailedMsg, attributeName), e);
    } catch (IOException e) {
        throw new JvmCoreException(IStatus.ERROR, NLS.bind(Messages.getAttributeFailedMsg, attributeName), e);
    }
}
Also used : JMException(javax.management.JMException) IOException(java.io.IOException) JvmCoreException(org.talend.designer.runtime.visualization.JvmCoreException)

Example 10 with JMException

use of javax.management.JMException in project nhin-d by DirectProject.

the class DNSServer method registerMBean.

/**
	 * Register the MBean
	 */
private void registerMBean(DNSServerSettings settings) {
    String[] itemNames = { "Port", "Bind Address", "Max Request Size", "Max Outstanding Accepts", "Max Active Accepts", "Max Connection Backlog", "Read Buffer Size", "Send Timeout", "Receive Timeout", "Socket Close Timeout" };
    String[] itemDesc = { "Port", "Bind Address", "Max Request Size", "Max Outstanding Accepts", "Max Active Accepts", "Max Connection Backlog", "Read Buffer Size", "Send Timeout", "Receive Timeout", "Socket Close Timeout" };
    OpenType<?>[] types = { SimpleType.INTEGER, SimpleType.STRING, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER };
    Object[] settingsValues = { settings.getPort(), settings.getBindAddress(), settings.getMaxRequestSize(), settings.getMaxOutstandingAccepts(), settings.getMaxActiveRequests(), settings.getMaxConnectionBacklog(), settings.getReadBufferSize(), settings.getSendTimeout(), settings.getReceiveTimeout(), settings.getSocketCloseTimeout() };
    try {
        CompositeType settingsType = new CompositeType(DNSServerSettings.class.getSimpleName(), "DNS server settings.", itemNames, itemDesc, types);
        settingsData = new CompositeDataSupport(settingsType, itemNames, settingsValues);
    } catch (OpenDataException e) {
        LOGGER.error("Failed to create settings composite type: " + e.getLocalizedMessage(), e);
        return;
    }
    Class<?> clazz = this.getClass();
    final StringBuilder objectNameBuilder = new StringBuilder(clazz.getPackage().getName());
    objectNameBuilder.append(":type=").append(clazz.getSimpleName());
    objectNameBuilder.append(",name=").append(UUID.randomUUID());
    try {
        final StandardMBean mbean = new StandardMBean(this, DNSServerMBean.class);
        final MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
        mbeanServer.registerMBean(mbean, new ObjectName(objectNameBuilder.toString()));
    } catch (JMException e) {
        LOGGER.error("Unable to register the DNSServer MBean", e);
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) StandardMBean(javax.management.StandardMBean) CompositeDataSupport(javax.management.openmbean.CompositeDataSupport) ObjectName(javax.management.ObjectName) OpenDataException(javax.management.openmbean.OpenDataException) JMException(javax.management.JMException) CompositeType(javax.management.openmbean.CompositeType) MBeanServer(javax.management.MBeanServer)

Aggregations

JMException (javax.management.JMException)114 ObjectName (javax.management.ObjectName)65 MBeanServer (javax.management.MBeanServer)35 IOException (java.io.IOException)21 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)13 MalformedObjectNameException (javax.management.MalformedObjectNameException)12 MBeanInfo (javax.management.MBeanInfo)10 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)8 SnmpStatusException (com.sun.management.snmp.SnmpStatusException)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 Map (java.util.Map)7 StandardMBean (javax.management.StandardMBean)7 RequiredModelMBean (javax.management.modelmbean.RequiredModelMBean)6 Date (java.util.Date)5 Attribute (javax.management.Attribute)5 InvalidTargetObjectTypeException (javax.management.modelmbean.InvalidTargetObjectTypeException)5 Element (org.w3c.dom.Element)5 PostConstruct (javax.annotation.PostConstruct)4 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)4