Log the transport ID when registering connections.

This commit is contained in:
akwizgran
2016-04-06 09:52:24 +01:00
parent d5bf7194f6
commit 90f3d33f86

View File

@@ -41,7 +41,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} }
public void registerConnection(ContactId c, TransportId t) { public void registerConnection(ContactId c, TransportId t) {
LOG.info("Connection registered"); if (LOG.isLoggable(INFO)) LOG.info("Connection registered: " + t);
boolean firstConnection = false; boolean firstConnection = false;
lock.lock(); lock.lock();
try { try {
@@ -63,7 +63,6 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} finally { } finally {
lock.unlock(); lock.unlock();
} }
if (firstConnection) { if (firstConnection) {
LOG.info("Contact connected"); LOG.info("Contact connected");
eventBus.broadcast(new ContactConnectedEvent(c)); eventBus.broadcast(new ContactConnectedEvent(c));
@@ -71,7 +70,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} }
public void unregisterConnection(ContactId c, TransportId t) { public void unregisterConnection(ContactId c, TransportId t) {
LOG.info("Connection unregistered"); if (LOG.isLoggable(INFO)) LOG.info("Connection unregistered: " + t);
boolean lastConnection = false; boolean lastConnection = false;
lock.lock(); lock.lock();
try { try {
@@ -95,15 +94,13 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} finally { } finally {
lock.unlock(); lock.unlock();
} }
if (lastConnection) { if (lastConnection) {
LOG.info("Contact disconnected"); LOG.info("Contact disconnected");
eventBus.broadcast(new ContactDisconnectedEvent(c)); eventBus.broadcast(new ContactDisconnectedEvent(c));
} }
} }
public Collection<ContactId> getConnectedContacts( public Collection<ContactId> getConnectedContacts(TransportId t) {
TransportId t) {
lock.lock(); lock.lock();
try { try {
Map<ContactId, Integer> m = connections.get(t); Map<ContactId, Integer> m = connections.get(t);
@@ -115,7 +112,6 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} finally { } finally {
lock.unlock(); lock.unlock();
} }
} }
public boolean isConnected(ContactId c) { public boolean isConnected(ContactId c) {
@@ -125,6 +121,5 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
} finally { } finally {
lock.unlock(); lock.unlock();
} }
} }
} }