OW2 Consortium joram

Compare Revisions

Ignore whitespace Rev 6432 → Rev 6433

/trunk/joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/UserAgent.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2016 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2017 ScalAgent Distributed Technologies
* Copyright (C) 2004 France Telecom R&D
* Copyright (C) 2003 - 2004 Bull SA
* Copyright (C) 1996 - 2000 Dyade
996,7 → 996,7
long date = System.currentTimeMillis();
if ((date - lastRequestDate) > timeout) {
if (logger.isLoggable(BasicLevel.WARN))
logger.log(BasicLevel.WARN, "HeartBeatTask: closeclose connection - key=" + key);
logger.log(BasicLevel.WARN, "HeartBeatTask: close connection - key=" + key);
 
Channel.sendTo(userId, (Notification) new CloseConnectionNot2(key.intValue()));
this.cancel();
2740,6 → 2740,15
// else the client doesn't expect any ack
}
 
private <K, V> K getKeyByValue(Map<K, V> map, V value) {
for (Map.Entry<K, V> entry : map.entrySet()) {
if (value.equals(entry.getValue())) {
return entry.getKey();
}
}
return null;
}
/**
* Method implementing the reaction to a <code>AddClientIDRequest</code>
* instance add the clientID value of a connection.
2748,8 → 2757,25
private void doReact(int key, AddClientIDRequest req) throws Exception {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "AddClientIDRequest key = " + key + ", clientID = " + req.clientID);
if (clientIDs.containsValue(req.clientID))
throw new Exception("clientID \""+ req.clientID + "\" already active.");
 
if (clientIDs.containsValue(req.clientID)) {
int oldKey = getKeyByValue(clientIDs, req.clientID);
ConnectionContext oldCtx = (ConnectionContext) connections.get(oldKey);
HeartBeatTask hbt = (HeartBeatTask) heartBeatTasks.get(oldKey);
if (oldCtx instanceof ReliableConnectionContext && !((ReliableConnectionContext) oldCtx).isActive()) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "doReact AddClientIDRequest: try to connect with the same clientID \"" + req.clientID +
"\" on inactive context, so close the old context - oldKey=" + oldKey);
Channel.sendTo(getId(), (Notification) new CloseConnectionNot2(oldKey));
hbt.cancel();
clientIDs.remove(oldKey);
heartBeatTasks.remove(oldKey);
connections.remove(oldKey);
} else {
throw new Exception("clientID \""+ req.clientID + "\" already active.");
}
}
clientIDs.put(new Integer(key), req.clientID);
AddClientIDReply reply = new AddClientIDReply();
/trunk/joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/ReliableConnectionContext.java
1,6 → 1,6
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2006 - 2013 ScalAgent Distributed Technologies
* Copyright (C) 2006 - 2017 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
29,7 → 29,6
import org.objectweb.joram.shared.client.CnxCloseRequest;
import org.objectweb.joram.shared.client.MomExceptionReply;
import org.objectweb.joram.shared.excepts.MomException;
import org.objectweb.util.monolog.api.BasicLevel;
import org.objectweb.util.monolog.api.Logger;
 
import fr.dyade.aaa.common.Debug;
60,6 → 59,8
private QueueWorker queueWorker;
private boolean active = false;
public ReliableConnectionContext() {}
 
public int getKey() {
159,4 → 160,12
}
closed = false;
}
public void setActive(boolean active) {
this.active = active;
}
public boolean isActive() {
return active;
}
}
/trunk/joram/joram/mom/core/src/main/java/org/objectweb/joram/mom/proxies/tcp/TcpConnection.java
1,5 → 1,5
/*
* Copyright (C) 2004 - 2013 ScalAgent Distributed Technologies
* Copyright (C) 2004 - 2017 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
132,6 → 132,7
tcpReader = new TcpReader(ioctrl, proxyId, this, closeConnection, ctx);
proxyService.registerConnection(this);
tcpReader.start();
ctx.setActive(true);
} catch (Exception exc) {
close();
throw exc;
150,6 → 151,7
tcpReader.stop();
if (ioctrl != null)
ioctrl.close();
ctx.setActive(false);
try {
MXWrapper.unregisterMBean("Joram#" + AgentServer.getServerId(), getMBeanName());
} catch (Exception e) {