Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARTEMIS-5332 add exportConfigAsProperties operation to server control #5533

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2859,4 +2859,11 @@ static void getTotalSessionCount(Object source) {

@LogMessage(id = 601797, value = "User {} is getting total session count on target resource: {}", level = LogMessage.Level.INFO)
void getTotalSessionCount(String user, Object source);

static void exportConfigAsProperties(Object source) {
BASE_LOGGER.exportConfigAsProperties(getCaller(), source);
}

@LogMessage(id = 601798, value = "User {} is exporting configuration as properties on target resource: {}", level = LogMessage.Level.INFO)
void exportConfigAsProperties(String user, Object source);
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public class FluentPropertyBeanIntrospectorWithIgnores extends FluentPropertyBea

private static ConcurrentHashSet<Pair<String, String>> ignores = new ConcurrentHashSet<>();

public static void addIgnore(String className, String propertyName) {
logger.trace("Adding ignore on {}/{}", className, propertyName);
ignores.add(new Pair<>(className, propertyName));
public static void addIgnore(String className, String methodName) {
logger.trace("Adding ignore on {}/{}", className, methodName);
ignores.add(new Pair<>(className, methodName));
}

public static boolean isIgnored(String className, String propertyName) {
return ignores.contains(new Pair<>(className, propertyName));
public static boolean isIgnored(String className, String methodName) {
return ignores.contains(new Pair<>(className, methodName));
}

@Override
Expand Down Expand Up @@ -72,6 +72,15 @@ private void introspect(IntrospectionContext icontext, Method writeMethod, Strin
if (pd != null) {
readMethod = pd.getReadMethod();
}
if (readMethod == null) {
try {
if (writeMethod != null && writeMethod.getParameterTypes().length == 1 && writeMethod.getParameterTypes()[0].equals(Boolean.class)) {
// is methods with Boolean return are not valid bean accessors but our fluent classes use them
readMethod = icontext.getTargetClass().getMethod("is" + capitalise(propertyName), null);
}
} catch (NoSuchMethodException ignored) {
}
}
try {
PropertyDescriptor withFluentWrite = createFluentPropertyDescriptor(readMethod, writeMethod, propertyName);
icontext.addPropertyDescriptor(withFluentWrite);
Expand All @@ -80,6 +89,13 @@ private void introspect(IntrospectionContext icontext, Method writeMethod, Strin
}
}

private String capitalise(String name) {
if (name.length() > 1) {
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
return name;
}

private PropertyDescriptor createFluentPropertyDescriptor(Method readMethod, Method writeMethod, String propertyName) throws IntrospectionException {
return new PropertyDescriptor(propertyName, readMethod, writeMethod);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2090,5 +2090,8 @@ void replay(@Parameter(name = "startScanDate", desc = "Start date where we will

@Attribute(desc = AUTHORIZATION_FAILURE_COUNT)
long getAuthorizationFailureCount();

@Operation(desc = "Export the broker configuration as properties", impact = MBeanOperationInfo.ACTION)
void exportConfigAsProperties() throws Exception;
}

Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ public static class Matcher implements Serializable {
private String name;

public String getName() {
if (name == null) {
return addressMatch;
}
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ public static class Matcher implements Serializable {
private String name;

public String getName() {
if (name == null) {
return addressMatch + queueMatch;
}
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ Configuration addDiscoveryGroupConfiguration(String key,
Configuration setMaskPassword(Boolean maskPassword);

/**
* If passwords are masked. True means the passwords are masked.enableda
* If passwords are masked. True means the passwords are masked.
*/
Boolean isMaskPassword();

Expand Down Expand Up @@ -1504,4 +1504,6 @@ default String resolvePropertiesSources(String propertiesFileUrl) {
Configuration setMirrorAckManagerWarnUnacked(boolean warnUnacked);

boolean isMirrorAckManagerWarnUnacked();

void exportAsProperties(File to) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,23 @@ public List<AMQPBrokerConnectionElement> getMirrors() {
return connectionElements;
}

public AMQPBrokerConnectConfiguration addPeer(AMQPBrokerConnectionElement element) {
element.setType(AMQPBrokerConnectionAddressType.PEER);
public AMQPBrokerConnectConfiguration addPeer(AMQPPeerBrokerConnectionElement element) {
return addElement(element);
}

public List<AMQPBrokerConnectionElement> getPeers() {
return connectionElements;
}

public AMQPBrokerConnectConfiguration addSender(AMQPBrokerConnectionElement element) {
element.setType(AMQPBrokerConnectionAddressType.SENDER);
public AMQPBrokerConnectConfiguration addSender(AMQPSenderBrokerConnectionElement element) {
return addElement(element);
}

public List<AMQPBrokerConnectionElement> getSenders() {
return connectionElements;
}

public AMQPBrokerConnectConfiguration addReceiver(AMQPBrokerConnectionElement element) {
element.setType(AMQPBrokerConnectionAddressType.RECEIVER);
public AMQPBrokerConnectConfiguration addReceiver(AMQPReceiverBrokerConnectionElement element) {
return addElement(element);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class AMQPBrokerConnectionElement implements Serializable {

private static final long serialVersionUID = 3653295602796835937L;

String name;
String name = "default";
SimpleString matchAddress;
SimpleString queueName;
AMQPBrokerConnectionAddressType type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ public static class AddressMatch implements Serializable {
private String addressMatch;

public String getName() {
if (name == null) {
return addressMatch;
}
return name;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ public static class QueueMatch implements Serializable {
private String queueMatch;

public String getName() {
if (name == null) {
return addressMatch + queueMatch;
}
return name;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.config.amqpBrokerConnectivity;

public class AMQPPeerBrokerConnectionElement extends AMQPBrokerConnectionElement {
private static final long serialVersionUID = -5021968319469459695L;

public AMQPPeerBrokerConnectionElement() {
this.setType(AMQPBrokerConnectionAddressType.PEER);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.config.amqpBrokerConnectivity;

public class AMQPReceiverBrokerConnectionElement extends AMQPBrokerConnectionElement {

private static final long serialVersionUID = 5257427388207911228L;

public AMQPReceiverBrokerConnectionElement() {
this.setType(AMQPBrokerConnectionAddressType.RECEIVER);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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.config.amqpBrokerConnectivity;

public class AMQPSenderBrokerConnectionElement extends AMQPBrokerConnectionElement {
private static final long serialVersionUID = -7213161391886866563L;

public AMQPSenderBrokerConnectionElement() {
this.setType(AMQPBrokerConnectionAddressType.SENDER);
}
}
Loading