Madan Jampani

1. MapDBLog log size calculation bug fix.

2. Minor logging improvements.
......@@ -2,6 +2,8 @@ package org.onlab.onos.store.service.impl;
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 class InternalWriteResult {
public WriteResult result() {
return result;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("status", status)
.add("result", result)
.toString();
}
}
......
......@@ -2,6 +2,7 @@ package org.onlab.onos.store.service.impl;
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.Serializer;
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 @@ import com.google.common.collect.Lists;
*/
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 @@ public class MapDBLog implements Log {
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();
}
});
......
......@@ -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.SocketChannel;
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 @@ public class NettyMessagingService implements MessagingService {
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());
......