Yuta HIGUCHI

Rename KryoPool -> KryoNamespace

Change-Id: Ife1c311b40eaab133bb3b8dd3314b98c60b4411d
Showing 18 changed files with 59 additions and 59 deletions
......@@ -23,10 +23,10 @@ import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
import org.onlab.onos.store.cluster.messaging.ClusterMessageResponse;
import org.onlab.onos.store.cluster.messaging.MessageSubject;
import org.onlab.onos.store.serializers.ClusterMessageSerializer;
import org.onlab.onos.store.serializers.KryoPoolUtil;
import org.onlab.onos.store.serializers.KryoNamespaces;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.onos.store.serializers.MessageSubjectSerializer;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import org.onlab.netty.Endpoint;
import org.onlab.netty.Message;
import org.onlab.netty.MessageHandler;
......@@ -52,8 +52,8 @@ public class ClusterCommunicationManager
private static final KryoSerializer SERIALIZER = new KryoSerializer() {
@Override
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
.register(KryoPoolUtil.API)
serializerPool = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(ClusterMessage.class, new ClusterMessageSerializer())
.register(ClusterMembershipEvent.class)
.register(byte[].class)
......
......@@ -42,7 +42,7 @@ import org.onlab.onos.store.impl.Timestamped;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.onos.store.serializers.DistributedStoreSerializers;
import org.onlab.packet.ChassisId;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import org.onlab.util.NewConcurrentHashMap;
import org.slf4j.Logger;
......@@ -117,7 +117,7 @@ public class GossipDeviceStore
protected static final KryoSerializer SERIALIZER = new KryoSerializer() {
@Override
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
serializerPool = KryoNamespace.newBuilder()
.register(DistributedStoreSerializers.COMMON)
.register(InternalDeviceEvent.class, new InternalDeviceEventSerializer())
......
......@@ -35,7 +35,7 @@ import org.onlab.onos.store.flow.ReplicaInfo;
import org.onlab.onos.store.flow.ReplicaInfoService;
import org.onlab.onos.store.serializers.DistributedStoreSerializers;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import org.slf4j.Logger;
import com.google.common.collect.ArrayListMultimap;
......@@ -72,7 +72,7 @@ public class DistributedFlowRuleStore
protected static final KryoSerializer SERIALIZER = new KryoSerializer() {
@Override
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
serializerPool = KryoNamespace.newBuilder()
.register(DistributedStoreSerializers.COMMON)
.build()
.populate(1);
......
......@@ -44,7 +44,7 @@ import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import org.slf4j.Logger;
import java.io.IOException;
......@@ -99,7 +99,7 @@ public class GossipHostStore
private static final KryoSerializer SERIALIZER = new KryoSerializer() {
@Override
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
serializerPool = KryoNamespace.newBuilder()
.register(DistributedStoreSerializers.COMMON)
.register(InternalHostEvent.class)
.register(InternalHostRemovedEvent.class)
......
......@@ -42,7 +42,7 @@ import org.onlab.onos.store.cluster.messaging.MessageSubject;
import org.onlab.onos.store.impl.Timestamped;
import org.onlab.onos.store.serializers.DistributedStoreSerializers;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import org.slf4j.Logger;
import java.io.IOException;
......@@ -110,7 +110,7 @@ public class GossipLinkStore
private static final KryoSerializer SERIALIZER = new KryoSerializer() {
@Override
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
serializerPool = KryoNamespace.newBuilder()
.register(DistributedStoreSerializers.COMMON)
.register(InternalLinkEvent.class)
.register(InternalLinkRemovedEvent.class)
......
......@@ -3,15 +3,15 @@ package org.onlab.onos.store.serializers;
import org.onlab.onos.store.impl.MastershipBasedTimestamp;
import org.onlab.onos.store.impl.Timestamped;
import org.onlab.onos.store.impl.WallClockTimestamp;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
public final class DistributedStoreSerializers {
/**
* KryoPool which can serialize ON.lab misc classes.
* KryoNamespace which can serialize ON.lab misc classes.
*/
public static final KryoPool COMMON = KryoPool.newBuilder()
.register(KryoPoolUtil.API)
public static final KryoNamespace COMMON = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(Timestamped.class)
.register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
.register(WallClockTimestamp.class)
......
......@@ -7,7 +7,7 @@ import java.nio.ByteBuffer;
import org.junit.Test;
import org.onlab.onos.store.Timestamp;
import org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import com.google.common.testing.EqualsTester;
......@@ -63,7 +63,7 @@ public class MastershipBasedTimestampTest {
@Test
public final void testKryoSerializable() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoPool kryos = KryoPool.newBuilder()
final KryoNamespace kryos = KryoNamespace.newBuilder()
.register(MastershipBasedTimestamp.class)
.build();
......@@ -79,7 +79,7 @@ public class MastershipBasedTimestampTest {
@Test
public final void testKryoSerializableWithHandcraftedSerializer() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoPool kryos = KryoPool.newBuilder()
final KryoNamespace kryos = KryoNamespace.newBuilder()
.register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer())
.build();
......
......@@ -6,7 +6,7 @@ import java.nio.ByteBuffer;
import org.junit.Test;
import org.onlab.onos.store.Timestamp;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import com.google.common.testing.EqualsTester;
......@@ -77,7 +77,7 @@ public class TimestampedTest {
@Test
public final void testKryoSerializable() {
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoPool kryos = KryoPool.newBuilder()
final KryoNamespace kryos = KryoNamespace.newBuilder()
.register(Timestamped.class,
MastershipBasedTimestamp.class)
.build();
......
......@@ -6,7 +6,7 @@ import java.nio.ByteBuffer;
import org.junit.Test;
import org.onlab.onos.store.Timestamp;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import com.google.common.testing.EqualsTester;
......@@ -30,7 +30,7 @@ public class WallClockTimestampTest {
public final void testKryoSerializable() {
WallClockTimestamp ts1 = new WallClockTimestamp();
final ByteBuffer buffer = ByteBuffer.allocate(1 * 1024 * 1024);
final KryoPool kryos = KryoPool.newBuilder()
final KryoNamespace kryos = KryoNamespace.newBuilder()
.register(WallClockTimestamp.class)
.build();
......
......@@ -24,9 +24,9 @@ import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
import org.onlab.onos.store.common.AbstractHazelcastStore;
import org.onlab.onos.store.common.SMap;
import org.onlab.onos.store.serializers.KryoPoolUtil;
import org.onlab.onos.store.serializers.KryoNamespaces;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import com.google.common.collect.ImmutableSet;
import com.hazelcast.core.EntryEvent;
......@@ -69,8 +69,8 @@ implements MastershipStore {
this.serializer = new KryoSerializer() {
@Override
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
.register(KryoPoolUtil.API)
serializerPool = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(RoleValue.class, new RoleValueSerializer())
.build()
......
package org.onlab.onos.store.serializers;
import org.onlab.util.KryoPool.FamilySerializer;
import org.onlab.util.KryoNamespace.FamilySerializer;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
......
......@@ -4,7 +4,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.onlab.util.KryoPool.FamilySerializer;
import org.onlab.util.KryoNamespace.FamilySerializer;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
......
......@@ -3,7 +3,7 @@ package org.onlab.onos.store.serializers;
import java.util.ArrayList;
import java.util.List;
import org.onlab.util.KryoPool.FamilySerializer;
import org.onlab.util.KryoNamespace.FamilySerializer;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
......
......@@ -36,18 +36,18 @@ import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
public final class KryoPoolUtil {
public final class KryoNamespaces {
/**
* KryoPool which can serialize ON.lab misc classes.
* KryoNamespace which can serialize ON.lab misc classes.
*/
public static final KryoPool MISC = KryoPool.newBuilder()
public static final KryoNamespace MISC = KryoNamespace.newBuilder()
.register(IpPrefix.class, new IpPrefixSerializer())
.register(IpAddress.class, new IpAddressSerializer())
.register(MacAddress.class, new MacAddressSerializer())
......@@ -56,9 +56,9 @@ public final class KryoPoolUtil {
// TODO: Populate other classes
/**
* KryoPool which can serialize API bundle classes.
* KryoNamespace which can serialize API bundle classes.
*/
public static final KryoPool API = KryoPool.newBuilder()
public static final KryoNamespace API = KryoNamespace.newBuilder()
.register(MISC)
.register(ImmutableMap.class, new ImmutableMapSerializer())
.register(ImmutableList.class, new ImmutableListSerializer())
......@@ -104,5 +104,5 @@ public final class KryoPoolUtil {
// not to be instantiated
private KryoPoolUtil() {}
private KryoNamespaces() {}
}
......
package org.onlab.onos.store.serializers;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import java.nio.ByteBuffer;
/**
......@@ -8,7 +8,7 @@ import java.nio.ByteBuffer;
*/
public class KryoSerializer implements StoreSerializer {
protected KryoPool serializerPool;
protected KryoNamespace serializerPool;
public KryoSerializer() {
setupKryoPool();
......@@ -18,8 +18,8 @@ public class KryoSerializer implements StoreSerializer {
* Sets up the common serialzers pool.
*/
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
.register(KryoPoolUtil.API)
serializerPool = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.build()
.populate(1);
}
......
......@@ -30,7 +30,7 @@ import org.onlab.packet.ChassisId;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
......@@ -76,8 +76,8 @@ public class KryoSerializerTest {
@Override
protected void setupKryoPool() {
serializerPool = KryoPool.newBuilder()
.register(KryoPoolUtil.API)
serializerPool = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.build()
.populate(1);
}
......
......@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableList;
* Pool of Kryo instances, with classes pre-registered.
*/
//@ThreadSafe
public final class KryoPool {
public final class KryoNamespace {
/**
* Default buffer size used for serialization.
......@@ -34,7 +34,7 @@ public final class KryoPool {
private final boolean registrationRequired;
/**
* KryoPool builder.
* KryoNamespace builder.
*/
//@NotThreadSafe
public static final class Builder {
......@@ -42,12 +42,12 @@ public final class KryoPool {
private final List<Pair<Class<?>, Serializer<?>>> types = new ArrayList<>();
/**
* Builds a {@link KryoPool} instance.
* Builds a {@link KryoNamespace} instance.
*
* @return KryoPool
* @return KryoNamespace
*/
public KryoPool build() {
return new KryoPool(types);
public KryoNamespace build() {
return new KryoNamespace(types);
}
/**
......@@ -76,19 +76,19 @@ public final class KryoPool {
}
/**
* Registers all the class registered to given KryoPool.
* Registers all the class registered to given KryoNamespace.
*
* @param pool KryoPool
* @param pool KryoNamespace
* @return this
*/
public Builder register(final KryoPool pool) {
public Builder register(final KryoNamespace pool) {
types.addAll(pool.registeredTypes);
return this;
}
}
/**
* Creates a new {@link KryoPool} builder.
* Creates a new {@link KryoNamespace} builder.
*
* @return builder
*/
......@@ -101,7 +101,7 @@ public final class KryoPool {
*
* @param registerdTypes types to register
*/
private KryoPool(final List<Pair<Class<?>, Serializer<?>>> registerdTypes) {
private KryoNamespace(final List<Pair<Class<?>, Serializer<?>>> registerdTypes) {
this.registeredTypes = ImmutableList.copyOf(registerdTypes);
// always true for now
this.registrationRequired = true;
......@@ -113,7 +113,7 @@ public final class KryoPool {
* @param instances to add to the pool
* @return this
*/
public KryoPool populate(int instances) {
public KryoNamespace populate(int instances) {
List<Kryo> kryos = new ArrayList<>(instances);
for (int i = 0; i < instances; ++i) {
kryos.add(newKryoInstance());
......
package org.onlab.netty;
import org.onlab.util.KryoPool;
import org.onlab.util.KryoNamespace;
import java.nio.ByteBuffer;
import java.util.ArrayList;
......@@ -12,7 +12,7 @@ import java.util.HashMap;
*/
public class KryoSerializer {
private KryoPool serializerPool;
private KryoNamespace serializerPool;
public KryoSerializer() {
setupKryoPool();
......@@ -23,7 +23,7 @@ public class KryoSerializer {
*/
protected void setupKryoPool() {
// FIXME Slice out types used in common to separate pool/namespace.
serializerPool = KryoPool.newBuilder()
serializerPool = KryoNamespace.newBuilder()
.register(ArrayList.class,
HashMap.class,
ArrayList.class,
......