Skip to content

Commit

Permalink
ARTEMIS-2749 - Broadcast Group Control Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
andytaylor committed May 4, 2020
1 parent 0fe11c7 commit 2ab3815
Show file tree
Hide file tree
Showing 13 changed files with 713 additions and 161 deletions.
Expand Up @@ -2390,6 +2390,30 @@ static void clearDuplicateIdCache(Object source) {
void clearDuplicateIdCache(String user, Object source, Object... args);


static void getChannelName(Object source) {
LOGGER.getChannelName(getCaller(), source);
}

@LogMessage(level = Logger.Level.INFO)
@Message(id = 601511, value = "User {0} is getting channelName property on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
void getChannelName(String user, Object source, Object... args);

static void getFileContents(Object source) {
LOGGER.getFileContents(getCaller(), source);
}

@LogMessage(level = Logger.Level.INFO)
@Message(id = 601512, value = "User {0} is getting fileContents property on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
void getFileContents(String user, Object source, Object... args);

static void getFile(Object source) {
LOGGER.getFile(getCaller(), source);
}

@LogMessage(level = Logger.Level.INFO)
@Message(id = 601513, value = "User {0} is getting file property on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
void getFile(String user, Object source, Object... args);

/*
* This logger is for message production and consumption and is on the hot path so enabled independently
*
Expand Down
@@ -0,0 +1,48 @@
/*
* 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.api.core.management;

/**
* A BroadcastGroupControl is used to manage a broadcast group.
*/
public interface BaseBroadcastGroupControl extends ActiveMQComponentControl {

/**
* Returns the configuration name of this broadcast group.
*/
@Attribute(desc = "name of this broadcast group")
String getName();

/**
* Returns the period used by this broadcast group.
*/
@Attribute(desc = "period used by this broadcast group")
long getBroadcastPeriod();

/**
* Returns the pairs of live-backup connectors that are broadcasted by this broadcast group.
*/
@Attribute(desc = "pairs of live-backup connectors that are broadcasted by this broadcast group")
Object[] getConnectorPairs();

/**
* Returns the pairs of live-backup connectors that are broadcasted by this broadcast group
* using JSON serialization.
*/
@Attribute(desc = "pairs of live-backup connectors that are broadcasted by this broadcast group using JSON serialization")
String getConnectorPairsAsJSON() throws Exception;
}
Expand Up @@ -19,13 +19,7 @@
/**
* A BroadcastGroupControl is used to manage a broadcast group.
*/
public interface BroadcastGroupControl extends ActiveMQComponentControl {

/**
* Returns the configuration name of this broadcast group.
*/
@Attribute(desc = "name of this broadcast group")
String getName();
public interface BroadcastGroupControl extends BaseBroadcastGroupControl {

/**
* Returns the local port this broadcast group is bound to.
Expand All @@ -44,23 +38,4 @@ public interface BroadcastGroupControl extends ActiveMQComponentControl {
*/
@Attribute(desc = "port this broadcast group is broadcasting to")
int getGroupPort() throws Exception;

/**
* Returns the period used by this broadcast group.
*/
@Attribute(desc = "period used by this broadcast group")
long getBroadcastPeriod();

/**
* Returns the pairs of live-backup connectors that are broadcasted by this broadcast group.
*/
@Attribute(desc = "pairs of live-backup connectors that are broadcasted by this broadcast group")
Object[] getConnectorPairs();

/**
* Returns the pairs of live-backup connectors that are broadcasted by this broadcast group
* using JSON serialization.
*/
@Attribute(desc = "pairs of live-backup connectors that are broadcasted by this broadcast group using JSON serialization")
String getConnectorPairsAsJSON() throws Exception;
}
@@ -0,0 +1,29 @@
/*
* 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.api.core.management;

/**
* A BroadcastGroupControl is used to manage a broadcast group.
*/
public interface JGroupsChannelBroadcastGroupControl extends BaseBroadcastGroupControl {

/**
* Returns the JGroups channel name
*/
@Attribute(desc = "Returns the JGroups channel name")
String getChannelName() throws Exception;
}
@@ -0,0 +1,41 @@
/*
* 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.api.core.management;

/**
* A BroadcastGroupControl is used to manage a broadcast group.
*/
public interface JGroupsFileBroadcastGroupControl extends BaseBroadcastGroupControl {

/**
* Returns jgroups channel name
*/
@Attribute(desc = "Returns jgroups channel name")
String getChannelName();

/**
* Returns the jgroups file name
*/
@Attribute(desc = "Returns the jgroups file name")
String getFile();

/**
* Returns the contents of the jgroups file
*/
@Attribute(desc = "Returns the contents of the jgroups file")
String getFileContents() throws Exception;
}
@@ -0,0 +1,180 @@
/*
* 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.core.management.impl;

import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
import org.apache.activemq.artemis.api.core.JsonUtil;
import org.apache.activemq.artemis.api.core.management.BaseBroadcastGroupControl;
import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
import org.apache.activemq.artemis.logs.AuditLogger;

import javax.management.MBeanAttributeInfo;
import javax.management.MBeanOperationInfo;

public class BaseBroadcastGroupControlImpl extends AbstractControl implements BaseBroadcastGroupControl {

// Constants -----------------------------------------------------

// Attributes ----------------------------------------------------

private Class broadcastGroupControlClass;

private final BroadcastGroup broadcastGroup;

private final BroadcastGroupConfiguration configuration;

// Static --------------------------------------------------------

// Constructors --------------------------------------------------

public BaseBroadcastGroupControlImpl(final Class broadcastGroupControlClass,
final BroadcastGroup broadcastGroup,
final StorageManager storageManager,
final BroadcastGroupConfiguration configuration) throws Exception {
super(broadcastGroupControlClass, storageManager);
this.broadcastGroupControlClass = broadcastGroupControlClass;
this.broadcastGroup = broadcastGroup;
this.configuration = configuration;
}

// BroadcastGroupControlMBean implementation ---------------------

@Override
public String getName() {
if (AuditLogger.isEnabled()) {
AuditLogger.getName(this.broadcastGroup);
}
clearIO();
try {
return configuration.getName();
} finally {
blockOnIO();
}
}

@Override
public long getBroadcastPeriod() {
if (AuditLogger.isEnabled()) {
AuditLogger.getBroadcastPeriod(this.broadcastGroup);
}
clearIO();
try {
return configuration.getBroadcastPeriod();
} finally {
blockOnIO();
}
}

@Override
public Object[] getConnectorPairs() {
if (AuditLogger.isEnabled()) {
AuditLogger.getConnectorPairs(this.broadcastGroup);
}
clearIO();
try {
Object[] ret = new Object[configuration.getConnectorInfos().size()];

int i = 0;
for (String connector : configuration.getConnectorInfos()) {
ret[i++] = connector;
}
return ret;
} finally {
blockOnIO();
}
}

@Override
public String getConnectorPairsAsJSON() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.getConnectorPairsAsJSON(this.broadcastGroup);
}
clearIO();
try {
return JsonUtil.toJsonArray(configuration.getConnectorInfos()).toString();
} finally {
blockOnIO();
}
}

// MessagingComponentControlMBean implementation -----------------

@Override
public boolean isStarted() {
if (AuditLogger.isEnabled()) {
AuditLogger.isStarted(this.broadcastGroup);
}
clearIO();
try {
return broadcastGroup.isStarted();
} finally {
blockOnIO();
}
}

@Override
public void start() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.startBroadcastGroup(this.broadcastGroup);
}
clearIO();
try {
broadcastGroup.start();
} finally {
blockOnIO();
}
}

@Override
public void stop() throws Exception {
if (AuditLogger.isEnabled()) {
AuditLogger.stopBroadcastGroup(this.broadcastGroup);
}
clearIO();
try {
broadcastGroup.stop();
} finally {
blockOnIO();
}
}

@Override
protected MBeanOperationInfo[] fillMBeanOperationInfo() {
return MBeanInfoHelper.getMBeanOperationsInfo(broadcastGroupControlClass);
}

@Override
protected MBeanAttributeInfo[] fillMBeanAttributeInfo() {
return MBeanInfoHelper.getMBeanAttributesInfo(broadcastGroupControlClass);
}

protected BroadcastGroup getBroadcastGroup() {
return broadcastGroup;
}

// Public --------------------------------------------------------

// Package protected ---------------------------------------------

// Protected -----------------------------------------------------

// Private -------------------------------------------------------

// Inner classes -------------------------------------------------

}

0 comments on commit 2ab3815

Please sign in to comment.