ARTEMIS-4772 expose broker plugin classes via management
This commit is contained in:
parent
1de617e503
commit
f7b15e351e
|
@ -2710,4 +2710,10 @@ public interface AuditLogger {
|
|||
@LogMessage(id = 601776, value = "User {} is getting first message as json on target resource: {}", level = LogMessage.Level.INFO)
|
||||
void peekFirstMessageAsJSON(String user, Object source);
|
||||
|
||||
static void getBrokerPluginClassNames(Object source) {
|
||||
BASE_LOGGER.getBrokerPluginClassNames(getCaller(), source);
|
||||
}
|
||||
|
||||
@LogMessage(id = 601777, value = "User {} is getting broker plugin class names on target resource: {}", level = LogMessage.Level.INFO)
|
||||
void getBrokerPluginClassNames(String user, Object source);
|
||||
}
|
||||
|
|
|
@ -111,6 +111,10 @@ public interface ActiveMQServerControl {
|
|||
@Attribute(desc = "List of interceptors used by this server for outgoing messages")
|
||||
String[] getOutgoingInterceptorClassNames();
|
||||
|
||||
|
||||
@Attribute(desc = "List of broker plugin class names used by this server")
|
||||
String[] getBrokerPluginClassNames();
|
||||
|
||||
/**
|
||||
* Returns whether this server is clustered.
|
||||
*/
|
||||
|
|
|
@ -49,6 +49,7 @@ import java.util.concurrent.Future;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
|
@ -125,6 +126,7 @@ import org.apache.activemq.artemis.core.server.group.GroupingHandler;
|
|||
import org.apache.activemq.artemis.core.server.impl.Activation;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.SharedNothingPrimaryActivation;
|
||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerBasePlugin;
|
||||
import org.apache.activemq.artemis.core.server.replay.ReplayManager;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
|
@ -351,6 +353,23 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBrokerPluginClassNames() {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.getBrokerPluginClassNames(this.server);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
return configuration.getBrokerPlugins().stream()
|
||||
.map(brokerPlugin -> brokerPlugin.getClass().getCanonicalName() != null ? brokerPlugin.getClass().getCanonicalName() : brokerPlugin.getClass().getName())
|
||||
.toArray(String[]::new);
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJournalPoolFiles() {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
|
|
|
@ -44,6 +44,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
|
@ -100,6 +101,7 @@ import org.apache.activemq.artemis.core.server.ServerSession;
|
|||
import org.apache.activemq.artemis.core.server.ServiceComponent;
|
||||
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
|
||||
import org.apache.activemq.artemis.core.server.impl.ServerLegacyProducersImpl;
|
||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
|
||||
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerSessionPlugin;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
|
@ -235,6 +237,28 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
Assert.assertTrue(serverControl.isActive());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrokerPluginClassNames() throws Exception {
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
conf.registerBrokerPlugin(new TestBrokerPlugin());
|
||||
conf.registerBrokerPlugin(new ActiveMQServerPlugin() {
|
||||
@Override
|
||||
public void registered(ActiveMQServer server) {
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assertEquals(2, conf.getBrokerPlugins().size());
|
||||
Assert.assertEquals(2, serverControl.getBrokerPluginClassNames().length);
|
||||
Assert.assertEquals(
|
||||
"org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlTest.TestBrokerPlugin",
|
||||
serverControl.getBrokerPluginClassNames()[0]);
|
||||
Assert.assertTrue(Pattern.matches(
|
||||
"org.apache.activemq.artemis.tests.integration.management.ActiveMQServerControlTest\\$\\d+$",
|
||||
serverControl.getBrokerPluginClassNames()[1]
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecurityCacheSizes() throws Exception {
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
@ -6190,5 +6214,10 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
session.commit();
|
||||
}
|
||||
|
||||
private static class TestBrokerPlugin implements ActiveMQServerPlugin {
|
||||
@Override
|
||||
public void registered(ActiveMQServer server) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -540,6 +540,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
return (String[]) proxy.retrieveAttributeValue("outgoingInterceptorClassNames", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBrokerPluginClassNames() {
|
||||
return (String[]) proxy.retrieveAttributeValue("brokerPluginClassNames", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJournalDirectory() {
|
||||
return (String) proxy.retrieveAttributeValue("journalDirectory");
|
||||
|
|
Loading…
Reference in New Issue