You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/05/10 16:03:29 UTC

[activemq-artemis] 10/19: progress

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch new-logging
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 24c8af3da8b01fd87be2c4ccba6eb601425dd961
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue May 3 18:58:39 2022 -0400

    progress
---
 .../core/client/ActiveMQClientMessageBundle.java   | 71 +++++++++++-----------
 .../core/client/impl/ClientSessionFactoryImpl.java |  2 +-
 .../artemis/core/client/impl/Topology.java         |  4 +-
 .../core/remoting/impl/netty/NettyConnector.java   |  2 +-
 .../artemis/logprocessor/LogProcessor.java         | 12 ++--
 5 files changed, 46 insertions(+), 45 deletions(-)

diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java
index 15194db21a..bcace3d203 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/ActiveMQClientMessageBundle.java
@@ -32,11 +32,10 @@ import org.apache.activemq.artemis.api.core.ActiveMQTransactionOutcomeUnknownExc
 import org.apache.activemq.artemis.api.core.ActiveMQTransactionRolledBackException;
 import org.apache.activemq.artemis.api.core.ActiveMQUnBlockedException;
 import org.apache.activemq.artemis.core.cluster.DiscoveryGroup;
+import org.apache.activemq.artemis.logprocessor.CodeFactory;
+import org.apache.activemq.artemis.logprocessor.annotation.ArtemisBundle;
+import org.apache.activemq.artemis.logprocessor.annotation.Message;
 import org.apache.activemq.artemis.spi.core.remoting.Connection;
-import org.jboss.logging.Messages;
-import org.jboss.logging.annotations.Cause;
-import org.jboss.logging.annotations.Message;
-import org.jboss.logging.annotations.MessageBundle;
 import org.w3c.dom.Node;
 
 /**
@@ -46,22 +45,22 @@ import org.w3c.dom.Node;
  *
  * so 219000 to 219999
  */
