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/04/15 00:05:48 UTC
[GitHub] [activemq-artemis] clebertsuconic opened a new pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
clebertsuconic opened a new pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545
--
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
[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r626450669
##########
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:
Its true >> and >>> can differ, and that can make a difference depending on their usage, but I don't believe it does in this case though.
This repeatedly carves off the low order 8 bits using a cast to byte, after shifting the original bits by between 56 and 0 steps right, to incrementally capture the original 64 bits from high to low. It discards the actual shifted value at each intermediate step, operating on the original long for the next shift done (if any).
That seems to mean it will neither access or store any of the high order bits introduced by the shifts. Those are what can be influenced by use of >> vs >>>, which would mean this does exactly the same as it did to begin with.
--
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
[GitHub] [activemq-artemis] clebertsuconic commented on pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#issuecomment-866165818
there is a new PR for this: #3633
--
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
[GitHub] [activemq-artemis] clebertsuconic commented on pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#issuecomment-860945815
I will close this PR, do some work and open a new one.
--
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
[GitHub] [activemq-artemis] clebertsuconic commented on pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#issuecomment-859656938
@gemmellr I have updated the PR with my suggestions, also I changed the schema to include the target-broker-id and source-broker-id as part of the XML...
I was stuck with the smoke tests missing acks after failures... and they are now fixed...
I will convert this as a regular PR now.. there are probably some more reviews to be made.. and I will still produce more fixes next week that can come on a different PR / improvements.
--
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
[GitHub] [activemq-artemis] clebertsuconic commented on pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#issuecomment-819927143
The idea with this PR is that two nodes could have their mirrors enabled... you just switch the consumers and producers from one node to the next and all the data should be there.
--
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
[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r626480739
##########
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:
(To be clear, >>> usage is fine and if the resulting behaviour hasnt altered then there is obviously no problem from the change being made....I made the comment on the change before I later realised it was already pushed, and was mainly just noting it didnt seem like a necessary change, as smaller changes are nice and easier to review and reason about 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
[GitHub] [activemq-artemis] clebertsuconic commented on pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#issuecomment-819926922
I am still working on this, there are a few failures.. and I have to do some tweaking when a node is reconnecting... and I will also include duplicate detection as part of this PR... which I should finish by early next week.
--
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
[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
clebertsuconic commented on a change in pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r626071390
##########
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:
this was a bug originally... >> in Java is signaled.. if you had a negative value things would be pretty much broken.
--
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
[GitHub] [activemq-artemis] clebertsuconic closed pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
clebertsuconic closed pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545
--
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
[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r626589356
##########
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:
Should it verify it isnt dropping/overwriting data within the original long while doing this, or is that the callers responsibility?
##########
File path: artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/PriorityLinkedList.java
##########
@@ -41,6 +41,11 @@
*/
void setIDSupplier(ToLongFunction<T> supplier);
+ /**
+ * Use non zeroed IDs. 0 is reserved for null values and it should return always null.
Review comment:
LinkedList#setIDSupplier(ToLongFunction) needs updated too, it says these values must be positive.
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java
##########
@@ -150,6 +172,17 @@ public void deleteQueue(SimpleString address, SimpleString queue) throws Excepti
@Override
public void sendMessage(Message message, RoutingContext context, List<MessageReference> refs) {
+ if (context.getMirrorSource() != null &&
+ context.getMirrorSource().getRemoteMirrorId() == this.getRemoteMirrorId()) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("server " + server + " is Rejecting ping pong on send " + message);
Review comment:
'Rejecting ping pong on send' could be easy to misinterpret, particularly given the AMQP context.
Perhaps something like 'Discarding send due to avoid looping, matched remote mirror-id <id> for message <msg>'?
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java
##########
@@ -202,8 +235,34 @@ private static Properties getProperties(Message message) {
@Override
public void postAcknowledge(MessageReference ref, AckReason reason) throws Exception {
+
+ MirrorController targetController = getControllerTarget();
+
+ if (targetController != null || ref.getQueue() != null && (ref.getQueue().isInternalQueue() || ref.getQueue().isMirrorController())) {
+ logger.trace(server + " rejecting ping pong for postAcknowledge queue=" + ref.getQueue().getName() +
Review comment:
Missing if (logger.isTraceEnabled()) {
Similar comment about 'rejecting ping pong' as before.
##########
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:
Related to above, is this change just for debugging or an intended permanent change?
There is nothing to say a message with a long in the body is one of these new 'munged mirroring IDs' so it seems inappropriate to typically describe them as such, thats just going to confuse.
With this change this 'getStringBody' method also goes from only returning a value if there was a string body value present, to returning the toString of any body type which would seem quite a drastic change.
The else will also NPE if it the body section contains a null value, as some will do.
##########
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:
Setting the initial size to 1 like this will mean it has to resize as soon as you use it. Use e.g 2 or perhaps play with the load factor (which defaults to 0.75) if trying to avoid allocating the standard size, and avoid a resize on use.
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerTarget.java
##########
@@ -38,51 +36,148 @@
import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
import org.apache.activemq.artemis.core.server.mirror.MirrorController;
import org.apache.activemq.artemis.core.transaction.Transaction;
+import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
+import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessageBrokerAccessor;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager;
import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext;
import org.apache.activemq.artemis.protocol.amqp.proton.AMQPSessionContext;
import org.apache.activemq.artemis.protocol.amqp.proton.ProtonAbstractReceiver;
+import org.apache.activemq.artemis.utils.ByteUtil;
+import org.apache.activemq.artemis.utils.StringPrintStream;
+import org.apache.activemq.artemis.utils.pools.MpscPool;
import org.apache.qpid.proton.amqp.messaging.Accepted;
import org.apache.qpid.proton.amqp.messaging.AmqpValue;
import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
import org.apache.qpid.proton.engine.Delivery;
import org.apache.qpid.proton.engine.Receiver;
import org.jboss.logging.Logger;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.EVENT_TYPE;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADDRESS;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_DESTINATION;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.POST_ACK;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.QUEUE;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADD_ADDRESS;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.DELETE_ADDRESS;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.CREATE_QUEUE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.DELETE_ADDRESS;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.DELETE_QUEUE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.EVENT_TYPE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_DESTINATION;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_ID;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADDRESS_SCAN_START;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADDRESS_SCAN_END;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.POST_ACK;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.QUEUE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_ID_EXTRA_PROPERTY;
public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implements MirrorController {
- public static final SimpleString INTERNAL_ID_EXTRA_PROPERTY = SimpleString.toSimpleString(INTERNAL_ID.toString());
-
private static final Logger logger = Logger.getLogger(AMQPMirrorControllerTarget.class);
- final ActiveMQServer server;
+ private static ThreadLocal<MirrorController> controllerThreadLocal = new ThreadLocal<>();
+
+ public static void setControllerTarget(MirrorController controller) {
+ controllerThreadLocal.set(controller);
+ }
+
+ public static MirrorController getControllerTarget() {
+ return controllerThreadLocal.get();
+ }
+
+ class ACKMessage extends TransactionOperationAbstract implements IOCallback, Runnable {
+
+ Delivery delivery;
+
+ void reset() {
+ this.delivery = null;
+ }
+
+ ACKMessage setDelivery(Delivery delivery) {
+ this.delivery = delivery;
+ return this;
+ }
+
+ @Override
+ public void run() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Delivery settling for " + delivery + ", context=" + delivery.getContext());
+ }
+ delivery.disposition(Accepted.getInstance());
+ settle(delivery);
+ connection.flush();
+ AMQPMirrorControllerTarget.this.ackMessageMpscPool.release(ACKMessage.this);
+ }
+
+ @Override
+ public void beforeCommit(Transaction tx) throws Exception {
+ }
+
+ @Override
+ public void afterCommit(Transaction tx) {
+ done();
+ }
+
+ @Override
+ public void done() {
+ connection.runNow(this);
+ }
+
+ @Override
+ public void onError(int errorCode, String errorMessage) {
+ }
+ }
+
+ // in a regular case we should not have more than amqpCredits on the pool, that's the max we would need
+ private final MpscPool<ACKMessage> ackMessageMpscPool = new MpscPool<>(amqpCredits, ACKMessage::reset, () -> new ACKMessage());
final RoutingContextImpl routingContext = new RoutingContextImpl(null);
- Map<SimpleString, Map<SimpleString, QueueConfiguration>> scanAddresses;
+ final BasicMirrorController<Receiver> basicController;
+
+ final ActiveMQServer server;
+
+ final DuplicateIDCache duplicateIDCache;
+
+ private final ToLongFunction<MessageReference> referenceIDSupplier;
public AMQPMirrorControllerTarget(AMQPSessionCallback sessionSPI,
AMQPConnectionContext connection,
AMQPSessionContext protonSession,
Receiver receiver,
ActiveMQServer server) {
super(sessionSPI, connection, protonSession, receiver);
+ this.basicController = new BasicMirrorController(server);
+ this.basicController.setLink(receiver);
this.server = server;
+
+ // we ise the number of credits for the duplicate detection, as that means the maximum number of elements you can have pending
+ if (logger.isTraceEnabled()) {
+ logger.trace("Setting up Duplicate detection on " + ProtonProtocolManager.MIRROR_ADDRESS + " wth " + connection.getAmqpCredits() + " as that's the number of credits");
Review comment:
with?
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java
##########
@@ -324,13 +326,13 @@ private static void uninstallMirrorController(AMQPMirrorBrokerConnectionElement
* It is returning the snfQueue to the replica, and I needed isolation from the actual instance.
* During development I had a mistake where I used a property from the Object,
* so, I needed this isolation for my organization and making sure nothing would be shared. */
- private static Queue installMirrorController(AMQPBrokerConnection brokerConnection, AMQPMirrorBrokerConnectionElement replicaConfig, ActiveMQServer server) throws Exception {
+ private Queue installMirrorController(AMQPMirrorBrokerConnectionElement replicaConfig, ActiveMQServer server) throws Exception {
Review comment:
The comment for the method seems to be describing why this method is static, which it isnt after this change, so the comment needs removed or updated.
##########
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:
Returning potentially the entire the body in the toString seems inadvisable. Is this just for debug?
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java
##########
@@ -170,16 +203,16 @@ public void sendMessage(Message message, RoutingContext context, List<MessageRef
}
}
- public static void validateProtocolData(MessageReference ref, SimpleString snfAddress) {
+ public static void validateProtocolData(ActiveMQServer server, MessageReference ref, SimpleString snfAddress) {
if (ref.getProtocolData() == null && !ref.getMessage().getAddressSimpleString().equals(snfAddress)) {
- setProtocolData(ref);
+ setProtocolData(server, ref);
}
}
- private static void setProtocolData(MessageReference ref) {
+ private static void setProtocolData(ActiveMQServer server, MessageReference ref) {
Map<Symbol, Object> daMap = new HashMap<>();
DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(daMap);
- daMap.put(INTERNAL_ID, ref.getMessage().getMessageID());
+ daMap.put(INTERNAL_ID, ByteUtil.mixByteAndLong((byte)server.getMirrorBrokerId(), ref.getMessage().getMessageID()));
Review comment:
Just using separate annotations seems like it would be simpler and less error prone. No validation that this mixing doesnt break the id value.
There are lots of places converting this back or forth, some places even convert it one way then back the other for logging. Using a specific broker id annotation seems like it would be simpler.
##########
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:
Would restricting it to 127 rather than 255 allowed values and just using a byte be simpler than using a short as it does here and then needing to convert it where it is actually used later, which is primarily as a byte it seems?
(or, since there are only 255 values being allowed, could still just use a byte and use negatives for the other IDs whenever they are really needed, which doesn't seem likely to be all that often)
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerSource.java
##########
@@ -202,8 +235,34 @@ private static Properties getProperties(Message message) {
@Override
public void postAcknowledge(MessageReference ref, AckReason reason) throws Exception {
+
+ MirrorController targetController = getControllerTarget();
+
+ if (targetController != null || ref.getQueue() != null && (ref.getQueue().isInternalQueue() || ref.getQueue().isMirrorController())) {
+ logger.trace(server + " rejecting ping pong for postAcknowledge queue=" + ref.getQueue().getName() +
+ ", ref=" + ref);
+ return;
+ }
+
+ if (logger.isTraceEnabled()) {
+ logger.trace(server + " postAcknowledge " + ref);
+ }
+
if (acks && !ref.getQueue().isMirrorController()) { // we don't call postACK on snfqueues, otherwise we would get infinite loop because of this feedback
- Message message = createMessage(ref.getQueue().getAddress(), ref.getQueue().getName(), POST_ACK, ref.getMessage().getMessageID());
+ Long internalIDObject = (Long)ref.getMessage().getBrokerProperty(INTERNAL_ID_EXTRA_PROPERTY);
+ long internalID;
+ if (internalIDObject == null) {
+ internalID = ByteUtil.mixByteAndLong((byte)localMirrorId, ref.getMessageID());
+ } else {
+ internalID = internalIDObject.longValue();
+ if (logger.isTraceEnabled()) {
+ logger.trace("server " + server + "postAcknowledge on " + server + " acking message " + ref);
Review comment:
"server" is referenced twice in the log message.
##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/mirror/AMQPMirrorControllerTarget.java
##########
@@ -38,51 +36,148 @@
import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
import org.apache.activemq.artemis.core.server.mirror.MirrorController;
import org.apache.activemq.artemis.core.transaction.Transaction;
+import org.apache.activemq.artemis.core.transaction.TransactionOperationAbstract;
+import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessageBrokerAccessor;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPSessionCallback;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager;
import org.apache.activemq.artemis.protocol.amqp.proton.AMQPConnectionContext;
import org.apache.activemq.artemis.protocol.amqp.proton.AMQPSessionContext;
import org.apache.activemq.artemis.protocol.amqp.proton.ProtonAbstractReceiver;
+import org.apache.activemq.artemis.utils.ByteUtil;
+import org.apache.activemq.artemis.utils.StringPrintStream;
+import org.apache.activemq.artemis.utils.pools.MpscPool;
import org.apache.qpid.proton.amqp.messaging.Accepted;
import org.apache.qpid.proton.amqp.messaging.AmqpValue;
import org.apache.qpid.proton.amqp.transport.ReceiverSettleMode;
import org.apache.qpid.proton.engine.Delivery;
import org.apache.qpid.proton.engine.Receiver;
import org.jboss.logging.Logger;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.EVENT_TYPE;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADDRESS;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_DESTINATION;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.POST_ACK;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.QUEUE;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADD_ADDRESS;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.DELETE_ADDRESS;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.CREATE_QUEUE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.DELETE_ADDRESS;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.DELETE_QUEUE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.EVENT_TYPE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_DESTINATION;
import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_ID;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADDRESS_SCAN_START;
-import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.ADDRESS_SCAN_END;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.POST_ACK;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.QUEUE;
+import static org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource.INTERNAL_ID_EXTRA_PROPERTY;
public class AMQPMirrorControllerTarget extends ProtonAbstractReceiver implements MirrorController {
- public static final SimpleString INTERNAL_ID_EXTRA_PROPERTY = SimpleString.toSimpleString(INTERNAL_ID.toString());
-
private static final Logger logger = Logger.getLogger(AMQPMirrorControllerTarget.class);
- final ActiveMQServer server;
+ private static ThreadLocal<MirrorController> controllerThreadLocal = new ThreadLocal<>();
+
+ public static void setControllerTarget(MirrorController controller) {
+ controllerThreadLocal.set(controller);
+ }
+
+ public static MirrorController getControllerTarget() {
+ return controllerThreadLocal.get();
+ }
+
+ class ACKMessage extends TransactionOperationAbstract implements IOCallback, Runnable {
+
+ Delivery delivery;
+
+ void reset() {
+ this.delivery = null;
+ }
+
+ ACKMessage setDelivery(Delivery delivery) {
+ this.delivery = delivery;
+ return this;
+ }
+
+ @Override
+ public void run() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Delivery settling for " + delivery + ", context=" + delivery.getContext());
+ }
+ delivery.disposition(Accepted.getInstance());
+ settle(delivery);
+ connection.flush();
+ AMQPMirrorControllerTarget.this.ackMessageMpscPool.release(ACKMessage.this);
+ }
+
+ @Override
+ public void beforeCommit(Transaction tx) throws Exception {
+ }
+
+ @Override
+ public void afterCommit(Transaction tx) {
+ done();
+ }
+
+ @Override
+ public void done() {
+ connection.runNow(this);
+ }
+
+ @Override
+ public void onError(int errorCode, String errorMessage) {
+ }
+ }
+
+ // in a regular case we should not have more than amqpCredits on the pool, that's the max we would need
+ private final MpscPool<ACKMessage> ackMessageMpscPool = new MpscPool<>(amqpCredits, ACKMessage::reset, () -> new ACKMessage());
final RoutingContextImpl routingContext = new RoutingContextImpl(null);
- Map<SimpleString, Map<SimpleString, QueueConfiguration>> scanAddresses;
+ final BasicMirrorController<Receiver> basicController;
+
+ final ActiveMQServer server;
+
+ final DuplicateIDCache duplicateIDCache;
+
+ private final ToLongFunction<MessageReference> referenceIDSupplier;
public AMQPMirrorControllerTarget(AMQPSessionCallback sessionSPI,
AMQPConnectionContext connection,
AMQPSessionContext protonSession,
Receiver receiver,
ActiveMQServer server) {
super(sessionSPI, connection, protonSession, receiver);
+ this.basicController = new BasicMirrorController(server);
+ this.basicController.setLink(receiver);
this.server = server;
+
+ // we ise the number of credits for the duplicate detection, as that means the maximum number of elements you can have pending
Review comment:
use?
--
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
[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
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
[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org
[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r649980472
##########
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:
I'm not talking about if it belongs to a server, but whether this method overwrites any data in the high order bits of the ID when munging the two values together.
##########
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:
I still don't see that the way it is used leaves room for a difference, it never seems to store the value or access the bits that the shifting makes a difference to.
Regardless, if you found a defect, add a test for it when you resolve it, makes it clearer what is being fixed and can save discussions like 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:
Try debugging it. Unless its changed, it will resize itself again immediately during/after insertion due to exceeding the load-factor.
--
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
[GitHub] [activemq-artemis] gtully commented on a change in pull request #3545: ARTEMIS-3243 Improve Mirror with dual mirror
Posted by GitBox <gi...@apache.org>.
gtully commented on a change in pull request #3545:
URL: https://github.com/apache/activemq-artemis/pull/3545#discussion_r618201765
##########
File path: artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
##########
@@ -984,6 +984,7 @@ public void appendDeleteRecord(final long id, final boolean sync, final IOComple
}
+
Review comment:
I guess you can drop this change, one less file touched.
--
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