Commit bcde7202 authored by Andre Freyssinet's avatar Andre Freyssinet

JORAM-323: Handling of temporary destinations (usage of DMQ on deletion).

JORAM-326: Allows to use strict values for counters.
JORAM-330: Fix potential issues with serialization (serialVersionUID).
parent ae245dfb
......@@ -38,6 +38,7 @@ import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
import org.objectweb.joram.mom.dest.AdminTopic.DestinationDesc;
import org.objectweb.joram.mom.notifications.AbstractRequestNot;
import org.objectweb.joram.mom.notifications.ClientMessages;
import org.objectweb.joram.mom.notifications.ExceptionReply;
......@@ -100,8 +101,14 @@ import fr.dyade.aaa.util.management.MXWrapper;
* MOM destinations.
*/
public abstract class Destination extends Agent implements DestinationMBean {
/** define serialVersionUID for interoperability, fix with 5.16.0 value */
private static final long serialVersionUID = -6697938753761953568L;
public static Logger logger = Debug.getLogger(Destination.class.getName());
// JORAM-323: Verify if the destination is temporary.
protected transient boolean temporary = false;
/**
* <code>true</code> if the destination successfully processed a deletion
* request.
......@@ -164,7 +171,21 @@ public abstract class Destination extends Agent implements DestinationMBean {
logger.log(BasicLevel.DEBUG, "agentInitialize(" + firstTime + ')');
super.agentInitialize(firstTime);
// JORAM-323: Verify if the destination is temporary.
if (getId().getStamp() != AgentId.JoramAdminStamp) {
DestinationDesc desc = AdminTopic.lookupDest(getName(), getType());
if (desc == null) {
logger.log(BasicLevel.WARN, "Cannot find destination in registry:" + getName());
} else {
if (DestinationConstants.isTemporary(desc.getType())) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Set temporary field, destination will be deleted:" + getName());
temporary = true;
}
}
}
// interceptors
if (interceptorsProp != null) {
interceptors = new ArrayList<MessageInterceptor>();
......@@ -339,6 +360,15 @@ public abstract class Destination extends Agent implements DestinationMBean {
* date of creation.
*/
public long creationDate = System.currentTimeMillis();
// JORAM-326:
static protected boolean strictCounters;
static {
strictCounters = AgentServer.getBoolean(DestinationConstants.DEST_STRICT_CPT);
// Be careful, may be logger is not already initialized!
Debug.getLogger(Destination.class.getName()).log(BasicLevel.WARN, "Force strict values for queue counters: " + strictCounters);
}
protected long nbMsgsDeliverSinceCreation = 0;
protected long nbMsgsSentToDMQSinceCreation = 0;
......@@ -672,7 +702,7 @@ public abstract class Destination extends Agent implements DestinationMBean {
if (AgentId.nullId.equals(from)) {
from = not.getProxyId();
}
// If sender is not a writer, sending the messages to the DMQ, and
// throwing an exception:
if (!isWriter(from)) {
......@@ -681,6 +711,12 @@ public abstract class Destination extends Agent implements DestinationMBean {
for (Iterator msgs = not.getMessages().iterator(); msgs.hasNext();) {
msg = (Message) msgs.next();
nbMsgsSentToDMQSinceCreation++;
// JORAM-326: Saves the queue to avoid bad counter value at restart.
if (strictCounters) {
logger.log(BasicLevel.ERROR, "Destination.clientMessages: " + strictCounters);
setSave();
}
dmqManager.addDeadMessage(msg, MessageErrorConstants.NOT_WRITEABLE);
handleDeniedMessage(msg.id, AgentId.fromString(msg.replyToId));
}
......@@ -745,6 +781,8 @@ public abstract class Destination extends Agent implements DestinationMBean {
logger.log(BasicLevel.WARN,
"Unauthorized deletion request from " + from);
} else {
// JORAM-323: Removes the destination from AdminTopic registry.
AdminTopic.unregisterDest(getName());
doDeleteNot(not);
setSave(); // state change, so save.
deletable = true;
......@@ -865,8 +903,7 @@ public abstract class Destination extends Agent implements DestinationMBean {
// nothing to do.
}
private void writeObject(java.io.ObjectOutputStream out)
throws IOException {
private void writeObject(java.io.ObjectOutputStream out) throws IOException {
out.writeBoolean(deletable);
out.writeObject(adminId);
out.writeBoolean(freeReading);
......@@ -880,8 +917,7 @@ public abstract class Destination extends Agent implements DestinationMBean {
out.writeObject(interceptorsProp);
}
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException {
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
deletable = in.readBoolean();
adminId = (AgentId)in.readObject();
freeReading = in.readBoolean();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment