Search in sources :

Example 1 with ServiceInfo

use of com.sun.messaging.jmq.util.admin.ServiceInfo in project openmq by eclipse-ee4j.

the class BrokerAdminHandler method doPauseService.

private void doPauseService(BrokerServiceCObj bSvcCObj) {
    BrokerAdmin ba = bSvcCObj.getBrokerAdmin();
    ServiceInfo svcInfo = bSvcCObj.getServiceInfo();
    int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_SERVICE_PAUSE, svcInfo.name, ba.getKey()), acr.getString(acr.I_PAUSE_SERVICE), JOptionPane.YES_NO_OPTION);
    if (result == JOptionPane.NO_OPTION) {
        return;
    }
    /*
         * Broker may take more time to complete the task than the specified timeout value. This value is used when refreshing
         * the console in such cases.
         */
    if (!ba.isBusy()) {
        ba.setAssociatedObj(bSvcCObj);
    }
    if (pauseService(ba, svcInfo.name)) {
        svcInfo = queryServiceInfo(ba, svcInfo.name);
        if (svcInfo != null) {
            bSvcCObj.setServiceInfo(svcInfo);
            app.getInspector().selectedObjectUpdated();
        }
        // Update menu items, buttons.
        controller.setActions(bSvcCObj);
    }
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin)

Example 2 with ServiceInfo

use of com.sun.messaging.jmq.util.admin.ServiceInfo in project openmq by eclipse-ee4j.

the class BrokerAdminHandler method doResumeService.

private void doResumeService(BrokerServiceCObj bSvcCObj) {
    BrokerAdmin ba = bSvcCObj.getBrokerAdmin();
    ServiceInfo svcInfo = bSvcCObj.getServiceInfo();
    int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_SERVICE_RESUME, svcInfo.name, ba.getKey()), acr.getString(acr.I_RESUME_SERVICE), JOptionPane.YES_NO_OPTION);
    if (result == JOptionPane.NO_OPTION) {
        return;
    }
    /*
         * Broker may take more time to complete the task than the specified timeout value. This value is used when refreshing
         * the console in such cases.
         */
    if (!ba.isBusy()) {
        ba.setAssociatedObj(bSvcCObj);
    }
    if (resumeService(ba, svcInfo.name)) {
        svcInfo = queryServiceInfo(ba, svcInfo.name);
        if (svcInfo != null) {
            bSvcCObj.setServiceInfo(svcInfo);
            app.getInspector().selectedObjectUpdated();
        }
        // Update menu items, buttons.
        controller.setActions(bSvcCObj);
    }
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin)

Example 3 with ServiceInfo

use of com.sun.messaging.jmq.util.admin.ServiceInfo in project openmq by eclipse-ee4j.

the class BrokerAdminHandler method handleBrokerCmdStatusEvent.

