Search in sources :

Example 1 with BrokerAdmin

use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin 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 BrokerAdmin

use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin 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 BrokerAdmin

use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin in project openmq by eclipse-ee4j.

the class BrokerAdminHandler method doPauseBroker.

private void doPauseBroker(BrokerCObj bCObj) {
    BrokerAdmin ba = bCObj.getBrokerAdmin();
    int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_BROKER_PAUSE, ba.getKey()), acr.getString(acr.I_PAUSE_BROKER), 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(bCObj);
    }
    if (pauseBroker(ba)) {
        Enumeration e = bCObj.children();
        BrokerServiceListCObj bSvclCObj = null;
        while (e.hasMoreElements()) {
            ConsoleObj cObj = (ConsoleObj) e.nextElement();
            if (cObj instanceof BrokerServiceListCObj) {
                bSvclCObj = (BrokerServiceListCObj) cObj;
            }
        }
        Vector svcs = queryAllServiceInfo(ba);
        if (svcs != null) {
            updateAllServiceInfo(bSvclCObj, svcs);
            // Update menu items, buttons.
            controller.setActions(bCObj);
            app.getInspector().refresh();
        }
    }
}
Also used : BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin) Enumeration(java.util.Enumeration) Vector(java.util.Vector)

Example 4 with BrokerAdmin

use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin in project openmq by eclipse-ee4j.

the class BrokerAdminHandler method loadBrokerList.

/*
     * Load broker list from property file. See ConsoleBrokerAdminManager and BrokerListProperties for details on the actual
     * file loading.
     */
private void loadBrokerList() {
    ConsoleBrokerAdminManager baMgr = app.getBrokerListCObj().getBrokerAdminManager();
    try {
        baMgr.setFileName(BROKERLIST_FILENAME);
        baMgr.readBrokerAdminsFromFile();
    } catch (Exception ex) {
        String errStr = acr.getString(acr.E_LOAD_BKR_LIST) + ex.getMessage();
        /*
             * Show popup to indicate that the loading failed.
             */
        JOptionPane.showOptionDialog(app.getFrame(), errStr, acr.getString(acr.I_LOAD_BKR_LIST) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_LOAD_BKR_LIST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
    /*
             * At this point, should we make sure the ConsoleBrokerAdminManager contains no obj stores ?
             */
    }
    Vector v = baMgr.getBrokerAdmins();
    for (int i = 0; i < v.size(); i++) {
        BrokerAdmin ba = (BrokerAdmin) v.get(i);
        ConsoleObj brokerCObj = new BrokerCObj(ba);
        /*
             * Add code to populate broker node here if connected
             */
        app.getExplorer().addBroker(brokerCObj);
    }
    app.getInspector().refresh();
}
Also used : BrokerAdmin(com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin) Vector(java.util.Vector) BrokerAdminException(com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException)

Example 5 with BrokerAdmin

use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin 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)

Aggregations

BrokerAdmin (com.sun.messaging.jmq.admin.bkrutil.BrokerAdmin)69 BrokerAdminException (com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException)44 SizeString (com.sun.messaging.jmq.util.SizeString)27 Vector (java.util.Vector)20 DestinationInfo (com.sun.messaging.jmq.util.admin.DestinationInfo)14 Enumeration (java.util.Enumeration)14 Properties (java.util.Properties)12 ServiceInfo (com.sun.messaging.jmq.util.admin.ServiceInfo)9 Hashtable (java.util.Hashtable)6 DurableInfo (com.sun.messaging.jmq.util.admin.DurableInfo)2 HashMap (java.util.HashMap)2 UserProperties (com.sun.messaging.jmq.admin.util.UserProperties)1 DestMetricsCounters (com.sun.messaging.jmq.util.DestMetricsCounters)1 MetricCounters (com.sun.messaging.jmq.util.MetricCounters)1 ConsumerInfo (com.sun.messaging.jmq.util.admin.ConsumerInfo)1 Message (jakarta.jms.Message)1 Map (java.util.Map)1