-@MessageBundle(projectCode = "AMQ")
+@ArtemisBundle(projectCode = "AMQ")
 public interface ActiveMQClientMessageBundle {
 
-   ActiveMQClientMessageBundle BUNDLE = Messages.getBundle(ActiveMQClientMessageBundle.class);
+   ActiveMQClientMessageBundle BUNDLE = CodeFactory.getCodeClass(ActiveMQClientMessageBundle.class);
 
    @Message(id = 219000, value = "ClientSession closed while creating session")
    ActiveMQInternalErrorException clientSessionClosed();
 
    @Message(id = 219001, value = "Failed to create session")
-   ActiveMQInternalErrorException failedToCreateSession(@Cause Throwable t);
+   ActiveMQInternalErrorException failedToCreateSession(Throwable t);
 
    @Message(id = 219003, value = "Queue can not be both durable and temporary")
    ActiveMQInternalErrorException queueMisConfigured();
 
    @Message(id = 219004, value = "Failed to initialise session factory")
-   ActiveMQInternalErrorException failedToInitialiseSessionFactory(@Cause Exception e);
+   ActiveMQInternalErrorException failedToInitialiseSessionFactory(Exception e);
 
    @Message(id = 219005, value = "Exception in Netty transport")
    ActiveMQInternalErrorException nettyError();
@@ -73,7 +72,7 @@ public interface ActiveMQClientMessageBundle {
    ActiveMQNotConnectedException cannotConnectToServers();
 
    @Message(id = 219008, value = "Failed to connect to any static connectors")
-   ActiveMQNotConnectedException cannotConnectToStaticConnectors(@Cause Exception e);
+   ActiveMQNotConnectedException cannotConnectToStaticConnectors(Exception e);
 
    @Message(id = 219009, value = "Failed to connect to any static connectors")
    ActiveMQNotConnectedException cannotConnectToStaticConnectors2();
@@ -81,23 +80,23 @@ public interface ActiveMQClientMessageBundle {
    @Message(id = 219010, value = "Connection is destroyed")
    ActiveMQNotConnectedException connectionDestroyed();
 
-   @Message(id = 219011, value = "Did not receive data from server for {0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219011, value = "Did not receive data from server for {0}")
    ActiveMQConnectionTimedOutException connectionTimedOut(Connection transportConnection);
 
    @Message(id = 219012, value = "Timed out waiting to receive initial broadcast from cluster")
    ActiveMQConnectionTimedOutException connectionTimedOutInInitialBroadcast();
 
-   @Message(id = 219013, value = "Timed out waiting to receive cluster topology. Group:{0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219013, value = "Timed out waiting to receive cluster topology. Group:{0}")
    ActiveMQConnectionTimedOutException connectionTimedOutOnReceiveTopology(DiscoveryGroup discoveryGroup);
 
-   @Message(id = 219014, value = "Timed out after waiting {0} ms for response when sending packet {1}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219014, value = "Timed out after waiting {0} ms for response when sending packet {1}")
    ActiveMQConnectionTimedOutException timedOutSendingPacket(long timeout, Byte type);
 
    @Message(id = 219015, value = "The connection was disconnected because of server shutdown")
    ActiveMQDisconnectedException disconnected();
 
    @Message(id = 219016, value = "Connection failure detected. Unblocking a blocking call that will never get a response")
-   ActiveMQUnBlockedException unblockingACall(@Cause Throwable t);
+   ActiveMQUnBlockedException unblockingACall(Throwable t);
 
    @Message(id = 219017, value = "Consumer is closed")
    ActiveMQObjectClosedException consumerClosed();
@@ -114,8 +113,7 @@ public interface ActiveMQClientMessageBundle {
    @Message(id = 219021, value = "Cannot set MessageHandler - consumer is in receive(...)")
    ActiveMQIllegalStateException inReceive();
 
-   @Message(id = 219022, value = "Header size ({0}) is too big, use the messageBody for large data, or increase minLargeMessageSize",
-      format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219022, value = "Header size ({0}) is too big, use the messageBody for large data, or increase minLargeMessageSize")
    ActiveMQIllegalStateException headerSizeTooBig(Integer headerSize);
 
    @Message(id = 219023, value = "The large message lost connection with its session, either because of a rollback or a closed session")
@@ -125,19 +123,19 @@ public interface ActiveMQClientMessageBundle {
    ActiveMQIllegalStateException noTCForSessionFactory();
 
    @Message(id = 219025, value = "Error saving the message body")
-   ActiveMQLargeMessageException errorSavingBody(@Cause Exception e);
+   ActiveMQLargeMessageException errorSavingBody(Exception e);
 
    @Message(id = 219026, value = "Error reading the LargeMessageBody")
-   ActiveMQLargeMessageException errorReadingBody(@Cause Exception e);
+   ActiveMQLargeMessageException errorReadingBody(Exception e);
 
    @Message(id = 219027, value = "Error closing stream from LargeMessageBody")
-   ActiveMQLargeMessageException errorClosingLargeMessage(@Cause Exception e);
+   ActiveMQLargeMessageException errorClosingLargeMessage(Exception e);
 
    @Message(id = 219028, value = "Timeout waiting for LargeMessage Body")
    ActiveMQLargeMessageException timeoutOnLargeMessage();
 
    @Message(id = 219029, value = "Error writing body of message")
-   ActiveMQLargeMessageException errorWritingLargeMessage(@Cause Exception e);
+   ActiveMQLargeMessageException errorWritingLargeMessage(Exception e);
 
    @Message(id = 219030, value = "The transaction was rolled back on failover to a backup server")
    ActiveMQTransactionRolledBackException txRolledBack();
@@ -145,23 +143,22 @@ public interface ActiveMQClientMessageBundle {
    @Message(id = 219031, value = "The transaction was rolled back on failover however commit may have been successful")
    ActiveMQTransactionOutcomeUnknownException txOutcomeUnknown();
 
-   @Message(id = 219032, value = "Invalid type: {0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219032, value = "Invalid type: {0}")
    IllegalArgumentException invalidType(Object type);
 
-   @Message(id = 219033, value = "Invalid type: {0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219033, value = "Invalid type: {0}")
    IllegalArgumentException invalidEncodeType(Object type);
 
-   @Message(id = 219034, value = "Params for management operations must be of the following type: int long double String boolean Map or array thereof but found {0}",
-      format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219034, value = "Params for management operations must be of the following type: int long double String boolean Map or array thereof but found {0}")
    IllegalArgumentException invalidManagementParam(Object type);
 
-   @Message(id = 219035, value = "Invalid window size {0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219035, value = "Invalid window size {0}")
    IllegalArgumentException invalidWindowSize(Integer size);
 
-   @Message(id = 219037, value = "Invalid last Received Command ID: {0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219037, value = "Invalid last Received Command ID: {0}")
    IllegalArgumentException invalidCommandID(Integer lastReceivedCommandID);
 
-   @Message(id = 219038, value = "Cannot find channel with id {0} to close", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219038, value = "Cannot find channel with id {0} to close")
    IllegalArgumentException noChannelToClose(Long id);
 
    @Message(id = 219039, value = "Close Listener cannot be null")
@@ -170,7 +167,7 @@ public interface ActiveMQClientMessageBundle {
    @Message(id = 219040, value = "Fail Listener cannot be null")
    IllegalArgumentException failListenerCannotBeNull();
 
-   @Message(id = 219041, value = "Connection already exists with id {0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219041, value = "Connection already exists with id {0}")
    IllegalArgumentException connectionExists(Object id);
 
    @Message(id = 219042, value = "Invalid argument null listener")
@@ -191,7 +188,7 @@ public interface ActiveMQClientMessageBundle {
    @Message(id = 219048, value = "nodes have a different number of attributes")
    IllegalArgumentException nodeHaveDifferentAttNumber();
 
-   @Message(id = 219049, value = "attribute {0}={1} does not match", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219049, value = "attribute {0}={1} does not match")
    IllegalArgumentException attsDontMatch(String name, String value);
 
    @Message(id = 219050, value = "one node has children and the other does not")
@@ -200,25 +197,25 @@ public interface ActiveMQClientMessageBundle {
    @Message(id = 219051, value = "nodes have a different number of children")
    IllegalArgumentException nodeHasDifferentChildNumber();
 
-   @Message(id = 219052, value = "Element {0} requires a valid Boolean value, but ''{1}'' cannot be parsed as a Boolean", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219052, value = "Element {0} requires a valid Boolean value, but ''{1}'' cannot be parsed as a Boolean")
    IllegalArgumentException mustBeBoolean(Node elem, String value);
 
-   @Message(id = 219053, value = "Element {0} requires a valid Double value, but ''{1}'' cannot be parsed as a Double", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219053, value = "Element {0} requires a valid Double value, but ''{1}'' cannot be parsed as a Double")
    IllegalArgumentException mustBeDouble(Node elem, String value);
 
-   @Message(id = 219054, value = "Element {0} requires a valid Integer value, but ''{1}'' cannot be parsed as an Integer", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219054, value = "Element {0} requires a valid Integer value, but ''{1}'' cannot be parsed as an Integer")
    IllegalArgumentException mustBeInteger(Node elem, String value);
 
-   @Message(id = 219055, value = "Element {0} requires a valid Long value, but ''{1}'' cannot be parsed as a Long", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219055, value = "Element {0} requires a valid Long value, but ''{1}'' cannot be parsed as a Long")
    IllegalArgumentException mustBeLong(Node element, String value);
 
    @Message(id = 219057, value = "Error decoding password")
-   IllegalArgumentException errordecodingPassword(@Cause Exception e);
+   IllegalArgumentException errordecodingPassword(Exception e);
 
-   @Message(id = 219058, value = "Address \"{0}\" is full. Message encode size = {1}B", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219058, value = "Address \"{0}\" is full. Message encode size = {1}B")
    ActiveMQAddressFullException addressIsFull(String addressName, int size);
 
-   @Message(id = 219059, value = "Interceptor {0} rejected packet in a blocking call. This call will never complete.", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219059, value = "Interceptor {0} rejected packet in a blocking call. This call will never complete.")
    ActiveMQInterceptorRejectedPacketException interceptorRejectedPacket(String interceptionResult);
 
    @Message(id = 219060, value = "Large Message Transmission interrupted on consumer shutdown.")
@@ -233,11 +230,11 @@ public interface ActiveMQClientMessageBundle {
    @Message(id = 219063, value = "Cannot send a packet while response cache is full.")
    IllegalStateException cannotSendPacketWhilstResponseCacheFull();
 
-   @Message(id = 219064, value = "Invalide packet: {0}", format = Message.Format.MESSAGE_FORMAT)
+   @Message(id = 219064, value = "Invalide packet: {0}")
    IllegalStateException invalidPacket(byte type);
 
    @Message(id = 219065, value = "Failed to handle packet.")
-   RuntimeException failedToHandlePacket(@Cause Exception e);
+   RuntimeException failedToHandlePacket(Exception e);
 
    @Message(id = 219066, value = "The connection was redirected")
    ActiveMQRoutingException redirected();
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
index d6bf376ed2..b091c039e6 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
@@ -556,7 +556,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
    private void failoverOrReconnect(final Object connectionID,
                                     final ActiveMQException me,
                                     String scaleDownTargetNodeID) {
-      ActiveMQClientLogger.LOGGER.failoverOrReconnect(connectionID, me);
+      logger.debug("Failure captured on connectionID={0}, performing failover or reconnection now", connectionID, me);
 
       for (ClientSessionInternal session : sessions) {
          SessionContext context = session.getSessionContext();
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
index dc85a932e1..edbd2856af 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/Topology.java
@@ -205,7 +205,7 @@ public final class Topology {
       }
 
       if (manager != null && !manager.updateMember(uniqueEventID, nodeId, memberInput)) {
-         logger.debugf("TopologyManager rejected the update towards %s", memberInput);
+         logger.debug("TopologyManager rejected the update towards %s", memberInput);
          return false;
       }
 
@@ -313,7 +313,7 @@ public final class Topology {
 
 
       if (manager != null && !manager.removeMember(uniqueEventID, nodeId)) {
-         logger.debugf("TopologyManager rejected the update towards %s", nodeId);
+         logger.debug("TopologyManager rejected the update towards %s", nodeId);
          return false;
       }
 
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
index 001fbbb541..b8ba084d5d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
@@ -731,7 +731,7 @@ public class NettyConnector extends AbstractConnector {
 
             if (handler != null) {
                pipeline.addLast(new ActiveMQClientChannelHandler(channelGroup, handler, new Listener(), closeExecutor));
-               logger.debugf("Added ActiveMQClientChannelHandler to Channel with id = %s ", channel.id());
+               logger.debug("Added ActiveMQClientChannelHandler to Channel with id = %s ", channel.id());
             }
          }
       });
diff --git a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
index 9c86e8aa65..5195c0759a 100644
--- a/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
+++ b/artemis-log-processor/src/main/java/org/apache/activemq/artemis/logprocessor/LogProcessor.java
@@ -158,7 +158,7 @@ public class LogProcessor extends AbstractProcessor {
       processedMessages.put(messageAnnotation.id(), messageAnnotation.value());
 
       // This is really a debug output
-      writerOutput.println("   // " + messageAnnotation.toString());
+      writerOutput.println("   // " + encodeSpecialChars(messageAnnotation.toString()));
 
       writerOutput.write("   public " + executableMember.getReturnType() + " " + executableMember.getSimpleName() + "(");
 
@@ -183,7 +183,7 @@ public class LogProcessor extends AbstractProcessor {
       writerOutput.println(")");
       writerOutput.println("   {");
 
-      String formattingString = bundleAnnotation.projectCode() + messageAnnotation.id() + " " + messageAnnotation.value();
+      String formattingString = encodeSpecialChars(bundleAnnotation.projectCode() + messageAnnotation.id() + " " + messageAnnotation.value());
       if (!hasParameters) {
          writerOutput.println("      String returnString = \"" + formattingString + "\";");
       } else {
@@ -200,6 +200,10 @@ public class LogProcessor extends AbstractProcessor {
       writerOutput.println();
    }
 
+   private String encodeSpecialChars(String input) {
+      return input.replaceAll("\n", "\\\\n").replaceAll("\"", "\\\\\"");
+   }
+
 
    private void generateGetLogger(ArtemisBundle bundleAnnotation,
                                PrintWriter writerOutput,
@@ -228,7 +232,7 @@ public class LogProcessor extends AbstractProcessor {
       processedMessages.put(messageAnnotation.id(), messageAnnotation.value());
 
       // This is really a debug output
-      writerOutput.println("   // " + messageAnnotation.toString());
+      writerOutput.println("   // " + encodeSpecialChars(messageAnnotation.toString()));
 
       writerOutput.write("   public void " + executableMember.getSimpleName() + "(");
 
@@ -253,7 +257,7 @@ public class LogProcessor extends AbstractProcessor {
       writerOutput.println(")");
       writerOutput.println("   {");
 
-      String formattingString = bundleAnnotation.projectCode() + messageAnnotation.id() + " " + messageAnnotation.value();
+      String formattingString = encodeSpecialChars(bundleAnnotation.projectCode() + messageAnnotation.id() + " " + messageAnnotation.value());
       if (!hasParameters) {
          writerOutput.println("      String messageString = \"" + formattingString + "\";");
       } else {