You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/05/04 13:16:25 UTC

[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror

gemmellr commented on a change in pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r619176695



##########
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:
       Does this change make any difference? If only shifting and storing full 8bit increments at a time, and never retaining the shifted value itself, isnt it just doing the same as originally?

##########
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;

Review comment:
       Using uppercase on the hex characters can be more readable.

##########
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:
       Typo: printSurving rather than printSurviving (I assume).

##########
File path: artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/PrintData.java
##########
@@ -140,21 +140,14 @@ public static void printData(File bindingsDirectory, File messagesDirectory, Fil
 
       printBanner(out, BINDINGS_BANNER);
 
-      try {
-         DescribeJournal.describeBindingsJournal(bindingsDirectory, out, safe);
-      } catch (Exception e) {
-         e.printStackTrace();
-      }
+      printBindings(bindingsDirectory, out, safe, true, true);
 
       printBanner(out, MESSAGES_BANNER);
 
       DescribeJournal describeJournal = null;
-      try {
-         describeJournal = DescribeJournal.describeMessagesJournal(messagesDirectory, out, safe);
-      } catch (Exception e) {
-         e.printStackTrace();
+      describeJournal = printMessages(messagesDirectory, out, safe, true, true);
+      if (describeJournal == null)

Review comment:
       Adding the braces would be more consistent, and less error prone later.




-- 
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:
users@infra.apache.org