Mercurial > dive4elements > river
annotate flys-backend/src/main/java/de/intevation/flys/App.java @ 5779:ebec12def170
Datacage: Add a pool of builders to make it multi threadable.
XML DOM is not thread safe. Therefore the old implementation only allowed one thread
to use the builder at a time. As the complexity of the configuration
has increased over time this has become a bottleneck of the whole application
because it took quiet some time to build a result. Furthermore the builder code path
is visited very frequent. So many concurrent requests were piled up
resulting in long waits for the users.
To mitigate this problem a round robin pool of builders is used now.
Each of the pooled builders has an independent copy of the XML template
and can be run in parallel.
The number of builders is determined by the system property
'flys.datacage.pool.size'. It defaults to 4.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 21 Apr 2013 12:48:09 +0200 |
parents | 76c75c8b9ee0 |
children |
rev | line source |
---|---|
165
a69b8494fcac
Created a new empty maven project
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys; |
a69b8494fcac
Created a new empty maven project
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
1229
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
464
diff
changeset
|
3 import de.intevation.flys.backend.SessionFactoryProvider; |
3333
76c75c8b9ee0
SedDB: Make access to SedDB configurable over conf.xml and provide access to sessions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1229
diff
changeset
|
4 import de.intevation.flys.backend.FLYSCredentials; |
1229
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
464
diff
changeset
|
5 |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
6 import org.hibernate.cfg.Configuration; |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
7 |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
8 import org.hibernate.dialect.resolver.DialectFactory; |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
9 |
464
d37ccb04ab5d
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
199
diff
changeset
|
10 public class App |
165
a69b8494fcac
Created a new empty maven project
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 { |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
12 public static void dumpSchema(Configuration cfg) { |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
13 System.out.println("BEGIN;"); |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
14 |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
15 String [] setupScript = cfg.generateSchemaCreationScript( |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
16 DialectFactory.constructDialect( |
3333
76c75c8b9ee0
SedDB: Make access to SedDB configurable over conf.xml and provide access to sessions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1229
diff
changeset
|
17 FLYSCredentials.getDefault().getDialect())); |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
18 |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
19 for (String line: setupScript) { |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
20 System.out.println(line + ";"); |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
21 } |
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
22 |
174
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
23 System.out.println("COMMIT;"); |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
24 } |
249390dd24e7
Added foreign key constraint annotations to model classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
169
diff
changeset
|
25 |
1229
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
464
diff
changeset
|
26 public static void main(String [] args) { |
8b12b338a3f6
Re-enabled Hibernate schema dumps.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
464
diff
changeset
|
27 dumpSchema(SessionFactoryProvider.createConfiguration()); |
165
a69b8494fcac
Created a new empty maven project
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 } |
a69b8494fcac
Created a new empty maven project
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 } |
168
86a1bd9cc50e
More Hibernate/JPA stuff
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
165
diff
changeset
|
30 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |