Madan Jampani
Committed by Gerrit Code Review

Minor fixes in DatabaseProxy

Change-Id: I2e1ac92a80f652acc324337383dba526e510f353
...@@ -45,7 +45,7 @@ public interface DatabaseProxy<K, V> { ...@@ -45,7 +45,7 @@ public interface DatabaseProxy<K, V> {
45 CompletableFuture<Map<String, Long>> counters(); 45 CompletableFuture<Map<String, Long>> counters();
46 46
47 /** 47 /**
48 - * 48 + * Returns the number of entries in map.
49 * @param mapName map name 49 * @param mapName map name
50 * @return A completable future to be completed with the result once complete. 50 * @return A completable future to be completed with the result once complete.
51 */ 51 */
......
...@@ -18,8 +18,6 @@ package org.onosproject.store.consistent.impl; ...@@ -18,8 +18,6 @@ package org.onosproject.store.consistent.impl;
18 18
19 import java.nio.ByteBuffer; 19 import java.nio.ByteBuffer;
20 20
21 -import org.apache.commons.lang3.tuple.ImmutablePair;
22 -import org.apache.commons.lang3.tuple.Pair;
23 import org.onlab.util.KryoNamespace; 21 import org.onlab.util.KryoNamespace;
24 import org.onosproject.cluster.NodeId; 22 import org.onosproject.cluster.NodeId;
25 import org.onosproject.store.serializers.KryoNamespaces; 23 import org.onosproject.store.serializers.KryoNamespaces;
...@@ -72,8 +70,6 @@ public class DatabaseSerializer extends SerializerConfig { ...@@ -72,8 +70,6 @@ public class DatabaseSerializer extends SerializerConfig {
72 .register(Versioned.class) 70 .register(Versioned.class)
73 .register(DatabaseUpdate.class) 71 .register(DatabaseUpdate.class)
74 .register(DatabaseUpdate.Type.class) 72 .register(DatabaseUpdate.Type.class)
75 - .register(Pair.class)
76 - .register(ImmutablePair.class)
77 .register(Result.class) 73 .register(Result.class)
78 .register(UpdateResult.class) 74 .register(UpdateResult.class)
79 .register(Result.Status.class) 75 .register(Result.Status.class)
......
...@@ -51,7 +51,7 @@ public interface DatabaseState<K, V> { ...@@ -51,7 +51,7 @@ public interface DatabaseState<K, V> {
51 Map<String, Long> counters(); 51 Map<String, Long> counters();
52 52
53 @Query 53 @Query
54 - int size(String mapName); 54 + int mapSize(String mapName);
55 55
56 @Query 56 @Query
57 boolean mapIsEmpty(String mapName); 57 boolean mapIsEmpty(String mapName);
......
...@@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicLong; ...@@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicLong;
27 import java.util.stream.Collectors; 27 import java.util.stream.Collectors;
28 import java.util.Set; 28 import java.util.Set;
29 29
30 -import org.apache.commons.lang3.tuple.Pair;
31 import org.onosproject.cluster.NodeId; 30 import org.onosproject.cluster.NodeId;
32 import org.onosproject.store.service.DatabaseUpdate; 31 import org.onosproject.store.service.DatabaseUpdate;
33 import org.onosproject.store.service.Transaction; 32 import org.onosproject.store.service.Transaction;
...@@ -112,7 +111,7 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> { ...@@ -112,7 +111,7 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> {
112 } 111 }
113 112
114 @Override 113 @Override
115 - public int size(String mapName) { 114 + public int mapSize(String mapName) {
116 return getMap(mapName).size(); 115 return getMap(mapName).size();
117 } 116 }
118 117
...@@ -186,7 +185,7 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> { ...@@ -186,7 +185,7 @@ public class DefaultDatabaseState implements DatabaseState<String, byte[]> {
186 return ImmutableSet.copyOf(getMap(mapName) 185 return ImmutableSet.copyOf(getMap(mapName)
187 .entrySet() 186 .entrySet()
188 .stream() 187 .stream()
189 - .map(entry -> Pair.of(entry.getKey(), entry.getValue())) 188 + .map(entry -> Maps.immutableEntry(entry.getKey(), entry.getValue()))
190 .collect(Collectors.toSet())); 189 .collect(Collectors.toSet()));
191 } 190 }
192 191
......
...@@ -22,8 +22,6 @@ import java.util.Collection; ...@@ -22,8 +22,6 @@ import java.util.Collection;
22 import java.util.concurrent.CompletableFuture; 22 import java.util.concurrent.CompletableFuture;
23 import java.util.stream.Collectors; 23 import java.util.stream.Collectors;
24 24
25 -import org.apache.commons.lang3.tuple.ImmutablePair;
26 -import org.apache.commons.lang3.tuple.Pair;
27 import org.onlab.util.KryoNamespace; 25 import org.onlab.util.KryoNamespace;
28 import org.onosproject.store.serializers.KryoNamespaces; 26 import org.onosproject.store.serializers.KryoNamespaces;
29 import org.onosproject.store.service.AsyncConsistentMap; 27 import org.onosproject.store.service.AsyncConsistentMap;
...@@ -47,8 +45,6 @@ public class TransactionManager { ...@@ -47,8 +45,6 @@ public class TransactionManager {
47 .register(DatabaseUpdate.Type.class) 45 .register(DatabaseUpdate.Type.class)
48 .register(DefaultTransaction.class) 46 .register(DefaultTransaction.class)
49 .register(Transaction.State.class) 47 .register(Transaction.State.class)
50 - .register(Pair.class)
51 - .register(ImmutablePair.class)
52 .build(); 48 .build();
53 49
54 private final Serializer serializer = Serializer.using(Arrays.asList(KRYO_NAMESPACE)); 50 private final Serializer serializer = Serializer.using(Arrays.asList(KRYO_NAMESPACE));
......
...@@ -18,6 +18,7 @@ package org.onosproject.store.serializers; ...@@ -18,6 +18,7 @@ package org.onosproject.store.serializers;
18 import com.google.common.collect.ImmutableList; 18 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.ImmutableMap; 19 import com.google.common.collect.ImmutableMap;
20 import com.google.common.collect.ImmutableSet; 20 import com.google.common.collect.ImmutableSet;
21 +import com.google.common.collect.Maps;
21 22
22 import org.onlab.packet.ChassisId; 23 import org.onlab.packet.ChassisId;
23 import org.onlab.packet.EthType; 24 import org.onlab.packet.EthType;
...@@ -222,6 +223,7 @@ public final class KryoNamespaces { ...@@ -222,6 +223,7 @@ public final class KryoNamespaces {
222 LinkedList.class, 223 LinkedList.class,
223 HashSet.class 224 HashSet.class
224 ) 225 )
226 + .register(Maps.immutableEntry("a", "b").getClass())
225 .register(new ArraysAsListSerializer(), Arrays.asList().getClass()) 227 .register(new ArraysAsListSerializer(), Arrays.asList().getClass())
226 .register(Collections.singletonList(1).getClass()) 228 .register(Collections.singletonList(1).getClass())
227 .register(Duration.class) 229 .register(Duration.class)
......