logging
This commit is contained in:
@ -42,8 +42,11 @@ public class PoolingTunnelManagerFacade implements TunnelManagerFacade {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startup() {
|
public void startup() {
|
||||||
if (_pool == null)
|
if (_pool == null) {
|
||||||
_pool = new TunnelPool(_context);
|
_pool = new TunnelPool(_context);
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": New tunnel pool created: " + _pool.toString());
|
||||||
|
}
|
||||||
_pool.startup();
|
_pool.startup();
|
||||||
_testManager = new TunnelTestManager(_context, _pool);
|
_testManager = new TunnelTestManager(_context, _pool);
|
||||||
}
|
}
|
||||||
@ -88,9 +91,9 @@ public class PoolingTunnelManagerFacade implements TunnelManagerFacade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
|
||||||
_log.debug("Joining tunnel: " + info);
|
|
||||||
boolean ok = _pool.addParticipatingTunnel(info);
|
boolean ok = _pool.addParticipatingTunnel(info);
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug("Joining tunnel (" + ok + "): " + info);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
_context.statManager().updateFrequency("tunnel.rejectRequestFrequency");
|
_context.statManager().updateFrequency("tunnel.rejectRequestFrequency");
|
||||||
else
|
else
|
||||||
|
@ -78,44 +78,71 @@ class TunnelPool {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public TunnelInfo getTunnelInfo(TunnelId id) {
|
public TunnelInfo getTunnelInfo(TunnelId id) {
|
||||||
if (!_isLive) return null;
|
if (!_isLive) {
|
||||||
if (id == null) return null;
|
if (_log.shouldLog(Log.ERROR))
|
||||||
|
_log.error(toString() + ": Not live, unable to search for tunnel " + id);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (id == null) {
|
||||||
|
if (_log.shouldLog(Log.ERROR))
|
||||||
|
_log.error(toString() + ": Id requested is null");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
boolean typeKnown = id.getType() != TunnelId.TYPE_UNSPECIFIED;
|
boolean typeKnown = id.getType() != TunnelId.TYPE_UNSPECIFIED;
|
||||||
|
|
||||||
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_PARTICIPANT) ) {
|
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_PARTICIPANT) ) {
|
||||||
synchronized (_participatingTunnels) {
|
synchronized (_participatingTunnels) {
|
||||||
if (_participatingTunnels.containsKey(id))
|
if (_participatingTunnels.containsKey(id)) {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": Found tunnel " + id + " as a participant");
|
||||||
return (TunnelInfo)_participatingTunnels.get(id);
|
return (TunnelInfo)_participatingTunnels.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_OUTBOUND) ) {
|
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_OUTBOUND) ) {
|
||||||
synchronized (_outboundTunnels) {
|
synchronized (_outboundTunnels) {
|
||||||
if (_outboundTunnels.containsKey(id))
|
if (_outboundTunnels.containsKey(id)) {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": Found tunnel " + id + " as outbound");
|
||||||
return (TunnelInfo)_outboundTunnels.get(id);
|
return (TunnelInfo)_outboundTunnels.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_INBOUND) ) {
|
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_INBOUND) ) {
|
||||||
synchronized (_freeInboundTunnels) {
|
synchronized (_freeInboundTunnels) {
|
||||||
if (_freeInboundTunnels.containsKey(id))
|
if (_freeInboundTunnels.containsKey(id)) {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": Found tunnel " + id + " as a free inbound");
|
||||||
return (TunnelInfo)_freeInboundTunnels.get(id);
|
return (TunnelInfo)_freeInboundTunnels.get(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
synchronized (_pendingTunnels) {
|
synchronized (_pendingTunnels) {
|
||||||
if (_pendingTunnels.containsKey(id))
|
if (_pendingTunnels.containsKey(id)) {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": Found tunnel " + id + " as a pending tunnel");
|
||||||
return (TunnelInfo)_pendingTunnels.get(id);
|
return (TunnelInfo)_pendingTunnels.get(id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_INBOUND) ) {
|
if ( (!typeKnown) || (id.getType() == TunnelId.TYPE_INBOUND) ) {
|
||||||
synchronized (_clientPools) {
|
synchronized (_clientPools) {
|
||||||
for (Iterator iter = _clientPools.values().iterator(); iter.hasNext(); ) {
|
for (Iterator iter = _clientPools.values().iterator(); iter.hasNext(); ) {
|
||||||
ClientTunnelPool pool = (ClientTunnelPool)iter.next();
|
ClientTunnelPool pool = (ClientTunnelPool)iter.next();
|
||||||
if (pool.isInboundTunnel(id))
|
if (pool.isInboundTunnel(id)) {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": Found tunnel " + id + " as an inbound tunnel for the client " + pool.getDestination().calculateHash().toBase64());
|
||||||
return pool.getInboundTunnel(id);
|
return pool.getInboundTunnel(id);
|
||||||
else if (pool.isInactiveInboundTunnel(id))
|
} else if (pool.isInactiveInboundTunnel(id)) {
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": Found tunnel " + id + " as an inactive inbound tunnel for the client " + pool.getDestination().calculateHash().toBase64());
|
||||||
return pool.getInactiveInboundTunnel(id);
|
return pool.getInactiveInboundTunnel(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug(toString() + ": Did NOT find the tunnel " + id);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +222,7 @@ class TunnelPool {
|
|||||||
}
|
}
|
||||||
public void addOutboundTunnel(TunnelInfo tunnel) {
|
public void addOutboundTunnel(TunnelInfo tunnel) {
|
||||||
if (!_isLive) return;
|
if (!_isLive) return;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Add outbound tunnel " + tunnel.getTunnelId());
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": Add outbound tunnel " + tunnel.getTunnelId());
|
||||||
_context.messageHistory().tunnelJoined("outbound", tunnel);
|
_context.messageHistory().tunnelJoined("outbound", tunnel);
|
||||||
synchronized (_outboundTunnels) {
|
synchronized (_outboundTunnels) {
|
||||||
_outboundTunnels.put(tunnel.getTunnelId(), tunnel);
|
_outboundTunnels.put(tunnel.getTunnelId(), tunnel);
|
||||||
@ -206,7 +233,7 @@ class TunnelPool {
|
|||||||
}
|
}
|
||||||
public void removeOutboundTunnel(TunnelId id) {
|
public void removeOutboundTunnel(TunnelId id) {
|
||||||
if (!_isLive) return;
|
if (!_isLive) return;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Removing outbound tunnel " + id);
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": Removing outbound tunnel " + id);
|
||||||
int remaining = 0;
|
int remaining = 0;
|
||||||
synchronized (_outboundTunnels) {
|
synchronized (_outboundTunnels) {
|
||||||
_outboundTunnels.remove(id);
|
_outboundTunnels.remove(id);
|
||||||
@ -240,7 +267,7 @@ class TunnelPool {
|
|||||||
}
|
}
|
||||||
public void addFreeTunnel(TunnelInfo tunnel) {
|
public void addFreeTunnel(TunnelInfo tunnel) {
|
||||||
if (!_isLive) return;
|
if (!_isLive) return;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Add free inbound tunnel " + tunnel.getTunnelId());
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": Add free inbound tunnel " + tunnel.getTunnelId());
|
||||||
_context.messageHistory().tunnelJoined("free inbound", tunnel);
|
_context.messageHistory().tunnelJoined("free inbound", tunnel);
|
||||||
synchronized (_freeInboundTunnels) {
|
synchronized (_freeInboundTunnels) {
|
||||||
_freeInboundTunnels.put(tunnel.getTunnelId(), tunnel);
|
_freeInboundTunnels.put(tunnel.getTunnelId(), tunnel);
|
||||||
@ -255,7 +282,7 @@ class TunnelPool {
|
|||||||
}
|
}
|
||||||
public TunnelInfo removeFreeTunnel(TunnelId id) {
|
public TunnelInfo removeFreeTunnel(TunnelId id) {
|
||||||
if (!_isLive) return null;
|
if (!_isLive) return null;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Removing free inbound tunnel " + id);
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": Removing free inbound tunnel " + id);
|
||||||
int remaining = 0;
|
int remaining = 0;
|
||||||
TunnelInfo rv = null;
|
TunnelInfo rv = null;
|
||||||
synchronized (_freeInboundTunnels) {
|
synchronized (_freeInboundTunnels) {
|
||||||
@ -291,7 +318,7 @@ class TunnelPool {
|
|||||||
|
|
||||||
public boolean addParticipatingTunnel(TunnelInfo tunnel) {
|
public boolean addParticipatingTunnel(TunnelInfo tunnel) {
|
||||||
if (!_isLive) return false;
|
if (!_isLive) return false;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Add participating tunnel " + tunnel.getTunnelId());
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": Add participating tunnel " + tunnel.getTunnelId());
|
||||||
_context.messageHistory().tunnelJoined("participant", tunnel);
|
_context.messageHistory().tunnelJoined("participant", tunnel);
|
||||||
synchronized (_participatingTunnels) {
|
synchronized (_participatingTunnels) {
|
||||||
if (_participatingTunnels.containsKey(tunnel.getTunnelId())) {
|
if (_participatingTunnels.containsKey(tunnel.getTunnelId())) {
|
||||||
@ -306,7 +333,7 @@ class TunnelPool {
|
|||||||
|
|
||||||
public TunnelInfo removeParticipatingTunnel(TunnelId id) {
|
public TunnelInfo removeParticipatingTunnel(TunnelId id) {
|
||||||
if (!_isLive) return null;
|
if (!_isLive) return null;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Removing participating tunnel " + id);
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": Removing participating tunnel " + id);
|
||||||
synchronized (_participatingTunnels) {
|
synchronized (_participatingTunnels) {
|
||||||
return (TunnelInfo)_participatingTunnels.remove(id);
|
return (TunnelInfo)_participatingTunnels.remove(id);
|
||||||
}
|
}
|
||||||
@ -396,7 +423,7 @@ class TunnelPool {
|
|||||||
}
|
}
|
||||||
public void removePendingTunnel(TunnelId id) {
|
public void removePendingTunnel(TunnelId id) {
|
||||||
if (!_isLive) return;
|
if (!_isLive) return;
|
||||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Removing pending tunnel " + id);
|
if (_log.shouldLog(Log.DEBUG)) _log.debug(toString() + ": Removing pending tunnel " + id);
|
||||||
synchronized (_pendingTunnels) {
|
synchronized (_pendingTunnels) {
|
||||||
_pendingTunnels.remove(id);
|
_pendingTunnels.remove(id);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user