private void handleBrokerCmdStatusEvent(BrokerCmdStatusEvent cse) {
    int type = cse.getType(), msgType;
    BrokerAdmin ba = cse.getBrokerAdmin();
    boolean success = cse.getSuccess();
    Exception ex = cse.getLinkedException();
    String dstName = cse.getDestinationName(), svcName = cse.getServiceName(), clientID = cse.getClientID(), durName = cse.getDurableName(), bkrName = ba.getKey(), title, msg;
    DestinationInfo dstInfo = cse.getDestinationInfo();
    ServiceInfo svcInfo = cse.getServiceInfo();
    Object refreshObj = ba.getAssociatedObj();
    if (type == BrokerCmdStatusEvent.BROKER_BUSY) {
        int numRetriesAttempted = cse.getNumRetriesAttempted(), maxNumRetries = cse.getMaxNumRetries();
        long retryTimeount = cse.getRetryTimeount();
        Object[] args = new Object[3];
        args[0] = Integer.toString(numRetriesAttempted);
        args[1] = Integer.toString(maxNumRetries);
        args[2] = Long.toString(retryTimeount);
        /*
             * This string is of the form: Broker not responding, retrying [1 of 5 attempts, timeout=20 seconds]
             */
        String s = ar.getString(ar.I_JMQCMD_BROKER_BUSY, args);
        app.getStatusArea().appendText(s + "\n");
        return;
    }
    /*
         * Do not bring up the result dialog for 1. QUERY_SVC 2. QUERY_DST 3. LIST_DUR (for querying destination) 4. QUERY_BKR
         */
    if ((type == BrokerCmdStatusEvent.QUERY_SVC) || (type == BrokerCmdStatusEvent.QUERY_DST) || (type == BrokerCmdStatusEvent.LIST_DUR) || (type == BrokerCmdStatusEvent.QUERY_BKR)) {
        /*
             * We need to refresh the console if 'connect' is successful but 'query broker' is not upon connecting to a broker.
             */
        if (refreshObj instanceof BrokerCObj) {
            app.getExplorer().nodeChanged((DefaultMutableTreeNode) refreshObj);
            controller.setActions((BrokerCObj) refreshObj);
        }
        return;
    }
    /*
         * Type of dialog depends on success/failure
         */
    if (success) {
        msgType = JOptionPane.INFORMATION_MESSAGE;
    } else {
        msgType = JOptionPane.ERROR_MESSAGE;
    }
    /*
         * Dialog title reads: Status received from broker
         */
    title = acr.getString(acr.I_STATUS_RECV);
    switch(type) {
        case BrokerCmdStatusEvent.HELLO:
            if (success) {
                msg = acr.getString(acr.S_BROKER_CONNECT, bkrName);
                if (refreshObj instanceof BrokerCObj) {
                    BrokerCObj bCObj = (BrokerCObj) refreshObj;
                    /*
                     * Connection is considered created when the hello protocol handshake takes place successfully.
                     */
                    ba.setIsConnected(true);
                    if (refreshBrokerServiceListCObj(bCObj.getBrokerServiceListCObj())) {
                        if (refreshBrokerDestListCObj(bCObj.getBrokerDestListCObj())) {
                            app.getExplorer().nodeChanged(bCObj);
                            app.getInspector().refresh();
                            controller.setActions(bCObj);
                        }
                    }
                }
            } else {
                msg = acr.getString(acr.E_CONNECT_BROKER, bkrName);
            }
            break;
        case BrokerCmdStatusEvent.CREATE_DST:
            if (success) {
                msg = acr.getString(acr.S_BROKER_DEST_ADD, dstInfo.name, bkrName);
                if (refreshObj instanceof BrokerCObj) {
                    BrokerCObj bCObj = (BrokerCObj) refreshObj;
                    BrokerDestListCObj bDestlCObj = bCObj.getBrokerDestListCObj();
                    BrokerDestCObj bDestCObj = new BrokerDestCObj(bCObj, dstInfo);
                    app.getExplorer().addToParent(bDestlCObj, bDestCObj);
                    app.getInspector().refresh();
                }
            } else {
                msg = acr.getString(acr.E_ADD_DEST_BROKER, dstInfo.name, bkrName);
            }
            break;
        case BrokerCmdStatusEvent.DESTROY_DST:
            if (success) {
                msg = acr.getString(acr.S_BROKER_DEST_DELETE, dstName, bkrName);
                if (refreshObj instanceof BrokerDestCObj) {
                    app.getExplorer().removeFromParent((BrokerDestCObj) refreshObj);
                    app.getInspector().refresh();
                }
            } else {
                msg = acr.getString(acr.E_BROKER_DEST_DELETE, dstName, bkrName);
            }
            break;
        case BrokerCmdStatusEvent.UPDATE_DST:
            if (success) {
                msg = acr.getString(acr.S_BROKER_UPDATE_DEST, dstInfo.name);
            } else {
                msg = acr.getString(acr.E_UPDATE_DEST, dstInfo.name);
            }
            break;
        case BrokerCmdStatusEvent.PURGE_DST:
            if (success) {
                msg = acr.getString(acr.S_BROKER_DEST_PURGE, dstName, bkrName);
            } else {
                msg = acr.getString(acr.E_BROKER_DEST_PURGE, dstName, bkrName);
            }
            break;
        case BrokerCmdStatusEvent.DESTROY_DUR:
            if (success) {
                msg = acr.getString(acr.S_BROKER_DESTROY_DUR, BrokerAdminUtil.getDSubLogString(clientID, durName));
                if (refreshObj instanceof BrokerDestCObj) {
                    BrokerDestCObj bDestCObj = (BrokerDestCObj) refreshObj;
                    refreshBrokerDestCObj(bDestCObj, BrokerAdminEvent.DELETE_DUR);
                    Vector durables = bDestCObj.getDurables();
                    if (durables != null) {
                        brokerDestPropsDialog.refresh(durables);
                    }
                }
            } else {
                msg = acr.getString(acr.E_BROKER_DESTROY_DUR, BrokerAdminUtil.getDSubLogString(clientID, durName));
            }
            break;
        case BrokerCmdStatusEvent.LIST_DST:
            if (success) {
                msg = acr.getString(acr.S_BROKER_REFRESH_DESTLIST, bkrName);
                Object obj = cse.getReturnedObject();
                BrokerDestListCObj bDestlCObj;
                if (obj instanceof Vector) {
                    Vector dests = (Vector) obj;
                    if (refreshObj instanceof BrokerDestListCObj) {
                        bDestlCObj = (BrokerDestListCObj) refreshObj;
                    } else if (refreshObj instanceof BrokerCObj) {
                        BrokerCObj bCObj = (BrokerCObj) refreshObj;
                        bDestlCObj = bCObj.getBrokerDestListCObj();
                    } else {
                        return;
                    }
                    refreshBrokerDestList(dests, bDestlCObj);
                    app.getInspector().refresh();
                }
            } else {
                msg = acr.getString(acr.E_REFRESH_DESTLIST);
            }
            break;
        case BrokerCmdStatusEvent.PAUSE_SVC:
            if (success) {
                msg = acr.getString(acr.S_SERVICE_PAUSE, svcName, bkrName);
                if (refreshObj instanceof BrokerServiceCObj) {
                    BrokerServiceCObj bSvcCObj = (BrokerServiceCObj) refreshObj;
                    if (refreshBrokerServiceCObj(bSvcCObj)) {
                        app.getInspector().refresh();
                        controller.setActions(bSvcCObj);
                    }
                }
            } else {
                msg = acr.getString(acr.E_SERVICE_PAUSE, svcName);
            }
            break;
        case BrokerCmdStatusEvent.RESUME_SVC:
            if (success) {
                msg = acr.getString(acr.S_SERVICE_RESUME, svcName, bkrName);
                if (refreshObj instanceof BrokerServiceCObj) {
                    BrokerServiceCObj bSvcCObj = (BrokerServiceCObj) refreshObj;
                    if (refreshBrokerServiceCObj(bSvcCObj)) {
                        app.getInspector().refresh();
                        controller.setActions(bSvcCObj);
                    }
                }
            } else {
                msg = acr.getString(acr.E_SERVICE_RESUME, svcName);
            }
            break;
        case BrokerCmdStatusEvent.UPDATE_SVC:
            if (success) {
                msg = acr.getString(acr.S_BROKER_UPDATE_SVC, svcInfo.name);
                if (refreshObj instanceof BrokerServiceCObj) {
                    if (refreshBrokerServiceCObj((BrokerServiceCObj) refreshObj)) {
                        app.getInspector().refresh();
                    }
                }
            } else {
                msg = acr.getString(acr.E_UPDATE_SERVICE, svcInfo.name);
            }
            break;
        case BrokerCmdStatusEvent.LIST_SVC:
            if (success) {
                msg = acr.getString(acr.S_BROKER_REFRESH_SVCLIST, bkrName);
                Object obj = cse.getReturnedObject();
                BrokerServiceListCObj bSvclCObj;
                if (obj instanceof Vector) {
                    Vector svcs = (Vector) obj;
                    if (refreshObj instanceof BrokerServiceListCObj) {
                        bSvclCObj = (BrokerServiceListCObj) refreshObj;
                    } else if (refreshObj instanceof BrokerCObj) {
                        BrokerCObj bCObj = (BrokerCObj) refreshObj;
                        bSvclCObj = bCObj.getBrokerServiceListCObj();
                    } else {
                        return;
                    }
                    refreshBrokerServiceList(svcs, bSvclCObj);
                    app.getInspector().refresh();
                }
            } else {
                msg = acr.getString(acr.E_REFRESH_SVCLIST);
            }
            break;
        case BrokerCmdStatusEvent.PAUSE_BKR:
            if (success) {
                msg = acr.getString(acr.S_BROKER_PAUSE, bkrName);
                if (refreshObj instanceof BrokerCObj) {
                    BrokerCObj bCObj = (BrokerCObj) refreshObj;
                    if (refreshBrokerServiceListCObj(bCObj.getBrokerServiceListCObj())) {
                        app.getInspector().refresh();
                        controller.setActions(bCObj);
                    }
                }
            } else {
                msg = acr.getString(acr.E_BROKER_PAUSE, bkrName);
            }
            break;
        case BrokerCmdStatusEvent.RESUME_BKR:
            if (success) {
                msg = acr.getString(acr.S_BROKER_RESUME, bkrName);
                if (refreshObj instanceof BrokerCObj) {
                    BrokerCObj bCObj = (BrokerCObj) refreshObj;
                    if (refreshBrokerServiceListCObj(bCObj.getBrokerServiceListCObj())) {
                        app.getInspector().refresh();
                        controller.setActions(bCObj);
                    }
                }
            } else {
                msg = acr.getString(acr.E_BROKER_RESUME, bkrName);
            }
            break;
        case BrokerCmdStatusEvent.UPDATE_BKR:
            if (success) {
                msg = acr.getString(acr.S_BROKER_UPDATE, bkrName);
            } else {
                msg = acr.getString(acr.E_UPDATE_BROKER, bkrName);
            }
            break;
        default:
            msg = acr.getString(acr.I_UNKNOWN_STATUS, bkrName);
            break;
    }
    if (!success) {
        if (ex instanceof BrokerAdminException) {
            msg = msg + "\n" + printBrokerAdminExceptionDetails((BrokerAdminException) ex);
        } else {
            msg = msg + "\n" + ex;
        }
    }
    JOptionPane.showOptionDialog(app.getFrame(), msg, title, JOptionPane.YES_NO_OPTION, msgType, null, close, close[0]);
}
Also used : BrokerAdminException(com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException) BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin) DestinationInfo(com.sun.messaging.jmq.util.admin.DestinationInfo) BrokerAdminException(com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException) ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) Vector(java.util.Vector)

