• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eXist-db / exist / 40117496345

24 Oct 2026 05:44PM UTC coverage: 58.138% (-0.03%) from 58.172%
40117496345

push

github

web-flow
Merge pull request #6905 from duncdrum/dp-ci-jacoco-merged-artifact

[ci] Publish the JaCoCo reports as a develop artifact

32463 of 61732 branches covered (52.59%)

Branch coverage included in aggregate %.

85515 of 141197 relevant lines covered (60.56%)

2.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.55
/exist-core/src/main/java/org/exist/storage/SystemTaskManager.java
1
/*
2
 * eXist-db Open Source Native XML Database
3
 * Copyright (C) 2001 The eXist-db Authors
4
 *
5
 * info@exist-db.org
6
 * http://www.exist-db.org
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21
 */
22
package org.exist.storage;
23

24
import net.jcip.annotations.GuardedBy;
25
import org.apache.logging.log4j.LogManager;
26
import org.apache.logging.log4j.Logger;
27
import org.exist.EXistException;
28
import org.exist.storage.sync.Sync;
29
import org.exist.storage.txn.Txn;
30

31
import java.util.ArrayDeque;
32
import java.util.Deque;
33

34
public class SystemTaskManager implements BrokerPoolService {
35

36
    private final static Logger LOG = LogManager.getLogger(SystemTaskManager.class);
4 ✔
37

38
    /**
39
         * The pending system maintenance tasks of the database instance.
40
         */
41
    @GuardedBy("itself")
42
        private final Deque<SystemTask> waitingSystemTasks = new ArrayDeque<>();
5 ✔
43

44
    private final BrokerPool pool;
45
    
46
    public SystemTaskManager(final BrokerPool pool) {
2 ✔
47
        this.pool = pool;
3 ✔
48
    }
1 ✔
49

50
    public void addSystemTask(final SystemTask task) {
51
        synchronized (waitingSystemTasks) {
8 ✔
52
            waitingSystemTasks.push(task);
4 ✔
53
        }
54
    }
1 ✔
55

56
    /**
57
     * Process system tasks.
58
     *
59
     * @param systemBroker a broker running as the SYSTEM subject.
60
     * @param transaction the transaction
61
     */
62
    public void processTasks(final DBBroker systemBroker, final Txn transaction) {
63
        //dont run the task if we are shutting down
64
        if (pool.isShuttingDownOrDown()) {
4 !
65
            return;
×
66
        }
67

68
        // broker must be running as the SYSTEM subject
69
        if (!systemBroker.getCurrentSubject().equals(pool.getSecurityManager().getSystemSubject())) {
8 !
70
            throw new IllegalArgumentException("Process tasks requires a system broker");
×
71
        }
72

73
        synchronized (waitingSystemTasks) {
8 ✔
74
            if(!waitingSystemTasks.isEmpty()) {
4 ✔
75
                try {
76
                    while (!waitingSystemTasks.isEmpty()) {
5 ✔
77
                        final SystemTask task = waitingSystemTasks.pop();
5 ✔
78

79
                        if (pool.isShuttingDown()) {
4 !
80
                            LOG.info("Skipping SystemTask: '{}' as database is shutting down...", task.getName());
×
81
                        } else if (pool.isShutDown()) {
4 !
82
                            LOG.warn("Unable to execute SystemTask: '{}' as database is shut down!", task.getName());
×
83
                        } else {
×
84
                            if (task.afterCheckpoint()) {
3 ✔
85
                                pool.sync(systemBroker, Sync.MAJOR);
5 ✔
86
                            }
87
                            runSystemTask(task, systemBroker, transaction);
5 ✔
88
                        }
89
                    }
90
                } catch (final Exception e) {
1 ✔
91
                    LOG.error("System maintenance task reported error: {}", e.getMessage(), e);
×
92
                }
93
            }
94
        }
95
    }
1 ✔
96

97
    private void runSystemTask(final SystemTask task, final DBBroker broker, final Txn transaction) throws EXistException {
98
        if (LOG.isDebugEnabled()) {
3 !
99
            LOG.debug("Running system maintenance task: {}", task.getClass().getName());
×
100
        }
101

102
        task.execute(broker, transaction);
4 ✔
103

104
        if (LOG.isDebugEnabled()) {
3 !
105
            LOG.debug("System task completed.");
×
106
        }
107
    }
1 ✔
108
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc