1. MapDBLog log size calculation bug fix.
2. Minor logging improvements.
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalWriteResult.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalWriteResult.java
index ba714af..e936f48 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalWriteResult.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/InternalWriteResult.java
@@ -2,6 +2,8 @@
import org.onlab.onos.store.service.WriteResult;
+import com.google.common.base.MoreObjects;
+
/**
* Result of a write operation executed on the DatabaseStateMachine.
*/
@@ -34,4 +36,12 @@
public WriteResult result() {
return result;
}
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("status", status)
+ .add("result", result)
+ .toString();
+ }
}
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java
index 933e0ee..663e0f0 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/service/impl/MapDBLog.java
@@ -2,6 +2,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
+import static org.slf4j.LoggerFactory.getLogger;
import java.io.File;
import java.io.IOException;
@@ -22,6 +23,7 @@
import org.mapdb.TxBlock;
import org.mapdb.TxMaker;
import org.onlab.onos.store.serializers.StoreSerializer;
+import org.slf4j.Logger;
import com.google.common.collect.Lists;
@@ -30,6 +32,8 @@
*/
public class MapDBLog implements Log {
+ private final Logger log = getLogger(getClass());
+
private final File dbFile;
private TxMaker txMaker;
private final StoreSerializer serializer;
@@ -273,7 +277,11 @@
size.addAndGet(-1 * deletedBytes);
byte[] entryBytes = serializer.encode(entry);
byte[] existingEntry = log.put(index, entryBytes);
- size.addAndGet(entryBytes.length - existingEntry.length);
+ if (existingEntry != null) {
+ size.addAndGet(entryBytes.length - existingEntry.length);
+ } else {
+ size.addAndGet(entryBytes.length);
+ }
db.compact();
}
});
diff --git a/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java b/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
index 54b02de..4a71265 100644
--- a/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
+++ b/utils/netty/src/main/java/org/onlab/netty/NettyMessagingService.java
@@ -15,14 +15,6 @@
*/
package org.onlab.netty;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicLong;
-
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.PooledByteBufAllocator;
@@ -44,6 +36,14 @@
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicLong;
+
import org.apache.commons.pool.KeyedPoolableObjectFactory;
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.slf4j.Logger;
@@ -307,7 +307,8 @@
futureResponse.set(message.payload());
} else {
log.warn("Received a reply for message id:[{}]. "
- + "But was unable to locate the request handle", message.id());
+ + " from {}. But was unable to locate the"
+ + " request handle", message.id(), message.sender());
}
} finally {
NettyMessagingService.this.responseFutures.invalidate(message.id());