You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by an...@apache.org on 2017/07/26 09:27:26 UTC
[1/3] activemq-artemis git commit: ARTEMIS-1305 Server Frozen during
shutdown if RA is retrying
Repository: activemq-artemis
Updated Branches:
refs/heads/1.x 1865e9fee -> 3ae55c068
ARTEMIS-1305 Server Frozen during shutdown if RA is retrying
(cherry picked from commit 7bf8e4e8900fad3f205aac95f3f5835f580baa43)
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/9eb2799c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/9eb2799c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/9eb2799c
Branch: refs/heads/1.x
Commit: 9eb2799cb57f938763564cc322d53e5b6b787f4b
Parents: 1865e9f
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Jul 25 22:33:55 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jul 25 22:40:47 2017 -0400
----------------------------------------------------------------------
.../core/client/impl/ServerLocatorImpl.java | 7 +-
.../artemis/ra/ActiveMQRAManagedConnection.java | 115 +++++++------------
.../artemis/ra/inflow/ActiveMQActivation.java | 26 ++---
3 files changed, 60 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9eb2799c/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
index 949ef90..1ea0cb3 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ServerLocatorImpl.java
@@ -1361,7 +1361,12 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
for (ClientSessionFactory factory : clonedFactory) {
if (sendClose) {
- factory.close();
+ try {
+ factory.close();
+ } catch (Throwable e) {
+ logger.debug(e.getMessage(), e);
+ factory.cleanup();
+ }
} else {
factory.cleanup();
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9eb2799c/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java
index efd8ccc..e53c3fd 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/ActiveMQRAManagedConnection.java
@@ -55,16 +55,14 @@ import org.apache.activemq.artemis.jms.client.ActiveMQXAConnection;
import org.apache.activemq.artemis.service.extensions.ServiceUtils;
import org.apache.activemq.artemis.service.extensions.xa.ActiveMQXAResourceWrapper;
import org.apache.activemq.artemis.utils.VersionLoader;
+import org.jboss.logging.Logger;
/**
* The managed connection
*/
public final class ActiveMQRAManagedConnection implements ManagedConnection, ExceptionListener {
- /**
- * Trace enabled
- */
- private static boolean trace = ActiveMQRALogger.LOGGER.isTraceEnabled();
+ private static final Logger logger = Logger.getLogger(ActiveMQRAManagedConnection.class);
/**
* The managed connection factory
@@ -141,7 +139,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
final ActiveMQResourceAdapter ra,
final String userName,
final String password) throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("constructor(" + mcf + ", " + cri + ", " + userName + ", ****)");
}
@@ -188,7 +186,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
@Override
public synchronized Object getConnection(final Subject subject,
final ConnectionRequestInfo cxRequestInfo) throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getConnection(" + subject + ", " + cxRequestInfo + ")");
}
@@ -219,19 +217,10 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @throws ResourceException Failed to close one or more handles.
*/
private void destroyHandles() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("destroyHandles()");
}
- try {
-
- if (connection != null) {
- connection.stop();
- }
- } catch (Throwable t) {
- ActiveMQRALogger.LOGGER.trace("Ignored error stopping connection", t);
- }
-
for (ActiveMQRASession session : handles) {
session.destroy();
}
@@ -246,7 +235,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public void destroy() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("destroy()");
}
@@ -259,41 +248,21 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
try {
connection.setExceptionListener(null);
} catch (JMSException e) {
- ActiveMQRALogger.LOGGER.debug("Error unsetting the exception listener " + this, e);
+ logger.debug("Error unsetting the exception listener " + this, e);
}
if (connection != null) {
connection.signalStopToAllSessions();
}
- destroyHandles();
-
try {
- /**
- * (xa|nonXA)Session.close() may NOT be called BEFORE connection.close()
- * <p>
- * If the ClientSessionFactory is trying to fail-over or reconnect with -1 attempts, and
- * one calls session.close() it may effectively dead-lock.
- * <p>
- * connection close will close the ClientSessionFactory which will close all sessions.
- */
- if (connection != null) {
- connection.close();
- }
-
- // The following calls should not be necessary, as the connection should close the
- // ClientSessionFactory, which will close the sessions.
- try {
- if (nonXAsession != null) {
- nonXAsession.close();
- }
+ connectionFactory.close();
+ } catch (Exception e) {
+ logger.debug(e.getMessage(), e);
+ }
- if (xaSession != null) {
- xaSession.close();
- }
- } catch (JMSException e) {
- ActiveMQRALogger.LOGGER.debug("Error closing session " + this, e);
- }
+ destroyHandles();
+ try {
// we must close the ActiveMQConnectionFactory because it contains a ServerLocator
if (connectionFactory != null) {
ra.closeConnectionFactory(mcf.getProperties());
@@ -310,7 +279,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public void cleanup() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("cleanup()");
}
@@ -340,7 +309,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public void associateConnection(final Object obj) throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("associateConnection(" + obj + ")");
}
@@ -361,9 +330,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
if (tx != null) {
int status = tx.getStatus();
// Only allow states that will actually succeed
- if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING &&
- status != Status.STATUS_PREPARED &&
- status != Status.STATUS_COMMITTING) {
+ if (status != Status.STATUS_ACTIVE && status != Status.STATUS_PREPARING && status != Status.STATUS_PREPARED && status != Status.STATUS_COMMITTING) {
throw new javax.jms.IllegalStateException("Transaction " + tx + " not active");
}
}
@@ -379,7 +346,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* Aqquire a lock on the managed connection
*/
protected void lock() {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("lock()");
}
@@ -392,7 +359,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @throws JMSException Thrown if an error occurs
*/
protected void tryLock() throws JMSException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("tryLock()");
}
@@ -414,7 +381,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* Unlock the managed connection
*/
protected void unlock() {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("unlock()");
}
@@ -428,7 +395,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public void addConnectionEventListener(final ConnectionEventListener l) {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("addConnectionEventListener(" + l + ")");
}
@@ -442,7 +409,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public void removeConnectionEventListener(final ConnectionEventListener l) {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("removeConnectionEventListener(" + l + ")");
}
@@ -457,7 +424,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public XAResource getXAResource() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getXAResource()");
}
@@ -476,7 +443,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
xaResource = ServiceUtils.wrapXAResource(activeMQRAXAResource, xaResourceProperties);
}
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("XAResource=" + xaResource);
}
@@ -491,13 +458,13 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public LocalTransaction getLocalTransaction() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getLocalTransaction()");
}
LocalTransaction tx = new ActiveMQRALocalTransaction(this);
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("LocalTransaction=" + tx);
}
@@ -513,7 +480,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public ManagedConnectionMetaData getMetaData() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getMetaData()");
}
@@ -532,7 +499,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public void setLogWriter(final PrintWriter out) throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("setLogWriter(" + out + ")");
}
}
@@ -545,7 +512,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
@Override
public PrintWriter getLogWriter() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getLogWriter()");
}
@@ -562,12 +529,12 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
if (ActiveMQConnection.EXCEPTION_FAILOVER.equals(exception.getErrorCode())) {
return;
}
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("onException(" + exception + ")");
}
if (isDestroyed.get()) {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("Ignoring error on already destroyed connection " + this, exception);
}
return;
@@ -578,7 +545,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
try {
connection.setExceptionListener(null);
} catch (JMSException e) {
- ActiveMQRALogger.LOGGER.debug("Unable to unset exception listener", e);
+ logger.debug("Unable to unset exception listener", e);
}
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, exception);
@@ -593,13 +560,13 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
*/
protected Session getSession() throws JMSException {
if (xaResource != null && inManagedTx) {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getSession() -> XA session " + xaSession.getSession());
}
return xaSession.getSession();
} else {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getSession() -> non XA session " + nonXAsession);
}
@@ -613,7 +580,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @param event The event to send.
*/
protected void sendEvent(final ConnectionEvent event) {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("sendEvent(" + event + ")");
}
@@ -656,7 +623,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @param handle The handle to remove.
*/
protected void removeHandle(final ActiveMQRASession handle) {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("removeHandle(" + handle + ")");
}
@@ -669,7 +636,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @return The connection request info for this connection.
*/
protected ActiveMQRAConnectionRequestInfo getCRI() {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getCRI()");
}
@@ -682,7 +649,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @return The connection factory for this connection.
*/
protected ActiveMQRAManagedConnectionFactory getManagedConnectionFactory() {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getManagedConnectionFactory()");
}
@@ -695,7 +662,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @throws JMSException Thrown if the connection can't be started
*/
void start() throws JMSException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("start()");
}
@@ -710,7 +677,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @throws JMSException Thrown if the connection can't be stopped
*/
void stop() throws JMSException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("stop()");
}
@@ -725,7 +692,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @return The user name
*/
protected String getUserName() {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getUserName()");
}
@@ -738,7 +705,7 @@ public final class ActiveMQRAManagedConnection implements ManagedConnection, Exc
* @throws ResourceException Thrown if a connection couldn't be created
*/
private void setup() throws ResourceException {
- if (ActiveMQRAManagedConnection.trace) {
+ if (logger.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("setup()");
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9eb2799c/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
----------------------------------------------------------------------
diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
index bd17dd3..c9f8d9b 100644
--- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
+++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java
@@ -64,7 +64,7 @@ import org.jboss.logging.Logger;
* The activation.
*/
public class ActiveMQActivation {
-
+
private static final Logger logger = Logger.getLogger(ActiveMQActivation.class);
/**
@@ -295,7 +295,7 @@ public class ActiveMQActivation {
* @throws Exception Thrown if an error occurs
*/
protected synchronized void setup() throws Exception {
- ActiveMQRALogger.LOGGER.debug("Setting up " + spec);
+ logger.debug("Setting up " + spec);
setupCF();
@@ -346,14 +346,14 @@ public class ActiveMQActivation {
factory.getServerLocator().addClusterTopologyListener(new RebalancingListener());
}
- ActiveMQRALogger.LOGGER.debug("Setup complete " + this);
+ logger.debug("Setup complete " + this);
}
/**
* Teardown the activation
*/
protected synchronized void teardown() {
- ActiveMQRALogger.LOGGER.debug("Tearing down " + spec);
+ logger.debug("Tearing down " + spec);
long timeout = factory == null ? ActiveMQClient.DEFAULT_CALL_TIMEOUT : factory.getCallTimeout();
@@ -442,7 +442,7 @@ public class ActiveMQActivation {
nodes.clear();
lastReceived = false;
- ActiveMQRALogger.LOGGER.debug("Tearing down complete " + this);
+ logger.debug("Tearing down complete " + this);
}
protected void setupCF() throws Exception {
@@ -486,7 +486,7 @@ public class ActiveMQActivation {
result.addMetaData(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);
}
- ActiveMQRALogger.LOGGER.debug("Using queue connection " + result);
+ logger.debug("Using queue connection " + result);
return result;
} catch (Throwable t) {
@@ -519,14 +519,14 @@ public class ActiveMQActivation {
} else {
ctx = new InitialContext(spec.getParsedJndiParams());
}
- ActiveMQRALogger.LOGGER.debug("Using context " + ctx.getEnvironment() + " for " + spec);
+ logger.debug("Using context " + ctx.getEnvironment() + " for " + spec);
if (logger.isTraceEnabled()) {
logger.trace("setupDestination(" + ctx + ")");
}
String destinationTypeString = spec.getDestinationType();
if (destinationTypeString != null && !destinationTypeString.trim().equals("")) {
- ActiveMQRALogger.LOGGER.debug("Destination type defined as " + destinationTypeString);
+ logger.debug("Destination type defined as " + destinationTypeString);
Class<?> destinationType;
if (Topic.class.getName().equals(destinationTypeString)) {
@@ -536,7 +536,7 @@ public class ActiveMQActivation {
destinationType = Queue.class;
}
- ActiveMQRALogger.LOGGER.debug("Retrieving " + destinationType.getName() + " \"" + destinationName + "\" from JNDI");
+ logger.debug("Retrieving " + destinationType.getName() + " \"" + destinationName + "\" from JNDI");
try {
destination = (ActiveMQDestination) ActiveMQRaUtils.lookup(ctx, destinationName, destinationType);
@@ -547,7 +547,7 @@ public class ActiveMQActivation {
String calculatedDestinationName = destinationName.substring(destinationName.lastIndexOf('/') + 1);
- ActiveMQRALogger.LOGGER.debug("Unable to retrieve " + destinationName +
+ logger.debug("Unable to retrieve " + destinationName +
" from JNDI. Creating a new " + destinationType.getName() +
" named " + calculatedDestinationName + " to be used by the MDB.");
@@ -559,8 +559,8 @@ public class ActiveMQActivation {
}
}
} else {
- ActiveMQRALogger.LOGGER.debug("Destination type not defined in MDB activation configuration.");
- ActiveMQRALogger.LOGGER.debug("Retrieving " + Destination.class.getName() + " \"" + destinationName + "\" from JNDI");
+ logger.debug("Destination type not defined in MDB activation configuration.");
+ logger.debug("Retrieving " + Destination.class.getName() + " \"" + destinationName + "\" from JNDI");
destination = (ActiveMQDestination) ActiveMQRaUtils.lookup(ctx, destinationName, Destination.class);
if (destination instanceof Topic) {
@@ -646,7 +646,7 @@ public class ActiveMQActivation {
try {
Thread.sleep(setupInterval);
} catch (InterruptedException e) {
- ActiveMQRALogger.LOGGER.debug("Interrupted trying to reconnect " + spec, e);
+ logger.debug("Interrupted trying to reconnect " + spec, e);
break;
}
[3/3] activemq-artemis git commit: This closes #1420 ARTEMIS-1305
Server Frozen during shutdown if RA is retrying
Posted by an...@apache.org.
This closes #1420 ARTEMIS-1305 Server Frozen during shutdown if RA is retrying
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/3ae55c06
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/3ae55c06
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/3ae55c06
Branch: refs/heads/1.x
Commit: 3ae55c06804eacf7203696d7eb382c3c002624a6
Parents: 1865e9f 41bd6c7
Author: Andy Taylor <an...@gmail.com>
Authored: Wed Jul 26 10:27:09 2017 +0100
Committer: Andy Taylor <an...@gmail.com>
Committed: Wed Jul 26 10:27:09 2017 +0100
----------------------------------------------------------------------
.../core/client/impl/ServerLocatorImpl.java | 7 +-
.../artemis/ra/ActiveMQRAManagedConnection.java | 115 ++++-------
.../artemis/ra/inflow/ActiveMQActivation.java | 26 +--
.../byteman/LargeMessageReplicationTest.java | 205 -------------------
4 files changed, 60 insertions(+), 293 deletions(-)
----------------------------------------------------------------------
[2/3] activemq-artemis git commit: ARTEMIS-1261 Fix compilation
Posted by an...@apache.org.
ARTEMIS-1261 Fix compilation
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/41bd6c7c
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/41bd6c7c
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/41bd6c7c
Branch: refs/heads/1.x
Commit: 41bd6c7cfb763025f3e0f7aa44260263dedd977c
Parents: 9eb2799
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Jul 25 22:43:57 2017 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Jul 25 22:43:57 2017 -0400
----------------------------------------------------------------------
.../byteman/LargeMessageReplicationTest.java | 205 -------------------
1 file changed, 205 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/41bd6c7c/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageReplicationTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageReplicationTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageReplicationTest.java
deleted file mode 100644
index 9429ab0..0000000
--- a/tests/extra-tests/src/test/java/org/apache/activemq/artemis/tests/extras/byteman/LargeMessageReplicationTest.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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.extras.byteman;
-
-import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
-import org.apache.activemq.artemis.api.core.RoutingType;
-import org.apache.activemq.artemis.api.core.TransportConfiguration;
-import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
-import org.apache.activemq.artemis.api.core.client.ClientConsumer;
-import org.apache.activemq.artemis.api.core.client.ClientMessage;
-import org.apache.activemq.artemis.api.core.client.ClientProducer;
-import org.apache.activemq.artemis.api.core.client.ClientSession;
-import org.apache.activemq.artemis.api.core.client.ServerLocator;
-import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal;
-import org.apache.activemq.artemis.core.config.Configuration;
-import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
-import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
-import org.apache.activemq.artemis.core.config.DivertConfiguration;
-import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
-import org.apache.activemq.artemis.tests.integration.cluster.failover.FailoverTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-@RunWith(BMUnitRunner.class)
-public class LargeMessageReplicationTest extends FailoverTestBase {
-
-
- private static final String DIVERT_ADDRESS = "jms.queue.testQueue";
- private static final String DIVERT_FORWARD_ADDRESS = "jms.queue.divertedQueue";
- private ClientSessionFactoryInternal sf;
-
- private static AtomicLong copyThread = new AtomicLong(-1);
- private static List<byte[]> sourceBytes = new ArrayList<>();
- private static byte[] originalBuffer;
- private static boolean isOk;
-
- @Before
- @Override
- public void setUp() throws Exception {
- super.setUp();
- isOk = true;
- }
-
- @Override
- protected TransportConfiguration getAcceptorTransportConfiguration(final boolean live) {
- return getNettyAcceptorTransportConfiguration(live);
- }
-
- @Override
- protected TransportConfiguration getConnectorTransportConfiguration(final boolean live) {
- return getNettyConnectorTransportConfiguration(live);
- }
-
- @Override
- protected void createConfigs() throws Exception {
- createReplicatedConfigs();
-
- liveConfig.setJournalFileSize(10240000);
- backupConfig.setJournalFileSize(10240000);
- addQueue(liveConfig, DIVERT_ADDRESS, DIVERT_ADDRESS);
- addQueue(liveConfig, DIVERT_FORWARD_ADDRESS, DIVERT_FORWARD_ADDRESS);
- addDivert(liveConfig, DIVERT_ADDRESS, DIVERT_FORWARD_ADDRESS, false);
- addDivert(backupConfig, DIVERT_ADDRESS, DIVERT_FORWARD_ADDRESS, false);
- }
-
- private void addQueue(Configuration serverConfig, String address, String name) {
-
- List<CoreAddressConfiguration> addrConfigs = serverConfig.getAddressConfigurations();
- CoreAddressConfiguration addrCfg = new CoreAddressConfiguration();
- addrCfg.setName(address);
- addrCfg.addRoutingType(RoutingType.ANYCAST);
- CoreQueueConfiguration qConfig = new CoreQueueConfiguration();
- qConfig.setName(name);
- qConfig.setAddress(address);
- addrCfg.addQueueConfiguration(qConfig);
- addrConfigs.add(addrCfg);
- }
-
- private void addDivert(Configuration serverConfig, String source, String target, boolean exclusive) {
- List<DivertConfiguration> divertConfigs = serverConfig.getDivertConfigurations();
- DivertConfiguration newDivert = new DivertConfiguration();
- newDivert.setName("myDivert");
- newDivert.setAddress(source);
- newDivert.setForwardingAddress(target);
- newDivert.setExclusive(exclusive);
- divertConfigs.add(newDivert);
- }
-
- @Test
- @BMRules(
- rules = {@BMRule(
- name = "record large message copy thread",
- targetClass = "org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl",
- targetMethod = "copy(long)",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.artemis.tests.extras.byteman.LargeMessageReplicationTest.copyThread()"), @BMRule(
- name = "record byte array in addBytes",
- targetClass = "org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl",
- targetMethod = "addBytes(byte[])",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.artemis.tests.extras.byteman.LargeMessageReplicationTest.addBytesIn($1)"), @BMRule(
- name = "record byte array used for reading large message",
- targetClass = "^org.apache.activemq.artemis.core.io.SequentialFile",
- isInterface = true,
- targetMethod = "read(java.nio.ByteBuffer)",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.artemis.tests.extras.byteman.LargeMessageReplicationTest.originBuff($1)")})
- //https://issues.apache.org/jira/browse/ARTEMIS-1220
- public void testDivertCopyMessageBuffer() throws Exception {
- Map<String, Object> params = new HashMap<>();
- params.put(TransportConstants.HOST_PROP_NAME, "localhost");
- TransportConfiguration tc = createTransportConfiguration(true, false, params);
- ServerLocator locator = addServerLocator(ActiveMQClient.createServerLocatorWithHA(tc)).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true).setReconnectAttempts(-1);
- sf = createSessionFactoryAndWaitForTopology(locator, 2);
- int minLarge = locator.getMinLargeMessageSize();
-
- ClientSession session = sf.createSession(false, false);
- addClientSession(session);
- session.start();
-
- ClientProducer producer = session.createProducer(DIVERT_ADDRESS);
- ClientMessage message = createLargeMessage(session, 3 * minLarge);
- producer.send(message);
-
- session.commit();
-
- ClientConsumer consumer = session.createConsumer(DIVERT_ADDRESS);
- ClientMessage receivedFromSourceQueue = consumer.receive(5000);
- assertNotNull(receivedFromSourceQueue);
- receivedFromSourceQueue.acknowledge();
- session.commit();
-
- crash(session);
-
- ClientConsumer consumer1 = session.createConsumer(DIVERT_FORWARD_ADDRESS);
- ClientMessage receivedFromTargetQueue = consumer1.receive(5000);
- assertNotNull(receivedFromTargetQueue);
- receivedFromTargetQueue.acknowledge();
-
- session.commit();
-
- checkBufferNotReused();
- }
-
- private void checkBufferNotReused() throws Exception {
- assertNotNull("Didn't catch the original buffer!", originalBuffer);
- assertTrue("Didn't catch the read buffer!", sourceBytes.size() > 0);
- for (byte[] array : sourceBytes) {
- assertFalse("Buffer reused!", originalBuffer == array);
- }
- }
-
- private ClientMessage createLargeMessage(ClientSession session, final int largeSize) {
- ClientMessage message = session.createMessage(true);
- ActiveMQBuffer bodyBuffer = message.getBodyBuffer();
- final int propSize = 10240;
- while (bodyBuffer.writerIndex() < largeSize) {
- byte[] prop = new byte[propSize];
- bodyBuffer.writeBytes(prop);
- }
- return message;
- }
-
- private static void copyThread() {
- System.out.println("_************************ " + Thread.currentThread().getId());
- copyThread.set(Thread.currentThread().getId());
- }
-
- private static void addBytesIn(final byte[] bytes) {
- if (copyThread.get() != -1 && copyThread.get() == Thread.currentThread().getId()) {
- sourceBytes.add(bytes);
- }
- }
-
- private static void originBuff(final ByteBuffer buff) {
- if (copyThread.get() != -1 && copyThread.get() == Thread.currentThread().getId()) {
- originalBuffer = buff.array();
- }
- }
-}