This commit is contained in:
Clebert Suconic 2017-04-19 00:49:48 -04:00
commit cc4c3957b1
8 changed files with 35 additions and 16 deletions

View File

@ -18,20 +18,28 @@
package org.apache.activemq.artemis.core.remoting.impl.netty;
import org.apache.activemq.artemis.utils.Env;
import org.jboss.logging.Logger;
/**
* Tells if <a href="http://netty.io/wiki/native-transports.html">{@code netty-transport-native-epoll}</a> is supported.
*/
public final class Epoll {
private static final boolean IS_AVAILABLE_EPOLL;
private static final Logger logger = Logger.getLogger(Epoll.class);
private static final boolean IS_AVAILABLE_EPOLL = isIsAvailableEpoll();
static {
if (Env.is64BitJvm() && Env.isLinuxOs()) {
IS_AVAILABLE_EPOLL = io.netty.channel.epoll.Epoll.isAvailable();
} else {
IS_AVAILABLE_EPOLL = false;
private static boolean isIsAvailableEpoll() {
try {
if (Env.is64BitJvm() && Env.isLinuxOs()) {
return io.netty.channel.epoll.Epoll.isAvailable();
} else {
return false;
}
} catch (Throwable e) {
logger.warn(e.getMessage(), e);
return false;
}
}
private Epoll() {

View File

@ -164,7 +164,7 @@ public class JournalCrashTest extends ActiveMQTestBase {
*/
private void runExternalProcess(final String tempDir, final int start, final int end) throws Exception {
System.err.println("running external process...");
Process process = SpawnedVMSupport.spawnVM(this.getClass().getCanonicalName(), "-Xms128m", "-Xmx128m", new String[]{}, true, true, tempDir, Integer.toString(start), Integer.toString(end));
Process process = SpawnedVMSupport.spawnVM(this.getClass().getCanonicalName(), "-Xms128m", "-Xmx128m", new String[]{}, true, true, true, tempDir, Integer.toString(start), Integer.toString(end));
Assert.assertEquals(100, process.waitFor());
}

View File

@ -45,7 +45,7 @@ public class RealNodeManagerTest extends NodeManagerTest {
public void performWork(NodeManagerAction... actions) throws Exception {
List<Process> processes = new ArrayList<>();
for (NodeManagerAction action : actions) {
Process p = SpawnedVMSupport.spawnVM(NodeManagerAction.class.getName(), "-Xms512m", "-Xmx512m", new String[0], true, true, action.getWork());
Process p = SpawnedVMSupport.spawnVM(NodeManagerAction.class.getName(), "-Xms512m", "-Xmx512m", new String[0], true, true, true, action.getWork());
processes.add(p);
}
for (Process process : processes) {

View File

@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.QueueImpl;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.utils.Base64;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.Assert;
@ -345,6 +346,7 @@ public class AddressControlTest extends ManagementTestBase {
Assert.assertEquals(1, addressControl.getQueueNames().length);
addressControl.sendMessage(null, Message.BYTES_TYPE, Base64.encodeBytes("test".getBytes()), false, null, null);
Wait.waitFor(() -> addressControl.getMessageCount() == 1);
Assert.assertEquals(1, addressControl.getMessageCount());
ClientConsumer consumer = session.createConsumer(address);

View File

@ -66,14 +66,13 @@ public class NettySecurityClientTest extends ActiveMQTestBase {
// spawn a JVM that creates a client with a security manager which sends and receives a
// test message
Process p = SpawnedVMSupport.spawnVM(SimpleClient.class.getName(), "-Xms512m", "-Xmx512m", vmargs, false, true, new String[]{NETTY_CONNECTOR_FACTORY});
Process p = SpawnedVMSupport.spawnVM(SimpleClient.class.getName(), "-Xms512m", "-Xmx512m", vmargs, true, true, false, new String[]{NETTY_CONNECTOR_FACTORY});
InputStreamReader isr = new InputStreamReader(p.getInputStream());
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
//System.out.println(line);
line = line.replace('|', '\n');
if (line.startsWith("Listening")) {
continue;

View File

@ -37,12 +37,14 @@ final class SimpleClient {
if (args.length != 1) {
throw new Exception("require 1 argument: connector factory class name");
}
System.out.println("I'm here");
String connectorFactoryClassName = args[0];
String queueName = RandomUtil.randomString();
String messageText = RandomUtil.randomString();
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorFactoryClassName));
ServerLocator locator = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(connectorFactoryClassName)).setReconnectAttempts(1).setInitialConnectAttempts(1);
try {
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = sf.createSession(false, true, true);
@ -77,6 +79,7 @@ final class SimpleClient {
locator.close();
}
} catch (Throwable t) {
t.printStackTrace(System.out);
String allStack = t.getMessage() + "|";
StackTraceElement[] stackTrace = t.getStackTrace();

View File

@ -29,6 +29,9 @@ grant {
permission java.util.PropertyPermission "activemq.artemis.client.global.thread.pool.max.size", "read";
permission java.util.PropertyPermission "activemq.artemis.client.global.scheduled.thread.pool.core.size", "read";
permission java.util.PropertyPermission "io.netty.eventLoopThreads", "read";
permission java.util.PropertyPermission "io.netty.maxThreadLocalCharBufferSize", "read";
permission java.util.PropertyPermission "io.netty.batch.bytes", "read";
permission java.util.PropertyPermission "com.ibm.vm.bitmode", "read";
permission java.util.PropertyPermission "io.netty.noUnsafe", "read";
permission java.util.PropertyPermission "io.netty.tryUnsafe", "read";
permission java.util.PropertyPermission "org.jboss.netty.tryUnsafe", "read";

View File

@ -57,7 +57,7 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final String... args) throws Exception {
return SpawnedVMSupport.spawnVM(className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, args);
return SpawnedVMSupport.spawnVM(className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, true, args);
}
public static Process spawnVMWithLogMacher(String wordMatch,
@ -66,7 +66,7 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final String... args) throws Exception {
return SpawnedVMSupport.spawnVM(wordMatch, runnable, className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, args);
return SpawnedVMSupport.spawnVM(wordMatch, runnable, className, "-Xms512m", "-Xmx512m", vmargs, logOutput, true, true, args);
}
public static Process spawnVM(final String className,
@ -75,8 +75,9 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final boolean logErrorOutput,
final boolean useLogging,
final String... args) throws Exception {
return spawnVM(null, null, className, memoryArg1, memoryArg2, vmargs, logOutput, logErrorOutput, args);
return spawnVM(null, null, className, memoryArg1, memoryArg2, vmargs, logOutput, logErrorOutput, useLogging, args);
}
public static Process spawnVM(final String wordMatch,
@ -87,6 +88,7 @@ public final class SpawnedVMSupport {
final String[] vmargs,
final boolean logOutput,
final boolean logErrorOutput,
final boolean useLogging,
final String... args) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
final String javaPath = Paths.get(System.getProperty("java.home"), "bin", "java").toAbsolutePath().toString();
@ -102,8 +104,10 @@ public final class SpawnedVMSupport {
}
// The logs will be huge if you don't set this
commandList.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager");
commandList.add("-Dlogging.configuration=file:../config/logging.properties");
if (useLogging) {
commandList.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager");
commandList.add("-Dlogging.configuration=file:../config/logging.properties");
}
commandList.add("-Djava.io.tmpdir=" + System.getProperty("java.io.tmpdir", "./tmp"));
commandList.add("-Djava.library.path=" + System.getProperty("java.library.path", "./native/bin"));