Example 4 with ServiceInfo

use of com.sun.messaging.jmq.util.admin.ServiceInfo in project openmq by eclipse-ee4j.

the class BrokerServiceListInspector method getValueAtCollumn.

/**
 * Returns the Object at a particular cell collumn for a given ConsoleObj object. Each row in the JTable represents one
 * ConsoleObj. This method returns the object/value for the ConsoleObj, for a particular collumn.
 *
 * @return the Object at a particular cell collumn for a given ConsoleObj object.
 */
@Override
public Object getValueAtCollumn(ConsoleObj conObj, int col) {
    BrokerServiceCObj bSvcCObj;
    if (!(conObj instanceof BrokerServiceCObj)) {
        return null;
    }
    bSvcCObj = (BrokerServiceCObj) conObj;
    ServiceInfo svcInfo = bSvcCObj.getServiceInfo();
    if (col == 0) {
        return (bSvcCObj);
    } else if (col == 1) {
        String portStr;
        // The port number is not applicable to this service
        if (svcInfo.port == -1) {
            portStr = "-";
        } else if (svcInfo.dynamicPort) {
            // dynamically generated or statically declared
            switch(svcInfo.state) {
                case ServiceState.UNKNOWN:
                    portStr = ar.getString(ar.I_DYNAMIC);
                    break;
                default:
                    portStr = Integer.toString(svcInfo.port) + " (" + ar.getString(ar.I_DYNAMIC) + ")";
            }
        } else {
            portStr = Integer.toString(svcInfo.port) + " (" + ar.getString(ar.I_STATIC) + ")";
        }
        return (portStr);
    } else if (col == 2) {
        // return (ServiceState.getString(svcInfo.state));
        return BrokerAdminUtil.getServiceState(svcInfo.state);
    }
    return (null);
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo)

