gemmellr commented on code in PR #5221:
URL: https://github.com/apache/activemq-artemis/pull/5221#discussion_r1771683716
##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/FileUtil.java:
##########
@@ -126,4 +133,21 @@ public static boolean findReplace(File file, String find,
String replace) throws
}
}
+ public static String readFile(InputStream inputStream) throws Exception {
+ BufferedReader bufferedReader = new BufferedReader(new
InputStreamReader(inputStream));
+ String fileOutput =
bufferedReader.lines().collect(Collectors.joining(System.lineSeparator()));
+ return fileOutput;
+ }
+
+ public static boolean find(File file, Predicate<String> search) throws
Exception {
+ AtomicBoolean found = new AtomicBoolean(false);
+ try (Stream<String> lines = Files.lines(file.toPath())) {
+ lines.filter(search::test).findFirst().ifPresent(line -> {
+ logger.info("pattern found at {}", line);
Review Comment:
Should this be info level given this is in artemis-commons?
Also, should the method be in artemis-commons at all given it is only used
in a test util?
##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/PriorityLinkedListImpl.java:
##########
@@ -40,6 +41,10 @@ public class PriorityLinkedListImpl<E> implements
PriorityLinkedList<E> {
private int lastPriority = -1;
+ protected void removed(final int level, final E element) {
+ exclusiveIncrementSize(-1);
+ }
Review Comment:
Is this new method just for debugging? It doesnt seem to use either of the
arguments, which seems odd given in one case new field tracking was added just
to pass it.
##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/LinkedListIterator.java:
##########
@@ -27,6 +27,9 @@ public interface LinkedListIterator<E> extends Iterator<E>,
AutoCloseable {
void repeat();
+ /** This method is doing exactly what {@link Iterator#remove()} would do,
however it will return the removed element being removed. */
+ E removeLastElement();
Review Comment:
removeLastElement() seems ambiguous. If its the same as remove(), which
operates on the _current_ element in most Iterators, something like
removeCurrentElement() element would probably be more straightforward for later
users. Or something much more on the nose like removeAndReturn().
##########
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/LinkedListImpl.java:
##########
@@ -599,23 +599,33 @@ public E next() {
@Override
public void remove() {
+ removeLastElement();
+ }
+
+ @Override
+ public E removeLastElement() {
Review Comment:
This doesnt seem like it satisfies the requirement to throw
IllegalStateException if the method is called again before next() is called
again.
Though I cant really follow what it actually does given it maintains 'last'
inside next() and yet then only removes based on 'current', both of which are
seemingly updated separately, including by other iterators 'nudges'?
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java:
##########
@@ -3070,6 +3053,11 @@ private void internalAddSorted(final MessageReference
ref) {
}
private int getPriority(MessageReference ref) {
+ if (isInternalQueue()) {
+ // if it's an internal queue we need to send the events on their
original ordering
+ // for example an ACK arriving before the send on a Mirror..
+ return 4;
+ }
Review Comment:
Is this true of _all_ such queues? They arent all for mirroring.
##########
tests/soak-tests/src/test/java/org/apache/activemq/artemis/tests/soak/brokerConnection/mirror/LogAssert.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.tests.soak.brokerConnection.mirror;
+
+import java.io.File;
+
+import org.apache.activemq.artemis.utils.FileUtil;
+
+public class LogAssert {
+
+ public static void assertServerLogsForMirror(File serverLocation) throws
Exception {
+ File log = new File(serverLocation, "log/artemis.log");
+ FileUtil.find(log, l -> l.contains("NullPointerException") ||
l.contains("AMQ111010"));
Review Comment:
This assert method seems like maybe it isnt asserting anything; it ignores
the boolean return value from FindUtil.find() ?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact