use of com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService in project openmq by eclipse-ee4j.
the class UpdateServiceHandler method handle.
/**
* Handle the incomming administration message.
*
* @param con The Connection the message came in on.
* @param cmd_msg The administration message
* @param cmd_props The properties from the administration message
*/
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
if (DEBUG) {
logger.log(Logger.DEBUG, this.getClass().getName() + ": " + cmd_props);
}
ServiceInfo info = (ServiceInfo) getBodyObject(cmd_msg);
int status = Status.OK;
String errMsg = null;
ServiceManager sm = Globals.getServiceManager();
Service svc = null;
HAMonitorService hamonitor = Globals.getHAMonitorService();
if (hamonitor != null && hamonitor.inTakeover()) {
status = Status.ERROR;
errMsg = rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);
logger.log(Logger.ERROR, this.getClass().getName() + ": " + errMsg);
} else {
if (info.name == null || ((svc = sm.getService(info.name)) == null)) {
status = Status.ERROR;
errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, (info.name == null ? "<null>" : info.name));
}
}
// OK .. set the service information
if (status == Status.OK) {
if (!(svc instanceof IMQService)) {
status = Status.ERROR;
errMsg = "Internal Error: can updated non-standard Service";
} else {
// to repair this by fcs
try {
IMQService stsvc = (IMQService) svc;
int port = -1;
int min = -1;
int max = -1;
if (info.isModified(info.PORT)) {
port = info.port;
}
if (info.isModified(info.MIN_THREADS)) {
min = info.minThreads;
}
if (info.isModified(info.MAX_THREADS)) {
max = info.maxThreads;
}
if (port != -1 || min != -1 || max != -1) {
stsvc.updateService(port, min, max);
} else {
status = Status.ERROR;
errMsg = rb.getString(rb.X_NO_SERVICE_PROPS_SET, info.name);
}
} catch (Exception ex) {
logger.logStack(Logger.WARNING, rb.W_ERROR_UPDATING_SERVICE, svc.getName(), ex);
status = Status.ERROR;
errMsg = getMessageFromException(ex);
}
}
}
// Send reply
Packet reply = new Packet(con.useDirectBuffers());
reply.setPacketType(PacketType.OBJECT_MESSAGE);
setProperties(reply, MessageType.UPDATE_SERVICE_REPLY, status, errMsg);
parent.sendReply(con, cmd_msg, reply);
return true;
}
use of com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService in project openmq by eclipse-ee4j.
the class TakingoverEntry method getTakeoverTimeout.
protected static int getTakeoverTimeout() {
HAMonitorService hams = Globals.getHAMonitorService();
if (hams == null) {
return DEFAULT_TAKEOVER_PENDING_TIMEOUT;
}
int to = (2 * hams.getMonitorInterval());
if (to < DEFAULT_TAKEOVER_PENDING_TIMEOUT) {
return DEFAULT_TAKEOVER_PENDING_TIMEOUT;
}
return to;
}
use of com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService in project openmq by eclipse-ee4j.
the class PurgeDestinationHandler method handle.
/**
* Handle the incomming administration message.
*
* @param con The Connection the message came in on.
* @param cmd_msg The administration message
* @param cmd_props The properties from the administration message
*/
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
if (DEBUG) {
logger.log(Logger.DEBUG, this.getClass().getName() + ": " + "Purging: " + cmd_props);
}
assert cmd_props != null;
String destination = (String) cmd_props.get(MessageType.JMQ_DESTINATION);
Integer destType = (Integer) cmd_props.get(MessageType.JMQ_DEST_TYPE);
assert destination != null;
assert destType != null;
int status = Status.OK;
String errMsg = null;
HAMonitorService hamonitor = Globals.getHAMonitorService();
if (hamonitor != null && hamonitor.inTakeover()) {
status = Status.ERROR;
errMsg = rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);
logger.log(Logger.ERROR, this.getClass().getName() + ": " + errMsg);
} else {
// FOR NOW .. we have just one criteria - ALL
String criteria_str = Globals.getBrokerResources().getKString(BrokerResources.I_ALL_PURGE_CRITERIA);
// LKS
// dont use filter for now
// Filter f = deleteAll;
logger.log(Logger.INFO, BrokerResources.I_PURGING_DESTINATION, destination, criteria_str);
try {
// for now .. just delete all
Destination[] ds = DL.getDestination(null, destination, DestType.isQueue(destType.intValue()));
Destination d = null;
for (int i = 0; i < ds.length; i++) {
d = ds[i];
if (d == null) {
continue;
}
// audit logging for purge destination
if (i == 0) {
Globals.getAuditSession().destinationOperation(con.getUserName(), con.remoteHostString(), MQAuditSession.PURGE_DESTINATION, d.isQueue() ? MQAuditSession.QUEUE : MQAuditSession.TOPIC, d.getDestinationName());
}
d.purgeDestination();
}
if (d == null) {
errMsg = Globals.getBrokerResources().getKString(BrokerResources.E_NO_SUCH_DESTINATION, getDestinationType(destType.intValue()), destination);
Exception e = new BrokerException(errMsg);
e.fillInStackTrace();
status = Status.ERROR;
logger.log(Logger.WARNING, BrokerResources.W_ADMIN_OPERATION_FAILED, e);
}
} catch (BrokerException ex) {
status = Status.ERROR;
errMsg = getMessageFromException(ex);
logger.log(Logger.WARNING, BrokerResources.W_ADMIN_OPERATION_FAILED, ex);
} catch (OutOfMemoryError err) {
// throw memory error so it is handled by memory code
throw err;
} catch (Throwable ex) {
status = Status.ERROR;
errMsg = Globals.getBrokerResources().getString(BrokerResources.X_INTERNAL_EXCEPTION, ex);
logger.logStack(Logger.WARNING, BrokerResources.W_ADMIN_OPERATION_FAILED, ex);
}
}
// Send reply
Packet reply = new Packet(con.useDirectBuffers());
reply.setPacketType(PacketType.OBJECT_MESSAGE);
setProperties(reply, MessageType.PURGE_DESTINATION_REPLY, status, errMsg);
parent.sendReply(con, cmd_msg, reply);
return true;
}
use of com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService in project openmq by eclipse-ee4j.
the class PurgeDurableHandler method handle.
/**
* Handle the incomming administration message.
*
* @param con The Connection the message came in on.
* @param cmd_msg The administration message
* @param cmd_props The properties from the administration message
*/
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
if (DEBUG) {
logger.log(Logger.INFO, this.getClass().getName() + ": " + "PurgeDurable: " + cmd_props);
}
int status = Status.OK;
String errMsg = null;
String durable = (String) cmd_props.get(MessageType.JMQ_DURABLE_NAME);
String clientID = (String) cmd_props.get(MessageType.JMQ_CLIENT_ID);
try {
if (clientID != null && clientID.trim().length() == 0) {
throw new BrokerException(rb.getKString(rb.X_INVALID_CLIENTID, clientID), Status.BAD_REQUEST);
}
HAMonitorService hamonitor = Globals.getHAMonitorService();
if (hamonitor != null && hamonitor.inTakeover()) {
status = Status.UNAVAILABLE;
errMsg = rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);
logger.log(Logger.WARNING, this.getClass().getName() + ": " + errMsg);
} else {
Subscription sub = Subscription.findDurableSubscription(clientID, durable);
if (sub == null) {
errMsg = rb.getKString(rb.X_DURA_SUB_NOT_FOUND, Subscription.getDSubLogString(clientID, durable));
status = Status.NOT_FOUND;
} else {
sub.purge();
}
}
} catch (BrokerException ex) {
status = ex.getStatusCode();
errMsg = getMessageFromException(ex);
if (status == Status.BAD_REQUEST || status == Status.NOT_FOUND || status == Status.UNAVAILABLE) {
logger.log(logger.ERROR, errMsg);
} else {
logger.logStack(logger.ERROR, ex.getMessage(), ex);
}
}
Packet reply = new Packet(con.useDirectBuffers());
reply.setPacketType(PacketType.OBJECT_MESSAGE);
setProperties(reply, MessageType.PURGE_DURABLE_REPLY, status, errMsg);
parent.sendReply(con, cmd_msg, reply);
return true;
}
use of com.sun.messaging.jmq.jmsserver.cluster.api.ha.HAMonitorService in project openmq by eclipse-ee4j.
the class ResetMetricsHandler method handle.
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
if (DEBUG) {
logger.log(Logger.DEBUG, this.getClass().getName() + ": " + cmd_props);
}
int status = Status.OK;
String errMsg = null;
HAMonitorService hamonitor = Globals.getHAMonitorService();
if (hamonitor != null && hamonitor.inTakeover()) {
status = Status.ERROR;
errMsg = rb.getString(rb.E_CANNOT_PROCEED_TAKEOVER_IN_PROCESS);
logger.log(Logger.ERROR, this.getClass().getName() + ": " + errMsg);
} else {
String resetType = (String) cmd_props.get(MessageType.JMQ_RESET_TYPE);
if ((resetType == null) || (resetType.equals(""))) {
logger.log(Logger.INFO, rb.I_RESET_BROKER_METRICS);
resetAllMetrics();
} else {
if (MessageType.JMQ_METRICS.equals(resetType)) {
logger.log(Logger.INFO, rb.I_RESET_BROKER_METRICS);
resetAllMetrics();
} else {
logger.log(Logger.ERROR, rb.E_INVALID_RESET_BROKER_TYPE, resetType);
errMsg = rb.getString(rb.E_INVALID_RESET_BROKER_TYPE, resetType);
status = Status.ERROR;
}
}
}
// Send reply
Packet reply = new Packet(con.useDirectBuffers());
reply.setPacketType(PacketType.OBJECT_MESSAGE);
setProperties(reply, MessageType.RESET_BROKER_REPLY, status, errMsg, null);
parent.sendReply(con, cmd_msg, reply);
return true;
}
Aggregations