Example 5 with ServiceInfo

use of com.sun.messaging.jmq.util.admin.ServiceInfo in project openmq by eclipse-ee4j.

the class BrokerAdminHandler method doUpdateService.

private void doUpdateService(BrokerAdminEvent bae, ConsoleObj selObj) {
    BrokerServiceCObj bSvcCObj;
    BrokerAdmin ba;
    String serviceName = null;
    int portValue = -1;
    int minThreadsValue = -1;
    int maxThreadsValue = -1;
    if (!(selObj instanceof BrokerServiceCObj)) {
        /*
             * REMINDER: Need to flag this error ?
             */
        return;
    }
    bSvcCObj = (BrokerServiceCObj) selObj;
    ba = bSvcCObj.getBrokerAdmin();
    /*
         * Broker may take more time to complete the task than the specified timeout value. This value is used when refreshing
         * the console in such cases.
         */
    if (!ba.isBusy()) {
        ba.setAssociatedObj(bSvcCObj);
    }
    serviceName = bSvcCObj.getServiceInfo().name;
    portValue = bae.getPort();
    minThreadsValue = bae.getMinThreads();
    maxThreadsValue = bae.getMaxThreads();
    ServiceInfo svcInfo = new ServiceInfo();
    svcInfo.setName(serviceName);
    svcInfo.setPort(portValue);
    svcInfo.setMinThreads(minThreadsValue);
    svcInfo.setMaxThreads(maxThreadsValue);
    try {
        ba.sendUpdateServiceMessage(svcInfo);
        ba.receiveUpdateServiceReplyMessage();
        app.getStatusArea().appendText(acr.getString(acr.S_BROKER_UPDATE_SVC, serviceName));
        if (bae.isOKAction()) {
            brokerSvcPropsDialog.setVisible(false);
        }
    } catch (BrokerAdminException baex) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_UPDATE_SERVICE, serviceName) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_BROKER_SVC_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_UPDATE_SERVICE), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return;
    }
    if (refreshBrokerServiceCObj(bSvcCObj)) {
        app.getInspector().selectedObjectUpdated();
        // Update menu items, buttons.
        controller.setActions(bSvcCObj);
    }
}
Also used : ServiceInfo(com.sun.messaging.jmq.util.admin.ServiceInfo) BrokerAdminException(com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException) BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin)

Aggregations

ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)27 BrokerAdmin (com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin)9 BrokerAdminException (com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException)9 MetricCounters (com.sun.messaging.jmq.util.MetricCounters)9 Enumeration (java.util.Enumeration)9 Vector (java.util.Vector)9 SizeString (com.sun.messaging.jmq.util.SizeString)5 DestinationInfo (com.sun.messaging.jmq.util.admin.DestinationInfo)4 Properties (java.util.Properties)4 Service (com.sun.messaging.jmq.jmsserver.service.Service)2 ServiceManager (com.sun.messaging.jmq.jmsserver.service.ServiceManager)2 IMQService (com.sun.messaging.jmq.jmsserver.service.imq.IMQService)2 DurableInfo (com.sun.messaging.jmq.util.admin.DurableInfo)2 HashMap (java.util.HashMap)2 Hashtable (java.util.Hashtable)2 Iterator (java.util.Iterator)2 List (java.util.List)2 HAMonitorService (com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService)1 ConnectionManager (com.sun.messaging.jmq.jmsserver.service.ConnectionManager)1 MetricManager (com.sun.messaging.jmq.jmsserver.service.MetricManager)1