X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.procore%2Fsrc%2Ffi%2Fvtt%2Fsimantics%2Fprocore%2Finternal%2FClusterControlImpl.java;h=20de4f62b9e1735cf49ce1cd4b1b94857b183457;hp=2fc264870c0dfd1bfd3542ecc1fdf5f88bde0011;hb=cec265e1216a0a211e6e6dc4f91d5fda4c5747db;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterControlImpl.java b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterControlImpl.java index 2fc264870..20de4f62b 100644 --- a/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterControlImpl.java +++ b/bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterControlImpl.java @@ -1,72 +1,72 @@ -package fi.vtt.simantics.procore.internal; - -import java.util.HashSet; -import java.util.Set; - -import org.simantics.db.ReadGraph; -import org.simantics.db.service.ClusterCollectorPolicy; -import org.simantics.db.service.ClusterCollectorPolicy.CollectorCluster; -import org.simantics.db.service.ClusterControl; - -public class ClusterControlImpl implements ClusterControl { - - final private SessionImplSocket session; - - ClusterControlImpl(SessionImplSocket session) { - this.session = session; - } - - @Override - public ClusterCollectorPolicy setPolicy(ClusterCollectorPolicy newPolicy) { - return session.clusterTable.collector.setPolicy(newPolicy); - } - - @Override - public int flushClusters() { - session.clusterTable.gc(); - System.gc(); - System.gc(); - return session.clusterTable.size(); - } - - - @Override - public int collectClusters(int desiredBytes) { - session.clusterTable.collector.collect(desiredBytes); - return 0; - } - - @Override - public int gc(ReadGraph graph) { - session.clusterTable.collector.collect(); - return 0; - } - - @Override - public int gc(ReadGraph graph, int objectiveBytes) { - if(objectiveBytes < 0) return gc(graph); - if(objectiveBytes > used()) return 0; - session.clusterTable.collector.collect(used() - objectiveBytes); - return 0; - } - - static class ClusterStateImpl implements ClusterState { - public Set ids = new HashSet(); - } - - @Override - public ClusterState getClusterState() { - return session.clusterTable.getState(); - } - - @Override - public void restoreClusterState(ClusterState state) { - session.clusterTable.restoreState((ClusterStateImpl)state); - } - - @Override - public int used() { - return (int)session.clusterTable.getSizeInBytes(); - } - -} +package fi.vtt.simantics.procore.internal; + +import java.util.HashSet; +import java.util.Set; + +import org.simantics.db.ReadGraph; +import org.simantics.db.service.ClusterCollectorPolicy; +import org.simantics.db.service.ClusterCollectorPolicy.CollectorCluster; +import org.simantics.db.service.ClusterControl; + +public class ClusterControlImpl implements ClusterControl { + + final private SessionImplSocket session; + + ClusterControlImpl(SessionImplSocket session) { + this.session = session; + } + + @Override + public ClusterCollectorPolicy setPolicy(ClusterCollectorPolicy newPolicy) { + return session.clusterTable.collector.setPolicy(newPolicy); + } + + @Override + public int flushClusters() { + session.clusterTable.gc(); + System.gc(); + System.gc(); + return session.clusterTable.size(); + } + + + @Override + public int collectClusters(int desiredBytes) { + session.clusterTable.collector.collect(desiredBytes); + return 0; + } + + @Override + public int gc(ReadGraph graph) { + session.clusterTable.collector.collect(); + return 0; + } + + @Override + public int gc(ReadGraph graph, int objectiveBytes) { + if(objectiveBytes < 0) return gc(graph); + if(objectiveBytes > used()) return 0; + session.clusterTable.collector.collect(used() - objectiveBytes); + return 0; + } + + static class ClusterStateImpl implements ClusterState { + public Set ids = new HashSet(); + } + + @Override + public ClusterState getClusterState() { + return session.clusterTable.getState(); + } + + @Override + public void restoreClusterState(ClusterState state) { + session.clusterTable.restoreState((ClusterStateImpl)state); + } + + @Override + public int used() { + return (int)session.clusterTable.getSizeInBytes(); + } + +}