Skip to content

Commit 4538da3

Browse files
authored
Merge branch 'develop' into feature/multivalued-hierarchical-facets
2 parents b39e0c8 + b0a7fc1 commit 4538da3

File tree

48 files changed

+2661
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2661
-439
lines changed

exist-core/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<dependency>
3636
<groupId>com.fasterxml.jackson.core</groupId>
3737
<artifactId>jackson-core</artifactId>
38-
<version>2.10.1</version>
38+
<version>2.10.2</version>
3939
</dependency>
4040

4141
<!-- dependency>
@@ -128,7 +128,7 @@
128128
<dependency>
129129
<groupId>org.lz4</groupId>
130130
<artifactId>lz4-java</artifactId>
131-
<version>1.7.0</version>
131+
<version>1.7.1</version>
132132
</dependency>
133133

134134
<dependency>
@@ -169,7 +169,7 @@
169169
<dependency>
170170
<groupId>org.jline</groupId>
171171
<artifactId>jline</artifactId>
172-
<version>3.13.2</version>
172+
<version>3.13.3</version>
173173
</dependency>
174174

175175
<dependency>
@@ -250,7 +250,7 @@
250250
<dependency>
251251
<groupId>org.exist-db.thirdparty.xerces</groupId>
252252
<artifactId>xercesImpl</artifactId>
253-
<version>2.12.0</version>
253+
<version>2.12.1</version>
254254
<classifier>xml-schema-1.1</classifier>
255255
</dependency>
256256

exist-core/src/main/java/org/exist/management/AgentFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222
package org.exist.management;
2323

24+
import net.jcip.annotations.ThreadSafe;
2425
import org.apache.logging.log4j.LogManager;
2526
import org.apache.logging.log4j.Logger;
2627

@@ -29,13 +30,14 @@
2930

3031
import static java.lang.invoke.MethodType.methodType;
3132

