Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARTEMIS-2749 - Broadcast Group Control Improvements
- Loading branch information
1 parent
0fe11c7
commit 2ab3815
Showing
13 changed files
with
713 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../main/java/org/apache/activemq/artemis/api/core/management/BaseBroadcastGroupControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../org/apache/activemq/artemis/api/core/management/JGroupsChannelBroadcastGroupControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
41 changes: 41 additions & 0 deletions
41
...ava/org/apache/activemq/artemis/api/core/management/JGroupsFileBroadcastGroupControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
180 changes: 180 additions & 0 deletions
180
.../java/org/apache/activemq/artemis/core/management/impl/BaseBroadcastGroupControlImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ------------------------------------------------- | ||
|
||
} |
Oops, something went wrong.