Skip to content

Commit 4f41ced

Browse files
Merge pull request #59 from icatproject/commit-thread
Allow auto-commit to be disabled
2 parents 55e5741 + 138c2e4 commit 4f41ced

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/main/config/run.properties.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# are marked with '!'
33

44
directory = ${HOME}/data/search
5-
commitSeconds = 5
5+
# A value of 0 will disable automatic commits and rely on icat.server to explicitly call commit after creating new documents
6+
commitSeconds = 0
67
# Lucene limits the max number of documents in an index to Integer.MAX_VALUE - 128
78
maxShardSize = 2147483519
89
ip = 127.0.0.1/32

src/main/java/org/icatproject/lucene/Lucene.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ private void init() {
10611061
throw new Exception(luceneDirectory + " is not a directory");
10621062
}
10631063

1064-
commitSeconds = props.getPositiveInt("commitSeconds");
1064+
commitSeconds = props.getNonNegativeInt("commitSeconds");
10651065
luceneCommitMillis = commitSeconds * 1000;
10661066
luceneMaxShardSize = Math.min(props.getPositiveLong("maxShardSize"), Long.valueOf(Integer.MAX_VALUE - 128));
10671067
maxSearchTimeSeconds = props.has("maxSearchTimeSeconds") ? props.getPositiveLong("maxSearchTimeSeconds")
@@ -1092,8 +1092,10 @@ private void init() {
10921092
* Starts a timer and schedules regular commits of the IndexWriter.
10931093
*/
10941094
private void initTimer() {
1095-
timer = new Timer("LuceneCommitTimer");
1096-
timer.schedule(new CommitTimerTask(), luceneCommitMillis, luceneCommitMillis);
1095+
if (luceneCommitMillis > 0) {
1096+
timer = new Timer("LuceneCommitTimer");
1097+
timer.schedule(new CommitTimerTask(), luceneCommitMillis, luceneCommitMillis);
1098+
}
10971099
}
10981100

10991101
class CommitTimerTask extends TimerTask {

src/main/resources/run.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# are marked with '!'
33

44
directory = ${HOME}/data/search
5-
commitSeconds = 5
5+
# A value of 0 will disable automatic commits and rely on icat.server to explicitly call commit after creating new documents
6+
commitSeconds = 0
67
maxShardSize = 2147483519
78
ip = 127.0.0.1/32
89
# A search taking longer than this will be cancelled to avoid blocking other users' searches

src/site/xhtml/installation.xhtml.vm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454

5555
<dt>commitSeconds</dt>
5656
<dd>the interval in seconds between committing lucene changes to
57-
disk and updating the index.</dd>
57+
disk and updating the index. Automatic commits can be disabled by setting to
58+
0, in which case icat.server will need to explicitly commit after creating a
59+
batch of documents.</dd>
5860

5961
<dt>maxShardSize</dt>
6062
<dd>The maximum number of documents to store in a single index before "sharding"

0 commit comments

Comments
 (0)