33+
@ThreadSafe
3234
public class AgentFactory {
3335

3436
private final static Logger LOG = LogManager.getLogger(AgentFactory.class);
3537

3638
private static Agent instance = null;
3739

38-
public static Agent getInstance() {
40+
public static synchronized Agent getInstance() {
3941
if (instance == null) {
4042
final String className = System.getProperty("exist.jmxagent", "org.exist.management.impl.JMXAgent");
4143
try {
@@ -48,7 +50,7 @@ public static Agent getInstance() {
4850
// 1. try for default constructor
4951
try {
5052
final MethodHandle mhConstructor = lookup.findConstructor(clazz, methodType(void.class));
51-
instance = (Agent) mhConstructor.invokeExact();
53+
instance = (Agent) mhConstructor.invoke();
5254
} catch (final NoSuchMethodException | IllegalAccessException e) {
5355
LOG.warn("No default constructor found for Agent: " + className + ". Will try singleton pattern...");
5456

exist-core/src/main/java/org/exist/management/impl/JMXAgent.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,19 @@
4141
/**
4242
* Real implementation of interface {@link org.exist.management.Agent}
4343
* which registers MBeans with the MBeanServer.
44+
*
45+
* Note that the agent will be constructed via reflection by the
46+
* {@link org.exist.management.AgentFactory}
4447
*/
45-
public class JMXAgent implements Agent {
48+
public final class JMXAgent implements Agent {
4649

4750
private static final Logger LOG = LogManager.getLogger(JMXAgent.class);
48-
private static final JMXAgent instance = new JMXAgent();
4951

5052
private final MBeanServer server;
5153
private final Map<String, Deque<ObjectName>> registeredMBeans = new HashMap<>();
5254
private final Map<ObjectName, Object> beanInstances = new HashMap<>();
5355

54-
public static Agent getInstance() {
55-
return instance;
56-
}
57-
58-
private JMXAgent() {
56+
public JMXAgent() {
5957
if (LOG.isDebugEnabled()) {
6058
LOG.debug("Creating the JMX MBeanServer.");
6159
}
@@ -67,13 +65,6 @@ private JMXAgent() {
6765
server = MBeanServerFactory.createMBeanServer();
6866
}
6967

70-
// try {
71-
// JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server");
72-
// JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
73-
// cs.start();
74-
// } catch (IOException e) {
75-
// LOG.warn("ERROR: failed to initialize JMX connector: " + e.getMessage(), e);
76-
// }
7768
registerSystemMBeans();
7869
}
7970

@@ -108,19 +99,14 @@ public synchronized void initDBInstance(final BrokerPool instance) {
10899

109100
@Override
110101
public synchronized void closeDBInstance(final BrokerPool instance) {
111-
try {
112-
final Deque<ObjectName> stack = registeredMBeans.get(instance.getId());
113-
while (!stack.isEmpty()) {
114-
final ObjectName on = stack.pop();
115-
if (LOG.isDebugEnabled()) {
116-
LOG.debug("Unregistering JMX MBean: " + on);
117-
}
118-
if (server.isRegistered(on)) {
119-
server.unregisterMBean(on);
120-
}
102+
final Deque<ObjectName> stack = registeredMBeans.get(instance.getId());
103+
while (!stack.isEmpty()) {
104+
final ObjectName on = stack.pop();
105+
if (LOG.isDebugEnabled()) {
106+
LOG.debug("deregistering JMX MBean: " + on);
121107
}
122-
} catch (final InstanceNotFoundException | MBeanRegistrationException e) {
123-
LOG.warn("Problem found while unregistering JMX", e);
108+
beanInstances.remove(on);
109+
removeMBean(on);
124110
}
125111
}
126112

@@ -155,6 +141,16 @@ private void addMBean(final ObjectName name, final Object mbean) throws Database
155141
}
156142
}
157143

144+
private void removeMBean(final ObjectName name) {
145+
try {
146+
if (server.isRegistered(name)) {
147+
server.unregisterMBean(name);
148+
}
149+
} catch (final InstanceNotFoundException | MBeanRegistrationException e) {
150+
LOG.warn("Problem unregistering mbean: " + e.getMessage(), e);
151+
}
152+
}
153+
158154
@Override
159155
public synchronized void changeStatus(final BrokerPool instance, final TaskStatus actualStatus) {
160156
try {

exist-core/src/main/java/org/exist/storage/BrokerPool.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,9 @@ void shutdown(final boolean killed, final Consumer<String> shutdownInstanceConsu
16881688
// final notification to database services to shutdown
16891689
servicesManager.shutdown();
16901690

1691+
// remove all remaining inactive brokers as we have shutdown now and no longer need those
1692+
inactiveBrokers.clear();
1693+
16911694
// deregister JMX MBeans
16921695
AgentFactory.getInstance().closeDBInstance(this);
16931696

@@ -1732,7 +1735,7 @@ void shutdown(final boolean killed, final Consumer<String> shutdownInstanceConsu
17321735

17331736
notificationService = null;
17341737
statusObservers.clear();
1735-
1738+
startupTriggersManager = null;
17361739
statusReporter.terminate();
17371740
statusReporter = null;
17381741

exist-core/src/main/java/org/exist/storage/BrokerPoolServicesManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,5 +297,7 @@ void shutdown() {
297297
}
298298
brokerPoolService.shutdown();
299299
}
300+
301+
brokerPoolServices.clear();
300302
}
301303
}

exist-core/src/main/java/org/exist/storage/ContentLoadingObserver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public interface ContentLoadingObserver extends AutoCloseable {
108108
@Override
109109
void close() throws DBException;
110110

111-
void closeAndRemove();
111+
void closeAndRemove() throws DBException;
112112

113113
void printStatistics();
114114

exist-core/src/main/java/org/exist/storage/DefaultCacheManager.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.text.NumberFormat;
3434

3535
import java.util.ArrayList;
36+
import java.util.Iterator;
3637
import java.util.List;
3738

3839

@@ -172,13 +173,10 @@ public void registerCache( Cache cache )
172173
@Override
173174
public void deregisterCache( Cache cache )
174175
{
175-
Cache next;
176-
177-
for( int i = 0; i < caches.size(); i++ ) {
178-
next = (Cache)caches.get( i );
179-
180-
if( cache == next ) {
181-
caches.remove( i );
176+
for (final Iterator<Cache> cacheIt = caches.iterator(); cacheIt.hasNext(); ) {
177+
if (cache == cacheIt.next()) {
178+
cache.setCacheManager( null );
179+
cacheIt.remove();
182180
break;
183181
}
184182
}

exist-core/src/main/java/org/exist/storage/NativeBroker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ private void notifyClose() throws DBException {
333333
clearContentLoadingObservers();
334334
}
335335

336-
private void notifyCloseAndRemove() {
336+
private void notifyCloseAndRemove() throws DBException {
337337
for(final ContentLoadingObserver observer : contentLoadingObservers) {
338338
observer.closeAndRemove();
339339
}
@@ -3626,8 +3626,8 @@ public void repair() throws PermissionDeniedException, IOException, LockExceptio
36263626
}
36273627

36283628
LOG.info("Removing index files ...");
3629-
notifyCloseAndRemove();
36303629
try {
3630+
notifyCloseAndRemove();
36313631
pool.getIndexManager().removeIndexes();
36323632
} catch(final DBException e) {
36333633
LOG.error("Failed to remove index files during repair: " + e.getMessage(), e);

exist-core/src/main/java/org/exist/storage/NativeValueIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ private AtomicValue convertToAtomic(final int xpathType, final String value) {
10481048
}
10491049

10501050
@Override
1051-
public void closeAndRemove() {
1051+
public void closeAndRemove() throws DBException {
10521052
try(final ManagedLock<ReentrantLock> bfileLock = lockManager.acquireBtreeWriteLock(dbValues.getLockName())) {
10531053
config.setProperty(getConfigKeyForFile(), null);
10541054
dbValues.closeAndRemove();

exist-core/src/main/java/org/exist/storage/btree/BTree.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,6 @@ public boolean open(final short expectedVersion) throws DBException {
217217
}
218218
}
219219

220-
@Override
221-
public void closeAndRemove() {
222-
super.closeAndRemove();
223-
cacheManager.deregisterCache(cache);
224-
}
225-
226220
@Override
227221
public String getLockName() {
228222
return null;
@@ -547,6 +541,7 @@ public void close() throws DBException {
547541
flush();
548542
}
549543
super.close();
544+
cacheManager.deregisterCache(cache);
550545
}
551546

552547
protected void dumpValue(final Writer writer, final Value value, final int status) throws IOException {

0 commit comments

Comments
 (0)