]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterBase.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / ClusterBase.java
index aa1db7d8bf405c76c39ba431985b16270930f4de..1539732159980f95f294d9e9c2bcdaa2f0021dd2 100644 (file)
-package org.simantics.db.impl;\r
-\r
-import java.util.UUID;\r
-\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.service.ClusterUID;\r
-import org.simantics.db.service.ClusteringSupport;\r
-import org.simantics.db.service.ClusteringSupport.Id;\r
-\r
-abstract public class ClusterBase implements ClusterI, TableSizeListener {\r
-    \r
-    protected static boolean DEBUG = false;\r
-    protected static boolean VERBOSE = false;\r
-    public static class IdImpl implements ClusteringSupport.Id {\r
-        private UUID id;\r
-        public IdImpl(UUID id) {\r
-            this.id = id;\r
-        }\r
-        @Override\r
-        public String toString() {\r
-            long[] longs = toLong();\r
-            return String.format("%x.%x", longs[0], longs[1]);\r
-        }\r
-        @Override\r
-        public boolean equals(Object o) {\r
-            if (null == o)\r
-                return false;\r
-            else if (this == o)\r
-                return true;\r
-            else if (o instanceof IdImpl)\r
-                return this.id.equals(((IdImpl)o).id);\r
-            else if (o instanceof Id) {\r
-                long[] self = toLong();\r
-                long[] other = ((Id)o).toLong();\r
-                if (self[0] != other[0])\r
-                    return false;\r
-                return self[1] == other[1];\r
-            } else\r
-                return false;\r
-        }\r
-        public long[] toLong() {\r
-            long[] longs = new long[2];\r
-            longs[0] = id.getMostSignificantBits();\r
-            longs[1] = id.getLeastSignificantBits();\r
-            return longs;\r
-        }\r
-    }\r
-    public final ClusterUID clusterUID; // unique identifier for this cluster with all servers, persistent\r
-    public final long clusterId; // unique identifier for this cluster with this server, persistent\r
-    public final int clusterKey; // unique identifier for this cluster with this process, transient\r
-//    private Id modifiedId;\r
-    protected long importance;\r
-\r
-    protected ClusterBase() {\r
-        this.clusterUID = null;\r
-        this.clusterId = 0;\r
-        this.clusterKey = 0;\r
-    }\r
-    \r
-    public ClusterBase(ClusterSupport support, ClusterUID clusterUID, int clusterKey) {\r
-        this.clusterUID = clusterUID;\r
-        this.clusterId = support.getClusterIdOrCreate(clusterUID);\r
-        this.clusterKey = 0 != clusterKey ? clusterKey : support.createClusterKeyByClusterUID(this.clusterUID, this.clusterId);\r
-//        this.modifiedId = new IdImpl(UUID.randomUUID()); // kraa666\r
-        if (DEBUG) {\r
-            System.out.println("DEBUG: Created cluster " + clusterUID + " id=" + clusterId + " key=" + clusterKey);\r
-            if (VERBOSE)\r
-                new Exception().printStackTrace();\r
-        }\r
-    }\r
-\r
-    final public int getClusterKey() {\r
-        return clusterKey;\r
-    }\r
-\r
-    final public long getClusterId() {\r
-        return clusterId;\r
-    }\r
-\r
-    @Override\r
-    final public long getImportance() {\r
-        return importance;\r
-    }\r
-\r
-    @Override\r
-    final public void setImportance(long importance) {\r
-        this.importance = importance;\r
-    }\r
-\r
-    @Override\r
-    public ClusterUID getClusterUID() {\r
-        return clusterUID;\r
-    }\r
-\r
-//    @Override\r
-//    public Id getModifiedId() {\r
-//        return modifiedId;\r
-//    }\r
-//\r
-//    public void setModifiedId(Id modifiedId) {\r
-//        this.modifiedId = modifiedId;\r
-//    }\r
-\r
-    public abstract ClusterBase toBig(ClusterSupport support) throws DatabaseException;\r
-    \r
-    public abstract void checkDirectReference(int dr) throws DatabaseException;\r
-\r
-    public abstract void checkForeingIndex(int fi) throws DatabaseException;\r
-\r
-    public abstract void checkObjectSetReference(int or) throws DatabaseException;\r
-\r
-    public abstract void checkValueInit() throws DatabaseException;\r
-\r
-    public abstract void checkCompleteSetReference(int cr) throws DatabaseException;\r
-\r
-    public abstract void checkPredicateIndex(int pi) throws DatabaseException;\r
-\r
-    public abstract void checkValue(int capacity, int index) throws DatabaseException;\r
-\r
-    public abstract void checkValueFini() throws DatabaseException;\r
-    \r
-    public abstract Table<?> getPredicateTable();\r
-\r
-    public abstract Table<?> getForeignTable();\r
-    \r
-    public abstract Table<?> getCompleteTable();\r
-\r
-    public abstract Table<?> getValueTable();\r
-\r
-    public abstract Table<?> getObjectTable();\r
-\r
-    public abstract int execute(int p1) throws DatabaseException;\r
-\r
-    public abstract int makeResourceKey(int pRef) throws DatabaseException;\r
-\r
-    public abstract IClusterTable getClusterTable();\r
-\r
-}\r
+package org.simantics.db.impl;
+
+import java.util.UUID;
+
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.ClusterUID;
+import org.simantics.db.service.ClusteringSupport;
+import org.simantics.db.service.ClusteringSupport.Id;
+
+abstract public class ClusterBase implements ClusterI, TableSizeListener {
+    
+    protected static boolean DEBUG = false;
+    protected static boolean VERBOSE = false;
+    public static class IdImpl implements ClusteringSupport.Id {
+        private UUID id;
+        public IdImpl(UUID id) {
+            this.id = id;
+        }
+        @Override
+        public String toString() {
+            long[] longs = toLong();
+            return String.format("%x.%x", longs[0], longs[1]);
+        }
+        @Override
+        public boolean equals(Object o) {
+            if (null == o)
+                return false;
+            else if (this == o)
+                return true;
+            else if (o instanceof IdImpl)
+                return this.id.equals(((IdImpl)o).id);
+            else if (o instanceof Id) {
+                long[] self = toLong();
+                long[] other = ((Id)o).toLong();
+                if (self[0] != other[0])
+                    return false;
+                return self[1] == other[1];
+            } else
+                return false;
+        }
+        public long[] toLong() {
+            long[] longs = new long[2];
+            longs[0] = id.getMostSignificantBits();
+            longs[1] = id.getLeastSignificantBits();
+            return longs;
+        }
+    }
+    public final ClusterUID clusterUID; // unique identifier for this cluster with all servers, persistent
+    public final long clusterId; // unique identifier for this cluster with this server, persistent
+    public final int clusterKey; // unique identifier for this cluster with this process, transient
+//    private Id modifiedId;
+    protected long importance;
+
+    protected ClusterBase() {
+        this.clusterUID = null;
+        this.clusterId = 0;
+        this.clusterKey = 0;
+    }
+    
+    public ClusterBase(ClusterSupport support, ClusterUID clusterUID, int clusterKey) {
+        this.clusterUID = clusterUID;
+        this.clusterId = support.getClusterIdOrCreate(clusterUID);
+        this.clusterKey = 0 != clusterKey ? clusterKey : support.createClusterKeyByClusterUID(this.clusterUID, this.clusterId);
+//        this.modifiedId = new IdImpl(UUID.randomUUID()); // kraa666
+        if (DEBUG) {
+            System.out.println("DEBUG: Created cluster " + clusterUID + " id=" + clusterId + " key=" + clusterKey);
+            if (VERBOSE)
+                new Exception().printStackTrace();
+        }
+    }
+
+    final public int getClusterKey() {
+        return clusterKey;
+    }
+
+    final public long getClusterId() {
+        return clusterId;
+    }
+
+    @Override
+    final public long getImportance() {
+        return importance;
+    }
+
+    @Override
+    final public void setImportance(long importance) {
+        this.importance = importance;
+    }
+
+    @Override
+    public ClusterUID getClusterUID() {
+        return clusterUID;
+    }
+
+//    @Override
+//    public Id getModifiedId() {
+//        return modifiedId;
+//    }
+//
+//    public void setModifiedId(Id modifiedId) {
+//        this.modifiedId = modifiedId;
+//    }
+
+    public abstract ClusterBase toBig(ClusterSupport support) throws DatabaseException;
+    
+    public abstract void checkDirectReference(int dr) throws DatabaseException;
+
+    public abstract void checkForeingIndex(int fi) throws DatabaseException;
+
+    public abstract void checkObjectSetReference(int or) throws DatabaseException;
+
+    public abstract void checkValueInit() throws DatabaseException;
+
+    public abstract void checkCompleteSetReference(int cr) throws DatabaseException;
+
+    public abstract void checkPredicateIndex(int pi) throws DatabaseException;
+
+    public abstract void checkValue(int capacity, int index) throws DatabaseException;
+
+    public abstract void checkValueFini() throws DatabaseException;
+    
+    public abstract Table<?> getPredicateTable();
+
+    public abstract Table<?> getForeignTable();
+    
+    public abstract Table<?> getCompleteTable();
+
+    public abstract Table<?> getValueTable();
+
+    public abstract Table<?> getObjectTable();
+
+    public abstract int execute(int p1) throws DatabaseException;
+
+    public abstract int makeResourceKey(int pRef) throws DatabaseException;
+
+    public abstract IClusterTable getClusterTable();
+
+}