Loosen Kryo config only for DistributedIntentStore
Change-Id: Ie3f05e2d894b0d44f7c0ad645b77c65d1f2ce02b
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/intent/impl/DistributedIntentStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/intent/impl/DistributedIntentStore.java
index 366ae3e..8c18fb0 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/intent/impl/DistributedIntentStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/intent/impl/DistributedIntentStore.java
@@ -30,6 +30,9 @@
import org.onlab.onos.net.intent.IntentStoreDelegate;
import org.onlab.onos.store.hz.AbstractHazelcastStore;
import org.onlab.onos.store.hz.SMap;
+import org.onlab.onos.store.serializers.KryoNamespaces;
+import org.onlab.onos.store.serializers.KryoSerializer;
+import org.onlab.util.KryoNamespace;
import org.slf4j.Logger;
import java.util.List;
@@ -61,9 +64,21 @@
@Activate
public void activate() {
// FIXME: We need a way to add serializer for intents which has been plugged-in.
- // TODO: As a short term workaround, relax Kryo config to
- // registrationRequired=false?
+ // As a short term workaround, relax Kryo config to
+ // registrationRequired=false
super.activate();
+ super.serializer = new KryoSerializer() {
+
+ @Override
+ protected void setupKryoPool() {
+ serializerPool = KryoNamespace.newBuilder()
+ .setRegistrationRequired(false)
+ .register(KryoNamespaces.API)
+ .build()
+ .populate(1);
+ }
+
+ };
// TODO: enable near cache, allow read from backup for this IMap
IMap<byte[], byte[]> rawIntents = super.theInstance.getMap("intents");
diff --git a/utils/misc/src/main/java/org/onlab/util/KryoNamespace.java b/utils/misc/src/main/java/org/onlab/util/KryoNamespace.java
index d44ed14..55368ad 100644
--- a/utils/misc/src/main/java/org/onlab/util/KryoNamespace.java
+++ b/utils/misc/src/main/java/org/onlab/util/KryoNamespace.java
@@ -56,6 +56,7 @@
public static final class Builder {
private final List<Pair<Class<?>, Serializer<?>>> types = new ArrayList<>();
+ private boolean registrationRequired = true;
/**
* Builds a {@link KryoNamespace} instance.
@@ -63,7 +64,7 @@
* @return KryoNamespace
*/
public KryoNamespace build() {
- return new KryoNamespace(types);
+ return new KryoNamespace(types, registrationRequired);
}
/**
@@ -101,6 +102,11 @@
types.addAll(pool.registeredTypes);
return this;
}
+
+ public Builder setRegistrationRequired(boolean registrationRequired) {
+ this.registrationRequired = registrationRequired;
+ return this;
+ }
}
/**
@@ -116,11 +122,11 @@
* Creates a Kryo instance pool.
*
* @param registeredTypes types to register
+ * @param registrationRequired
*/
- private KryoNamespace(final List<Pair<Class<?>, Serializer<?>>> registeredTypes) {
+ private KryoNamespace(final List<Pair<Class<?>, Serializer<?>>> registeredTypes, boolean registrationRequired) {
this.registeredTypes = ImmutableList.copyOf(registeredTypes);
- // always true for now
- this.registrationRequired = true;
+ this.registrationRequired = registrationRequired;
}
/**