Madan Jampani

1. MapDBLog log size calculation bug fix.

2. Minor logging improvements.
...@@ -2,6 +2,8 @@ package org.onlab.onos.store.service.impl; ...@@ -2,6 +2,8 @@ package org.onlab.onos.store.service.impl;
2 2
3 import org.onlab.onos.store.service.WriteResult; 3 import org.onlab.onos.store.service.WriteResult;
4 4
5 +import com.google.common.base.MoreObjects;
6 +
5 /** 7 /**
6 * Result of a write operation executed on the DatabaseStateMachine. 8 * Result of a write operation executed on the DatabaseStateMachine.
7 */ 9 */
...@@ -34,4 +36,12 @@ public class InternalWriteResult { ...@@ -34,4 +36,12 @@ public class InternalWriteResult {
34 public WriteResult result() { 36 public WriteResult result() {
35 return result; 37 return result;
36 } 38 }
39 +
40 + @Override
41 + public String toString() {
42 + return MoreObjects.toStringHelper(getClass())
43 + .add("status", status)
44 + .add("result", result)
45 + .toString();
46 + }
37 } 47 }
......
...@@ -2,6 +2,7 @@ package org.onlab.onos.store.service.impl; ...@@ -2,6 +2,7 @@ package org.onlab.onos.store.service.impl;
2 2
3 import static com.google.common.base.Preconditions.checkArgument; 3 import static com.google.common.base.Preconditions.checkArgument;
4 import static com.google.common.base.Preconditions.checkState; 4 import static com.google.common.base.Preconditions.checkState;
5 +import static org.slf4j.LoggerFactory.getLogger;
5 6
6 import java.io.File; 7 import java.io.File;
7 import java.io.IOException; 8 import java.io.IOException;
...@@ -22,6 +23,7 @@ import org.mapdb.Serializer; ...@@ -22,6 +23,7 @@ import org.mapdb.Serializer;
22 import org.mapdb.TxBlock; 23 import org.mapdb.TxBlock;
23 import org.mapdb.TxMaker; 24 import org.mapdb.TxMaker;
24 import org.onlab.onos.store.serializers.StoreSerializer; 25 import org.onlab.onos.store.serializers.StoreSerializer;
26 +import org.slf4j.Logger;
25 27
26 import com.google.common.collect.Lists; 28 import com.google.common.collect.Lists;
27 29
...@@ -30,6 +32,8 @@ import com.google.common.collect.Lists; ...@@ -30,6 +32,8 @@ import com.google.common.collect.Lists;
30 */ 32 */
31 public class MapDBLog implements Log { 33 public class MapDBLog implements Log {
32 34
35 + private final Logger log = getLogger(getClass());
36 +
33 private final File dbFile; 37 private final File dbFile;
34 private TxMaker txMaker; 38 private TxMaker txMaker;
35 private final StoreSerializer serializer; 39 private final StoreSerializer serializer;
...@@ -273,7 +277,11 @@ public class MapDBLog implements Log { ...@@ -273,7 +277,11 @@ public class MapDBLog implements Log {
273 size.addAndGet(-1 * deletedBytes); 277 size.addAndGet(-1 * deletedBytes);
274 byte[] entryBytes = serializer.encode(entry); 278 byte[] entryBytes = serializer.encode(entry);
275 byte[] existingEntry = log.put(index, entryBytes); 279 byte[] existingEntry = log.put(index, entryBytes);
276 - size.addAndGet(entryBytes.length - existingEntry.length); 280 + if (existingEntry != null) {
281 + size.addAndGet(entryBytes.length - existingEntry.length);
282 + } else {
283 + size.addAndGet(entryBytes.length);
284 + }
277 db.compact(); 285 db.compact();
278 } 286 }
279 }); 287 });
......
...@@ -15,14 +15,6 @@ ...@@ -15,14 +15,6 @@
15 */ 15 */
16 package org.onlab.netty; 16 package org.onlab.netty;
17 17
18 -import java.io.IOException;
19 -import java.net.UnknownHostException;
20 -import java.util.concurrent.ConcurrentHashMap;
21 -import java.util.concurrent.ConcurrentMap;
22 -import java.util.concurrent.TimeUnit;
23 -import java.util.concurrent.TimeoutException;
24 -import java.util.concurrent.atomic.AtomicLong;
25 -
26 import io.netty.bootstrap.Bootstrap; 18 import io.netty.bootstrap.Bootstrap;
27 import io.netty.bootstrap.ServerBootstrap; 19 import io.netty.bootstrap.ServerBootstrap;
28 import io.netty.buffer.PooledByteBufAllocator; 20 import io.netty.buffer.PooledByteBufAllocator;
...@@ -44,6 +36,14 @@ import io.netty.channel.socket.SocketChannel; ...@@ -44,6 +36,14 @@ import io.netty.channel.socket.SocketChannel;
44 import io.netty.channel.socket.nio.NioServerSocketChannel; 36 import io.netty.channel.socket.nio.NioServerSocketChannel;
45 import io.netty.channel.socket.nio.NioSocketChannel; 37 import io.netty.channel.socket.nio.NioSocketChannel;
46 38
39 +import java.io.IOException;
40 +import java.net.UnknownHostException;
41 +import java.util.concurrent.ConcurrentHashMap;
42 +import java.util.concurrent.ConcurrentMap;
43 +import java.util.concurrent.TimeUnit;
44 +import java.util.concurrent.TimeoutException;
45 +import java.util.concurrent.atomic.AtomicLong;
46 +
47 import org.apache.commons.pool.KeyedPoolableObjectFactory; 47 import org.apache.commons.pool.KeyedPoolableObjectFactory;
48 import org.apache.commons.pool.impl.GenericKeyedObjectPool; 48 import org.apache.commons.pool.impl.GenericKeyedObjectPool;
49 import org.slf4j.Logger; 49 import org.slf4j.Logger;
...@@ -307,7 +307,8 @@ public class NettyMessagingService implements MessagingService { ...@@ -307,7 +307,8 @@ public class NettyMessagingService implements MessagingService {
307 futureResponse.set(message.payload()); 307 futureResponse.set(message.payload());
308 } else { 308 } else {
309 log.warn("Received a reply for message id:[{}]. " 309 log.warn("Received a reply for message id:[{}]. "
310 - + "But was unable to locate the request handle", message.id()); 310 + + " from {}. But was unable to locate the"
311 + + " request handle", message.id(), message.sender());
311 } 312 }
312 } finally { 313 } finally {
313 NettyMessagingService.this.responseFutures.invalidate(message.id()); 314 NettyMessagingService.this.responseFutures.invalidate(message.id());
......