Make OSGiModuleInfoSnapshot generation unsigned 31/88131/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 28 Feb 2020 15:02:58 +0000 (16:02 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 28 Feb 2020 15:04:20 +0000 (16:04 +0100)
The intent is to have this an unsigned counter, expose it as such.

JIRA: MDSAL-392
Change-Id: I7d240933ae35288be0ba6a5f8a047587ab179803
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-runtime-osgi/src/main/java/org/opendaylight/mdsal/binding/runtime/osgi/impl/BindingRuntimeContextImpl.java
dom/mdsal-dom-schema-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/osgi/OSGiModuleInfoSnapshot.java
dom/mdsal-dom-schema-osgi/src/main/java/org/opendaylight/mdsal/dom/schema/osgi/impl/OSGiEffectiveModelImpl.java

index ddde76201cc0ff63cc75853efaec510e224caf61..f177833c099e17dfe7a22019125c61073642858b 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.mdsal.binding.runtime.osgi.impl;
 
+import com.google.common.primitives.UnsignedLong;
 import org.opendaylight.binding.runtime.api.AbstractBindingRuntimeContext;
 import org.opendaylight.binding.runtime.api.BindingRuntimeContext;
 import org.opendaylight.binding.runtime.api.BindingRuntimeGenerator;
@@ -33,8 +34,8 @@ public final class BindingRuntimeContextImpl extends AbstractBindingRuntimeConte
     @Reference
     BindingRuntimeGenerator generator = null;
 
-    private BindingRuntimeContext delegate = null;
-    private long generation;
+    private BindingRuntimeContext delegate;
+    private UnsignedLong generation;
 
     @Override
     public ClassLoadingStrategy getStrategy() {
index 8f16b23b274ba0f8c71dddf5119ffcadb77ef9d8..f68b197d554ed0b381a7f350f0471835c05c6244 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.mdsal.dom.schema.osgi;
 
 import com.google.common.annotations.Beta;
+import com.google.common.primitives.UnsignedLong;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.binding.runtime.api.ModuleInfoSnapshot;
 
 /**
@@ -16,5 +18,5 @@ import org.opendaylight.binding.runtime.api.ModuleInfoSnapshot;
 @Beta
 public interface OSGiModuleInfoSnapshot extends ModuleInfoSnapshot {
 
-    long getGeneration();
+    @NonNull UnsignedLong getGeneration();
 }
index 96b58a52d0706447df1612d63a5ab94a07a2059d..1608e5d032155f66213864501099e2652c1a6ef9 100644 (file)
@@ -12,6 +12,7 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Dictionary;
 import java.util.Hashtable;
@@ -45,10 +46,10 @@ public final class OSGiEffectiveModelImpl implements OSGiModuleInfoSnapshot {
     private static final Logger LOG = LoggerFactory.getLogger(OSGiEffectiveModelImpl.class);
 
     private ModuleInfoSnapshot delegate;
-    private long generation;
+    private UnsignedLong generation;
 
     @Override
-    public long getGeneration() {
+    public UnsignedLong getGeneration() {
         return generation;
     }
 
@@ -69,7 +70,7 @@ public final class OSGiEffectiveModelImpl implements OSGiModuleInfoSnapshot {
 
     @Activate
     void activate(final Map<String, ?> properties) {
-        generation = (Long) verifyNotNull(properties.get(GENERATION));
+        generation = (UnsignedLong) verifyNotNull(properties.get(GENERATION));
         delegate = (ModuleInfoSnapshot) verifyNotNull(properties.get(DELEGATE));
         LOG.debug("ClassLoadingEffectiveModelContext generation {} activated", generation);
     }
@@ -84,7 +85,7 @@ public final class OSGiEffectiveModelImpl implements OSGiModuleInfoSnapshot {
     static Dictionary<String, ?> props(final long generation, final ModuleInfoSnapshot delegate) {
         final Dictionary<String, Object> ret = new Hashtable<>(4);
         ret.put(Constants.SERVICE_RANKING, ranking(generation));
-        ret.put(GENERATION, generation);
+        ret.put(GENERATION, UnsignedLong.fromLongBits(generation));
         ret.put(DELEGATE, requireNonNull(delegate));
         return ret;
     }