Permalink
Browse files

Clean up several points of logging.

  • Loading branch information...
1 parent 5204d08 commit 919a8aa61996db3548b293039e504c2e0428bb27 @willscott willscott committed Apr 6, 2012
@@ -42,7 +42,7 @@
@SuppressWarnings("unchecked")
@Override
public void execute(String command) {
- logger.info("parsing command: '" + command + "'");
+ logger.finest("parsing command: '" + command + "'");
String[] toks = command.split("\\s+");
toks[0] = toks[0].toLowerCase();
if (toks[0].equals("port")) {
@@ -141,7 +141,8 @@ private synchronized void sanity_check_perms() {
*/
public synchronized void f2fInitialized() {
AzureusCoreImpl.getSingleton().getGlobalManager().addDownloadManagerInitialisationAdapter(new DownloadManagerInitialisationAdapter(){
- public void initialised(DownloadManager manager) {
+ @Override
+ public void initialised(DownloadManager manager) {
try {
String hexHash = ByteFormatter.encodeString(manager.getTorrent().getHash());
ArrayList<GroupBean> groups = PermissionsDAO.this.getGroupsForHash(hexHash);
@@ -354,7 +355,7 @@ public synchronized void refresh_friend_groups() {
removeGroupID(base64Key_to_groupid.get(key), true);
save = true;
} catch (IOException e) {
- e.printStackTrace();
+ // e.printStackTrace();
logger.warning(e.toString());
}
}
@@ -619,22 +620,28 @@ private synchronized void setGroupsForHash( String inHexHash, final ArrayList<Gr
if (dm != null) {
if (dm.getState() != DownloadManager.STATE_STOPPED || dm.getState() != DownloadManager.STATE_STOPPING) {
dm.addListener(new DownloadManagerListener() {
- public void completionChanged(DownloadManager manager, boolean completed) {
+ @Override
+ public void completionChanged(DownloadManager manager, boolean completed) {
}
- public void downloadComplete(DownloadManager manager) {
+ @Override
+ public void downloadComplete(DownloadManager manager) {
}
- public void filePriorityChanged(DownloadManager download, DiskManagerFileInfo file) {
+ @Override
+ public void filePriorityChanged(DownloadManager download, DiskManagerFileInfo file) {
}
- public void positionChanged(DownloadManager download, int oldPosition, int newPosition) {
+ @Override
+ public void positionChanged(DownloadManager download, int oldPosition, int newPosition) {
}
- public void stateChanged(final DownloadManager manager, int state) {
+ @Override
+ public void stateChanged(final DownloadManager manager, int state) {
if (state == DownloadManager.STATE_QUEUED) {
DownloadManagerStarter.startDownload(manager, new DownloadManagerStartListener() {
- public void downloadStarted() {
+ @Override
+ public void downloadStarted() {
if (started_with_public == false && inGroups.contains(GroupBean.PUBLIC) == true) {
logger.finer("public network added, forcing tracker update");
manager.getTrackerClient().update(true);
@@ -131,7 +131,7 @@ protected void distribute(String command) {
for (ExperimentInterface ei : experiments) {
for (String offer : ei.getKeys()) {
if (offer.equals(key)) {
- logger.info(key + " is executed by " + ei.getClass().getName());
+ logger.fine(key + " is executed by " + ei.getClass().getName());
ei.execute(command);
return;
}
@@ -605,6 +605,10 @@ private void sendMessage(RawMessage[] messages, int num) {
if (logger.isLoggable(Level.FINEST)) {
logger.finest("encrypting " + size + " bytes");
}
+ if (size > outgoingPacketBuf.length) {
+ logger.warning("Attempting to encrypt over-full packet of size " + size
+ + " bytes.");
+ }
// Encrypt the serialized payload into the payload buffer.
EncryptedPacket encrypted = encrypter.encrypt(unencryptedPayload, buffers,
outgoingPacketBuf);
@@ -5,6 +5,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.logging.Logger;
import org.gudy.azureus2.core3.util.DirectByteBuffer;
@@ -18,6 +19,7 @@
*
*/
public class MessageStreamMultiplexer {
+ public final static Logger logger = Logger.getLogger(MessageStreamMultiplexer.class.getName());
private Integer next;
private final short flow;
private final HashMap<Integer, ServiceChannelEndpoint> channels;
@@ -72,7 +74,7 @@ public void onAck(OSF2FServiceDataMsg message) {
}
}
for (Integer num : retransmissions) {
- System.out.println("Non outstanding packet acked: " + num);
+ logger.info("Non outstanding packet acked: " + num);
}
}
@@ -97,7 +99,10 @@ public boolean hasOutstanding(ServiceChannelEndpoint channel) {
Set<SequenceNumber> outstanding = channelOutstanding.get(channel.getChannelId());
HashMap<SequenceNumber, DirectByteBuffer> mapping = new HashMap<SequenceNumber, DirectByteBuffer>();
for (SequenceNumber s : outstanding) {
- mapping.put(s, channel.getMessage(s));
+ DirectByteBuffer msg = channel.getMessage(s);
+ if (msg != null) {
+ mapping.put(s, msg);
+ }
}
return mapping;
}
@@ -54,4 +54,9 @@ public void removeChannel(int channelId) {
public short getFlow() {
return flow;
}
+
+ @Override
+ public String toString() {
+ return "[message " + this.number + "." + this.flow + "]";
+ }
}
@@ -217,8 +217,7 @@ private void writeMessage(final SequenceNumber num, DirectByteBuffer buffer, int
long totalWritten = buffer.remaining(DirectByteBuffer.SS_MSG);
if (logger.isLoggable(Level.FINEST)) {
- logger.finest(String.format("Wrote msg to network. bytes: %d, sequence number: %d",
- length, num.getNum()));
+ logger.finest(String.format("Wrote %s to network. bytes: %d", num, length));
}
super.writeMessage(msg);
bytesOut += totalWritten;
@@ -244,7 +243,11 @@ public long getLatency() {
}
public DirectByteBuffer getMessage(SequenceNumber num) {
- return this.sentMessages.get(num).msg;
+ sentMessage m = this.sentMessages.get(num);
+ if (m != null) {
+ return m.msg;
+ }
+ return null;
}
/**
@@ -313,8 +316,7 @@ public void run() {
sentMessage self = sentMessages.remove(num);
if (self != null && !closed) {
if (self.attempt == attempt) {
- logger.fine("Message with sequence number " + num.getNum()
- + " was retransmitted.");
+ logger.fine(num + " was retransmitted.");
outstandingBytes -= length;
msg.position(ss, position);
writeMessage(num, msg, attempt + 1, datagram);

0 comments on commit 919a8aa

Please sign in to comment.