use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException 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]);
}
use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method handleBrokerAdminEvents.
public void handleBrokerAdminEvents(BrokerAdminEvent bae) {
int type = bae.getType();
ConsoleBrokerAdminManager baMgr = app.getBrokerListCObj().getBrokerAdminManager();
ConsoleObj selObj = app.getSelectedObj();
BrokerAdmin ba;
BrokerCObj bCObj;
switch(type) {
case BrokerAdminEvent.ADD_BROKER:
if (selObj instanceof BrokerListCObj) {
try {
ba = new BrokerAdmin(bae.getHost(), bae.getPort(), bae.getUsername(), bae.getPassword(), -1, JMQ_RECONNECT, JMQ_RECONNECT_RETRIES, JMQ_RECONNECT_DELAY);
ba.setKey(bae.getBrokerName());
} catch (BrokerAdminException baex) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_BROKER_ADD_BROKER, bae.getBrokerName()) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_ADD_BROKER) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_BROKER_ADD_BROKER), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
} catch (Exception e) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_BROKER_ADD_BROKER, bae.getBrokerName()) + e, acr.getString(acr.I_ADD_BROKER) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_BROKER_ADD_BROKER), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
if (baMgr.exist(ba.getKey())) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_BROKER_EXISTS, ba.getKey()), acr.getString(acr.I_ADD_BROKER) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_BROKER_EXISTS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
bCObj = new BrokerCObj(ba);
/*
* bae.isConnectAttempt() is always false, since we no longer allow users to 'connect after add'. if
* (bae.isConnectAttempt()) { if (connectToBroker(ba)) { baMgr.addBrokerAdmin(ba); app.getExplorer().addBroker(bCObj);
* if (!refreshBrokerCObj(bCObj)) return; if (!populateBrokerServices(bCObj)) return; if
* (!populateBrokerDestinations(bCObj)) return; app.getInspector().refresh(); saveBrokerList(); } else return; } else {
*/
baMgr.addBrokerAdmin(ba);
app.getExplorer().addBroker(bCObj);
app.getInspector().refresh();
saveBrokerList();
if (bae.isOKAction()) {
brokerAddDialog.setVisible(false);
}
}
break;
case BrokerAdminEvent.ADD_DEST:
if (selObj instanceof BrokerDestListCObj) {
BrokerDestCObj bDestCObj = null;
bCObj = ((BrokerDestListCObj) selObj).getBrokerCObj();
if ((bDestCObj = addDestination(bCObj, bae)) == null) {
return;
}
// Update the table entry
app.getExplorer().addToParent(selObj, bDestCObj);
app.getInspector().refresh();
if (bae.isOKAction()) {
brokerDestAddDialog.setVisible(false);
}
}
break;
case BrokerAdminEvent.UPDATE_LOGIN:
doUpdateLogin(bae, selObj);
break;
case BrokerAdminEvent.UPDATE_BROKER:
doUpdateBroker(bae, selObj);
break;
case BrokerAdminEvent.DELETE_DUR:
doDeleteDurable(bae, selObj);
break;
case BrokerAdminEvent.PURGE_DUR:
doPurgeDurable(bae, selObj);
break;
case BrokerAdminEvent.UPDATE_SVC:
doUpdateService(bae, selObj);
break;
case BrokerAdminEvent.UPDATE_DEST:
doUpdateDestination(bae, selObj);
break;
case BrokerAdminEvent.QUERY_BROKER:
doQueryBroker(selObj);
break;
case BrokerAdminEvent.UPDATE_BROKER_ENTRY:
doUpdateBrokerEntry(bae, selObj);
break;
}
}
use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method addDestination.
private BrokerDestCObj addDestination(BrokerCObj bCObj, BrokerAdminEvent bae) {
BrokerDestCObj bDestCObj;
DestinationInfo destInfo = createDestination(bae);
BrokerAdmin ba = bCObj.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(bCObj);
}
String destName = destInfo.name;
try {
ba.sendCreateDestinationMessage(destInfo);
ba.receiveCreateDestinationReplyMessage();
bDestCObj = new BrokerDestCObj(bCObj, destInfo);
app.getStatusArea().appendText(acr.getString(acr.S_BROKER_DEST_ADD, destInfo.name, ba.getKey()));
} catch (BrokerAdminException baex) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_ADD_DEST_BROKER, destName, ba.getKey()) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_ADD_BROKER_DEST) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_ADD_DEST_BROKER), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return null;
}
return bDestCObj;
}
use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method refreshBrokerDestCObj.
private boolean refreshBrokerDestCObj(BrokerDestCObj bDestCObj, int eventType) {
DestinationInfo oldDestInfo = bDestCObj.getDestinationInfo();
BrokerAdmin ba = bDestCObj.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(bDestCObj);
}
Vector dests = null;
Vector durables = null;
boolean succeed = false;
try {
ba.sendGetDurablesMessage(oldDestInfo.name, null);
/*
* False because users do not need to know whether or not the operation had succeeded after timeout.
*/
durables = ba.receiveGetDurablesReplyMessage(false);
} catch (BrokerAdminException baex) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_RETRIEVE_DUR, oldDestInfo.name) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_BROKER_DEST_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_RETRIEVE_DUR), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return false;
}
bDestCObj.setDurables(durables);
succeed = true;
try {
ba.sendGetDestinationsMessage(oldDestInfo.name, oldDestInfo.type);
/*
* False because users do not need to know whether or not the operation had succeeded after timeout.
*/
dests = ba.receiveGetDestinationsReplyMessage(false);
} catch (BrokerAdminException baex) {
/*
* Do not pop up an error message, as another error message will be popped up.
*/
if (eventType == BrokerAdminEvent.DELETE_DUR || eventType == BrokerAdminEvent.UPDATE_DEST) {
return false;
}
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_RETRIEVE_DEST, oldDestInfo.name) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_BROKER_DEST_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_RETRIEVE_DEST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return false;
}
if ((dests != null) && (dests.size() == 1)) {
Enumeration e = dests.elements();
DestinationInfo dInfo = (DestinationInfo) e.nextElement();
if ((!DestType.isTemporary(dInfo.type)) && (!DestType.isInternal(dInfo.fulltype)) && (!MessageType.JMQ_BRIDGE_ADMIN_DEST.equals(dInfo.name)) && (!MessageType.JMQ_ADMIN_DEST.equals(dInfo.name))) {
bDestCObj.setDestinationInfo(dInfo);
}
succeed = true;
}
return succeed;
}
use of com.sun.messaging.jmq.admin.bkrutil.BrokerAdminException in project openmq by eclipse-ee4j.
the class BrokerAdminHandler method doDeleteDurable.
private void doDeleteDurable(BrokerAdminEvent bae, ConsoleObj selObj) {
BrokerDestCObj bDestCObj;
BrokerAdmin ba;
String durableName = null;
String clientID = null;
if (!(selObj instanceof BrokerDestCObj)) {
/*
* REMINDER: Need to flag this error ?
*/
return;
}
bDestCObj = (BrokerDestCObj) selObj;
ba = bDestCObj.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(bDestCObj);
}
durableName = bae.getDurableName();
clientID = bae.getClientID();
int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_BROKER_DELETE_DUR, durableName, "" + clientID), acr.getString(acr.I_DELETE_DURABLE), JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
return;
}
try {
ba.sendDestroyDurableMessage(durableName, clientID);
ba.receiveDestroyDurableReplyMessage();
app.getStatusArea().appendText(acr.getString(acr.S_BROKER_DESTROY_DUR, BrokerAdminUtil.getDSubLogString(clientID, durableName)));
} catch (BrokerAdminException baex) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_BROKER_DESTROY_DUR, BrokerAdminUtil.getDSubLogString(clientID, durableName)) + printBrokerAdminExceptionDetails(baex), acr.getString(acr.I_DELETE_DURABLE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_BROKER_DESTROY_DUR), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
/*
* Refresh the durable subscription table.
*/
refreshBrokerDestCObj(bDestCObj, bae.getType());
Vector durables = bDestCObj.getDurables();
if (durables != null) {
brokerDestPropsDialog.refresh(durables);
}
}
Aggregations