1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.tests.scalability;
14 import org.simantics.db.Resource;
15 import org.simantics.db.Session;
16 import org.simantics.db.WriteGraph;
17 import org.simantics.db.common.request.WriteRequest;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.db.testing.base.ExistingDatabaseTest;
20 import org.simantics.db.testing.common.WriteQuery;
21 import org.simantics.db.tests.common.Configuration;
22 import org.simantics.layer0.Layer0;
24 public class CreateManyClustersTest extends ExistingDatabaseTest {
26 final static int CLUSTERS = Configuration.get().cachedClusterCount;
28 private Throwable exception;
29 private Resource rootResource = null;
31 public void test() throws Exception {
33 Session session = getSession();
35 session.syncRequest(new WriteQuery(this) {
37 public void run(WriteGraph g) throws Throwable {
38 Layer0 b = Layer0.getInstance(g);
39 rootResource = g.newResource();
40 g.claim(g.getRootLibrary(), b.ConsistsOf, rootResource);
44 session.syncRequest(new WriteRequest() {
47 public void perform(WriteGraph graph) throws DatabaseException {
53 Layer0 b = Layer0.getInstance(graph);
55 for(int i=0;i<CLUSTERS;i++) {
58 Resource newResource = graph.newResource();
59 graph.claim(rootResource, b.ConsistsOf, newResource);
63 } catch (Throwable t) {
71 if(exception != null) {
72 exception.printStackTrace();
73 fail("Write transaction threw and exception (" + exception.getMessage() + ") which was not passed through ");