Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ISPN-2644 Create externalizer for SimpleClusteredVersion

  • Loading branch information...
commit 77b277df337bb1bbe24fa7058ce0942829cd011c 1 parent 202f93a
@anistor anistor authored galderz committed
View
37 core/src/main/java/org/infinispan/container/versioning/SimpleClusteredVersion.java
@@ -20,8 +20,14 @@
package org.infinispan.container.versioning;
import net.jcip.annotations.Immutable;
+import org.infinispan.marshall.AbstractExternalizer;
+import org.infinispan.marshall.Ids;
-import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Collections;
+import java.util.Set;
/**
* A simple versioning scheme that is cluster-aware
@@ -30,7 +36,7 @@
* @since 5.1
*/
@Immutable
-public class SimpleClusteredVersion implements IncrementableEntryVersion, Serializable {
+public class SimpleClusteredVersion implements IncrementableEntryVersion {
/**
* The cache topology id in which it was first created.
@@ -72,4 +78,31 @@ public String toString() {
", version=" + version +
'}';
}
+
+ public static class Externalizer extends AbstractExternalizer<SimpleClusteredVersion> {
+
+ @Override
+ public void writeObject(ObjectOutput output, SimpleClusteredVersion ch) throws IOException {
+ output.writeInt(ch.topologyId);
+ output.writeLong(ch.version);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public SimpleClusteredVersion readObject(ObjectInput unmarshaller) throws IOException, ClassNotFoundException {
+ int topologyId = unmarshaller.readInt();
+ long version = unmarshaller.readLong();
+ return new SimpleClusteredVersion(topologyId, version);
+ }
+
+ @Override
+ public Integer getId() {
+ return Ids.SIMPLE_CLUSTERED_VERSION;
+ }
+
+ @Override
+ public Set<Class<? extends SimpleClusteredVersion>> getTypeClasses() {
+ return Collections.<Class<? extends SimpleClusteredVersion>>singleton(SimpleClusteredVersion.class);
+ }
+ }
}
View
1  core/src/main/java/org/infinispan/marshall/Ids.java
@@ -123,4 +123,5 @@
int SYNC_CONSISTENT_HASH_FACTORY = 93;
int TOPOLOGY_AWARE_CONSISTENT_HASH_FACTORY = 94;
int TOPOLOGY_AWARE_SYNC_CONSISTENT_HASH_FACTORY = 95;
+ int SIMPLE_CLUSTERED_VERSION = 96;
}
View
2  core/src/main/java/org/infinispan/marshall/jboss/ExternalizerTable.java
@@ -51,6 +51,7 @@
import org.infinispan.container.entries.versioned.VersionedTransientCacheValue;
import org.infinispan.container.entries.versioned.VersionedTransientMortalCacheEntry;
import org.infinispan.container.entries.versioned.VersionedTransientMortalCacheValue;
+import org.infinispan.container.versioning.SimpleClusteredVersion;
import org.infinispan.context.Flag;
import org.infinispan.distribution.ch.DefaultConsistentHash;
import org.infinispan.distribution.ch.DefaultConsistentHashFactory;
@@ -266,6 +267,7 @@ private void loadInternalMarshallables() {
addInternalExternalizer(new TransientCacheValue.Externalizer());
addInternalExternalizer(new TransientMortalCacheValue.Externalizer());
+ addInternalExternalizer(new SimpleClusteredVersion.Externalizer());
addInternalExternalizer(new VersionedImmortalCacheEntry.Externalizer());
addInternalExternalizer(new VersionedMortalCacheEntry.Externalizer());
addInternalExternalizer(new VersionedTransientCacheEntry.Externalizer());
Please sign in to comment.
Something went wrong with that request. Please try again.