--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.db.tests.scalability;
+
+import org.simantics.db.Resource;
+import org.simantics.db.Session;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.testing.base.ExistingDatabaseTest;
+import org.simantics.db.testing.common.WriteQuery;
+import org.simantics.db.tests.common.Configuration;
+import org.simantics.layer0.Layer0;
+
+public class CreateManyClustersTest2 extends ExistingDatabaseTest {
+
+ final static int ROUNDS = Configuration.get().cachedClusterRounds;
+ final static int CLUSTERS = Configuration.get().cachedClusterCount;
+
+ private Throwable exception;
+ private Resource rootResource = null;
+
+ public void test() throws Exception {
+
+ Session session = getSession();
+
+ session.syncRequest(new WriteQuery(this) {
+ @Override
+ public void run(WriteGraph g) throws Throwable {
+ Layer0 b = Layer0.getInstance(g);
+ rootResource = g.newResource();
+ g.claim(g.getRootLibrary(), b.ConsistsOf, rootResource);
+ }
+ });
+
+ for(int j=0;j<ROUNDS;j++) {
+
+ session.syncRequest(new WriteRequest() {
+
+ @Override
+ public void perform(WriteGraph graph) throws DatabaseException {
+
+ try {
+
+ Layer0 b = Layer0.getInstance(graph);
+
+ for(int i=0;i<CLUSTERS;i++) {
+
+ graph.flushCluster();
+ Resource newResource = graph.newResource();
+ graph.claim(rootResource, b.ConsistsOf, newResource);
+
+ }
+
+ } catch (Throwable t) {
+ exception = t;
+ }
+
+ }
+
+ });
+
+ }
+
+ if(exception != null) {
+ fail("Write transaction threw and exception (" + exception.getMessage() + ") which was not passed through ");
+ }
+
+ }
+
+}