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 CreateManyClustersTest2 extends ExistingDatabaseTest {
26 final static int ROUNDS = Configuration.get().cachedClusterRounds;
27 final static int CLUSTERS = Configuration.get().cachedClusterCount;
29 private Throwable exception;
30 private Resource rootResource = null;
32 public void test() throws Exception {
34 Session session = getSession();
36 session.syncRequest(new WriteQuery(this) {
38 public void run(WriteGraph g) throws Throwable {
39 Layer0 b = Layer0.getInstance(g);
40 rootResource = g.newResource();
41 g.claim(g.getRootLibrary(), b.ConsistsOf, rootResource);
45 for(int j=0;j<ROUNDS;j++) {
47 session.syncRequest(new WriteRequest() {
50 public void perform(WriteGraph graph) throws DatabaseException {
54 Layer0 b = Layer0.getInstance(graph);
56 for(int i=0;i<CLUSTERS;i++) {
59 Resource newResource = graph.newResource();
60 graph.claim(rootResource, b.ConsistsOf, newResource);
64 } catch (Throwable t) {
74 if(exception != null) {
75 fail("Write transaction threw and exception (" + exception.getMessage() + ") which was not passed through ");