[ 
https://issues.apache.org/jira/browse/ARTEMIS-3243?focusedWorklogId=610253&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-610253
 ]

ASF GitHub Bot logged work on ARTEMIS-3243:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Jun/21 07:32
            Start Date: 14/Jun/21 07:32
    Worklog Time Spent: 10m 
      Work Description: clebertsuconic commented on a change in pull request 
#3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r649962862



##########
File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
##########
@@ -205,23 +205,49 @@ public static int bytesToInt(byte[] b) {
             | ((int) b[0] & 0xff) << 24;
    }
 
+   public static long bytesToLong(byte[] b) {
+      return ((long) b[7] & 0xff)
+         | ((long) b[6] & 0xff) << 8
+         | ((long) b[5] & 0xff) << 16
+         | ((long) b[4] & 0xff) << 24
+         | ((long) b[3] & 0xff) << 32
+         | ((long) b[2] & 0xff) << 40
+         | ((long) b[1] & 0xff) << 48
+         | ((long) b[0] & 0xff) << 56;
+   }
+
    public static byte[] longToBytes(long value) {
       byte[] output = new byte[8];
       longToBytes(value, output, 0);
       return output;
    }
 
    public static void longToBytes(long x, byte[] output, int offset) {
-      output[offset] = (byte)(x >> 56);
-      output[offset + 1] = (byte)(x >> 48);
-      output[offset + 2] = (byte)(x >> 40);
-      output[offset + 3] = (byte)(x >> 32);
-      output[offset + 4] = (byte)(x >> 24);
-      output[offset + 5] = (byte)(x >> 16);
-      output[offset + 6] = (byte)(x >>  8);
+      output[offset] = (byte)(x >>> 56);
+      output[offset + 1] = (byte)(x >>> 48);
+      output[offset + 2] = (byte)(x >>> 40);
+      output[offset + 3] = (byte)(x >>> 32);
+      output[offset + 4] = (byte)(x >>> 24);
+      output[offset + 5] = (byte)(x >>> 16);
+      output[offset + 6] = (byte)(x >>>  8);

Review comment:
       @gemmellr it would been broken without the >>>
   
   >> in Java would add further -1 if the value was negative.. totally 
different from the intention here.
   
   As the byte was really unsigned, we can't use >> here
   
   As a matter of fact that's how Netty does on their libraries as well.
   
   
   It wasn't really part of this PR.. it was here as supporting my test. I'm 
updating the branch now.

##########
File path: 
artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
##########
@@ -167,6 +164,25 @@ public static void printData(File bindingsDirectory, File 
messagesDirectory, Fil
 
    }
 
+   public static DescribeJournal printMessages(File messagesDirectory, 
PrintStream out, boolean safe, boolean printRecords, boolean printSurving, 
boolean reclaimed) {

Review comment:
       will send a commit with the fix.

##########
File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ByteUtil.java
##########
@@ -233,6 +233,21 @@ public static void longToBytes(long x, byte[] output, int 
offset) {
       output[offset + 7] = (byte)(x);
    }
 
+   /** the byte ID goes to the first byte, everything else stays where they 
are. */
+   public static long mixByteAndLong(byte id, long longID) {

Review comment:
       caller's responsibility.
   
   We validate if the ID belong to the server's before we send it.

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPStandardMessage.java
##########
@@ -322,17 +323,26 @@ public String toString() {
       // toString will only call ensureScanning on regular messages
       // as large messages might need to do extra work to parse it
       ensureScanning();
-      return super.toString();
+      String body = getStringBody();
+      return super.toString() + (body != null ? ",body=[" + body + "]" : "");

Review comment:
       this is for print-data and debug. It's been quite useful.

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPStandardMessage.java
##########
@@ -322,17 +323,26 @@ public String toString() {
       // toString will only call ensureScanning on regular messages
       // as large messages might need to do extra work to parse it
       ensureScanning();
-      return super.toString();
+      String body = getStringBody();
+      return super.toString() + (body != null ? ",body=[" + body + "]" : "");
    }
 
    @Override
    public String getStringBody() {
       final Section body = getBody();
-      if (body instanceof AmqpValue && ((AmqpValue) body).getValue() 
instanceof String) {
-         return (String) ((AmqpValue) body).getValue();
-      } else {
-         return null;
+      if (body instanceof AmqpValue) {
+         AmqpValue sectionBody = (AmqpValue) body;
+         if (sectionBody != null) {
+            if (sectionBody.getValue() instanceof Long) {
+               long id = (long)sectionBody.getValue();
+               return sectionBody.getValue().toString() + ", byte[0]=" + 
ByteUtil.getFirstByte(id) + ", messageID=" + ByteUtil.removeFirstByte(id);
+            } else {
+               return sectionBody.getValue().toString();
+            }

Review comment:
       this one was not intentional.. I will remove it.

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPStandardMessage.java
##########
@@ -322,17 +323,26 @@ public String toString() {
       // toString will only call ensureScanning on regular messages
       // as large messages might need to do extra work to parse it
       ensureScanning();
-      return super.toString();
+      String body = getStringBody();
+      return super.toString() + (body != null ? ",body=[" + body + "]" : "");

Review comment:
       although.. I will remove it... if we need it in the future I may revisit 
this.

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java
##########
@@ -490,12 +495,18 @@ private void connectSender(Queue queue,
             Source source = new Source();
             source.setAddress(queue.getAddress().toString());
             sender.setSource(source);
+            HashMap<Symbol, Object> mapProperties = new HashMap<>(1);

Review comment:
       @gemmellr I'm only using a single element here. as I read the code, when 
you call putVal on hashMap, it will resize for 1 element, which is my intention.

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java
##########
@@ -490,12 +495,18 @@ private void connectSender(Queue queue,
             Source source = new Source();
             source.setAddress(queue.getAddress().toString());
             sender.setSource(source);
+            HashMap<Symbol, Object> mapProperties = new HashMap<>(1);
+            mapProperties.put(AMQPMirrorControllerSource.BROKER_ID, 
server.getMirrorBrokerId());

Review comment:
       I'm changing the datatype to byte all the way.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 610253)
    Time Spent: 1h 20m  (was: 1h 10m)

> Enhance AMQP Mirror support with dual mirror
> --------------------------------------------
>
>                 Key: ARTEMIS-3243
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3243
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.17.0
>            Reporter: Clebert Suconic
>            Assignee: Clebert Suconic
>            Priority: Major
>             Fix For: 2.18.0
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> at the current Mirror version, we can only mirror into a single direction.
> With this enhancement the two (or more brokers) would be connected to each 
> other, each one having its own ID, and each one would send updates to the 
> other broker.
> The outcome is that if you just transferred producers and consumers from one 
> broker into the other, the fallback would be automatic and simple. No need to 
> disable and enable mirror options.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to