X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.impl%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fimpl%2FClusterBase.java;h=1539732159980f95f294d9e9c2bcdaa2f0021dd2;hp=aa1db7d8bf405c76c39ba431985b16270930f4de;hb=ae2e31aa5eb35410e5b2ce222d42421154f3fecc;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterBase.java b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterBase.java index aa1db7d8b..153973215 100644 --- a/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterBase.java +++ b/bundles/org.simantics.db.impl/src/org/simantics/db/impl/ClusterBase.java @@ -1,138 +1,138 @@ -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(); - -} +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(); + +}