Merge lp:~pbeaman/akiban-persistit/support-spring-framework into lp:akiban-persistit
- support-spring-framework
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Nathan Williams |
Approved revision: | 398 |
Merged at revision: | 395 |
Proposed branch: | lp:~pbeaman/akiban-persistit/support-spring-framework |
Merge into: | lp:akiban-persistit |
Diff against target: |
2533 lines (+867/-460) 45 files modified
examples/SpringFrameworkExample/Beans.xml (+48/-0) examples/SpringFrameworkExample/README.txt (+43/-0) examples/SpringFrameworkExample/SpringFrameworkDemo.java (+80/-0) examples/SpringFrameworkExample/build.xml (+56/-0) examples/SpringFrameworkExample/persistit.properties (+30/-0) pom.xml (+6/-0) src/main/java/com/persistit/CLI.java (+15/-7) src/main/java/com/persistit/Configuration.java (+137/-15) src/main/java/com/persistit/Persistit.java (+211/-250) src/test/java/com/persistit/AccumulatorRecoveryTest.java (+5/-7) src/test/java/com/persistit/BackupTaskTest.java (+6/-7) src/test/java/com/persistit/Bug1018526Test.java (+1/-2) src/test/java/com/persistit/Bug1064565Test.java (+3/-6) src/test/java/com/persistit/Bug1065677Test.java (+4/-5) src/test/java/com/persistit/Bug706132Test.java (+2/-1) src/test/java/com/persistit/Bug777918Test.java (+9/-20) src/test/java/com/persistit/Bug911849Test.java (+1/-3) src/test/java/com/persistit/Bug915594Test.java (+1/-3) src/test/java/com/persistit/Bug918909Test.java (+2/-5) src/test/java/com/persistit/Bug932097Test.java (+1/-3) src/test/java/com/persistit/Bug942669Test.java (+5/-8) src/test/java/com/persistit/Bug974589Test.java (+3/-6) src/test/java/com/persistit/Bug980292Test.java (+1/-3) src/test/java/com/persistit/ClassIndexTest.java (+1/-3) src/test/java/com/persistit/CommandLineTest.java (+3/-1) src/test/java/com/persistit/ConfigurationTest.java (+14/-1) src/test/java/com/persistit/CreateAndDeleteVolumeTest.java (+3/-8) src/test/java/com/persistit/IOFailureTest.java (+6/-2) src/test/java/com/persistit/IntegrityCheckTest.java (+3/-3) src/test/java/com/persistit/JournalManagerTest.java (+11/-19) src/test/java/com/persistit/PersistitUnitTestCase.java (+7/-7) src/test/java/com/persistit/RecoveryTest.java (+19/-35) src/test/java/com/persistit/StatisticsTaskTest.java (+5/-1) src/test/java/com/persistit/TreeTest2.java (+1/-3) src/test/java/com/persistit/VolumeTest.java (+1/-3) src/test/java/com/persistit/WarmupTest.java (+5/-7) src/test/java/com/persistit/stress/AbstractSuite.java (+1/-4) src/test/java/com/persistit/stress/InsertBigLoad.java (+1/-2) src/test/java/com/persistit/stress/PreloadMixtureTxn1.java (+1/-2) src/test/java/com/persistit/stress/unit/BigLoad.java (+2/-1) src/test/java/com/persistit/unit/BufferPoolMemConfigurationTest.java (+8/-4) src/test/java/com/persistit/unit/FileLockTest.java (+4/-2) src/test/java/com/persistit/unit/Log4JLoggerTest.java (+2/-1) src/test/java/com/persistit/unit/SpringFrameworkConfigurationTest.java (+65/-0) src/test/resources/com/persistit/unit/SpringFrameworkConfiguraitonTest.xml (+34/-0) |
To merge this branch: | bzr merge lp:~pbeaman/akiban-persistit/support-spring-framework |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nathan Williams | Approve | ||
Peter Beaman | Needs Resubmitting | ||
Review via email: mp+135208@code.launchpad.net |
Commit message
Description of the change
Adds infrastructure needed to support Spring Framework. With these changes it is possible without extraordinary effort to configure and initialize a Persistit instance within a Spring application.
Changes:
- new setters in Persistit
- new constructors in Persistit
- refactoring of the configuration and initialization code in Persistit
- changed behavior of initialize() - specifically the argument-less version
- new code in the Configuration class to allow a buffer pool configuration for multiple pools to be set by a simple string valued property.
- a new test that demonstrates the ability to inject an initialized Persistit instance
- a new example
- all uses of deprecated methods (initialize(
Normal applications using the original API are unaffected. However, a few tests in which the Configuration of a Persistit instance was read after the instance was closed were required to change since close() now removed the configuration from the instances.
Documentation changes will be done in a separate branch.
- 398. By Peter Beaman
-
Restore Persistit#
substitutePrope rties
Peter Beaman (pbeaman) wrote : | # |
There, it's back. TreeServiceImpl compiles once again.
Nathan Williams (nwilliams) wrote : | # |
A lot of shuffling but it all looks pretty straight forward.
Preview Diff
1 | === added directory 'examples/SpringFrameworkExample' |
2 | === added file 'examples/SpringFrameworkExample/Beans.xml' |
3 | --- examples/SpringFrameworkExample/Beans.xml 1970-01-01 00:00:00 +0000 |
4 | +++ examples/SpringFrameworkExample/Beans.xml 2012-11-21 16:34:24 +0000 |
5 | @@ -0,0 +1,48 @@ |
6 | +<!-- |
7 | + |
8 | + Copyright © 2011-2012 Akiban Technologies, Inc. All rights reserved. |
9 | + |
10 | + This program and the accompanying materials are made available |
11 | + under the terms of the Eclipse Public License v1.0 which |
12 | + accompanies this distribution, and is available at |
13 | + http://www.eclipse.org/legal/epl-v10.html |
14 | + |
15 | + This program may also be available under different license terms. |
16 | + For more information, see www.akiban.com or contact licensing@akiban.com. |
17 | + |
18 | + Contributors: |
19 | + Akiban Technologies, Inc. |
20 | + |
21 | +--> |
22 | +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
23 | + xsi:schemaLocation="http://www.springframework.org/schema/beans |
24 | + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> |
25 | + |
26 | + <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> |
27 | + <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_FALLBACK" /> |
28 | + <property name="location" value="classpath:persistit.properties" /> |
29 | + </bean> |
30 | + |
31 | + <bean id="persistit" class="com.persistit.Persistit" init-method="initialize"> |
32 | + <property name="configuration"> |
33 | + <bean class="com.persistit.Configuration"> |
34 | + <property name="bufferPoolConfiguration" value="8192,count=${buffer.count.8192}" /> |
35 | + <property name="volumeList"> |
36 | + <list> |
37 | + <bean class="com.persistit.VolumeSpecification"> |
38 | + <constructor-arg value="${volume.1}" /> |
39 | + </bean> |
40 | + </list> |
41 | + </property> |
42 | + <property name="journalPath" value="${journalpath}" /> |
43 | + </bean> |
44 | + </property> |
45 | + </bean> |
46 | + |
47 | + <bean id="testClient" class="SpringFrameworkDemo.TestClient"> |
48 | + <constructor-arg> |
49 | + <ref local="persistit" /> |
50 | + </constructor-arg> |
51 | + </bean> |
52 | + |
53 | +</beans> |
54 | \ No newline at end of file |
55 | |
56 | === added file 'examples/SpringFrameworkExample/README.txt' |
57 | --- examples/SpringFrameworkExample/README.txt 1970-01-01 00:00:00 +0000 |
58 | +++ examples/SpringFrameworkExample/README.txt 2012-11-21 16:34:24 +0000 |
59 | @@ -0,0 +1,43 @@ |
60 | +==== |
61 | + Copyright © 2011-2012 Akiban Technologies, Inc. All rights reserved. |
62 | + |
63 | + This program and the accompanying materials are made available |
64 | + under the terms of the Eclipse Public License v1.0 which |
65 | + accompanies this distribution, and is available at |
66 | + http://www.eclipse.org/legal/epl-v10.html |
67 | + |
68 | + This program may also be available under different license terms. |
69 | + For more information, see www.akiban.com or contact licensing@akiban.com. |
70 | + |
71 | + Contributors: |
72 | + Akiban Technologies, Inc. |
73 | +==== |
74 | + |
75 | + |
76 | +SpringFrameworkExample performs the following steps: |
77 | + |
78 | +- Initializes com.persistit.Persistit using Spring Framework. |
79 | +- Prints status message to indicate success. |
80 | + |
81 | + |
82 | +To build SpringFrameworkExample: |
83 | + |
84 | + Run Ant on build.xml in this directory (target "compile") |
85 | + |
86 | + - or - |
87 | + |
88 | + javac -classpath ../../target/akiban-persistit-3.2.2-jar-with-dependencies-and-tests.jar SpringFrameworkExample.java |
89 | + |
90 | +To run SimpleTransaction: |
91 | + |
92 | + Run Ant on build.xml in this directory (target "run") |
93 | + |
94 | + - or - |
95 | + |
96 | + java -classpath ../../target/akiban-persistit-3.2.2-jar-with-dependencies-and-tests.jar;. SpringFrameworkExample |
97 | + |
98 | +Persistit will place a volume file in paths specified by persistit.properties. |
99 | +You can change the location of these files by modifying the datapath property |
100 | +of this configuration file. |
101 | + |
102 | + |
103 | |
104 | === added file 'examples/SpringFrameworkExample/SpringFrameworkDemo.java' |
105 | --- examples/SpringFrameworkExample/SpringFrameworkDemo.java 1970-01-01 00:00:00 +0000 |
106 | +++ examples/SpringFrameworkExample/SpringFrameworkDemo.java 2012-11-21 16:34:24 +0000 |
107 | @@ -0,0 +1,80 @@ |
108 | +/** |
109 | + * Copyright © 2011-2012 Akiban Technologies, Inc. All rights reserved. |
110 | + * |
111 | + * This program and the accompanying materials are made available |
112 | + * under the terms of the Eclipse Public License v1.0 which |
113 | + * accompanies this distribution, and is available at |
114 | + * http://www.eclipse.org/legal/epl-v10.html |
115 | + * |
116 | + * This program may also be available under different license terms. |
117 | + * For more information, see www.akiban.com or contact licensing@akiban.com. |
118 | + * |
119 | + * Contributors: |
120 | + * Akiban Technologies, Inc. |
121 | + */ |
122 | + |
123 | +import com.persistit.Persistit; |
124 | +import com.persistit.Volume; |
125 | + |
126 | +import org.springframework.context.ApplicationContext; |
127 | +import org.springframework.context.support.ClassPathXmlApplicationContext; |
128 | + |
129 | + |
130 | +/** |
131 | + * Simple example using Spring Framework to configure and initialize a Persistit |
132 | + * instance. |
133 | + * |
134 | + */ |
135 | +public class SpringFrameworkDemo { |
136 | + |
137 | + /** |
138 | + * A "client" class that will receive a configured Persistit instance by |
139 | + * constructor injection. |
140 | + * |
141 | + * @author peter |
142 | + * |
143 | + */ |
144 | + public static class TestClient { |
145 | + final Persistit db; |
146 | + |
147 | + public TestClient(final Persistit db) { |
148 | + this.db = db; |
149 | + } |
150 | + |
151 | + private void test() { |
152 | + if (db == null) { |
153 | + System.out.println("Problem: no persistit bean was supplied"); |
154 | + return; |
155 | + } |
156 | + if (!db.isInitialized()) { |
157 | + System.out.println("Problem: persistit was not initialized"); |
158 | + return; |
159 | + } |
160 | + |
161 | + final Volume volume = db.getVolume("springdemo"); |
162 | + if (volume == null) { |
163 | + System.out.println("Problem: no volume named \"springdemo\" was created"); |
164 | + return; |
165 | + } |
166 | + |
167 | + System.out.println("Success: Persistit was initialized and injected into the TestClient class"); |
168 | + |
169 | + } |
170 | + } |
171 | + |
172 | + public static void main(final String[] args) throws Exception { |
173 | + ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml"); |
174 | + final Persistit db = (Persistit) context.getBean("persistit"); |
175 | + try { |
176 | + |
177 | + final TestClient testClient = (TestClient) context.getBean("testClient"); |
178 | + testClient.test(); |
179 | + |
180 | + } finally { |
181 | + if (db != null) { |
182 | + db.close(); |
183 | + } |
184 | + } |
185 | + } |
186 | + |
187 | +} |
188 | |
189 | === added file 'examples/SpringFrameworkExample/build.xml' |
190 | --- examples/SpringFrameworkExample/build.xml 1970-01-01 00:00:00 +0000 |
191 | +++ examples/SpringFrameworkExample/build.xml 2012-11-21 16:34:24 +0000 |
192 | @@ -0,0 +1,56 @@ |
193 | +<!-- |
194 | + |
195 | + Copyright © 2011-2012 Akiban Technologies, Inc. All rights reserved. |
196 | + |
197 | + This program and the accompanying materials are made available |
198 | + under the terms of the Eclipse Public License v1.0 which |
199 | + accompanies this distribution, and is available at |
200 | + http://www.eclipse.org/legal/epl-v10.html |
201 | + |
202 | + This program may also be available under different license terms. |
203 | + For more information, see www.akiban.com or contact licensing@akiban.com. |
204 | + |
205 | + Contributors: |
206 | + Akiban Technologies, Inc. |
207 | + |
208 | +--> |
209 | +<project name="SpringFrameworkDemo" default="run" basedir="."> |
210 | + <description> |
211 | + Build SpringFrameworkDemo.java |
212 | + </description> |
213 | + |
214 | + <target name="compile" description="compile the source "> |
215 | + <javac debug="true" srcdir="." destdir="."> |
216 | + <classpath> |
217 | + <fileset dir="../.."> |
218 | + <!-- Source location --> |
219 | + <filename name="target/akiban-persistit-*dependencies-and-tests.jar" /> |
220 | + </fileset> |
221 | + <pathelement location="." /> |
222 | + </classpath> |
223 | + </javac> |
224 | + </target> |
225 | + |
226 | + <target name="run" depends="compile"> |
227 | + <java classname="SpringFrameworkDemo" fork="true"> |
228 | + <classpath> |
229 | + <fileset dir="../.."> |
230 | + <!-- Source location --> |
231 | + <filename name="target/akiban-persistit-*dependencies-and-tests.jar" /> |
232 | + </fileset> |
233 | + <pathelement location="." /> |
234 | + </classpath> |
235 | + </java> |
236 | + </target> |
237 | + |
238 | + <target name="clean"> |
239 | + <delete> |
240 | + <fileset dir="."> |
241 | + <include name="*.class" /> |
242 | + <include name="txndemo*" /> |
243 | + </fileset> |
244 | + </delete> |
245 | + </target> |
246 | + |
247 | +</project> |
248 | + |
249 | |
250 | === added file 'examples/SpringFrameworkExample/persistit.properties' |
251 | --- examples/SpringFrameworkExample/persistit.properties 1970-01-01 00:00:00 +0000 |
252 | +++ examples/SpringFrameworkExample/persistit.properties 2012-11-21 16:34:24 +0000 |
253 | @@ -0,0 +1,30 @@ |
254 | +# |
255 | +# Copyright © 2011-2012 Akiban Technologies, Inc. All rights reserved. |
256 | +# |
257 | +# This program and the accompanying materials are made available |
258 | +# under the terms of the Eclipse Public License v1.0 which |
259 | +# accompanies this distribution, and is available at |
260 | +# http://www.eclipse.org/legal/epl-v10.html |
261 | +# |
262 | +# This program may also be available under different license terms. |
263 | +# For more information, see www.akiban.com or contact licensing@akiban.com. |
264 | +# |
265 | +# Contributors: |
266 | +# Akiban Technologies, Inc. |
267 | +# |
268 | + |
269 | +# |
270 | +# Change this property to locate the volume files |
271 | +# in a different directory: |
272 | +# |
273 | +datapath=. |
274 | + |
275 | +buffer.count.8192=512 |
276 | + |
277 | +logfile=${datapath}/springdemo.log |
278 | + |
279 | +volume.1=${datapath}/springdemo,create,pageSize:8192,\ |
280 | + initialPages:5,extensionPages:5,maximumPages:100000 |
281 | + |
282 | +journalpath=${datapath}/springdemo_journal |
283 | + |
284 | |
285 | === modified file 'pom.xml' |
286 | --- pom.xml 2012-11-09 20:03:01 +0000 |
287 | +++ pom.xml 2012-11-21 16:34:24 +0000 |
288 | @@ -80,6 +80,12 @@ |
289 | </exclusion> |
290 | </exclusions> |
291 | </dependency> |
292 | + <dependency> |
293 | + <groupId>org.springframework</groupId> |
294 | + <artifactId>spring-context</artifactId> |
295 | + <version>3.1.3.RELEASE</version> |
296 | + <scope>test</scope> |
297 | + </dependency> |
298 | </dependencies> |
299 | |
300 | <pluginRepositories> |
301 | |
302 | === modified file 'src/main/java/com/persistit/CLI.java' |
303 | --- src/main/java/com/persistit/CLI.java 2012-08-24 13:57:19 +0000 |
304 | +++ src/main/java/com/persistit/CLI.java 2012-11-21 16:34:24 +0000 |
305 | @@ -15,6 +15,13 @@ |
306 | |
307 | package com.persistit; |
308 | |
309 | +import static com.persistit.Configuration.APPEND_ONLY_PROPERTY_NAME; |
310 | +import static com.persistit.Configuration.BUFFERS_PROPERTY_NAME; |
311 | +import static com.persistit.Configuration.ENABLE_JMX_PROPERTY_NAME; |
312 | +import static com.persistit.Configuration.JOURNAL_PATH_PROPERTY_NAME; |
313 | +import static com.persistit.Configuration.RMI_REGISTRY_PORT_PROPERTY_NAME; |
314 | +import static com.persistit.Configuration.VOLUME_PROPERTY_PREFIX; |
315 | + |
316 | import java.io.BufferedOutputStream; |
317 | import java.io.BufferedReader; |
318 | import java.io.DataOutputStream; |
319 | @@ -703,7 +710,7 @@ |
320 | for (final Integer size : bufferSizes) { |
321 | final int alloc = (int) (size * 1.25); |
322 | final int count = (int) ((bpoolMemory / bufferSizes.size()) / alloc); |
323 | - properties.put(Persistit.BUFFERS_PROPERTY_NAME + size, Integer.toString(count)); |
324 | + properties.put(BUFFERS_PROPERTY_NAME + size, Integer.toString(count)); |
325 | } |
326 | int index = 0; |
327 | for (final VolumeSpecification vs : volumeSpecifications) { |
328 | @@ -711,23 +718,24 @@ |
329 | if (!y) { |
330 | value += ",readOnly"; |
331 | } |
332 | - properties.put(Persistit.VOLUME_PROPERTY_PREFIX + (++index), value); |
333 | + properties.put(VOLUME_PROPERTY_PREFIX + (++index), value); |
334 | } |
335 | if (jpath != null) { |
336 | - properties.put(Persistit.JOURNAL_PATH_PROPERTY_NAME, jpath); |
337 | + properties.put(JOURNAL_PATH_PROPERTY_NAME, jpath); |
338 | } |
339 | - properties.put(Persistit.APPEND_ONLY_PROPERTY, "true"); |
340 | + properties.put(APPEND_ONLY_PROPERTY_NAME, "true"); |
341 | |
342 | if (rmiport > 0) { |
343 | - properties.put(Persistit.RMI_REGISTRY_PORT, Integer.toString(rmiport)); |
344 | + properties.put(RMI_REGISTRY_PORT_PROPERTY_NAME, Integer.toString(rmiport)); |
345 | } |
346 | - properties.put(Persistit.JMX_PARAMS, "true"); |
347 | + properties.put(ENABLE_JMX_PROPERTY_NAME, "true"); |
348 | |
349 | final Persistit persistit = new Persistit(); |
350 | if (!y) { |
351 | persistit.getRecoveryManager().setRecoveryDisabledForTestMode(true); |
352 | } |
353 | - persistit.initialize(properties); |
354 | + persistit.setProperties(properties); |
355 | + persistit.initialize(); |
356 | |
357 | /** |
358 | * Following is a hack to figure ought whether there is a classIndex in |
359 | |
360 | === modified file 'src/main/java/com/persistit/Configuration.java' |
361 | --- src/main/java/com/persistit/Configuration.java 2012-10-23 19:08:32 +0000 |
362 | +++ src/main/java/com/persistit/Configuration.java 2012-11-21 16:34:24 +0000 |
363 | @@ -35,6 +35,8 @@ |
364 | import java.util.Properties; |
365 | import java.util.ResourceBundle; |
366 | import java.util.TreeMap; |
367 | +import java.util.regex.Matcher; |
368 | +import java.util.regex.Pattern; |
369 | |
370 | import com.persistit.Transaction.CommitPolicy; |
371 | import com.persistit.exception.CorruptJournalException; |
372 | @@ -411,6 +413,7 @@ |
373 | * the minimumCount to set |
374 | */ |
375 | public void setMinimumCount(final int minimumCount) { |
376 | + Util.rangeCheck(minimumCount, 0, BufferPool.MAXIMUM_POOL_COUNT); |
377 | this.minimumCount = minimumCount; |
378 | } |
379 | |
380 | @@ -426,6 +429,7 @@ |
381 | * the maximumCount to set |
382 | */ |
383 | public void setMaximumCount(final int maximumCount) { |
384 | + Util.rangeCheck(maximumCount, BufferPool.MINIMUM_POOL_COUNT, Integer.MAX_VALUE); |
385 | this.maximumCount = maximumCount; |
386 | } |
387 | |
388 | @@ -496,9 +500,21 @@ |
389 | * the fraction to set |
390 | */ |
391 | public void setFraction(final float fraction) { |
392 | + Util.rangeCheck(fraction, 0.0f, 1.0f); |
393 | this.fraction = fraction; |
394 | } |
395 | |
396 | + private final static String SIMPLE_COUNT_FORMAT = "count=%d"; |
397 | + private final static String MIN_MAX_COUNT_FORMAT = "minCount=%d,maxCount=%d"; |
398 | + private final static String MIN_MAX_MEMORY_FORMAT = "minMem=%s,maxMem=%s,reserved=%s,fraction=%s"; |
399 | + private final static Pattern SIMPLE_COUNT_PATTERN = Pattern.compile("count=([0-9]+[KMGT]?)", |
400 | + Pattern.CASE_INSENSITIVE); |
401 | + private final static Pattern MIN_MAX_COUNT_PATTERN = Pattern.compile( |
402 | + "minCount=([0-9KMGT]+),maxCount=([0-9KMGT]+)", Pattern.CASE_INSENSITIVE); |
403 | + private final static Pattern MIN_MAX_MEMORY_PATTERN = Pattern.compile( |
404 | + "minMem=([0-9]+[KMGT]?),maxMem=([0-9]+[KMGT]?),reserved=([0-9]+[KMGT]?),fraction=([0-9\\.]+)", |
405 | + Pattern.CASE_INSENSITIVE); |
406 | + |
407 | /** |
408 | * Compute the buffer count determined by the constraints of this |
409 | * <code>BufferPoolConfiguration</code> given the supplied |
410 | @@ -531,23 +547,60 @@ |
411 | |
412 | @Override |
413 | public String toString() { |
414 | - final StringBuilder sb = new StringBuilder("BufferPoolConfiguration("); |
415 | - sb.append(String.format("size=%d", bufferSize)); |
416 | + final StringBuilder sb = new StringBuilder(); |
417 | + sb.append(bufferSize).append(","); |
418 | if (minimumCount == maximumCount) { |
419 | - sb.append(String.format(",count=%d", minimumCount)); |
420 | + sb.append(String.format(SIMPLE_COUNT_FORMAT, minimumCount)); |
421 | } else if (minimumCount != 0 || maximumCount != Integer.MAX_VALUE) { |
422 | - sb.append(String.format(",minCount=%d,maxCount=%d", minimumCount, maximumCount)); |
423 | + sb.append(String.format(MIN_MAX_COUNT_FORMAT, minimumCount, maximumCount)); |
424 | } |
425 | if (minimumMemory != 0 || maximumMemory != Long.MAX_VALUE || reservedMemory != 0 || fraction != 1.0f) { |
426 | - sb.append(String.format(",minMem=%s,maxMem=%s,reserved=%s,fraction=%f", |
427 | - displayableLongValue(minimumMemory), displayableLongValue(maximumMemory), |
428 | - displayableLongValue(reservedMemory), fraction)); |
429 | + sb.append(String.format(MIN_MAX_MEMORY_FORMAT, displayableLongValue(minimumMemory), |
430 | + displayableLongValue(maximumMemory), displayableLongValue(reservedMemory), fraction)); |
431 | } |
432 | - sb.append(')'); |
433 | return sb.toString(); |
434 | } |
435 | |
436 | /** |
437 | + * Parse the String description generated by {@link #toString()}. The |
438 | + * string format is |
439 | + * |
440 | + * <code><pre> |
441 | + * bufferSize,propertyName=value,... |
442 | + * </pre><code> |
443 | + * |
444 | + * where propertyNames are <code>count</code>, <code>minCount</code>, |
445 | + * <code>maxCount</code>, <code>minMemory</code>, <code>maxMemory</code> |
446 | + * , <code>reserved</code> or <code>fraction</code> |
447 | + */ |
448 | + public void parse(final String string) { |
449 | + final String[] terms = string.split(",", 2); |
450 | + if (terms.length > 1) { |
451 | + checkBufferSize((int) parseLongProperty(string, terms[0]), string); |
452 | + Matcher matcher; |
453 | + matcher = SIMPLE_COUNT_PATTERN.matcher(terms[1]); |
454 | + if (matcher.matches()) { |
455 | + setCount((int) parseLongProperty(string, matcher.group(1))); |
456 | + return; |
457 | + } |
458 | + matcher = MIN_MAX_COUNT_PATTERN.matcher(terms[1]); |
459 | + if (matcher.matches()) { |
460 | + setMinimumCount((int) parseLongProperty(string, matcher.group(1))); |
461 | + setMaximumCount((int) parseLongProperty(string, matcher.group(2))); |
462 | + return; |
463 | + } |
464 | + matcher = MIN_MAX_MEMORY_PATTERN.matcher(terms[1]); |
465 | + if (matcher.matches()) { |
466 | + setMemoryConstraints(string, parseLongProperty(string, matcher.group(1)), |
467 | + parseLongProperty(string, matcher.group(2)), parseLongProperty(string, matcher.group(3)), |
468 | + parseFloatProperty(string, matcher.group(4))); |
469 | + return; |
470 | + } |
471 | + } |
472 | + throw new IllegalArgumentException("Invalid BufferPool memory specification: " + string); |
473 | + } |
474 | + |
475 | + /** |
476 | * Parse the supplied property value as an integer-valued buffer count. |
477 | * Both <code>minimumCount</code> and <code>maximumCount</code> are set |
478 | * to this value. The supplied property value must be a valid integer or |
479 | @@ -564,11 +617,9 @@ |
480 | * Integer |
481 | */ |
482 | public void parseBufferCount(final int bufferSize, final String propertyName, final String propertyValue) { |
483 | + checkBufferSize(bufferSize, propertyName); |
484 | reset(); |
485 | - final int count = (int) parseLongProperty(propertyName, propertyValue); |
486 | - Util.rangeCheck(count, BufferPool.MINIMUM_POOL_COUNT, BufferPool.MAXIMUM_POOL_COUNT); |
487 | - setMaximumCount(count); |
488 | - setMinimumCount(count); |
489 | + setCount((int) parseLongProperty(propertyName, propertyValue)); |
490 | } |
491 | |
492 | /** |
493 | @@ -594,6 +645,7 @@ |
494 | * @param propertyValue |
495 | */ |
496 | public void parseBufferMemory(final int bufferSize, final String propertyName, final String propertyValue) { |
497 | + checkBufferSize(bufferSize, propertyName); |
498 | reset(); |
499 | long minimum = 0; |
500 | long maximum = Long.MAX_VALUE; |
501 | @@ -614,10 +666,14 @@ |
502 | } |
503 | if (terms.length > 3 && !terms[3].isEmpty()) { |
504 | fraction = parseFloatProperty(propertyName, terms[3]); |
505 | + } |
506 | + setMemoryConstraints(propertyValue, minimum, maximum, reserved, fraction); |
507 | + } |
508 | + |
509 | + private void setMemoryConstraints(final String propertyValue, final long minimum, final long maximum, |
510 | + final long reserved, final float fraction) { |
511 | + if (minimum >= 0 && minimum <= maximum && maximum - minimum >= reserved && reserved >= 0) { |
512 | Util.rangeCheck(fraction, 0.0f, 1.0f); |
513 | - } |
514 | - |
515 | - if (minimum >= 0 && minimum <= maximum && maximum - minimum >= reserved && reserved >= 0) { |
516 | setMinimumMemory(minimum); |
517 | setMaximumMemory(maximum); |
518 | setReservedMemory(reserved); |
519 | @@ -627,7 +683,12 @@ |
520 | } else { |
521 | throw new IllegalArgumentException("Invalid BufferPool memory specification: " + propertyValue); |
522 | } |
523 | + } |
524 | |
525 | + private void checkBufferSize(final int size, final String s) { |
526 | + if (size != this.bufferSize) { |
527 | + throw new IllegalArgumentException("Buffer size " + size + " does not match " + s); |
528 | + } |
529 | } |
530 | |
531 | } |
532 | @@ -1226,6 +1287,53 @@ |
533 | } |
534 | |
535 | /** |
536 | + * Return a summary of the buffer configuration of all buffer pool sizes as |
537 | + * a string. For example, a value such as |
538 | + * |
539 | + * <code><pre> |
540 | + * 4096,count=1000;16384,minMemory=0,maxMemory=512G,reserved=1G,fraction=0.6 |
541 | + * </pre></code> |
542 | + * |
543 | + * @return describes two buffer pools, on with 4K buffers and the other with |
544 | + * 16K buffers. There the configuration specifies the smaller pool |
545 | + * by count, and the larger buffers by memory. |
546 | + */ |
547 | + public String getBufferPoolConfiguration() { |
548 | + final StringBuilder sb = new StringBuilder(); |
549 | + for (final BufferPoolConfiguration bpc : bufferPoolMap.values()) { |
550 | + if (bpc.getMaximumCount() > 0) { |
551 | + if (sb.length() > 0) { |
552 | + sb.append(";"); |
553 | + } |
554 | + sb.append(bpc); |
555 | + } |
556 | + } |
557 | + return sb.toString(); |
558 | + } |
559 | + |
560 | + /** |
561 | + * Parses and sets up the configuration of all buffer pools from the |
562 | + * supplied string. |
563 | + * |
564 | + * @param string |
565 | + */ |
566 | + public void setBufferPoolConfiguration(final String string) { |
567 | + for (final BufferPoolConfiguration bpc : bufferPoolMap.values()) { |
568 | + bpc.reset(); |
569 | + } |
570 | + for (final String s : string.split(";")) { |
571 | + try { |
572 | + final int bufferSize = Integer.parseInt(s.split(",")[0]); |
573 | + bufferPoolMap.get(bufferSize).parse(s); |
574 | + } catch (final NumberFormatException e) { |
575 | + throw new IllegalArgumentException("Invalid BufferPool memory specification: " + string); |
576 | + } catch (final ArrayIndexOutOfBoundsException e) { |
577 | + throw new IllegalArgumentException("Invalid BufferPool memory specification: " + string); |
578 | + } |
579 | + } |
580 | + } |
581 | + |
582 | + /** |
583 | * Return a List of <code>VolumeSpecification</code> instances for |
584 | * {@link Volume}s that Persistit should load or create during |
585 | * initialization. An application can add <code>VolumeSpecification</code> |
586 | @@ -1239,6 +1347,20 @@ |
587 | } |
588 | |
589 | /** |
590 | + * Copies the supplied {@link VolumeSpecification} elements to the volume |
591 | + * list after first clearing it. This method allows a list of |
592 | + * VolumeSpecifications to be injected as a property. |
593 | + * |
594 | + * @param list |
595 | + * List of VolumeSpecifications for volumes to be opened when the |
596 | + * {@link Persistit#initialize()} method is called |
597 | + */ |
598 | + public void setVolumeList(final List<VolumeSpecification> list) { |
599 | + volumeSpecifications.clear(); |
600 | + volumeSpecifications.addAll(list); |
601 | + } |
602 | + |
603 | + /** |
604 | * Return the value defined by {@link #setJournalPath} |
605 | * |
606 | * @return the journalPath |
607 | |
608 | === modified file 'src/main/java/com/persistit/Persistit.java' |
609 | --- src/main/java/com/persistit/Persistit.java 2012-10-26 19:44:17 +0000 |
610 | +++ src/main/java/com/persistit/Persistit.java 2012-11-21 16:34:24 +0000 |
611 | @@ -15,6 +15,9 @@ |
612 | |
613 | package com.persistit; |
614 | |
615 | +import static com.persistit.Configuration.DEFAULT_SYSTEM_VOLUME_NAME; |
616 | +import static com.persistit.Configuration.SYSTEM_PROPERTY_PREFIX; |
617 | +import static com.persistit.Configuration.SYSTEM_VOLUME_PROPERTY_NAME; |
618 | import static com.persistit.util.Util.NS_PER_S; |
619 | |
620 | import java.io.BufferedReader; |
621 | @@ -122,197 +125,8 @@ |
622 | * builds. |
623 | */ |
624 | public final static boolean BIG_ENDIAN = true; |
625 | - /** |
626 | - * Prefix used to form the a system property name. For example, the property |
627 | - * named <code>journalpath=xyz</code> can also be specified as a system |
628 | - * property on the command line with the option |
629 | - * -Dcom.persistit.journalpath=xyz. |
630 | - */ |
631 | - public final static String SYSTEM_PROPERTY_PREFIX = "com.persistit."; |
632 | - /** |
633 | - * Name of utility GUI class. |
634 | - */ |
635 | + |
636 | private final static String PERSISTIT_GUI_CLASS_NAME = SYSTEM_PROPERTY_PREFIX + "ui.AdminUI"; |
637 | - |
638 | - /** |
639 | - * Default suffix for properties file name |
640 | - */ |
641 | - public final static String DEFAULT_PROPERTIES_FILE_SUFFIX = ".properties"; |
642 | - /** |
643 | - * Default properties file name |
644 | - */ |
645 | - public final static String DEFAULT_CONFIG_FILE = "persistit.properties"; |
646 | - /** |
647 | - * Default maximum time (in milliseconds) to allow for successful completion |
648 | - * of an operation. |
649 | - */ |
650 | - static final long DEFAULT_TIMEOUT_VALUE = 30000; // Thirty seconds |
651 | - /** |
652 | - * Upper bound maximum time (in milliseconds) to allow for successful |
653 | - * completion of an operation. This is the maximum timeout value you can |
654 | - * specify for individual <code>Exchange</code>. |
655 | - */ |
656 | - static final long MAXIMUM_TIMEOUT_VALUE = 86400000; // One day |
657 | - /** |
658 | - * Property name by which name of properties file can be supplied. |
659 | - */ |
660 | - public final static String CONFIG_FILE_PROPERTY_NAME = "properties"; |
661 | - /** |
662 | - * Property name prefix for specifying buffer size and count. The full |
663 | - * property name should be one of "1024", "2048", "4096", "8192" or "16384" |
664 | - * appended to this string, e.g., "buffer.count.8192". |
665 | - */ |
666 | - public final static String BUFFERS_PROPERTY_NAME = "buffer.count."; |
667 | - /** |
668 | - * Property name prefix for specifying buffer memory allocation. The full |
669 | - * property name should be one of "1024", "2048", "4096", "8192" or "16384" |
670 | - * appended to this string, e.g., "buffer.memory.8192". This property is an |
671 | - * alternative to "buffer.count.nnnn", and only one of these may be used in |
672 | - * a configuration per buffer size. With the buffer.memory property |
673 | - * Persistit computes a buffer count that will consume approximately the |
674 | - * specified memory allocation, including overhead for FastIndex elements. |
675 | - */ |
676 | - public final static String BUFFER_MEM_PROPERTY_NAME = "buffer.memory."; |
677 | - /** |
678 | - * Property name prefix for specifying Volumes. The full property name |
679 | - * should be a unique ordinal number appended to this string, e.g., |
680 | - * "volume.1", "volume.2", etc. |
681 | - */ |
682 | - public final static String VOLUME_PROPERTY_PREFIX = "volume."; |
683 | - /** |
684 | - * Property name for specifying the file specification for the journal. |
685 | - */ |
686 | - public final static String JOURNAL_PATH_PROPERTY_NAME = "journalpath"; |
687 | - |
688 | - /** |
689 | - * Property name for specifying the size of each journal file, e.g., |
690 | - * "journalsize=400000000". |
691 | - */ |
692 | - public final static String JOURNAL_BLOCKSIZE_PROPERTY_NAME = "journalsize"; |
693 | - |
694 | - /** |
695 | - * Default path name for the journal. Note, sequence suffix in the form |
696 | - * .nnnnnnnnnnnnnnnn (16 digits, zero-filled) will be appended. |
697 | - */ |
698 | - public final static String DEFAULT_JOURNAL_PATH = "persistit_journal"; |
699 | - |
700 | - /** |
701 | - * Default System Volume Name |
702 | - */ |
703 | - public final static String DEFAULT_SYSTEM_VOLUME_NAME = "_system"; |
704 | - |
705 | - /** |
706 | - * Property name for specifying the system volume name |
707 | - */ |
708 | - public final static String SYSTEM_VOLUME_PROPERTY = "sysvolume"; |
709 | - |
710 | - /** |
711 | - * Property name for specifying default temporary volume page size |
712 | - */ |
713 | - public final static String TEMPORARY_VOLUME_PAGE_SIZE_NAME = "tvpagesize"; |
714 | - |
715 | - /** |
716 | - * Property name for specifying default temporary volume directory |
717 | - */ |
718 | - public final static String TEMPORARY_VOLUME_DIR_NAME = "tmpvoldir"; |
719 | - |
720 | - /** |
721 | - * Property name for specifying upper bound on temporary volume size |
722 | - */ |
723 | - public final static String TEMPORARY_VOLUME_MAX_SIZE = "tmpvolmaxsize"; |
724 | - |
725 | - /** |
726 | - * Property name for specifying the default {@link Transaction.CommitPolicy} |
727 | - * ("soft", "hard" or "group") |
728 | - */ |
729 | - public final static String TRANSACTION_COMMIT_POLICY_NAME = "txnpolicy"; |
730 | - |
731 | - /** |
732 | - * Property name for specifying whether Persistit should display diagnostic |
733 | - * messages. Property value must be "true" or "false". |
734 | - */ |
735 | - public final static String VERBOSE_PROPERTY = "verbose"; |
736 | - /** |
737 | - * Property name for specifying whether Persistit should retry read |
738 | - * operations that fail due to IOExceptions. |
739 | - */ |
740 | - public final static String READ_RETRY_PROPERTY = "readretry"; |
741 | - /** |
742 | - * Property name for maximum length of time a Persistit operation will wait |
743 | - * for I/O completion before throwing a TimeoutException. |
744 | - */ |
745 | - public final static String TIMEOUT_PROPERTY = "timeout"; |
746 | - |
747 | - /** |
748 | - * Property name to specify package and/or class names of classes that must |
749 | - * be serialized using standard Java serialization. |
750 | - */ |
751 | - public final static String SERIAL_OVERRIDE_PROPERTY = "serialOverride"; |
752 | - |
753 | - /** |
754 | - * Property name to specify whether DefaultValueCoder should use a declared |
755 | - * no-arg contructor within each class being deserialized. Unless specified |
756 | - * as <code>true</code>, Serializable classes will be instantiated through |
757 | - * platform-specific API calls. |
758 | - */ |
759 | - public final static String CONSTRUCTOR_OVERRIDE_PROPERTY = "constructorOverride"; |
760 | - |
761 | - /** |
762 | - * Property name for specifying whether Persistit should attempt to launch a |
763 | - * diagnostic utility for viewing internal state. |
764 | - */ |
765 | - public final static String SHOW_GUI_PROPERTY = "showgui"; |
766 | - |
767 | - /** |
768 | - * Property name for log switches |
769 | - */ |
770 | - public final static String LOGGING_PROPERTIES = "logging"; |
771 | - |
772 | - /** |
773 | - * Property name for log file name |
774 | - */ |
775 | - public final static String LOGFILE_PROPERTY = "logfile"; |
776 | - /** |
777 | - * Property name for the optional RMI registry host name |
778 | - */ |
779 | - public final static String RMI_REGISTRY_HOST_PROPERTY = "rmihost"; |
780 | - /** |
781 | - * Property name for the optional RMI registry port |
782 | - */ |
783 | - public final static String RMI_REGISTRY_PORT = "rmiport"; |
784 | - |
785 | - /** |
786 | - * Name of port on which RMI server accepts connects. If zero or unassigned, |
787 | - * RMI picks a random port. Specifying a port can be helpful when using SSH |
788 | - * to tunnel RMI to a server. |
789 | - */ |
790 | - public final static String RMI_SERVER_PORT = "rmiserverport"; |
791 | - |
792 | - /** |
793 | - * Property name for enabling Persistit Open MBean for JMX |
794 | - */ |
795 | - public final static String JMX_PARAMS = "jmx"; |
796 | - |
797 | - /** |
798 | - * Property name for pseudo-property "timestamp"; |
799 | - */ |
800 | - public final static String TIMESTAMP_PROPERTY = "timestamp"; |
801 | - |
802 | - /** |
803 | - * Property name for the "append only" property. |
804 | - */ |
805 | - public final static String APPEND_ONLY_PROPERTY = "appendonly"; |
806 | - |
807 | - /** |
808 | - * Property name to specify the default {@link SplitPolicy}. |
809 | - */ |
810 | - public final static String SPLIT_POLICY_PROPERTY = "splitpolicy"; |
811 | - |
812 | - /** |
813 | - * Property name to specify the default {@link JoinPolicy}. |
814 | - */ |
815 | - public final static String JOIN_POLICY_PROPERTY = "joinpolicy"; |
816 | - |
817 | /** |
818 | * Maximum number of Exchanges that will be held in an internal pool. |
819 | */ |
820 | @@ -471,13 +285,119 @@ |
821 | private final ThreadLocal<SoftReference<Value>> _valueThreadLocal = new ThreadLocal<SoftReference<Value>>(); |
822 | |
823 | /** |
824 | - * <p> |
825 | - * Initialize Persistit using properties supplied by the default properties |
826 | - * file. The name of this file is supplied by the system property |
827 | + * Construct a hollow Persistit instance. To be useful, the instance must |
828 | + * receive a <code>Configuration</code> through one of the methods |
829 | + * {@link #setConfiguration(Configuration)}, |
830 | + * {@link #setProperties(Properties)} or |
831 | + * {@link #setPropertiesFromFile(String)}. The instance must then be started |
832 | + * by the {@link #initialize()} method. |
833 | + */ |
834 | + public Persistit() { |
835 | + |
836 | + } |
837 | + |
838 | + /** |
839 | + * Construct a Persistit instance with the supplied |
840 | + * <code>Configuration</code> and then initialize it. The code <code><pre> |
841 | + * Persistit db = new Persistit(configuration); |
842 | + * </pre></code> is equivalent to <code><pre> |
843 | + * Persistit db = new Persistit(); |
844 | + * db.setConfiguration(configuration); |
845 | + * db.intialize(); |
846 | + * </pre></code> |
847 | + * |
848 | + * @see #setConfiguration(Configuration) |
849 | + * @param configuration |
850 | + * the Configuration |
851 | + */ |
852 | + public Persistit(final Configuration configuration) throws PersistitException { |
853 | + setConfiguration(configuration); |
854 | + initialize(); |
855 | + } |
856 | + |
857 | + /** |
858 | + * Construct a Persistit instance with a <code>Configuration</code> derived |
859 | + * from the supplied <code>Properties</code> instance. The code <code><pre> |
860 | + * Persistit db = new Persistit(properties); |
861 | + * </pre></code> is equivalent to <code><pre> |
862 | + * Persistit db = new Persistit(); |
863 | + * db.setProperties(properties); |
864 | + * db.intialize(); |
865 | + * </pre></code> |
866 | + * |
867 | + * @see #setProperties(Properties) |
868 | + * @param properties |
869 | + * the Properties |
870 | + */ |
871 | + public Persistit(final Properties properties) throws PersistitException { |
872 | + setProperties(properties); |
873 | + initialize(); |
874 | + } |
875 | + |
876 | + /** |
877 | + * Receive the supplied <code>Configuration</code> which will be used to |
878 | + * control the creation of a functional <code>Persistit</code> within the |
879 | + * {@link #initialize()} method. The configuration may only be set once. |
880 | + * |
881 | + * @param configuration |
882 | + * @throws IllegalStateException |
883 | + * if the <code>Configuration</code> has already been set |
884 | + */ |
885 | + public synchronized void setConfiguration(final Configuration configuration) { |
886 | + if (_configuration != null) { |
887 | + throw new IllegalStateException("Configuration has already been set"); |
888 | + } |
889 | + _configuration = configuration; |
890 | + } |
891 | + |
892 | + /** |
893 | + * Sets a <code>Configuration</code> derived from <code>Properties</code> |
894 | + * read from the supplied file name. |
895 | + * |
896 | + * @see #setConfiguration(Configuration) |
897 | + * @param propertiesFileName |
898 | + * path to properties file |
899 | + * @throws PersistitException |
900 | + * if the properties file is invalid |
901 | + * @throws IllegalStateException |
902 | + * if the <code>Configuration</code> has already been set |
903 | + */ |
904 | + public void setPropertiesFromFile(final String propertiesFileName) throws PersistitException { |
905 | + final Configuration configuration = new Configuration(); |
906 | + configuration.readPropertiesFile(propertiesFileName); |
907 | + setConfiguration(configuration); |
908 | + } |
909 | + |
910 | + /** |
911 | + * Sets a <code>Configuration</code> derived from the supplied |
912 | + * <code>Properties</code>. |
913 | + * |
914 | + * @see #setConfiguration(Configuration) |
915 | + * @param properties |
916 | + * the Properties from which to build a |
917 | + * <code>Configuration</code> |
918 | + * @throws IllegalStateException |
919 | + * if the <code>Configuration</code> has already been set |
920 | + */ |
921 | + public void setProperties(final Properties properties) { |
922 | + setConfiguration(new Configuration(properties)); |
923 | + } |
924 | + |
925 | + /** |
926 | + * <p> |
927 | + * Initialize Persistit using the <code>Configuration</code> supplied by the |
928 | + * {@link #setConfiguration(Configuration)} method or derived from |
929 | + * properties supplied by {@link #setProperties(Properties)} or |
930 | + * {@link #setPropertiesFromFile(String)}. |
931 | + * </p> |
932 | + * <p> |
933 | + * If no configuration has been set, this method reverts to its legacy |
934 | + * behavior which is to load a configuration from a default properties file. |
935 | + * The name of this file is supplied by the system property |
936 | * <code>com.persistit.properties</code>. If that property is not specified, |
937 | * the default file path is <code>./persistit.properties</code> in the |
938 | * current working directory. If Persistit has already been initialized, |
939 | - * this method does nothing. This method is threadsafe; if multiple threads |
940 | + * this method does nothing. This method is thread-safe; if multiple threads |
941 | * concurrently attempt to invoke this method, one of the threads will |
942 | * actually perform the initialization and the other threads will do |
943 | * nothing. |
944 | @@ -492,11 +412,42 @@ |
945 | * @throws IOException |
946 | * @throws Exception |
947 | */ |
948 | - public void initialize() throws PersistitException { |
949 | - if (!isInitialized()) { |
950 | - final Configuration configuration = new Configuration(); |
951 | - configuration.readPropertiesFile(); |
952 | - initialize(configuration); |
953 | + public synchronized void initialize() throws PersistitException { |
954 | + if (isInitialized()) { |
955 | + return; |
956 | + } |
957 | + if (_configuration == null) { |
958 | + final Configuration config = new Configuration(); |
959 | + config.readPropertiesFile(); |
960 | + _configuration = config; |
961 | + } |
962 | + try { |
963 | + _closed.set(false); |
964 | + |
965 | + initializeLogging(); |
966 | + initializeManagement(); |
967 | + initializeOther(); |
968 | + initializeRecovery(); |
969 | + initializeJournal(); |
970 | + initializeBufferPools(); |
971 | + initializeVolumes(); |
972 | + startJournal(); |
973 | + startBufferPools(); |
974 | + preloadBufferPools(); |
975 | + finishRecovery(); |
976 | + startCheckpointManager(); |
977 | + startTransactionIndexPollTask(); |
978 | + flush(); |
979 | + _checkpointManager.checkpoint(); |
980 | + _journalManager.pruneObsoleteTransactions(); |
981 | + |
982 | + startCleanupManager(); |
983 | + _initialized.set(true); |
984 | + } finally { |
985 | + if (!isInitialized()) { |
986 | + releaseAllResources(); |
987 | + _configuration = null; |
988 | + } |
989 | } |
990 | } |
991 | |
992 | @@ -504,7 +455,7 @@ |
993 | * <p> |
994 | * Initialize Persistit using the supplied properties file path. If |
995 | * Persistit has already been initialized, this method does nothing. This |
996 | - * method is threadsafe; if multiple threads concurrently attempt to invoke |
997 | + * method is thread-safe; if multiple threads concurrently attempt to invoke |
998 | * this method, one of the threads will actually perform the initialization |
999 | * and the other threads will do nothing. |
1000 | * </p> |
1001 | @@ -513,17 +464,28 @@ |
1002 | * exiting until {@link #close} is invoked. This is to ensure that all |
1003 | * pending updates are written before the JVM exit. |
1004 | * </p> |
1005 | + * <p> |
1006 | + * This method is deprecated. Applications should instead call |
1007 | + * |
1008 | + * <pre> |
1009 | + * <code> |
1010 | + * setPropertiesFromFile(propertiesFileName); |
1011 | + * initialize(); |
1012 | + * </code> |
1013 | + * </pre> |
1014 | + * |
1015 | + * </p> |
1016 | * |
1017 | * @param propertiesFileName |
1018 | * The path to the properties file. |
1019 | * @throws PersistitException |
1020 | * @throws IOException |
1021 | */ |
1022 | + @Deprecated |
1023 | public void initialize(final String propertiesFileName) throws PersistitException { |
1024 | if (!isInitialized()) { |
1025 | - final Configuration configuration = new Configuration(); |
1026 | - configuration.readPropertiesFile(propertiesFileName); |
1027 | - initialize(configuration); |
1028 | + setPropertiesFromFile(propertiesFileName); |
1029 | + initialize(); |
1030 | } |
1031 | } |
1032 | |
1033 | @@ -532,7 +494,7 @@ |
1034 | * Initialize Persistit using the supplied <code>java.util.Properties</code> |
1035 | * instance. Applications can use this method to supply computed Properties |
1036 | * rather than reading them from a file. If Persistit has already been |
1037 | - * initialized, this method does nothing. This method is threadsafe; if |
1038 | + * initialized, this method does nothing. This method is thread-safe; if |
1039 | * multiple threads concurrently attempt to invoke this method, one of the |
1040 | * threads will actually perform the initialization and the other threads |
1041 | * will do nothing. |
1042 | @@ -542,6 +504,17 @@ |
1043 | * exiting until {@link #close} is invoked. This is to ensure that all |
1044 | * pending updates are written before the JVM exit. |
1045 | * </p> |
1046 | + * <p> |
1047 | + * This method is deprecated. Applications should instead call |
1048 | + * |
1049 | + * <pre> |
1050 | + * <code> |
1051 | + * setProperties(properties); |
1052 | + * initialize(); |
1053 | + * </code> |
1054 | + * </pre> |
1055 | + * |
1056 | + * </p> |
1057 | * |
1058 | * @param properties |
1059 | * The <code>Properties</code> instance from which to build the |
1060 | @@ -549,10 +522,11 @@ |
1061 | * @throws PersistitException |
1062 | * @throws IOException |
1063 | */ |
1064 | + @Deprecated |
1065 | public void initialize(final Properties properties) throws PersistitException { |
1066 | if (!isInitialized()) { |
1067 | - final Configuration configuration = new Configuration(properties); |
1068 | - initialize(configuration); |
1069 | + setProperties(properties); |
1070 | + initialize(); |
1071 | } |
1072 | } |
1073 | |
1074 | @@ -560,7 +534,7 @@ |
1075 | * <p> |
1076 | * Initialize Persistit using the supplied {@link Configuration}. If |
1077 | * Persistit has already been initialized, this method does nothing. This |
1078 | - * method is threadsafe; if multiple threads concurrently attempt to invoke |
1079 | + * method is thread-safe; if multiple threads concurrently attempt to invoke |
1080 | * this method, one of the threads will actually perform the initialization |
1081 | * and the other threads will do nothing. |
1082 | * </p> |
1083 | @@ -569,6 +543,17 @@ |
1084 | * exiting until {@link #close} is invoked. This is to ensure that all |
1085 | * pending updates are written before the JVM exit. |
1086 | * </p> |
1087 | + * <p> |
1088 | + * This method is deprecated. Applications should instead call |
1089 | + * |
1090 | + * <pre> |
1091 | + * <code> |
1092 | + * setConfiguration(configuration); |
1093 | + * initialize(); |
1094 | + * </code> |
1095 | + * </pre> |
1096 | + * |
1097 | + * </p> |
1098 | * |
1099 | * @param configuration |
1100 | * The <code>Configuration</code> from which to initialize |
1101 | @@ -576,41 +561,15 @@ |
1102 | * @throws PersistitException |
1103 | * @throws IOException |
1104 | */ |
1105 | - public synchronized void initialize(final Configuration configuration) throws PersistitException { |
1106 | + @Deprecated |
1107 | + public void initialize(final Configuration configuration) throws PersistitException { |
1108 | if (!isInitialized()) { |
1109 | - _configuration = configuration; |
1110 | - try { |
1111 | - _closed.set(false); |
1112 | - |
1113 | - initializeLogging(); |
1114 | - initializeManagement(); |
1115 | - initializeOther(); |
1116 | - initializeRecovery(); |
1117 | - initializeJournal(); |
1118 | - initializeBufferPools(); |
1119 | - initializeVolumes(); |
1120 | - startJournal(); |
1121 | - startBufferPools(); |
1122 | - preloadBufferPools(); |
1123 | - finishRecovery(); |
1124 | - startCheckpointManager(); |
1125 | - startTransactionIndexPollTask(); |
1126 | - flush(); |
1127 | - _checkpointManager.checkpoint(); |
1128 | - _journalManager.pruneObsoleteTransactions(); |
1129 | - |
1130 | - startCleanupManager(); |
1131 | - _initialized.set(true); |
1132 | - } finally { |
1133 | - if (!isInitialized()) { |
1134 | - releaseAllResources(); |
1135 | - _configuration = null; |
1136 | - } |
1137 | - } |
1138 | + setConfiguration(configuration); |
1139 | + initialize(); |
1140 | } |
1141 | } |
1142 | |
1143 | - void initializeLogging() throws PersistitException { |
1144 | + private void initializeLogging() throws PersistitException { |
1145 | try { |
1146 | _logFlusher = new LogFlusher(); |
1147 | _logFlusher.start(); |
1148 | @@ -633,7 +592,7 @@ |
1149 | |
1150 | } |
1151 | |
1152 | - void initializeRecovery() throws PersistitException { |
1153 | + private void initializeRecovery() throws PersistitException { |
1154 | final String journalPath = _configuration.getJournalPath(); |
1155 | _recoveryManager.init(journalPath); |
1156 | _recoveryManager.buildRecoveryPlan(); |
1157 | @@ -648,7 +607,7 @@ |
1158 | _journalManager.setIgnoreMissingVolumes(_configuration.isIgnoreMissingVolumes()); |
1159 | } |
1160 | |
1161 | - void initializeBufferPools() { |
1162 | + private void initializeBufferPools() { |
1163 | for (final BufferPoolConfiguration config : _configuration.getBufferPoolMap().values()) { |
1164 | final int poolSize = config.computeBufferCount(getAvailableHeap()); |
1165 | if (poolSize > 0) { |
1166 | @@ -663,7 +622,7 @@ |
1167 | } |
1168 | } |
1169 | |
1170 | - void initializeVolumes() throws PersistitException { |
1171 | + private void initializeVolumes() throws PersistitException { |
1172 | for (final VolumeSpecification volumeSpecification : _configuration.getVolumeList()) { |
1173 | Volume volume = _journalManager.getVolumeByName(volumeSpecification.getName()); |
1174 | if (volume == null) { |
1175 | @@ -676,7 +635,7 @@ |
1176 | } |
1177 | } |
1178 | |
1179 | - void initializeManagement() { |
1180 | + private void initializeManagement() { |
1181 | final String rmiHost = _configuration.getRmiHost(); |
1182 | final int rmiPort = _configuration.getRmiPort(); |
1183 | final int serverPort = _configuration.getRmiServerPort(); |
1184 | @@ -691,7 +650,7 @@ |
1185 | } |
1186 | } |
1187 | |
1188 | - void initializeOther() { |
1189 | + private void initializeOther() { |
1190 | // Set up the parent CoderManager for this instance. |
1191 | final DefaultCoderManager cm = new DefaultCoderManager(this, _configuration.getSerialOverride()); |
1192 | _coderManager.set(cm); |
1193 | @@ -1223,23 +1182,23 @@ |
1194 | return System.currentTimeMillis() - _startTime; |
1195 | } |
1196 | |
1197 | - public Configuration getConfiguration() { |
1198 | + public synchronized Configuration getConfiguration() { |
1199 | return _configuration; |
1200 | } |
1201 | |
1202 | @Deprecated |
1203 | public Properties getProperties() { |
1204 | - return _configuration.getProperties(); |
1205 | + return getConfiguration().getProperties(); |
1206 | } |
1207 | |
1208 | @Deprecated |
1209 | public String getProperty(final String key) { |
1210 | - return _configuration.getProperty(key); |
1211 | + return getConfiguration().getProperty(key); |
1212 | } |
1213 | - |
1214 | + |
1215 | @Deprecated |
1216 | public String substituteProperties(final String text, final Properties properties) { |
1217 | - return _configuration.substituteProperties(text, properties, 0); |
1218 | + return getConfiguration().substituteProperties(text, properties); |
1219 | } |
1220 | |
1221 | /** |
1222 | @@ -1319,7 +1278,7 @@ |
1223 | * if the volume was not found |
1224 | */ |
1225 | public Volume getSystemVolume() throws VolumeNotFoundException { |
1226 | - return getSpecialVolume(SYSTEM_VOLUME_PROPERTY, DEFAULT_SYSTEM_VOLUME_NAME); |
1227 | + return getSpecialVolume(SYSTEM_VOLUME_PROPERTY_NAME, DEFAULT_SYSTEM_VOLUME_NAME); |
1228 | } |
1229 | |
1230 | /** |
1231 | @@ -1853,6 +1812,7 @@ |
1232 | _initialized.set(false); |
1233 | _sessionIdThreadLocal.remove(); |
1234 | _cleanupManager.clear(); |
1235 | + _configuration = null; |
1236 | } |
1237 | synchronized (_exchangePoolMap) { |
1238 | _exchangePoolMap.clear(); |
1239 | @@ -2558,7 +2518,8 @@ |
1240 | final String propertiesFileName = ap.getStringValue("properties"); |
1241 | if (!propertiesFileName.isEmpty()) { |
1242 | persistit = new Persistit(); |
1243 | - persistit.initialize(propertiesFileName); |
1244 | + persistit.setPropertiesFromFile(propertiesFileName); |
1245 | + persistit.initialize(); |
1246 | } |
1247 | final String scriptName = ap.getStringValue("script"); |
1248 | |
1249 | |
1250 | === modified file 'src/test/java/com/persistit/AccumulatorRecoveryTest.java' |
1251 | --- src/test/java/com/persistit/AccumulatorRecoveryTest.java 2012-08-24 13:57:19 +0000 |
1252 | +++ src/test/java/com/persistit/AccumulatorRecoveryTest.java 2012-11-21 16:34:24 +0000 |
1253 | @@ -92,13 +92,14 @@ |
1254 | } |
1255 | |
1256 | _persistit.getJournalManager().flush(); |
1257 | + final Configuration config = _persistit.getConfiguration(); |
1258 | _persistit.crash(); |
1259 | - final Properties saveProperties = _persistit.getProperties(); |
1260 | _persistit = new Persistit(); |
1261 | _persistit.getJournalManager().setAppendOnly(true); |
1262 | final RecoveryManager plan = _persistit.getRecoveryManager(); |
1263 | plan.setRecoveryDisabledForTestMode(true); |
1264 | - _persistit.initialize(saveProperties); |
1265 | + _persistit.setConfiguration(config); |
1266 | + _persistit.initialize(); |
1267 | assertEquals(15, plan.getCommittedCount()); |
1268 | plan.setRecoveryDisabledForTestMode(false); |
1269 | final Set<Long> recoveryTimestamps = new HashSet<Long>(); |
1270 | @@ -251,12 +252,9 @@ |
1271 | for (int i = 0; i < threads.length; i++) { |
1272 | threads[i].join(); |
1273 | } |
1274 | - |
1275 | + final Configuration config = _persistit.getConfiguration(); |
1276 | _persistit.crash(); |
1277 | - |
1278 | - final Properties props = _persistit.getProperties(); |
1279 | - _persistit = new Persistit(); |
1280 | - _persistit.initialize(props); |
1281 | + _persistit = new Persistit(config); |
1282 | |
1283 | verifyRowCount(); |
1284 | } |
1285 | |
1286 | === modified file 'src/test/java/com/persistit/BackupTaskTest.java' |
1287 | --- src/test/java/com/persistit/BackupTaskTest.java 2012-08-24 13:57:19 +0000 |
1288 | +++ src/test/java/com/persistit/BackupTaskTest.java 2012-11-21 16:34:24 +0000 |
1289 | @@ -15,6 +15,7 @@ |
1290 | |
1291 | package com.persistit; |
1292 | |
1293 | +import static org.junit.Assert.assertEquals; |
1294 | import static org.junit.Assert.assertTrue; |
1295 | |
1296 | import java.io.File; |
1297 | @@ -60,16 +61,15 @@ |
1298 | backup1.setup(1, "backup file=" + file.getAbsolutePath(), "cli", 0, 5); |
1299 | backup1.run(); |
1300 | |
1301 | - final Properties properties = _persistit.getProperties(); |
1302 | + final Configuration config = _persistit.getConfiguration(); |
1303 | _persistit.close(); |
1304 | |
1305 | - _persistit = new Persistit(); |
1306 | final BackupTask backup2 = new BackupTask(); |
1307 | backup2.setMessageWriter(writer); |
1308 | backup2.setPersistit(_persistit); |
1309 | backup2.doRestore(file.getAbsolutePath()); |
1310 | |
1311 | - _persistit.initialize(properties); |
1312 | + _persistit = new Persistit(config); |
1313 | _persistit.checkAllVolumes(); |
1314 | |
1315 | final PersistitMap<Integer, String> pmap2 = new PersistitMap<Integer, String>(_persistit.getExchange( |
1316 | @@ -103,18 +103,17 @@ |
1317 | tw.stop.set(true); |
1318 | twThread.join(); |
1319 | |
1320 | - final Properties properties = _persistit.getProperties(); |
1321 | + final Configuration config = _persistit.getConfiguration(); |
1322 | _persistit.crash(); |
1323 | UnitTestProperties.cleanUpDirectory(new File(UnitTestProperties.DATA_PATH)); |
1324 | |
1325 | - _persistit = new Persistit(); |
1326 | final BackupTask backup2 = new BackupTask(); |
1327 | backup2.setMessageWriter(writer); |
1328 | backup2.setPersistit(_persistit); |
1329 | backup2.doRestore(file.getAbsolutePath()); |
1330 | - properties.setProperty("appendonly", "true"); |
1331 | |
1332 | - _persistit.initialize(properties); |
1333 | + config.setAppendOnly(true); |
1334 | + _persistit = new Persistit(config); |
1335 | _persistit.checkAllVolumes(); |
1336 | final Exchange exchange = _persistit.getExchange("persistit", "BackupTest", false); |
1337 | exchange.to(Key.BEFORE); |
1338 | |
1339 | === modified file 'src/test/java/com/persistit/Bug1018526Test.java' |
1340 | --- src/test/java/com/persistit/Bug1018526Test.java 2012-08-24 13:57:19 +0000 |
1341 | +++ src/test/java/com/persistit/Bug1018526Test.java 2012-11-21 16:34:24 +0000 |
1342 | @@ -86,8 +86,7 @@ |
1343 | } |
1344 | final Configuration cfg = _persistit.getConfiguration(); |
1345 | _persistit.close(); |
1346 | - _persistit = new Persistit(); |
1347 | - _persistit.initialize(cfg); |
1348 | + _persistit = new Persistit(cfg); |
1349 | final Map<Integer, TreeDescriptor> map = _persistit.getJournalManager().queryTreeMap(); |
1350 | for (final Integer handle : permTreeHandleSet) { |
1351 | final TreeDescriptor td = map.remove(handle); |
1352 | |
1353 | === modified file 'src/test/java/com/persistit/Bug1064565Test.java' |
1354 | --- src/test/java/com/persistit/Bug1064565Test.java 2012-10-10 16:24:44 +0000 |
1355 | +++ src/test/java/com/persistit/Bug1064565Test.java 2012-11-21 16:34:24 +0000 |
1356 | @@ -91,11 +91,9 @@ |
1357 | txn.end(); |
1358 | sequence(ACCUMULATOR_CHECKPOINT_C); |
1359 | |
1360 | + final Configuration config = _persistit.getConfiguration(); |
1361 | _persistit.close(); |
1362 | - |
1363 | - final Configuration config = _persistit.getConfiguration(); |
1364 | - _persistit = new Persistit(); |
1365 | - _persistit.initialize(config); |
1366 | + _persistit = new Persistit(config); |
1367 | |
1368 | exchange = getExchange(); |
1369 | txn = exchange.getTransaction(); |
1370 | @@ -128,8 +126,7 @@ |
1371 | _persistit.copyBackPages(); |
1372 | final Configuration config = _persistit.getConfiguration(); |
1373 | _persistit.close(); |
1374 | - _persistit = new Persistit(); |
1375 | - _persistit.initialize(config); |
1376 | + _persistit = new Persistit(config); |
1377 | |
1378 | exchange = getExchange(); |
1379 | txn = exchange.getTransaction(); |
1380 | |
1381 | === modified file 'src/test/java/com/persistit/Bug1065677Test.java' |
1382 | --- src/test/java/com/persistit/Bug1065677Test.java 2012-10-12 21:25:01 +0000 |
1383 | +++ src/test/java/com/persistit/Bug1065677Test.java 2012-11-21 16:34:24 +0000 |
1384 | @@ -97,13 +97,13 @@ |
1385 | |
1386 | _persistit = new Persistit(); |
1387 | _persistit.getTimestampAllocator().updateTimestamp(lastTimestamp + 1000); |
1388 | - _persistit.initialize(config); |
1389 | + _persistit.setConfiguration(config); |
1390 | + _persistit.initialize(); |
1391 | _persistit.crash(); |
1392 | truncate(); |
1393 | |
1394 | - _persistit = new Persistit(); |
1395 | config.setAppendOnly(true); |
1396 | - _persistit.initialize(config); |
1397 | + _persistit = new Persistit(config); |
1398 | |
1399 | doTransaction(); |
1400 | |
1401 | @@ -111,8 +111,7 @@ |
1402 | jman.rollover(); |
1403 | _persistit.close(); |
1404 | |
1405 | - _persistit = new Persistit(); |
1406 | - _persistit.initialize(config); |
1407 | + _persistit = new Persistit(config); |
1408 | _persistit.close(); |
1409 | |
1410 | } |
1411 | |
1412 | === modified file 'src/test/java/com/persistit/Bug706132Test.java' |
1413 | --- src/test/java/com/persistit/Bug706132Test.java 2012-08-24 13:57:19 +0000 |
1414 | +++ src/test/java/com/persistit/Bug706132Test.java 2012-11-21 16:34:24 +0000 |
1415 | @@ -46,7 +46,8 @@ |
1416 | p.remove("buffer.count.8192"); |
1417 | p.setProperty("volume.1", "${datapath}/persistit,create," |
1418 | + "pageSize:1024,initialPages:100,extensionPages:100," + "maximumPages:25000"); |
1419 | - _persistit.initialize(p); |
1420 | + _persistit.setProperties(p); |
1421 | + _persistit.initialize(); |
1422 | } |
1423 | |
1424 | @Test |
1425 | |
1426 | === modified file 'src/test/java/com/persistit/Bug777918Test.java' |
1427 | --- src/test/java/com/persistit/Bug777918Test.java 2012-08-24 13:57:19 +0000 |
1428 | +++ src/test/java/com/persistit/Bug777918Test.java 2012-11-21 16:34:24 +0000 |
1429 | @@ -80,11 +80,9 @@ |
1430 | ex.to(i).store(); |
1431 | } |
1432 | _persistit.getJournalManager().rollover(); |
1433 | - final Properties properties = _persistit.getProperties(); |
1434 | _persistit.close(); |
1435 | |
1436 | - _persistit = new Persistit(); |
1437 | - _persistit.initialize(properties); |
1438 | + _persistit = new Persistit(_config); |
1439 | _persistit.checkAllVolumes(); |
1440 | ex = _persistit.getExchange("persistit", "Bug777918Test", false); |
1441 | // ensure updates after the checkpoint did make it, i.e., |
1442 | @@ -93,8 +91,7 @@ |
1443 | assertEquals(true, ex.to(i).isValueDefined()); |
1444 | } |
1445 | _persistit.close(); |
1446 | - _persistit = new Persistit(); |
1447 | - _persistit.initialize(properties); |
1448 | + _persistit = new Persistit(_config); |
1449 | _persistit.checkAllVolumes(); |
1450 | ex = _persistit.getExchange("persistit", "Bug777918Test", false); |
1451 | // ensure updates after the checkpoint did make it, i.e., |
1452 | @@ -116,15 +113,12 @@ |
1453 | ex.to(i).store(); |
1454 | } |
1455 | _persistit.flush(); |
1456 | - final Properties properties = _persistit.getProperties(); |
1457 | _persistit.crash(); |
1458 | - _persistit = new Persistit(); |
1459 | - _persistit.initialize(properties); |
1460 | + _persistit = new Persistit(_config); |
1461 | _persistit.checkAllVolumes(); |
1462 | _persistit.close(); |
1463 | |
1464 | - _persistit = new Persistit(); |
1465 | - _persistit.initialize(properties); |
1466 | + _persistit = new Persistit(_config); |
1467 | _persistit.checkAllVolumes(); |
1468 | ex = _persistit.getExchange("persistit", "Bug777918Test", false); |
1469 | // ensure updates after the checkpoint didn't make it |
1470 | @@ -152,14 +146,11 @@ |
1471 | ex.getTransaction().end(); |
1472 | } |
1473 | _persistit.flush(); |
1474 | - final Properties properties = _persistit.getProperties(); |
1475 | _persistit.crash(); |
1476 | - _persistit = new Persistit(); |
1477 | - _persistit.initialize(properties); |
1478 | + _persistit = new Persistit(_config); |
1479 | _persistit.checkAllVolumes(); |
1480 | _persistit.close(); |
1481 | - _persistit = new Persistit(); |
1482 | - _persistit.initialize(properties); |
1483 | + _persistit = new Persistit(_config); |
1484 | _persistit.checkAllVolumes(); |
1485 | ex = _persistit.getExchange("persistit", "Bug777918Test", false); |
1486 | // ensure updates after the checkpoint didn't make it |
1487 | @@ -171,7 +162,6 @@ |
1488 | @Test |
1489 | public void testMakeBranchTxnLongRecord() throws Exception { |
1490 | final StringBuilder sb = new StringBuilder(); |
1491 | - final Properties properties = _persistit.getProperties(); |
1492 | |
1493 | while (sb.length() < 20000) { |
1494 | sb.append(RED_FOX); |
1495 | @@ -198,13 +188,13 @@ |
1496 | _persistit.crash(); |
1497 | _persistit = new Persistit(); |
1498 | _persistit.getRecoveryManager().setDefaultCommitListener(new TestCrashingRecoveryListener()); |
1499 | - |
1500 | + _persistit.setConfiguration(_config); |
1501 | // |
1502 | // The recovery process deliberately crashes after applying some |
1503 | // transactions. |
1504 | // |
1505 | try { |
1506 | - _persistit.initialize(properties); |
1507 | + _persistit.initialize(); |
1508 | } catch (final MissingThreadException e) { |
1509 | // expected |
1510 | } catch (final TestException e) { |
1511 | @@ -214,8 +204,7 @@ |
1512 | // This startup should divide the pages into page- and branch-map |
1513 | // and apply committed transactions using branch-map pages. |
1514 | // |
1515 | - _persistit = new Persistit(); |
1516 | - _persistit.initialize(properties); |
1517 | + _persistit = new Persistit(_config); |
1518 | _persistit.checkAllVolumes(); |
1519 | |
1520 | ex = _persistit.getExchange("persistit", "Bug777918Test", false); |
1521 | |
1522 | === modified file 'src/test/java/com/persistit/Bug911849Test.java' |
1523 | --- src/test/java/com/persistit/Bug911849Test.java 2012-08-24 13:57:19 +0000 |
1524 | +++ src/test/java/com/persistit/Bug911849Test.java 2012-11-21 16:34:24 +0000 |
1525 | @@ -67,13 +67,11 @@ |
1526 | |
1527 | @Test |
1528 | public void testOverlappingCheckpointTransactions() throws Exception { |
1529 | - final Properties props = _persistit.getProperties(); |
1530 | for (int i = 0; i < 10; i++) { |
1531 | accumulateRows(10000); |
1532 | _persistit.getJournalManager().force(); |
1533 | _persistit.crash(); |
1534 | - _persistit = new Persistit(); |
1535 | - _persistit.initialize(props); |
1536 | + _persistit = new Persistit(_config); |
1537 | final Exchange exchange = _persistit.getExchange("persistit", "AccumulatorRecoveryTest", false); |
1538 | final Accumulator rowCount = exchange.getTree().getAccumulator(Accumulator.Type.SUM, |
1539 | ROW_COUNT_ACCUMULATOR_INDEX); |
1540 | |
1541 | === modified file 'src/test/java/com/persistit/Bug915594Test.java' |
1542 | --- src/test/java/com/persistit/Bug915594Test.java 2012-08-24 13:57:19 +0000 |
1543 | +++ src/test/java/com/persistit/Bug915594Test.java 2012-11-21 16:34:24 +0000 |
1544 | @@ -84,13 +84,11 @@ |
1545 | txn.rollback(); |
1546 | txn.end(); |
1547 | _persistit.checkpoint(); |
1548 | - final Properties properties = _persistit.getProperties(); |
1549 | ex = null; |
1550 | txn = null; |
1551 | _persistit.close(); |
1552 | |
1553 | - _persistit = new Persistit(); |
1554 | - _persistit.initialize(properties); |
1555 | + _persistit = new Persistit(_config); |
1556 | final Exchange ex2 = _persistit.getExchange("persistit", "Bug915594Test", true); |
1557 | assertTrue(!ex2.clear().next(true)); |
1558 | } |
1559 | |
1560 | === modified file 'src/test/java/com/persistit/Bug918909Test.java' |
1561 | --- src/test/java/com/persistit/Bug918909Test.java 2012-08-24 13:57:19 +0000 |
1562 | +++ src/test/java/com/persistit/Bug918909Test.java 2012-11-21 16:34:24 +0000 |
1563 | @@ -115,12 +115,10 @@ |
1564 | txn.end(); |
1565 | } |
1566 | } |
1567 | - final Properties properties = _persistit.getProperties(); |
1568 | _persistit.crash(); |
1569 | |
1570 | for (int i = 0; i < RESTART_ITERATIONS; i++) { |
1571 | - _persistit = new Persistit(); |
1572 | - _persistit.initialize(properties); |
1573 | + _persistit = new Persistit(_config); |
1574 | final Exchange ex = _persistit.getExchange("persistit", "Bug918909Test", true); |
1575 | final Transaction txn = ex.getTransaction(); |
1576 | txn.begin(); |
1577 | @@ -136,8 +134,7 @@ |
1578 | _persistit.close(); |
1579 | } |
1580 | |
1581 | - _persistit = new Persistit(); |
1582 | - _persistit.initialize(properties); |
1583 | + _persistit = new Persistit(_config); |
1584 | _persistit.checkpoint(); |
1585 | _persistit.copyBackPages(); |
1586 | assertTrue(_persistit.getJournalManager().getBaseAddress() > RESTART_ITERATIONS |
1587 | |
1588 | === modified file 'src/test/java/com/persistit/Bug932097Test.java' |
1589 | --- src/test/java/com/persistit/Bug932097Test.java 2012-08-15 16:12:34 +0000 |
1590 | +++ src/test/java/com/persistit/Bug932097Test.java 2012-11-21 16:34:24 +0000 |
1591 | @@ -41,10 +41,8 @@ |
1592 | */ |
1593 | } |
1594 | _persistit.checkpoint(); |
1595 | - final Properties properties = _persistit.getProperties(); |
1596 | _persistit.crash(); |
1597 | - _persistit = new Persistit(); |
1598 | - _persistit.initialize(properties); |
1599 | + _persistit = new Persistit(_config); |
1600 | /* |
1601 | * To exploit the bug, register a bunch of new transactions which will |
1602 | * draw the TransactionStatus instances freed after recovery finishes |
1603 | |
1604 | === modified file 'src/test/java/com/persistit/Bug942669Test.java' |
1605 | --- src/test/java/com/persistit/Bug942669Test.java 2012-08-24 13:57:19 +0000 |
1606 | +++ src/test/java/com/persistit/Bug942669Test.java 2012-11-21 16:34:24 +0000 |
1607 | @@ -21,8 +21,6 @@ |
1608 | import static com.persistit.util.ThreadSequencer.enableSequencer; |
1609 | import static org.junit.Assert.assertNull; |
1610 | |
1611 | -import java.util.Properties; |
1612 | - |
1613 | import org.junit.Ignore; |
1614 | import org.junit.Test; |
1615 | |
1616 | @@ -93,14 +91,14 @@ |
1617 | _persistit.checkpoint(); |
1618 | txn.commit(); |
1619 | txn.end(); |
1620 | + final Configuration config = _persistit.getConfiguration(); |
1621 | _persistit.crash(); |
1622 | - final Properties properties = _persistit.getProperties(); |
1623 | _persistit = new Persistit(); |
1624 | - |
1625 | + _persistit.setConfiguration(config); |
1626 | enableSequencer(true); |
1627 | addSchedules(RECOVERY_PRUNING_SCHEDULE); |
1628 | |
1629 | - _persistit.initialize(properties); |
1630 | + _persistit.initialize(); |
1631 | _persistit.copyBackPages(); |
1632 | disableSequencer(); |
1633 | } |
1634 | @@ -144,12 +142,11 @@ |
1635 | */ |
1636 | _persistit.copyBackPages(); |
1637 | _persistit.copyBackPages(); |
1638 | + final Configuration config = _persistit.getConfiguration(); |
1639 | |
1640 | _persistit.close(); |
1641 | |
1642 | - final Properties properties = _persistit.getProperties(); |
1643 | - _persistit = new Persistit(); |
1644 | - _persistit.initialize(properties); |
1645 | + _persistit = new Persistit(config); |
1646 | _persistit.copyBackPages(); |
1647 | assertNull(_persistit.getJournalManager().getLastCopierException()); |
1648 | } |
1649 | |
1650 | === modified file 'src/test/java/com/persistit/Bug974589Test.java' |
1651 | --- src/test/java/com/persistit/Bug974589Test.java 2012-08-24 13:57:19 +0000 |
1652 | +++ src/test/java/com/persistit/Bug974589Test.java 2012-11-21 16:34:24 +0000 |
1653 | @@ -17,8 +17,6 @@ |
1654 | |
1655 | import static org.junit.Assert.assertEquals; |
1656 | |
1657 | -import java.util.Properties; |
1658 | - |
1659 | import org.junit.Test; |
1660 | |
1661 | import com.persistit.exception.PersistitException; |
1662 | @@ -57,11 +55,10 @@ |
1663 | txn1 = null; |
1664 | acc1 = null; |
1665 | _persistit.checkpoint(); |
1666 | + |
1667 | + final Configuration config = _persistit.getConfiguration(); |
1668 | _persistit.close(); |
1669 | - |
1670 | - final Properties properties = _persistit.getProperties(); |
1671 | - _persistit = new Persistit(); |
1672 | - _persistit.initialize(properties); |
1673 | + _persistit = new Persistit(config); |
1674 | |
1675 | Exchange ex2 = getExchange(_persistit); |
1676 | Transaction txn2 = ex2.getTransaction(); |
1677 | |
1678 | === modified file 'src/test/java/com/persistit/Bug980292Test.java' |
1679 | --- src/test/java/com/persistit/Bug980292Test.java 2012-08-24 13:57:19 +0000 |
1680 | +++ src/test/java/com/persistit/Bug980292Test.java 2012-11-21 16:34:24 +0000 |
1681 | @@ -62,11 +62,9 @@ |
1682 | _persistit.checkpoint(); |
1683 | txn.rollback(); |
1684 | txn.end(); |
1685 | - final Properties properties = _persistit.getProperties(); |
1686 | _persistit.getJournalManager().force(); |
1687 | _persistit.crash(); |
1688 | - _persistit = new Persistit(); |
1689 | - _persistit.initialize(properties); |
1690 | + _persistit = new Persistit(_config); |
1691 | assertEquals(0, _persistit.getRecoveryManager().getErrorCount()); |
1692 | } |
1693 | } |
1694 | |
1695 | === modified file 'src/test/java/com/persistit/ClassIndexTest.java' |
1696 | --- src/test/java/com/persistit/ClassIndexTest.java 2012-08-24 13:57:19 +0000 |
1697 | +++ src/test/java/com/persistit/ClassIndexTest.java 2012-11-21 16:34:24 +0000 |
1698 | @@ -195,10 +195,8 @@ |
1699 | txn.end(); |
1700 | } |
1701 | |
1702 | - final Configuration config = _persistit.getConfiguration(); |
1703 | _persistit.crash(); |
1704 | - _persistit = new Persistit(); |
1705 | - _persistit.initialize(config); |
1706 | + _persistit = new Persistit(_config); |
1707 | ex = _persistit.getExchange("persistit", "ClassIndexTest", false); |
1708 | final Object b = ex.to("B").fetch().getValue().get(); |
1709 | final Object a = ex.to("A").fetch().getValue().get(); |
1710 | |
1711 | === modified file 'src/test/java/com/persistit/CommandLineTest.java' |
1712 | --- src/test/java/com/persistit/CommandLineTest.java 2012-08-24 13:57:19 +0000 |
1713 | +++ src/test/java/com/persistit/CommandLineTest.java 2012-11-21 16:34:24 +0000 |
1714 | @@ -96,10 +96,12 @@ |
1715 | for (int index = 0; index < 500; index++) { |
1716 | pmap.put(new Integer(index), "This is the record for index=" + index); |
1717 | } |
1718 | - _persistit.close(); |
1719 | |
1720 | final String datapath = _persistit.getConfiguration().getProperty("datapath"); |
1721 | final String rmiport = _persistit.getConfiguration().getProperty("rmiport"); |
1722 | + |
1723 | + _persistit.close(); |
1724 | + |
1725 | final StringReader stringReader = new StringReader(String.format( |
1726 | "help\nopen datapath=%s rmiport=%s\nicheck -v\n", datapath, rmiport)); |
1727 | final BufferedReader reader = new BufferedReader(stringReader); |
1728 | |
1729 | === modified file 'src/test/java/com/persistit/ConfigurationTest.java' |
1730 | --- src/test/java/com/persistit/ConfigurationTest.java 2012-08-24 13:57:19 +0000 |
1731 | +++ src/test/java/com/persistit/ConfigurationTest.java 2012-11-21 16:34:24 +0000 |
1732 | @@ -38,6 +38,8 @@ |
1733 | |
1734 | private final static String RESOURCE_NAME = "com.persistit.ConfigurationTest"; |
1735 | |
1736 | + private final static String PARSE_MEMORY_EXAMPLE = "1024,count=1000;16384,minMem=0,maxMem=1G,reserved=128M,fraction=0.5"; |
1737 | + |
1738 | @Test |
1739 | public void testStaticMethods() throws Exception { |
1740 | assertEquals(1024, bufferSizeFromPropertyName("buffer.memory.1024")); |
1741 | @@ -219,12 +221,23 @@ |
1742 | |
1743 | @Test |
1744 | public void canReinitialize() throws Exception { |
1745 | + final Configuration config = _persistit.getConfiguration(); |
1746 | _persistit.close(); |
1747 | assertTrue("Should have closed all volumes", _persistit.getVolumes().isEmpty()); |
1748 | - _persistit.initialize(_persistit.getConfiguration()); |
1749 | + _persistit.setConfiguration(config); |
1750 | + _persistit.initialize(); |
1751 | assertTrue("Should have reopened volumes", !_persistit.getVolumes().isEmpty()); |
1752 | } |
1753 | |
1754 | + @Test |
1755 | + public void setBufferConfiguration() throws Exception { |
1756 | + final Configuration configuration = new Configuration(); |
1757 | + configuration.setBufferPoolConfiguration(PARSE_MEMORY_EXAMPLE); |
1758 | + assertEquals("toString() of parsed version should be equal", PARSE_MEMORY_EXAMPLE, |
1759 | + configuration.getBufferPoolConfiguration()); |
1760 | + |
1761 | + } |
1762 | + |
1763 | private Configuration testLoadPropertiesBufferSpecificationsHelper(final Properties properties) throws Exception { |
1764 | final Configuration configuration = new Configuration(); |
1765 | configuration.merge(properties); |
1766 | |
1767 | === modified file 'src/test/java/com/persistit/CreateAndDeleteVolumeTest.java' |
1768 | --- src/test/java/com/persistit/CreateAndDeleteVolumeTest.java 2012-10-05 23:08:51 +0000 |
1769 | +++ src/test/java/com/persistit/CreateAndDeleteVolumeTest.java 2012-11-21 16:34:24 +0000 |
1770 | @@ -42,14 +42,12 @@ |
1771 | @Test |
1772 | public void recoverDynamicVolumes() throws Exception { |
1773 | VolumeSpecification volumeSpec; |
1774 | - final Configuration configuration = _persistit.getConfiguration(); |
1775 | _persistit.close(); |
1776 | int remainingJournalFiles = 0; |
1777 | |
1778 | for (int i = 5; --i >= 0;) { |
1779 | - final Persistit db = new Persistit(); |
1780 | + final Persistit db = new Persistit(_config); |
1781 | try { |
1782 | - db.initialize(configuration); |
1783 | volumeSpec = new VolumeSpecification(DATA_PATH + "/hwdemo" + i, null, 16384, 1, 1000, 1, true, false, |
1784 | false); |
1785 | db.loadVolume(volumeSpec); |
1786 | @@ -79,9 +77,8 @@ |
1787 | configuration.setUseOldVSpec(true); |
1788 | |
1789 | for (int i = 5; --i >= 0;) { |
1790 | - final Persistit db = new Persistit(); |
1791 | + final Persistit db = new Persistit(_config); |
1792 | try { |
1793 | - db.initialize(configuration); |
1794 | volumeSpec = new VolumeSpecification(DATA_PATH + "/hwdemo" + i, null, 16384, 1, 1000, 1, true, false, |
1795 | false); |
1796 | db.loadVolume(volumeSpec); |
1797 | @@ -138,14 +135,12 @@ |
1798 | public void truncateDynamicVolumes() throws Exception { |
1799 | |
1800 | VolumeSpecification volumeSpec; |
1801 | - final Configuration configuration = _persistit.getConfiguration(); |
1802 | _persistit.close(); |
1803 | |
1804 | - final Persistit db = new Persistit(); |
1805 | + final Persistit db = new Persistit(_config); |
1806 | |
1807 | for (int i = 0; i < 2; i++) { |
1808 | try { |
1809 | - db.initialize(configuration); |
1810 | volumeSpec = new VolumeSpecification(DATA_PATH + "/truncated", null, 16384, 1, 1000, 1, true, false, |
1811 | false); |
1812 | final Volume volume = db.loadVolume(volumeSpec); |
1813 | |
1814 | === modified file 'src/test/java/com/persistit/IOFailureTest.java' |
1815 | --- src/test/java/com/persistit/IOFailureTest.java 2012-10-08 19:48:22 +0000 |
1816 | +++ src/test/java/com/persistit/IOFailureTest.java 2012-11-21 16:34:24 +0000 |
1817 | @@ -318,8 +318,9 @@ |
1818 | channel1.close(); |
1819 | |
1820 | _persistit = new Persistit(); |
1821 | + _persistit.setConfiguration(_config); |
1822 | try { |
1823 | - _persistit.initialize(properties); |
1824 | + _persistit.initialize(); |
1825 | fail("Expected CorruptJournalException"); |
1826 | } catch (final CorruptJournalException cje) { |
1827 | // expected |
1828 | @@ -327,12 +328,15 @@ |
1829 | file1.delete(); |
1830 | |
1831 | _persistit = new Persistit(); |
1832 | + _persistit.setConfiguration(_config); |
1833 | try { |
1834 | - _persistit.initialize(properties); |
1835 | + _persistit.initialize(); |
1836 | fail("Expected CorruptVolumeException"); |
1837 | } catch (final CorruptVolumeException cve) { |
1838 | // expected |
1839 | } |
1840 | + channel0.close(); |
1841 | + channel1.close(); |
1842 | } |
1843 | |
1844 | @Test |
1845 | |
1846 | === modified file 'src/test/java/com/persistit/IntegrityCheckTest.java' |
1847 | --- src/test/java/com/persistit/IntegrityCheckTest.java 2012-08-31 20:20:13 +0000 |
1848 | +++ src/test/java/com/persistit/IntegrityCheckTest.java 2012-11-21 16:34:24 +0000 |
1849 | @@ -20,7 +20,6 @@ |
1850 | import static org.junit.Assert.assertTrue; |
1851 | |
1852 | import java.io.PrintWriter; |
1853 | -import java.util.Properties; |
1854 | |
1855 | import org.junit.Test; |
1856 | |
1857 | @@ -174,12 +173,13 @@ |
1858 | txn.end(); |
1859 | } |
1860 | } |
1861 | + final Configuration config = _persistit.getConfiguration(); |
1862 | _persistit.crash(); |
1863 | - final Properties properties = _persistit.getProperties(); |
1864 | _persistit = new Persistit(); |
1865 | + _persistit.setConfiguration(config); |
1866 | _persistit.getRecoveryManager().setRecoveryDisabledForTestMode(true); |
1867 | _persistit.getJournalManager().setRollbackPruningEnabled(false); |
1868 | - _persistit.initialize(properties); |
1869 | + _persistit.initialize(); |
1870 | disableBackgroundCleanup(); |
1871 | |
1872 | for (int i = 0; i < 10; i++) { |
1873 | |
1874 | === modified file 'src/test/java/com/persistit/JournalManagerTest.java' |
1875 | --- src/test/java/com/persistit/JournalManagerTest.java 2012-09-08 19:48:39 +0000 |
1876 | +++ src/test/java/com/persistit/JournalManagerTest.java 2012-11-21 16:34:24 +0000 |
1877 | @@ -243,10 +243,8 @@ |
1878 | final Checkpoint checkpoint1 = _persistit.getCheckpointManager().createCheckpoint(); |
1879 | jman.writeCheckpointToJournal(checkpoint1); |
1880 | _persistit.checkpoint(); |
1881 | - final Properties saveProperties = _persistit.getProperties(); |
1882 | _persistit.close(); |
1883 | - _persistit = new Persistit(); |
1884 | - _persistit.initialize(saveProperties); |
1885 | + _persistit = new Persistit(_config); |
1886 | _persistit.getJournalManager().setAppendOnly(true); |
1887 | final RecoveryManager rman = new RecoveryManager(_persistit); |
1888 | rman.init(path); |
1889 | @@ -390,10 +388,8 @@ |
1890 | txn.end(); |
1891 | } |
1892 | _persistit.getJournalManager().rollover(); |
1893 | - final Properties saveProperties = _persistit.getProperties(); |
1894 | _persistit.close(); |
1895 | - _persistit = new Persistit(); |
1896 | - _persistit.initialize(saveProperties); |
1897 | + _persistit = new Persistit(_config); |
1898 | |
1899 | acc = _persistit.getVolume("persistit").getTree("JournalManagerTest", true) |
1900 | .getAccumulator(Accumulator.Type.SUM, 0); |
1901 | @@ -458,11 +454,10 @@ |
1902 | |
1903 | @Test |
1904 | public void missingVolumePageHandling() throws Exception { |
1905 | - final Configuration config = _persistit.getConfiguration(); |
1906 | - Volume volume1 = new Volume(config.volumeSpecification("${datapath}/missing1,create," |
1907 | + Volume volume1 = new Volume(_config.volumeSpecification("${datapath}/missing1,create," |
1908 | + "pageSize:16384,initialPages:1,extensionPages:1,maximumPages:25000")); |
1909 | volume1.open(_persistit); |
1910 | - Volume volume2 = new Volume(config.volumeSpecification("${datapath}/missing2,create," |
1911 | + Volume volume2 = new Volume(_config.volumeSpecification("${datapath}/missing2,create," |
1912 | + "pageSize:16384,initialPages:1,extensionPages:1,maximumPages:25000")); |
1913 | volume2.open(_persistit); |
1914 | _persistit.getExchange(volume1, "test1", true); |
1915 | @@ -472,8 +467,7 @@ |
1916 | new File(volume2.getPath()).delete(); |
1917 | volume1 = null; |
1918 | volume2 = null; |
1919 | - _persistit = new Persistit(); |
1920 | - _persistit.initialize(config); |
1921 | + _persistit = new Persistit(_config); |
1922 | final AlertMonitor am = _persistit.getAlertMonitor(); |
1923 | assertTrue("Startup with missing volumes should have generated alerts", |
1924 | am.getHistory(AlertMonitor.MISSING_VOLUME_CATEGORY) != null); |
1925 | @@ -489,8 +483,7 @@ |
1926 | |
1927 | @Test |
1928 | public void missingVolumeTransactionHandlingNotIgnored() throws Exception { |
1929 | - final Configuration config = _persistit.getConfiguration(); |
1930 | - Volume volume = new Volume(config.volumeSpecification("${datapath}/missing1,create," |
1931 | + Volume volume = new Volume(_config.volumeSpecification("${datapath}/missing1,create," |
1932 | + "pageSize:16384,initialPages:1,extensionPages:1,maximumPages:25000")); |
1933 | volume.open(_persistit); |
1934 | final Exchange ex = _persistit.getExchange(volume, "test1", true); |
1935 | @@ -504,16 +497,14 @@ |
1936 | _persistit.crash(); |
1937 | new File(volume.getPath()).delete(); |
1938 | volume = null; |
1939 | - _persistit = new Persistit(); |
1940 | - _persistit.initialize(config); |
1941 | + _persistit = new Persistit(_config); |
1942 | assertTrue("Should have failed updates during recovery", _persistit.getRecoveryManager().getPlayer() |
1943 | .getFailedUpdates() > 0); |
1944 | } |
1945 | |
1946 | @Test |
1947 | public void missingVolumeTransactionHandlingIgnored() throws Exception { |
1948 | - final Configuration config = _persistit.getConfiguration(); |
1949 | - Volume volume = new Volume(config.volumeSpecification("${datapath}/missing1,create," |
1950 | + Volume volume = new Volume(_config.volumeSpecification("${datapath}/missing1,create," |
1951 | + "pageSize:16384,initialPages:1,extensionPages:1,maximumPages:25000")); |
1952 | volume.open(_persistit); |
1953 | final Exchange ex = _persistit.getExchange(volume, "test1", true); |
1954 | @@ -527,10 +518,11 @@ |
1955 | _persistit.crash(); |
1956 | new File(volume.getPath()).delete(); |
1957 | volume = null; |
1958 | - config.setIgnoreMissingVolumes(true); |
1959 | + _config.setIgnoreMissingVolumes(true); |
1960 | _persistit = new Persistit(); |
1961 | _persistit.getJournalManager().setIgnoreMissingVolumes(true); |
1962 | - _persistit.initialize(config); |
1963 | + _persistit.setConfiguration(_config); |
1964 | + _persistit.initialize(); |
1965 | final AlertMonitor am = _persistit.getAlertMonitor(); |
1966 | assertTrue("Startup with missing volumes should have generated alerts", |
1967 | am.getHistory(AlertMonitor.MISSING_VOLUME_CATEGORY) != null); |
1968 | |
1969 | === modified file 'src/test/java/com/persistit/PersistitUnitTestCase.java' |
1970 | --- src/test/java/com/persistit/PersistitUnitTestCase.java 2012-08-30 16:19:35 +0000 |
1971 | +++ src/test/java/com/persistit/PersistitUnitTestCase.java 2012-11-21 16:34:24 +0000 |
1972 | @@ -47,6 +47,8 @@ |
1973 | |
1974 | protected Persistit _persistit = new Persistit(); |
1975 | |
1976 | + protected Configuration _config; |
1977 | + |
1978 | protected Properties getProperties(final boolean cleanup) { |
1979 | return UnitTestProperties.getProperties(cleanup); |
1980 | } |
1981 | @@ -54,7 +56,9 @@ |
1982 | @Before |
1983 | public void setUp() throws Exception { |
1984 | checkNoPersistitThreads(); |
1985 | - _persistit.initialize(getProperties(true)); |
1986 | + _persistit.setProperties(getProperties(true)); |
1987 | + _persistit.initialize(); |
1988 | + _config = _persistit.getConfiguration(); |
1989 | } |
1990 | |
1991 | @After |
1992 | @@ -109,18 +113,14 @@ |
1993 | } |
1994 | |
1995 | protected void safeCrashAndRestoreProperties() throws PersistitException { |
1996 | - final Properties properties = _persistit.getProperties(); |
1997 | _persistit.flush(); |
1998 | _persistit.crash(); |
1999 | - _persistit = new Persistit(); |
2000 | - _persistit.initialize(properties); |
2001 | + _persistit = new Persistit(_config); |
2002 | } |
2003 | |
2004 | protected void crashWithoutFlushAndRestoreProperties() throws PersistitException { |
2005 | - final Properties properties = _persistit.getProperties(); |
2006 | _persistit.crash(); |
2007 | - _persistit = new Persistit(); |
2008 | - _persistit.initialize(properties); |
2009 | + _persistit = new Persistit(_config); |
2010 | } |
2011 | |
2012 | public static boolean doesRefBecomeNull(final WeakReference<?> ref) throws InterruptedException { |
2013 | |
2014 | === modified file 'src/test/java/com/persistit/RecoveryTest.java' |
2015 | --- src/test/java/com/persistit/RecoveryTest.java 2012-10-05 23:08:51 +0000 |
2016 | +++ src/test/java/com/persistit/RecoveryTest.java 2012-11-21 16:34:24 +0000 |
2017 | @@ -48,12 +48,14 @@ |
2018 | |
2019 | private String journalSize = "10000000"; |
2020 | private final String _volumeName = "persistit"; |
2021 | + private Configuration _config; |
2022 | |
2023 | @Override |
2024 | public void setUp() throws Exception { |
2025 | super.setUp(); |
2026 | _persistit.getJournalManager().setRollbackPruningEnabled(false); |
2027 | _persistit.getJournalManager().setWritePagePruningEnabled(false); |
2028 | + _config = _persistit.getConfiguration(); |
2029 | |
2030 | } |
2031 | |
2032 | @@ -69,9 +71,7 @@ |
2033 | _persistit.getJournalManager().setAppendOnly(true); |
2034 | store1(); |
2035 | _persistit.close(); |
2036 | - final Properties saveProperties = _persistit.getProperties(); |
2037 | - _persistit = new Persistit(); |
2038 | - _persistit.initialize(saveProperties); |
2039 | + _persistit = new Persistit(_config); |
2040 | final JournalManager logMan = _persistit.getJournalManager(); |
2041 | assertTrue(logMan.getPageMapSize() + logMan.getCopiedPageCount() > 0); |
2042 | fetch1a(); |
2043 | @@ -88,9 +88,7 @@ |
2044 | jman.copyBack(); |
2045 | assertEquals(0, jman.getPageMapSize()); |
2046 | _persistit.close(); |
2047 | - final Properties saveProperties = _persistit.getProperties(); |
2048 | - _persistit = new Persistit(); |
2049 | - _persistit.initialize(saveProperties); |
2050 | + _persistit = new Persistit(_config); |
2051 | jman = _persistit.getJournalManager(); |
2052 | // opening a volume modifies its head page |
2053 | assertTrue(jman.getPageMapSize() <= 1); |
2054 | @@ -105,12 +103,12 @@ |
2055 | store2(); |
2056 | _persistit.getJournalManager().flush(); |
2057 | _persistit.crash(); |
2058 | - final Properties saveProperties = _persistit.getProperties(); |
2059 | _persistit = new Persistit(); |
2060 | _persistit.getJournalManager().setAppendOnly(true); |
2061 | final RecoveryManager plan = _persistit.getRecoveryManager(); |
2062 | plan.setRecoveryDisabledForTestMode(true); |
2063 | - _persistit.initialize(saveProperties); |
2064 | + _persistit.setConfiguration(_config); |
2065 | + _persistit.initialize(); |
2066 | assertEquals(15, plan.getCommittedCount()); |
2067 | plan.setRecoveryDisabledForTestMode(false); |
2068 | final Set<Long> recoveryTimestamps = new HashSet<Long>(); |
2069 | @@ -174,12 +172,12 @@ |
2070 | fetch3(); |
2071 | _persistit.getJournalManager().flush(); |
2072 | _persistit.crash(); |
2073 | - final Properties saveProperties = _persistit.getProperties(); |
2074 | _persistit = new Persistit(); |
2075 | _persistit.getJournalManager().setAppendOnly(true); |
2076 | final RecoveryManager rman = _persistit.getRecoveryManager(); |
2077 | rman.setRecoveryDisabledForTestMode(true); |
2078 | - _persistit.initialize(saveProperties); |
2079 | + _persistit.setConfiguration(_config); |
2080 | + _persistit.initialize(); |
2081 | assertTrue(rman.getCommittedCount() > 0); |
2082 | rman.setRecoveryDisabledForTestMode(false); |
2083 | rman.applyAllRecoveredTransactions(rman.getDefaultCommitListener(), rman.getDefaultRollbackListener()); |
2084 | @@ -295,9 +293,7 @@ |
2085 | exchanges = null; |
2086 | _persistit.getJournalManager().flush(); |
2087 | _persistit.crash(); |
2088 | - final Properties saveProperties = _persistit.getProperties(); |
2089 | - _persistit = new Persistit(); |
2090 | - _persistit.initialize(saveProperties); |
2091 | + _persistit = new Persistit(_config); |
2092 | final Volume volume = _persistit.getVolume("persistit"); |
2093 | |
2094 | for (int index = 0; index < 5; index++) { |
2095 | @@ -368,9 +364,7 @@ |
2096 | // retrieve the value of the handle counter before crashing |
2097 | final int initialHandleValue = _persistit.getJournalManager().getHandleCount(); |
2098 | _persistit.close(); |
2099 | - Properties saveProperties = _persistit.getProperties(); |
2100 | - _persistit = new Persistit(); |
2101 | - _persistit.initialize(saveProperties); |
2102 | + _persistit = new Persistit(_config); |
2103 | // verify the value of the handle counter after recovery is |
2104 | // still valid. |
2105 | assertTrue(_persistit.getJournalManager().getHandleCount() > initialHandleValue); |
2106 | @@ -381,9 +375,7 @@ |
2107 | _persistit.getJournalManager().handleForTree(td, true); |
2108 | final int updatedHandleValue = _persistit.getJournalManager().getHandleCount(); |
2109 | _persistit.close(); |
2110 | - saveProperties = _persistit.getProperties(); |
2111 | - _persistit = new Persistit(); |
2112 | - _persistit.initialize(saveProperties); |
2113 | + _persistit = new Persistit(_config); |
2114 | // verify the value of the handle counter after recovery is |
2115 | // still valid. |
2116 | assertTrue(_persistit.getJournalManager().getHandleCount() > updatedHandleValue); |
2117 | @@ -440,10 +432,10 @@ |
2118 | } |
2119 | _persistit.crash(); |
2120 | |
2121 | - final Properties saveProperties = _persistit.getProperties(); |
2122 | _persistit = new Persistit(); |
2123 | _persistit.getJournalManager().setAppendOnly(true); |
2124 | - _persistit.initialize(saveProperties); |
2125 | + _persistit.setConfiguration(_config); |
2126 | + _persistit.initialize(); |
2127 | _persistit.checkAllVolumes(); |
2128 | |
2129 | final Volume volume = _persistit.getVolume("persistit"); |
2130 | @@ -478,11 +470,8 @@ |
2131 | for (int i = 0; i < count + 100; i++) { |
2132 | assertEquals(i < count, exchange.to(i).isValueDefined()); |
2133 | } |
2134 | - final Properties properties = _persistit.getProperties(); |
2135 | _persistit.close(); |
2136 | - |
2137 | - _persistit = new Persistit(); |
2138 | - _persistit.initialize(properties); |
2139 | + _persistit = new Persistit(_config); |
2140 | exchange = _persistit.getExchange(_volumeName, "RecoveryTest", false); |
2141 | for (int i = 0; i < count + 100; i++) { |
2142 | if (i < count && !exchange.to(i).isValueDefined()) { |
2143 | @@ -493,8 +482,7 @@ |
2144 | } |
2145 | |
2146 | _persistit.close(); |
2147 | - _persistit = new Persistit(); |
2148 | - _persistit.initialize(properties); |
2149 | + _persistit = new Persistit(_config); |
2150 | exchange = _persistit.getExchange(_volumeName, "RecoveryTest", false); |
2151 | for (int i = 0; i < count + 100; i++) { |
2152 | assertEquals(i < count, exchange.to(i).isValueDefined()); |
2153 | @@ -507,12 +495,10 @@ |
2154 | @Test |
2155 | @Deprecated |
2156 | public void testNormalRestartUseOldVSpec() throws Exception { |
2157 | - final Configuration config = _persistit.getConfiguration(); |
2158 | _persistit.close(); |
2159 | UnitTestProperties.cleanUpDirectory(new File(UnitTestProperties.DATA_PATH)); |
2160 | - config.setUseOldVSpec(true); |
2161 | - _persistit = new Persistit(); |
2162 | - _persistit.initialize(config); |
2163 | + _config.setUseOldVSpec(true); |
2164 | + _persistit = new Persistit(_config); |
2165 | |
2166 | final JournalManager jman = _persistit.getJournalManager(); |
2167 | Exchange exchange = _persistit.getExchange(_volumeName, "RecoveryTest", true); |
2168 | @@ -532,8 +518,7 @@ |
2169 | } |
2170 | _persistit.close(); |
2171 | |
2172 | - _persistit = new Persistit(); |
2173 | - _persistit.initialize(config); |
2174 | + _persistit = new Persistit(_config); |
2175 | exchange = _persistit.getExchange(_volumeName, "RecoveryTest", false); |
2176 | for (int i = 0; i < count + 100; i++) { |
2177 | if (i < count && !exchange.to(i).isValueDefined()) { |
2178 | @@ -544,8 +529,7 @@ |
2179 | } |
2180 | |
2181 | _persistit.close(); |
2182 | - _persistit = new Persistit(); |
2183 | - _persistit.initialize(config); |
2184 | + _persistit = new Persistit(_config); |
2185 | exchange = _persistit.getExchange(_volumeName, "RecoveryTest", false); |
2186 | for (int i = 0; i < count + 100; i++) { |
2187 | assertEquals(i < count, exchange.to(i).isValueDefined()); |
2188 | |
2189 | === modified file 'src/test/java/com/persistit/StatisticsTaskTest.java' |
2190 | --- src/test/java/com/persistit/StatisticsTaskTest.java 2012-11-19 16:35:35 +0000 |
2191 | +++ src/test/java/com/persistit/StatisticsTaskTest.java 2012-11-21 16:34:24 +0000 |
2192 | @@ -15,7 +15,11 @@ |
2193 | |
2194 | package com.persistit; |
2195 | |
2196 | -import static com.persistit.StatisticsTask.*; |
2197 | +import static com.persistit.StatisticsTask.COUNT_FORMAT; |
2198 | +import static com.persistit.StatisticsTask.PCOUNT_FORMAT; |
2199 | +import static com.persistit.StatisticsTask.PHEADER_FORMAT; |
2200 | +import static com.persistit.StatisticsTask.PRATE_FORMAT; |
2201 | +import static com.persistit.StatisticsTask.RATE_FORMAT; |
2202 | import static org.junit.Assert.assertEquals; |
2203 | |
2204 | import java.io.BufferedReader; |
2205 | |
2206 | === modified file 'src/test/java/com/persistit/TreeTest2.java' |
2207 | --- src/test/java/com/persistit/TreeTest2.java 2012-08-24 13:57:19 +0000 |
2208 | +++ src/test/java/com/persistit/TreeTest2.java 2012-11-21 16:34:24 +0000 |
2209 | @@ -51,11 +51,9 @@ |
2210 | txn.end(); |
2211 | } |
2212 | |
2213 | - final Properties properties = _persistit.getProperties(); |
2214 | _persistit.getJournalManager().flush(); |
2215 | _persistit.crash(); |
2216 | - _persistit = new Persistit(); |
2217 | - _persistit.initialize(properties); |
2218 | + _persistit = new Persistit(_config); |
2219 | |
2220 | volume = _persistit.getVolume("persistit"); |
2221 | assertTrue(1 != volume.getStructure().directoryExchange().getTree().getRootPageAddr()); |
2222 | |
2223 | === modified file 'src/test/java/com/persistit/VolumeTest.java' |
2224 | --- src/test/java/com/persistit/VolumeTest.java 2012-10-05 23:08:51 +0000 |
2225 | +++ src/test/java/com/persistit/VolumeTest.java 2012-11-21 16:34:24 +0000 |
2226 | @@ -233,7 +233,6 @@ |
2227 | _persistit.copyBackPages(); |
2228 | |
2229 | final List<File> journalFiles = _persistit.getJournalManager().unitTestGetAllJournalFiles(); |
2230 | - final Properties properties = _persistit.getProperties(); |
2231 | _persistit.crash(); |
2232 | |
2233 | /* |
2234 | @@ -244,8 +243,7 @@ |
2235 | assertEquals("Deleted journal file " + file.getName(), true, success); |
2236 | } |
2237 | |
2238 | - _persistit = new Persistit(); |
2239 | - _persistit.initialize(properties); |
2240 | + _persistit = new Persistit(_config); |
2241 | } |
2242 | |
2243 | @Test |
2244 | |
2245 | === modified file 'src/test/java/com/persistit/WarmupTest.java' |
2246 | --- src/test/java/com/persistit/WarmupTest.java 2012-08-28 14:29:50 +0000 |
2247 | +++ src/test/java/com/persistit/WarmupTest.java 2012-11-21 16:34:24 +0000 |
2248 | @@ -46,12 +46,10 @@ |
2249 | buff[i] = pool.getBufferCopy(i); |
2250 | } |
2251 | |
2252 | - final Configuration config = _persistit.getConfiguration(); |
2253 | ex = null; |
2254 | _persistit.close(); |
2255 | |
2256 | - _persistit = new Persistit(); |
2257 | - _persistit.initialize(config); |
2258 | + _persistit = new Persistit(_config); |
2259 | ex = _persistit.getExchange("persistit", "WarmupTest", false); |
2260 | pool = ex.getBufferPool(); |
2261 | |
2262 | @@ -101,16 +99,16 @@ |
2263 | |
2264 | assertTrue("Buffer pool should have scrambled page address", breaks > 0); |
2265 | |
2266 | - final Configuration config = _persistit.getConfiguration(); |
2267 | ex = null; |
2268 | pool = null; |
2269 | _persistit.copyBackPages(); |
2270 | _persistit.close(); |
2271 | |
2272 | _persistit = new Persistit(); |
2273 | - config.setBufferInventoryEnabled(false); |
2274 | - config.setBufferPreloadEnabled(false); |
2275 | - _persistit.initialize(config); |
2276 | + _config.setBufferInventoryEnabled(false); |
2277 | + _config.setBufferPreloadEnabled(false); |
2278 | + _persistit.setConfiguration(_config); |
2279 | + _persistit.initialize(); |
2280 | |
2281 | final Volume volume = _persistit.getVolume("persistit"); |
2282 | final MediatedFileChannel mfc = (MediatedFileChannel) volume.getStorage().getChannel(); |
2283 | |
2284 | === modified file 'src/test/java/com/persistit/stress/AbstractSuite.java' |
2285 | --- src/test/java/com/persistit/stress/AbstractSuite.java 2012-10-23 19:08:32 +0000 |
2286 | +++ src/test/java/com/persistit/stress/AbstractSuite.java 2012-11-21 16:34:24 +0000 |
2287 | @@ -292,10 +292,7 @@ |
2288 | |
2289 | protected Persistit makePersistit(final int pageSize, final String mem, final CommitPolicy policy) |
2290 | throws PersistitException { |
2291 | - final Persistit persistit = new Persistit(); |
2292 | - persistit.initialize(makeConfiguration(pageSize, mem, policy)); |
2293 | - return persistit; |
2294 | - |
2295 | + return new Persistit(makeConfiguration(pageSize, mem, policy)); |
2296 | } |
2297 | |
2298 | protected Configuration makeConfiguration(final int pageSize, final String mem, final CommitPolicy policy) { |
2299 | |
2300 | === modified file 'src/test/java/com/persistit/stress/InsertBigLoad.java' |
2301 | --- src/test/java/com/persistit/stress/InsertBigLoad.java 2012-11-01 19:04:11 +0000 |
2302 | +++ src/test/java/com/persistit/stress/InsertBigLoad.java 2012-11-21 16:34:24 +0000 |
2303 | @@ -43,8 +43,7 @@ |
2304 | |
2305 | final Configuration config = makeConfiguration(16384, "50000", CommitPolicy.SOFT); |
2306 | config.setTmpVolMaxSize(100000000000l); |
2307 | - final Persistit persistit = new Persistit(); |
2308 | - persistit.initialize(config); |
2309 | + final Persistit persistit = new Persistit(config); |
2310 | |
2311 | try { |
2312 | execute(persistit); |
2313 | |
2314 | === modified file 'src/test/java/com/persistit/stress/PreloadMixtureTxn1.java' |
2315 | --- src/test/java/com/persistit/stress/PreloadMixtureTxn1.java 2012-08-23 20:36:42 +0000 |
2316 | +++ src/test/java/com/persistit/stress/PreloadMixtureTxn1.java 2012-11-21 16:34:24 +0000 |
2317 | @@ -69,8 +69,7 @@ |
2318 | configuration.setBufferInventoryEnabled(true); |
2319 | configuration.setBufferPreloadEnabled(true); |
2320 | |
2321 | - final Persistit persistit = new Persistit(); |
2322 | - persistit.initialize(configuration); |
2323 | + final Persistit persistit = new Persistit(configuration); |
2324 | |
2325 | try { |
2326 | execute(persistit); |
2327 | |
2328 | === modified file 'src/test/java/com/persistit/stress/unit/BigLoad.java' |
2329 | --- src/test/java/com/persistit/stress/unit/BigLoad.java 2012-11-01 19:04:11 +0000 |
2330 | +++ src/test/java/com/persistit/stress/unit/BigLoad.java 2012-11-21 16:34:24 +0000 |
2331 | @@ -195,7 +195,8 @@ |
2332 | final BigLoad bl = new BigLoad(records, buckets); |
2333 | final Persistit db = new Persistit(); |
2334 | if (args.length > 2) { |
2335 | - db.initialize(args[2]); |
2336 | + db.setPropertiesFromFile(args[2]); |
2337 | + db.initialize(); |
2338 | } else { |
2339 | db.initialize(); |
2340 | } |
2341 | |
2342 | === modified file 'src/test/java/com/persistit/unit/BufferPoolMemConfigurationTest.java' |
2343 | --- src/test/java/com/persistit/unit/BufferPoolMemConfigurationTest.java 2012-08-24 13:57:19 +0000 |
2344 | +++ src/test/java/com/persistit/unit/BufferPoolMemConfigurationTest.java 2012-11-21 16:34:24 +0000 |
2345 | @@ -36,7 +36,8 @@ |
2346 | @Test |
2347 | public void testBufferMemConfiguration() throws Exception { |
2348 | final Properties properties = UnitTestProperties.getPropertiesByMemory(true, "1M"); |
2349 | - _persistit.initialize(properties); |
2350 | + _persistit.setProperties(properties); |
2351 | + _persistit.initialize(); |
2352 | final BufferPoolInfo[] infoArray = _persistit.getManagement().getBufferPoolInfoArray(); |
2353 | assertEquals(1, infoArray.length); |
2354 | final int bufferSize = infoArray[0].getBufferSize(); |
2355 | @@ -50,7 +51,8 @@ |
2356 | public void testBufferMemConfigurationErrors() throws Exception { |
2357 | Properties properties = UnitTestProperties.getPropertiesByMemory(true, "1000,999"); |
2358 | try { |
2359 | - _persistit.initialize(properties); |
2360 | + _persistit.setProperties(properties); |
2361 | + _persistit.initialize(); |
2362 | fail("Accepted allocation 10000 bytes"); |
2363 | } catch (final IllegalArgumentException e) { |
2364 | // okay |
2365 | @@ -58,7 +60,8 @@ |
2366 | |
2367 | properties = UnitTestProperties.getPropertiesByMemory(true, "10000G"); |
2368 | try { |
2369 | - _persistit.initialize(properties); |
2370 | + _persistit.setProperties(properties); |
2371 | + _persistit.initialize(); |
2372 | fail("Accepted allocation 10000G bytes"); |
2373 | } catch (final IllegalArgumentException e) { |
2374 | // okay |
2375 | @@ -67,7 +70,8 @@ |
2376 | properties = UnitTestProperties.getPropertiesByMemory(true, "10M"); |
2377 | properties.put("buffer.count.16384", "1234"); |
2378 | try { |
2379 | - _persistit.initialize(properties); |
2380 | + _persistit.setProperties(properties); |
2381 | + _persistit.initialize(); |
2382 | fail("Accepted allocation specified by both count and size"); |
2383 | } catch (final IllegalArgumentException e) { |
2384 | // okay |
2385 | |
2386 | === modified file 'src/test/java/com/persistit/unit/FileLockTest.java' |
2387 | --- src/test/java/com/persistit/unit/FileLockTest.java 2012-08-24 13:57:19 +0000 |
2388 | +++ src/test/java/com/persistit/unit/FileLockTest.java 2012-11-21 16:34:24 +0000 |
2389 | @@ -39,7 +39,8 @@ |
2390 | final Properties properties = _persistit.getProperties(); |
2391 | final Persistit p2 = new Persistit(); |
2392 | try { |
2393 | - p2.initialize(properties); |
2394 | + p2.setProperties(properties); |
2395 | + p2.initialize(); |
2396 | fail("Created second Persistit instance"); |
2397 | } catch (final PersistitException pe) { |
2398 | // success - we intended to fail |
2399 | @@ -51,7 +52,8 @@ |
2400 | final Persistit p3 = new Persistit(); |
2401 | // now this should succeed. |
2402 | try { |
2403 | - p3.initialize(properties); |
2404 | + p3.setProperties(properties); |
2405 | + p3.initialize(); |
2406 | } finally { |
2407 | p3.close(false); |
2408 | } |
2409 | |
2410 | === modified file 'src/test/java/com/persistit/unit/Log4JLoggerTest.java' |
2411 | --- src/test/java/com/persistit/unit/Log4JLoggerTest.java 2012-08-24 13:57:19 +0000 |
2412 | +++ src/test/java/com/persistit/unit/Log4JLoggerTest.java 2012-11-21 16:34:24 +0000 |
2413 | @@ -43,7 +43,8 @@ |
2414 | BasicConfigurator.configure(); |
2415 | final Persistit persistit = new Persistit(); |
2416 | persistit.setPersistitLogger(new Log4JAdapter(logger)); |
2417 | - persistit.initialize(UnitTestProperties.getAlternateProperties(true)); |
2418 | + persistit.setProperties(UnitTestProperties.getAlternateProperties(true)); |
2419 | + persistit.initialize(); |
2420 | try { |
2421 | test1(); |
2422 | } finally { |
2423 | |
2424 | === added file 'src/test/java/com/persistit/unit/SpringFrameworkConfigurationTest.java' |
2425 | --- src/test/java/com/persistit/unit/SpringFrameworkConfigurationTest.java 1970-01-01 00:00:00 +0000 |
2426 | +++ src/test/java/com/persistit/unit/SpringFrameworkConfigurationTest.java 2012-11-21 16:34:24 +0000 |
2427 | @@ -0,0 +1,65 @@ |
2428 | +/** |
2429 | + * Copyright © 2011-2012 Akiban Technologies, Inc. All rights reserved. |
2430 | + * |
2431 | + * This program and the accompanying materials are made available |
2432 | + * under the terms of the Eclipse Public License v1.0 which |
2433 | + * accompanies this distribution, and is available at |
2434 | + * http://www.eclipse.org/legal/epl-v10.html |
2435 | + * |
2436 | + * This program may also be available under different license terms. |
2437 | + * For more information, see www.akiban.com or contact licensing@akiban.com. |
2438 | + * |
2439 | + * Contributors: |
2440 | + * Akiban Technologies, Inc. |
2441 | + */ |
2442 | + |
2443 | +package com.persistit.unit; |
2444 | + |
2445 | +import static org.junit.Assert.assertTrue; |
2446 | + |
2447 | +import org.junit.Test; |
2448 | +import org.springframework.context.ApplicationContext; |
2449 | +import org.springframework.context.support.ClassPathXmlApplicationContext; |
2450 | + |
2451 | +import com.persistit.Persistit; |
2452 | +import com.persistit.exception.PersistitException; |
2453 | + |
2454 | +/** |
2455 | + * Create a Persistit instance using Spring Framework. |
2456 | + * |
2457 | + * @author peter |
2458 | + * |
2459 | + */ |
2460 | +public class SpringFrameworkConfigurationTest { |
2461 | + |
2462 | + public static class TestClient { |
2463 | + final Persistit db; |
2464 | + |
2465 | + public TestClient(final Persistit db) { |
2466 | + this.db = db; |
2467 | + } |
2468 | + |
2469 | + private void test() { |
2470 | + System.out.println(db.getVolumes()); |
2471 | + try { |
2472 | + db.close(); |
2473 | + } catch (final PersistitException e) { |
2474 | + e.printStackTrace(); |
2475 | + } |
2476 | + } |
2477 | + } |
2478 | + |
2479 | + @Test |
2480 | + public void configurePersistitFromSpring() throws Exception { |
2481 | + System.setProperty("com.persistit.datapath", UnitTestProperties.DATA_PATH); |
2482 | + final ApplicationContext context = new ClassPathXmlApplicationContext( |
2483 | + "com/persistit/unit/SpringFrameworkConfiguraitonTest.xml"); |
2484 | + |
2485 | + final Persistit persistit = (Persistit) context.getBean("persistit"); |
2486 | + assertTrue("Persistit should be initialized", persistit.isInitialized()); |
2487 | + |
2488 | + final TestClient testClient = (TestClient) context.getBean("testClient"); |
2489 | + testClient.test(); |
2490 | + } |
2491 | + |
2492 | +} |
2493 | |
2494 | === added directory 'src/test/resources/com/persistit/unit' |
2495 | === added file 'src/test/resources/com/persistit/unit/SpringFrameworkConfiguraitonTest.xml' |
2496 | --- src/test/resources/com/persistit/unit/SpringFrameworkConfiguraitonTest.xml 1970-01-01 00:00:00 +0000 |
2497 | +++ src/test/resources/com/persistit/unit/SpringFrameworkConfiguraitonTest.xml 2012-11-21 16:34:24 +0000 |
2498 | @@ -0,0 +1,34 @@ |
2499 | +<?xml version="1.0" encoding="UTF-8"?> |
2500 | + |
2501 | +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
2502 | + xsi:schemaLocation="http://www.springframework.org/schema/beans |
2503 | + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> |
2504 | + |
2505 | + <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> |
2506 | + <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /> |
2507 | + </bean> |
2508 | + |
2509 | + <bean id="persistit" class="com.persistit.Persistit" init-method="initialize"> |
2510 | + <property name="configuration"> |
2511 | + <bean class="com.persistit.Configuration"> |
2512 | + <property name="bufferPoolConfiguration" value="16384,count=1000" /> |
2513 | + <property name="volumeList"> |
2514 | + <list> |
2515 | + <bean class="com.persistit.VolumeSpecification"> |
2516 | + <constructor-arg |
2517 | + value="${com.persistit.datapath}/persistit,create,pageSize:16384,initialPages:100,extensionPages:100,maximumPages:25000" /> |
2518 | + </bean> |
2519 | + </list> |
2520 | + </property> |
2521 | + <property name="journalPath" value="${com.persistit.datapath}/persistit_journal" /> |
2522 | + </bean> |
2523 | + </property> |
2524 | + </bean> |
2525 | + |
2526 | + <bean id="testClient" class="com.persistit.unit.SpringFrameworkConfigurationTest.TestClient"> |
2527 | + <constructor-arg> |
2528 | + <ref local="persistit" /> |
2529 | + </constructor-arg> |
2530 | + </bean> |
2531 | + |
2532 | +</beans> |
2533 | \ No newline at end of file |
I refactored away the Persistit# substitutePrope rties method too soon. Server trunk still uses it.