1 package org.simantics.db.tests.api.support.clusterControl;
4 import org.simantics.db.AsyncReadGraph;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Session;
7 import org.simantics.db.common.procedure.adapter.AsyncProcedureAdapter;
8 import org.simantics.db.common.procedure.adapter.ListenerAdapter;
9 import org.simantics.db.exception.DatabaseException;
10 import org.simantics.db.procedure.AsyncProcedure;
11 import org.simantics.db.request.AsyncRead;
12 import org.simantics.db.request.Read;
13 import org.simantics.db.service.ClusterControl;
14 import org.simantics.db.testing.base.ExistingDatabaseTest;
15 import org.simantics.layer0.Layer0;
17 public class CachedDirectPredicatesWithNoCluster extends ExistingDatabaseTest {
20 public void test() throws DatabaseException {
22 Session session = getSession();
24 final Layer0 L0 = Layer0.getInstance(session);
26 session.syncRequest(new Read<Boolean>() {
29 public Boolean perform(ReadGraph graph) throws DatabaseException {
30 Layer0 L0 = Layer0.getInstance(graph);
31 return graph.hasStatement(L0.Entity);
34 }, new ListenerAdapter<Boolean>() {
36 public boolean isDisposed() {
41 ClusterControl support = getSession().getService(ClusterControl.class);
42 support.collectClusters(Integer.MAX_VALUE);
44 session.syncRequest(new AsyncRead<Boolean>() {
47 public void perform(AsyncReadGraph graph, AsyncProcedure<Boolean> procedure) {
48 graph.forHasStatement(L0.Entity, procedure);
52 public int threadHash() {
57 public int getFlags() {
61 }, new AsyncProcedureAdapter<Boolean>() {
64 public void execute(AsyncReadGraph graph, Boolean result) {
66 System.err.println("exec: " + result);
70 public void exception(AsyncReadGraph graph, Throwable t) {
72 System.err.println("exception: " + t);