-package fi.vtt.simantics.procore.internal;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.service.ClusterCollectorPolicy;\r
-import org.simantics.db.service.ClusterCollectorPolicy.CollectorCluster;\r
-import org.simantics.db.service.ClusterControl;\r
-\r
-public class ClusterControlImpl implements ClusterControl {\r
-\r
- final private SessionImplSocket session;\r
- \r
- ClusterControlImpl(SessionImplSocket session) {\r
- this.session = session;\r
- }\r
- \r
- @Override\r
- public ClusterCollectorPolicy setPolicy(ClusterCollectorPolicy newPolicy) {\r
- return session.clusterTable.collector.setPolicy(newPolicy);\r
- }\r
- \r
- @Override\r
- public int flushClusters() {\r
- session.clusterTable.gc();\r
- System.gc();\r
- System.gc();\r
- return session.clusterTable.size();\r
- }\r
-\r
-\r
- @Override\r
- public int collectClusters(int desiredBytes) {\r
- session.clusterTable.collector.collect(desiredBytes);\r
- return 0;\r
- }\r
-\r
- @Override\r
- public int gc(ReadGraph graph) {\r
- session.clusterTable.collector.collect();\r
- return 0;\r
- }\r
- \r
- @Override\r
- public int gc(ReadGraph graph, int objectiveBytes) {\r
- if(objectiveBytes < 0) return gc(graph);\r
- if(objectiveBytes > used()) return 0;\r
- session.clusterTable.collector.collect(used() - objectiveBytes);\r
- return 0;\r
- }\r
-\r
- static class ClusterStateImpl implements ClusterState {\r
- public Set<CollectorCluster> ids = new HashSet<CollectorCluster>();\r
- }\r
- \r
- @Override\r
- public ClusterState getClusterState() {\r
- return session.clusterTable.getState();\r
- }\r
- \r
- @Override\r
- public void restoreClusterState(ClusterState state) {\r
- session.clusterTable.restoreState((ClusterStateImpl)state);\r
- }\r
- \r
- @Override\r
- public int used() {\r
- return (int)session.clusterTable.getSizeInBytes();\r
- }\r
-\r
-}\r
+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<CollectorCluster> ids = new HashSet<CollectorCluster>();
+ }
+
+ @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();
+ }
+
+}