ARTEMIS-3085 support custom IOCriticalErrorListener
This commit is contained in:
parent
bb05e04f69
commit
00592d6dd8
|
@ -35,6 +35,7 @@ import org.apache.activemq.artemis.core.config.BridgeConfiguration;
|
|||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.DivertConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.FederationConfiguration;
|
||||
import org.apache.activemq.artemis.core.io.IOCriticalErrorListener;
|
||||
import org.apache.activemq.artemis.core.management.impl.ActiveMQServerControlImpl;
|
||||
import org.apache.activemq.artemis.core.paging.PagingManager;
|
||||
import org.apache.activemq.artemis.core.persistence.OperationContext;
|
||||
|
@ -68,8 +69,8 @@ import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerMessagePlugi
|
|||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerQueuePlugin;
|
||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerResourcePlugin;
|
||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin;
|
||||
import org.apache.activemq.artemis.core.server.routing.ConnectionRouterManager;
|
||||
import org.apache.activemq.artemis.core.server.reload.ReloadManager;
|
||||
import org.apache.activemq.artemis.core.server.routing.ConnectionRouterManager;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.core.transaction.ResourceManager;
|
||||
|
@ -198,6 +199,13 @@ public interface ActiveMQServer extends ServiceComponent {
|
|||
*/
|
||||
void registerActivationFailureListener(ActivationFailureListener listener);
|
||||
|
||||
/**
|
||||
* Register a listener to detect I/O Critical errors
|
||||
*
|
||||
* @param listener @see org.apache.activemq.artemis.core.io.IOCriticalErrorListener
|
||||
*/
|
||||
void registerIOCriticalErrorListener(IOCriticalErrorListener listener);
|
||||
|
||||
void replay(Date start, Date end, String address, String target, String filter) throws Exception;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.URL;
|
||||
import java.security.AccessController;
|
||||
|
@ -172,10 +173,10 @@ import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerQueuePlugin;
|
|||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerResourcePlugin;
|
||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin;
|
||||
import org.apache.activemq.artemis.core.server.reload.ReloadCallback;
|
||||
import org.apache.activemq.artemis.core.server.routing.ConnectionRouterManager;
|
||||
import org.apache.activemq.artemis.core.server.reload.ReloadManager;
|
||||
import org.apache.activemq.artemis.core.server.reload.ReloadManagerImpl;
|
||||
import org.apache.activemq.artemis.core.server.replay.ReplayManager;
|
||||
import org.apache.activemq.artemis.core.server.routing.ConnectionRouterManager;
|
||||
import org.apache.activemq.artemis.core.server.transformer.Transformer;
|
||||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
|
@ -211,7 +212,6 @@ import org.apache.activemq.artemis.utils.critical.CriticalComponent;
|
|||
import org.apache.activemq.artemis.utils.critical.EmptyCriticalAnalyzer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
import static org.apache.activemq.artemis.utils.collections.IterableStream.iterableOf;
|
||||
|
||||
|
@ -343,6 +343,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
|
||||
private final Set<ActivationFailureListener> activationFailureListeners = new ConcurrentHashSet<>();
|
||||
|
||||
private final Set<IOCriticalErrorListener> ioCriticalErrorListeners = new ConcurrentHashSet<>();
|
||||
|
||||
private final Set<PostQueueCreationCallback> postQueueCreationCallbacks = new ConcurrentHashSet<>();
|
||||
|
||||
private final Set<PostQueueDeletionCallback> postQueueDeletionCallbacks = new ConcurrentHashSet<>();
|
||||
|
@ -2517,6 +2519,11 @@ public class ActiveMQServerImpl implements ActiveMQServer {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIOCriticalErrorListener(final IOCriticalErrorListener listener) {
|
||||
ioCriticalErrorListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPostQueueCreationCallback(final PostQueueCreationCallback callback) {
|
||||
postQueueCreationCallbacks.add(callback);
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.server;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IOCriticalErrorListenerTest extends ActiveMQTestBase {
|
||||
protected ActiveMQServer server;
|
||||
|
||||
@Test
|
||||
public void simpleTest() throws Exception {
|
||||
ServerSocket s = new ServerSocket();
|
||||
try {
|
||||
s.bind(new InetSocketAddress("127.0.0.1", 61616));
|
||||
server = createServer(false, createDefaultNettyConfig());
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
server.registerIOCriticalErrorListener((code, message, file) -> latch.countDown());
|
||||
server.start();
|
||||
assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
|
||||
} finally {
|
||||
s.close();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue