ARTEMIS-1333 fixing test, cannot flush itself from Runnable
This commit is contained in:
parent
4762e52ef1
commit
012fe58b2c
|
@ -91,6 +91,11 @@ public abstract class ProcessorBase<T> {
|
||||||
long timeLimit = System.currentTimeMillis() + unit.toMillis(timeout);
|
long timeLimit = System.currentTimeMillis() + unit.toMillis(timeout);
|
||||||
try {
|
try {
|
||||||
while (stateUpdater.get(this) == STATE_RUNNING && timeLimit > System.currentTimeMillis()) {
|
while (stateUpdater.get(this) == STATE_RUNNING && timeLimit > System.currentTimeMillis()) {
|
||||||
|
|
||||||
|
if (tasks.isEmpty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.activemq.artemis.core.protocol.core;
|
||||||
import javax.transaction.xa.XAResource;
|
import javax.transaction.xa.XAResource;
|
||||||
import javax.transaction.xa.Xid;
|
import javax.transaction.xa.Xid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
|
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
|
||||||
|
@ -158,6 +159,8 @@ public class ServerSessionPacketHandler implements ChannelHandler {
|
||||||
|
|
||||||
private final boolean direct;
|
private final boolean direct;
|
||||||
|
|
||||||
|
private static final ThreadLocal<AtomicBoolean> inHandler = ThreadLocal.withInitial(AtomicBoolean::new);
|
||||||
|
|
||||||
public ServerSessionPacketHandler(final ActiveMQServer server,
|
public ServerSessionPacketHandler(final ActiveMQServer server,
|
||||||
final CoreProtocolManager manager,
|
final CoreProtocolManager manager,
|
||||||
final ServerSession session,
|
final ServerSession session,
|
||||||
|
@ -225,9 +228,11 @@ public class ServerSessionPacketHandler implements ChannelHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flushExecutor() {
|
public void flushExecutor() {
|
||||||
|
if (!inHandler.get().get()) {
|
||||||
packetActor.flush();
|
packetActor.flush();
|
||||||
callExecutor.flush();
|
callExecutor.flush();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
flushExecutor();
|
flushExecutor();
|
||||||
|
@ -256,6 +261,8 @@ public class ServerSessionPacketHandler implements ChannelHandler {
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.trace("ServerSessionPacketHandler::handlePacket," + packet);
|
logger.trace("ServerSessionPacketHandler::handlePacket," + packet);
|
||||||
}
|
}
|
||||||
|
inHandler.get().set(true);
|
||||||
|
try {
|
||||||
final byte type = packet.getType();
|
final byte type = packet.getType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SESS_SEND: {
|
case SESS_SEND: {
|
||||||
|
@ -279,6 +286,9 @@ public class ServerSessionPacketHandler implements ChannelHandler {
|
||||||
slowPacketHandler(packet);
|
slowPacketHandler(packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
inHandler.get().set(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is being separated from onMessagePacket as JIT was more efficient with a small method for the
|
// This is being separated from onMessagePacket as JIT was more efficient with a small method for the
|
||||||
|
|
|
@ -65,7 +65,7 @@ public final class CoreSessionCallback implements SessionCallback {
|
||||||
@Override
|
@Override
|
||||||
public void close(boolean failed) {
|
public void close(boolean failed) {
|
||||||
ServerSessionPacketHandler localHandler = handler;
|
ServerSessionPacketHandler localHandler = handler;
|
||||||
if (failed && localHandler != null) {
|
if (localHandler != null) {
|
||||||
// We wait any pending tasks before we make this as closed
|
// We wait any pending tasks before we make this as closed
|
||||||
localHandler.flushExecutor();
|
localHandler.flushExecutor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,15 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
||||||
public void testScaleDownWithConnector() throws Exception {
|
public void testScaleDownWithConnector() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// it doesn't make sense through the core
|
||||||
|
// the pool will be shutdown while a connection is being used
|
||||||
|
// makes no sense!
|
||||||
|
@Override
|
||||||
|
public void testForceFailover() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ActiveMQServerControl createManagementControl() throws Exception {
|
protected ActiveMQServerControl createManagementControl() throws Exception {
|
||||||
return new ActiveMQServerControl() {
|
return new ActiveMQServerControl() {
|
||||||
|
|
Loading…
Reference in New Issue