ARTEMIS-3995 Mute Artemis Maven Plugin
The ActiveMQ Artemis Maven plugin will throw system.out and log.info for a lot of stuff, This should mute some of that output.
This commit is contained in:
parent
fda7f6ba37
commit
8d1865fdcb
|
@ -47,7 +47,7 @@ public class Artemis {
|
|||
String instance = System.getProperty("artemis.instance");
|
||||
File fileInstance = instance != null ? new File(instance) : null;
|
||||
|
||||
Object result = execute(fileHome, fileInstance, args);
|
||||
Object result = execute(fileHome, fileInstance, true, args);
|
||||
if (result instanceof Exception) {
|
||||
// Set a nonzero status code for the exceptions caught and printed by org.apache.activemq.artemis.cli.Artemis.execute
|
||||
System.exit(1);
|
||||
|
@ -57,14 +57,14 @@ public class Artemis {
|
|||
/**
|
||||
* This is a good method for booting an embedded command
|
||||
*/
|
||||
public static Object execute(File artemisHome, File artemisInstance, List<String> args) throws Throwable {
|
||||
return execute(artemisHome, artemisInstance, args.toArray(new String[args.size()]));
|
||||
public static Object execute(File artemisHome, File artemisInstance, boolean useSystemOut, List<String> args) throws Throwable {
|
||||
return execute(artemisHome, artemisInstance, useSystemOut, args.toArray(new String[args.size()]));
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a good method for booting an embedded command
|
||||
*/
|
||||
public static Object execute(File fileHome, File fileInstance, String... args) throws Throwable {
|
||||
public static Object execute(File fileHome, File fileInstance, boolean useSystemOut, String... args) throws Throwable {
|
||||
ArrayList<File> dirs = new ArrayList<>();
|
||||
if (fileHome != null) {
|
||||
dirs.add(new File(fileHome, "lib"));
|
||||
|
@ -128,10 +128,10 @@ public class Artemis {
|
|||
URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
|
||||
Thread.currentThread().setContextClassLoader(loader);
|
||||
Class<?> clazz = loader.loadClass("org.apache.activemq.artemis.cli.Artemis");
|
||||
Method method = clazz.getMethod("execute", Boolean.TYPE, File.class, File.class, args.getClass());
|
||||
Method method = clazz.getMethod("execute", Boolean.TYPE, Boolean.TYPE, File.class, File.class, args.getClass());
|
||||
|
||||
try {
|
||||
return method.invoke(null, true, fileHome, fileInstance, args);
|
||||
return method.invoke(null, useSystemOut, useSystemOut, fileHome, fileInstance, args);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw e.getTargetException();
|
||||
} finally {
|
||||
|
|
|
@ -88,7 +88,7 @@ public class Artemis {
|
|||
String instance = System.getProperty("artemis.instance");
|
||||
File fileInstance = instance != null ? new File(instance) : null;
|
||||
|
||||
execute(true, fileHome, fileInstance, args);
|
||||
execute(true, true, fileHome, fileInstance, args);
|
||||
}
|
||||
|
||||
public static Object internalExecute(String... args) throws Exception {
|
||||
|
@ -96,23 +96,34 @@ public class Artemis {
|
|||
}
|
||||
|
||||
public static Object execute(File artemisHome, File artemisInstance, List<String> args) throws Exception {
|
||||
return execute(false, artemisHome, artemisInstance, args.toArray(new String[args.size()]));
|
||||
return execute(false, false, artemisHome, artemisInstance, args.toArray(new String[args.size()]));
|
||||
}
|
||||
|
||||
public static Object execute(boolean inputEnabled, File artemisHome, File artemisInstance, ActionContext context, String... args) throws Exception {
|
||||
public static Object execute(boolean inputEnabled, boolean useSystemOut, File artemisHome, File artemisInstance, String... args) throws Exception {
|
||||
|
||||
if (inputEnabled) {
|
||||
InputAbstract.enableInput();
|
||||
}
|
||||
|
||||
final ActionContext context;
|
||||
|
||||
if (useSystemOut) {
|
||||
context = new ActionContext();
|
||||
} else {
|
||||
context = new ActionContext(InputStream.nullInputStream(), new PrintStream(OutputStream.nullOutputStream()), System.err);
|
||||
}
|
||||
|
||||
ActionContext.setSystem(context);
|
||||
|
||||
try {
|
||||
return internalExecute(artemisHome, artemisInstance, args, context);
|
||||
} catch (ConfigurationException configException) {
|
||||
System.err.println(configException.getMessage());
|
||||
System.out.println();
|
||||
System.out.println("Configuration should be specified as 'scheme:location'. Default configuration is 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'");
|
||||
context.err.println(configException.getMessage());
|
||||
context.out.println();
|
||||
context.out.println("Configuration should be specified as 'scheme:location'. Default configuration is 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'");
|
||||
return configException;
|
||||
} catch (CLIException cliException) {
|
||||
System.err.println(cliException.getMessage());
|
||||
context.err.println(cliException.getMessage());
|
||||
return cliException;
|
||||
} catch (NullPointerException e) {
|
||||
// Yeah.. I really meant System.err..
|
||||
|
@ -121,20 +132,18 @@ public class Artemis {
|
|||
e.printStackTrace();
|
||||
return e;
|
||||
} catch (RuntimeException | InvalidOptionsError re) {
|
||||
System.err.println(re.getMessage());
|
||||
System.out.println();
|
||||
context.err.println(re.getMessage());
|
||||
context.out.println();
|
||||
|
||||
Cli<Action> parser = builder(null).build();
|
||||
|
||||
parser.parse("help").execute(context);
|
||||
return re;
|
||||
} finally {
|
||||
ActionContext.setSystem(new ActionContext());
|
||||
}
|
||||
}
|
||||
|
||||
public static Object execute(boolean inputEnabled, File artemisHome, File artemisInstance, String... args) throws Exception {
|
||||
return execute(inputEnabled, artemisHome, artemisInstance, ActionContext.system(), args);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to validate exception returns.
|
||||
* Useful on test cases
|
||||
|
@ -148,12 +157,12 @@ public class Artemis {
|
|||
action.setHomeValues(artemisHome, artemisInstance);
|
||||
|
||||
if (action.isVerbose()) {
|
||||
System.out.print("Executing " + action.getClass().getName() + " ");
|
||||
context.out.print("Executing " + action.getClass().getName() + " ");
|
||||
for (String arg : args) {
|
||||
System.out.print(arg + " ");
|
||||
context.out.print(arg + " ");
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("Home::" + action.getBrokerHome() + ", Instance::" + action.getBrokerInstance());
|
||||
context.out.println();
|
||||
context.out.println("Home::" + action.getBrokerHome() + ", Instance::" + action.getBrokerInstance());
|
||||
}
|
||||
|
||||
action.checkOptions(args);
|
||||
|
@ -198,10 +207,6 @@ public class Artemis {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static void printBanner() throws Exception {
|
||||
printBanner(System.out);
|
||||
}
|
||||
|
||||
public static void printBanner(PrintStream out) throws Exception {
|
||||
copy(Artemis.class.getResourceAsStream("banner.txt"), out);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,14 @@ public abstract class ActionAbstract implements Action {
|
|||
|
||||
private URI brokerInstanceURI;
|
||||
|
||||
protected ActionContext context;
|
||||
private ActionContext actionContext;
|
||||
|
||||
protected ActionContext getActionContext() {
|
||||
if (actionContext == null) {
|
||||
actionContext = ActionContext.system();
|
||||
}
|
||||
return actionContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVerbose() {
|
||||
|
@ -105,7 +112,7 @@ public abstract class ActionAbstract implements Action {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
if (isVerbose()) {
|
||||
System.out.print("Can not get the broker url instance: " + e.toString());
|
||||
getActionContext().out.print("Can not get the broker url instance: " + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +185,8 @@ public abstract class ActionAbstract implements Action {
|
|||
|
||||
@Override
|
||||
public Object execute(ActionContext context) throws Exception {
|
||||
this.context = context;
|
||||
this.actionContext = context;
|
||||
ActionContext.setSystem(context);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,14 @@ public class ActionContext {
|
|||
public PrintStream out;
|
||||
public PrintStream err;
|
||||
|
||||
private static ThreadLocal<ActionContext> contextThreadLocal = ThreadLocal.withInitial(() -> new ActionContext());
|
||||
|
||||
public static void setSystem(ActionContext context) {
|
||||
contextThreadLocal.set(context);
|
||||
}
|
||||
|
||||
public static ActionContext system() {
|
||||
return new ActionContext(System.in, System.out, System.err);
|
||||
return contextThreadLocal.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -506,7 +506,7 @@ public class Create extends InputAbstract {
|
|||
password = inputPassword("--password", "Please provide the default password:", "admin");
|
||||
}
|
||||
|
||||
password = HashUtil.tryHash(context, password);
|
||||
password = HashUtil.tryHash(getActionContext(), password);
|
||||
|
||||
return password;
|
||||
}
|
||||
|
@ -874,9 +874,9 @@ public class Create extends InputAbstract {
|
|||
|
||||
if (jdbc) {
|
||||
noAutoTune = true;
|
||||
System.out.println();
|
||||
context.out.println();
|
||||
printStar("Copy a jar containing the JDBC Driver '" + jdbcClassName + "' into " + directory.getAbsolutePath() + "/lib");
|
||||
System.out.println();
|
||||
context.out.println();
|
||||
}
|
||||
|
||||
performAutoTune(filters, journalType, dataFolder);
|
||||
|
@ -958,11 +958,11 @@ public class Create extends InputAbstract {
|
|||
for (int i = 0; i < size; i++) {
|
||||
buffer.append("*");
|
||||
}
|
||||
System.out.println(buffer.toString());
|
||||
System.out.println();
|
||||
System.out.println(message);
|
||||
System.out.println();
|
||||
System.out.println(buffer.toString());
|
||||
getActionContext().out.println(buffer.toString());
|
||||
getActionContext().out.println();
|
||||
getActionContext().out.println(message);
|
||||
getActionContext().out.println();
|
||||
getActionContext().out.println(buffer.toString());
|
||||
}
|
||||
|
||||
private void setupJournalType() {
|
||||
|
@ -1081,8 +1081,8 @@ public class Create extends InputAbstract {
|
|||
} else {
|
||||
try {
|
||||
int writes = 250;
|
||||
System.out.println("");
|
||||
System.out.println("Auto tuning journal ...");
|
||||
getActionContext().out.println("");
|
||||
getActionContext().out.println("Auto tuning journal ...");
|
||||
|
||||
if (mapped && noJournalSync) {
|
||||
HashMap<String, String> syncFilter = new HashMap<>();
|
||||
|
@ -1090,7 +1090,7 @@ public class Create extends InputAbstract {
|
|||
syncFilter.put("${writesPerMillisecond}", "0");
|
||||
syncFilter.put("${maxaio}", journalType == JournalType.ASYNCIO ? "" + ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio() : "1");
|
||||
|
||||
System.out.println("...Since you disabled sync and are using MAPPED journal, we are diabling buffer times");
|
||||
getActionContext().out.println("...Since you disabled sync and are using MAPPED journal, we are diabling buffer times");
|
||||
|
||||
filters.put("${journal-buffer.settings}", readTextFile(ETC_JOURNAL_BUFFER_SETTINGS, syncFilter));
|
||||
|
||||
|
@ -1107,7 +1107,7 @@ public class Create extends InputAbstract {
|
|||
syncFilter.put("${writesPerMillisecond}", writesPerMillisecondStr);
|
||||
syncFilter.put("${maxaio}", journalType == JournalType.ASYNCIO ? "" + ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio() : "1");
|
||||
|
||||
System.out.println("done! Your system can make " + writesPerMillisecondStr +
|
||||
getActionContext().out.println("done! Your system can make " + writesPerMillisecondStr +
|
||||
" writes per millisecond, your journal-buffer-timeout will be " + nanoseconds);
|
||||
|
||||
filters.put("${journal-buffer.settings}", readTextFile(ETC_JOURNAL_BUFFER_SETTINGS, syncFilter));
|
||||
|
@ -1222,7 +1222,7 @@ public class Create extends InputAbstract {
|
|||
try {
|
||||
content = replace(content, entry.getKey(), entry.getValue());
|
||||
} catch (Throwable e) {
|
||||
System.out.println("Error on " + entry.getKey());
|
||||
getActionContext().out.println("Error on " + entry.getKey());
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
}
|
||||
|
|
|
@ -101,13 +101,13 @@ public class InputAbstract extends ActionAbstract {
|
|||
|
||||
String inputStr;
|
||||
boolean valid = false;
|
||||
System.out.println();
|
||||
getActionContext().out.println();
|
||||
do {
|
||||
context.out.println(propertyName + ":");
|
||||
context.out.println(prompt);
|
||||
getActionContext().out.println(propertyName + ":");
|
||||
getActionContext().out.println(prompt);
|
||||
inputStr = scanner.nextLine();
|
||||
if (!acceptNull && inputStr.trim().equals("")) {
|
||||
System.out.println("Invalid Entry!");
|
||||
getActionContext().out.println("Invalid Entry!");
|
||||
} else {
|
||||
valid = true;
|
||||
}
|
||||
|
@ -124,22 +124,22 @@ public class InputAbstract extends ActionAbstract {
|
|||
|
||||
String inputStr = "";
|
||||
boolean valid = false;
|
||||
System.out.println();
|
||||
getActionContext().out.println();
|
||||
do {
|
||||
context.out.println(propertyName + ": is mandatory with this configuration:");
|
||||
context.out.println(prompt);
|
||||
getActionContext().out.println(propertyName + ": is mandatory with this configuration:");
|
||||
getActionContext().out.println(prompt);
|
||||
char[] chars = System.console().readPassword();
|
||||
|
||||
// could be null if the user input something weird like Ctrl-d
|
||||
if (chars == null) {
|
||||
System.out.println("Invalid Entry!");
|
||||
getActionContext().out.println("Invalid Entry!");
|
||||
continue;
|
||||
}
|
||||
|
||||
inputStr = new String(chars);
|
||||
|
||||
if (inputStr.trim().equals("")) {
|
||||
System.out.println("Invalid Entry!");
|
||||
getActionContext().out.println("Invalid Entry!");
|
||||
} else {
|
||||
valid = true;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class Run extends LockAbstract {
|
|||
ManagementContextDTO managementDTO = getManagementDTO();
|
||||
managementContext = ManagementFactory.create(managementDTO, securityManager);
|
||||
|
||||
Artemis.printBanner();
|
||||
Artemis.printBanner(getActionContext().out);
|
||||
|
||||
addShutdownHook(broker.server.getConfigurationFile().getParentFile());
|
||||
|
||||
|
@ -190,8 +190,8 @@ public class Run extends LockAbstract {
|
|||
stop();
|
||||
shutdownTimer.cancel();
|
||||
} finally {
|
||||
System.out.println("Server stopped!");
|
||||
System.out.flush();
|
||||
getActionContext().out.println("Server stopped!");
|
||||
getActionContext().out.flush();
|
||||
latchRunning.countDown();
|
||||
if (!embedded) {
|
||||
Runtime.getRuntime().exit(0);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class Browse extends DestAbstract {
|
|||
public Object execute(ActionContext context) throws Exception {
|
||||
super.execute(context);
|
||||
|
||||
System.out.println("Consumer:: filter = " + filter);
|
||||
context.out.println("Consumer:: filter = " + filter);
|
||||
|
||||
ConnectionFactory factory = createConnectionFactory();
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ public class ConnectionAbstract extends InputAbstract {
|
|||
}
|
||||
}
|
||||
|
||||
System.out.println("Connection brokerURL = " + brokerURL);
|
||||
context.out.println("Connection brokerURL = " + brokerURL);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ public class ConnectionAbstract extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSSecurityException e) {
|
||||
// if a security exception will get the user and password through an input
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
cf = new JmsConnectionFactory(inputUser(user), inputPassword(password), brokerURL);
|
||||
if (clientID != null) {
|
||||
cf.setClientID(clientID);
|
||||
|
@ -170,7 +170,7 @@ public class ConnectionAbstract extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSException e) {
|
||||
// if a connection exception will ask for the URL, user and password
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
cf = new JmsConnectionFactory(inputUser(user), inputPassword(password), inputBrokerURL(brokerURL));
|
||||
if (clientID != null) {
|
||||
cf.setClientID(clientID);
|
||||
|
@ -189,7 +189,7 @@ public class ConnectionAbstract extends InputAbstract {
|
|||
String clientID) {
|
||||
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerURL, user, password);
|
||||
if (clientID != null) {
|
||||
System.out.println("Consumer:: clientID = " + clientID);
|
||||
getActionContext().out.println("Consumer:: clientID = " + clientID);
|
||||
cf.setClientID(clientID);
|
||||
}
|
||||
try {
|
||||
|
@ -198,8 +198,8 @@ public class ConnectionAbstract extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSSecurityException e) {
|
||||
// if a security exception will get the user and password through an input
|
||||
if (context != null) {
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
if (getActionContext() != null) {
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
}
|
||||
cf = new ActiveMQConnectionFactory(brokerURL, inputUser(user), inputPassword(password));
|
||||
if (clientID != null) {
|
||||
|
@ -208,8 +208,8 @@ public class ConnectionAbstract extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSException e) {
|
||||
// if a connection exception will ask for the URL, user and password
|
||||
if (context != null) {
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
if (getActionContext() != null) {
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
}
|
||||
cf = new ActiveMQConnectionFactory(inputBrokerURL(brokerURL), inputUser(user), inputPassword(password));
|
||||
if (clientID != null) {
|
||||
|
|
|
@ -53,7 +53,7 @@ public class Consumer extends DestAbstract {
|
|||
public Object execute(ActionContext context) throws Exception {
|
||||
super.execute(context);
|
||||
|
||||
System.out.println("Consumer:: filter = " + filter);
|
||||
context.out.println("Consumer:: filter = " + filter);
|
||||
|
||||
SerialiserMessageListener listener = null;
|
||||
MessageSerializer serializer = null;
|
||||
|
|
|
@ -497,7 +497,7 @@ public class Transfer extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSSecurityException e) {
|
||||
// if a security exception will get the user and password through an input
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
userPassword(brokerURL);
|
||||
cf = new JmsConnectionFactory(user, password, brokerURL);
|
||||
if (clientID != null) {
|
||||
|
@ -506,7 +506,7 @@ public class Transfer extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSException e) {
|
||||
// if a connection exception will ask for the URL, user and password
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
brokerURL = input("--url", "Type in the broker URL for a retry (e.g. tcp://localhost:61616)", brokerURL);
|
||||
userPassword(brokerURL);
|
||||
cf = new JmsConnectionFactory(user, password, brokerURL);
|
||||
|
@ -533,9 +533,7 @@ public class Transfer extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSSecurityException e) {
|
||||
// if a security exception will get the user and password through an input
|
||||
if (context != null) {
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
}
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
Pair<String, String> userPair = userPassword(brokerURL);
|
||||
cf = new ActiveMQConnectionFactory(brokerURL, userPair.getA(), userPair.getB());
|
||||
if (clientID != null) {
|
||||
|
@ -544,9 +542,7 @@ public class Transfer extends InputAbstract {
|
|||
return cf;
|
||||
} catch (JMSException e) {
|
||||
// if a connection exception will ask for the URL, user and password
|
||||
if (context != null) {
|
||||
context.err.println("Connection failed::" + e.getMessage());
|
||||
}
|
||||
getActionContext().err.println("Connection failed::" + e.getMessage());
|
||||
brokerURL = input("--url", "Type in the broker URL for a retry (e.g. tcp://localhost:61616)", brokerURL);
|
||||
Pair<String, String> userPair = userPassword(brokerURL);
|
||||
cf = new ActiveMQConnectionFactory(brokerURL, userPair.getA(), userPair.getB());
|
||||
|
|
|
@ -112,7 +112,7 @@ public abstract class PerfCommand extends ConnectionAbstract {
|
|||
skratchBuffer.setLength(0);
|
||||
statistics.outAtInterval(warmingUp, skratchBuffer, LiveStatistics.ReportInterval.sec, showLatency);
|
||||
if (!isSilentInput()) {
|
||||
context.out.println(skratchBuffer);
|
||||
getActionContext().out.println(skratchBuffer);
|
||||
}
|
||||
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(1));
|
||||
}
|
||||
|
|
|
@ -142,10 +142,10 @@ public class StatQueue extends AbstractAction {
|
|||
}
|
||||
|
||||
if (verbose) {
|
||||
context.out.println("filter is '" + filter + "'");
|
||||
context.out.println("maxRows='" + maxRows + "'");
|
||||
getActionContext().out.println("filter is '" + filter + "'");
|
||||
getActionContext().out.println("maxRows='" + maxRows + "'");
|
||||
}
|
||||
printStats(context, filter);
|
||||
printStats(getActionContext(), filter);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class StatQueue extends AbstractAction {
|
|||
@Override
|
||||
public void requestFailed(ClientMessage reply) throws Exception {
|
||||
String errMsg = (String) ManagementHelper.getResult(reply, String.class);
|
||||
context.err.println("Failed to get Stats for Queues. Reason: " + errMsg);
|
||||
getActionContext().err.println("Failed to get Stats for Queues. Reason: " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class StatQueue extends AbstractAction {
|
|||
//should not happen but...
|
||||
if (result == null) {
|
||||
if (verbose) {
|
||||
context.err.println("printStats(): got NULL result string.");
|
||||
getActionContext().err.println("printStats(): got NULL result string.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ public class StatQueue extends AbstractAction {
|
|||
}
|
||||
|
||||
if (count > maxRows) {
|
||||
context.out.println(String.format("WARNING: the displayed queues are %d/%d, set maxRows to display more queues.", maxRows, count));
|
||||
getActionContext().out.println(String.format("WARNING: the displayed queues are %d/%d, set maxRows to display more queues.", maxRows, count));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class StatQueue extends AbstractAction {
|
|||
stringBuilder.append(paddingString(new StringBuilder(e.toString()), columnSizes[i++])).append('|');
|
||||
}
|
||||
|
||||
context.out.println(stringBuilder);
|
||||
getActionContext().out.println(stringBuilder);
|
||||
}
|
||||
|
||||
private void printQueueStats(JsonObject jsonObject, int[] columnSizes) {
|
||||
|
@ -237,7 +237,7 @@ public class StatQueue extends AbstractAction {
|
|||
//should not happen but just in case..
|
||||
if (jsonObject == null) {
|
||||
if (verbose) {
|
||||
context.err.println("printQueueStats(): jsonObject is null");
|
||||
getActionContext().err.println("printQueueStats(): jsonObject is null");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ public class StatQueue extends AbstractAction {
|
|||
stringBuilder.append(paddingString(new StringBuilder(jsonObject.getString(e.jsonId)), columnSizes[i++])).append('|');
|
||||
}
|
||||
|
||||
context.out.println(stringBuilder);
|
||||
getActionContext().out.println(stringBuilder);
|
||||
}
|
||||
|
||||
private StringBuilder paddingString(StringBuilder value, int maxColumnSize) {
|
||||
|
@ -285,7 +285,7 @@ public class StatQueue extends AbstractAction {
|
|||
HashMap<String, Object> filterMap = new HashMap<>();
|
||||
|
||||
if (((fieldName != null) && (fieldName.trim().length() > 0)) && ((queueName != null && queueName.trim().length() > 0))) {
|
||||
context.err.println("'--field' and '--queueName' cannot be specified together.");
|
||||
getActionContext().err.println("'--field' and '--queueName' cannot be specified together.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -300,19 +300,19 @@ public class StatQueue extends AbstractAction {
|
|||
|
||||
filterMap.put("field", field.toString());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
context.err.println("'--field' must be set to one of the following " + Arrays.toString(FIELD.values()));
|
||||
getActionContext().err.println("'--field' must be set to one of the following " + Arrays.toString(FIELD.values()));
|
||||
return null;
|
||||
}
|
||||
|
||||
//full filter being set ensure value is set
|
||||
if (value == null || value.trim().length() == 0) {
|
||||
context.err.println("'--value' needs to be set when '--field' is specified");
|
||||
getActionContext().err.println("'--value' needs to be set when '--field' is specified");
|
||||
return null;
|
||||
}
|
||||
filterMap.put("value", value);
|
||||
|
||||
if (operationName == null) {
|
||||
context.err.println("'--operation' must be set when '--field' is specified " + Arrays.toString(OPERATION.values()));
|
||||
getActionContext().err.println("'--operation' must be set when '--field' is specified " + Arrays.toString(OPERATION.values()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ public class StatQueue extends AbstractAction {
|
|||
OPERATION operation = OPERATION.valueOf(operationName);
|
||||
filterMap.put("operation", operation.toString());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
context.err.println("'--operation' must be set to one of the following " + Arrays.toString(OPERATION.values()));
|
||||
getActionContext().err.println("'--operation' must be set to one of the following " + Arrays.toString(OPERATION.values()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ public class RecoverMessages extends DBOption {
|
|||
|
||||
public static void recover(Configuration configuration, String journallocation, File journalOutput, File largeMessage, boolean reclaimed) throws Exception {
|
||||
|
||||
final ActionContext context = ActionContext.system();
|
||||
|
||||
File journal = new File(journallocation);
|
||||
|
||||
if (!journalOutput.exists()) {
|
||||
|
@ -115,7 +117,7 @@ public class RecoverMessages extends DBOption {
|
|||
for (JournalFile file : files) {
|
||||
// For reviewers and future maintainers: I really meant System.out.println here
|
||||
// This is part of the CLI, hence this is like user's output
|
||||
System.out.println("Recovering messages from file " + file);
|
||||
context.out.println("Recovering messages from file " + file);
|
||||
|
||||
JournalImpl.readJournalFile(messagesFF, file, new JournalReaderCallback() {
|
||||
long lastlargeMessageId = -1;
|
||||
|
@ -163,14 +165,14 @@ public class RecoverMessages extends DBOption {
|
|||
|
||||
if (targetJournal.getRecords().get(info.id) != null) {
|
||||
// Really meant System.out.. user's information on the CLI
|
||||
System.out.println("RecordID " + info.id + " would been duplicated, ignoring it");
|
||||
context.out.println("RecordID " + info.id + " would been duplicated, ignoring it");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
targetJournal.appendAddRecord(info.id, info.userRecordType, info.data, false);
|
||||
} catch (Exception e) {
|
||||
// Really meant System.out.. user's information on the CLI
|
||||
System.out.println("Cannot append record for " + info.id + "->" + e.getMessage());
|
||||
context.out.println("Cannot append record for " + info.id + "->" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +185,7 @@ public class RecoverMessages extends DBOption {
|
|||
Pair<Long, Long> pairQueue = new Pair<>(info.id, queue);
|
||||
if (routeBindigns.contains(pairQueue)) {
|
||||
// really meant system.out
|
||||
System.out.println("AddReference on " + info.id + " / queue=" + queue + " has already been recorded, ignoring it");
|
||||
context.out.println("AddReference on " + info.id + " / queue=" + queue + " has already been recorded, ignoring it");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -192,8 +194,8 @@ public class RecoverMessages extends DBOption {
|
|||
try {
|
||||
targetJournal.appendUpdateRecord(info.id, info.userRecordType, info.data, true);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Cannot update record " + info.id + "-> " + e.getMessage());
|
||||
e.printStackTrace(System.out);
|
||||
context.out.println("Cannot update record " + info.id + "-> " + e.getMessage());
|
||||
e.printStackTrace(context.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,13 +57,13 @@ public class AddUser extends PasswordAction {
|
|||
|
||||
@Override
|
||||
public void requestSuccessful(ClientMessage reply) throws Exception {
|
||||
context.out.println(userCommandUser + " added successfully.");
|
||||
getActionContext().out.println(userCommandUser + " added successfully.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFailed(ClientMessage reply) throws Exception {
|
||||
String errMsg = (String) ManagementHelper.getResult(reply, String.class);
|
||||
context.err.println("Failed to add user " + userCommandUser + ". Reason: " + errMsg);
|
||||
getActionContext().err.println("Failed to add user " + userCommandUser + ". Reason: " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public class ListUser extends UserAction {
|
|||
@Override
|
||||
public void requestFailed(ClientMessage reply) throws Exception {
|
||||
String errMsg = (String) ManagementHelper.getResult(reply, String.class);
|
||||
context.err.println("Failed to list user " + userCommandUser + ". Reason: " + errMsg);
|
||||
getActionContext().err.println("Failed to list user " + userCommandUser + ". Reason: " + errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class ListUser extends UserAction {
|
|||
userCount++;
|
||||
}
|
||||
logMessage.append("\n Total: ").append(userCount);
|
||||
context.out.println(logMessage);
|
||||
getActionContext().out.println(logMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,13 +46,13 @@ public class RemoveUser extends UserAction {
|
|||
|
||||
@Override
|
||||
public void requestSuccessful(ClientMessage reply) throws Exception {
|
||||
context.out.println(userCommandUser + " removed successfully.");
|
||||
getActionContext().out.println(userCommandUser + " removed successfully.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFailed(ClientMessage reply) throws Exception {
|
||||
String errMsg = (String) ManagementHelper.getResult(reply, String.class);
|
||||
context.err.println("Failed to remove user " + userCommandUser + ". Reason: " + errMsg);
|
||||
getActionContext().err.println("Failed to remove user " + userCommandUser + ". Reason: " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -51,13 +51,13 @@ public class ResetUser extends PasswordAction {
|
|||
|
||||
@Override
|
||||
public void requestSuccessful(ClientMessage reply) throws Exception {
|
||||
context.out.println(userCommandUser + " reset successfully.");
|
||||
getActionContext().out.println(userCommandUser + " reset successfully.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestFailed(ClientMessage reply) throws Exception {
|
||||
String errMsg = (String) ManagementHelper.getResult(reply, String.class);
|
||||
context.err.println("Failed to reset user " + userCommandUser + ". Reason: " + errMsg);
|
||||
getActionContext().err.println("Failed to reset user " + userCommandUser + ". Reason: " + errMsg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2111,7 +2111,9 @@ public class ArtemisTest extends CliTestBase {
|
|||
|
||||
String currentLine = bufferedReader.readLine();
|
||||
while (currentLine != null) {
|
||||
lines.add(currentLine);
|
||||
if (!currentLine.startsWith("Connection brokerURL")) {
|
||||
lines.add(currentLine);
|
||||
}
|
||||
currentLine = bufferedReader.readLine();
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ public class CheckTest extends CliTestBase {
|
|||
"--replicated", "--host", "127.0.0.1", "--default-port", "61626", "--silent", "--no-autotune", "--no-web", "--require-login", "--slave");
|
||||
|
||||
System.setProperty("artemis.instance", masterInstance.getAbsolutePath());
|
||||
Object master = Artemis.execute(false, null, masterInstance, "run");
|
||||
Object master = Artemis.execute(false, false, null, masterInstance, "run");
|
||||
ActiveMQServerImpl masterServer = (ActiveMQServerImpl)((Pair)master).getB();
|
||||
|
||||
try {
|
||||
|
@ -181,7 +181,7 @@ public class CheckTest extends CliTestBase {
|
|||
}
|
||||
|
||||
LockAbstract.unlock();
|
||||
Object slave = Artemis.execute(false, null, slaveInstance, "run");
|
||||
Object slave = Artemis.execute(false, false, null, slaveInstance, "run");
|
||||
ActiveMQServerImpl slaveServer = (ActiveMQServerImpl)((Pair)slave).getB();
|
||||
|
||||
Wait.assertTrue("Backup isn't announced", () -> slaveServer.getBackupManager() != null &&
|
||||
|
|
|
@ -71,6 +71,8 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
|||
@Parameter
|
||||
private String testPassword = null;
|
||||
|
||||
@Parameter boolean useSystemOutput = getLog().isDebugEnabled();
|
||||
|
||||
@Override
|
||||
protected boolean isIgnore() {
|
||||
return ignore;
|
||||
|
@ -125,7 +127,7 @@ public class ArtemisCLIPlugin extends ArtemisAbstractPlugin {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
Artemis.execute(home, location, args);
|
||||
Artemis.execute(home, location, useSystemOutput, args);
|
||||
}
|
||||
|
||||
Thread.sleep(600);
|
||||
|
|
|
@ -147,6 +147,8 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
|||
@Parameter(defaultValue = "${noServer}")
|
||||
boolean ignore;
|
||||
|
||||
@Parameter boolean useSystemOutput = getLog().isDebugEnabled();
|
||||
|
||||
private void add(List<String> list, String... str) {
|
||||
for (String s : str) {
|
||||
list.add(s);
|
||||
|
@ -160,7 +162,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
|||
|
||||
@Override
|
||||
protected void doExecute() throws MojoExecutionException, MojoFailureException {
|
||||
getLog().info("Local " + localRepository);
|
||||
getLog().debug("Local " + localRepository);
|
||||
MavenProject project = (MavenProject) getPluginContext().get("project");
|
||||
|
||||
if (!isArtemisHome(home.toPath())) {
|
||||
|
@ -180,9 +182,11 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
|||
|
||||
Set<Map.Entry> entries = properties.entrySet();
|
||||
|
||||
getLog().info("Entries.size " + entries.size());
|
||||
for (Map.Entry entry : entries) {
|
||||
getLog().info("... key=" + entry.getKey() + " = " + entry.getValue());
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("Entries.size " + entries.size());
|
||||
for (Map.Entry entry : entries) {
|
||||
getLog().debug("... key=" + entry.getKey() + " = " + entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> listCommands = new ArrayList<>();
|
||||
|
@ -260,7 +264,7 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
|||
commandLineStream.println("# These are the commands used to create " + instance.getName());
|
||||
commandLineStream.println(getCommandline(listCommands));
|
||||
|
||||
Artemis.execute(home, null, listCommands);
|
||||
Artemis.execute(home, null, useSystemOutput, listCommands);
|
||||
|
||||
if (configuration != null) {
|
||||
String[] list = configuration.list();
|
||||
|
@ -297,10 +301,12 @@ public class ArtemisCreatePlugin extends ArtemisAbstractPlugin {
|
|||
|
||||
FileUtil.makeExec(commandLine);
|
||||
|
||||
getLog().info("###################################################################################################");
|
||||
getLog().info(commandLine.getName() + " created with commands to reproduce " + instance.getName());
|
||||
getLog().info("under " + commandLine.getParent());
|
||||
getLog().info("###################################################################################################");
|
||||
if (getLog().isDebugEnabled()) {
|
||||
getLog().debug("###################################################################################################");
|
||||
getLog().debug(commandLine.getName() + " created with commands to reproduce " + instance.getName());
|
||||
getLog().debug("under " + commandLine.getParent());
|
||||
getLog().debug("###################################################################################################");
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
getLog().error(e);
|
||||
|
|
Loading…
Reference in New Issue