ARTEMIS-904 Remove cyclic dependencies from artemis-cli
move classes and methods to their correct location to avoid cyclic dependencies between packages and classes. ARTEMIS-904 Remove cyclic dependencies from artemis-cli move classes and methods to their correct location to avoid cyclic dependencies between packages and classes. ARTEMIS-904 Remove cyclic dependencies from artemis-cli move classes and methods to their correct location to avoid cyclic dependencies between packages and classes.
This commit is contained in:
parent
eeca06d259
commit
f82623a20c
|
@ -17,8 +17,6 @@
|
||||||
package org.apache.activemq.artemis.cli;
|
package org.apache.activemq.artemis.cli;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.airlift.airline.Cli;
|
import io.airlift.airline.Cli;
|
||||||
|
@ -37,22 +35,22 @@ import org.apache.activemq.artemis.cli.commands.address.DeleteAddress;
|
||||||
import org.apache.activemq.artemis.cli.commands.address.HelpAddress;
|
import org.apache.activemq.artemis.cli.commands.address.HelpAddress;
|
||||||
import org.apache.activemq.artemis.cli.commands.address.ShowAddress;
|
import org.apache.activemq.artemis.cli.commands.address.ShowAddress;
|
||||||
import org.apache.activemq.artemis.cli.commands.address.UpdateAddress;
|
import org.apache.activemq.artemis.cli.commands.address.UpdateAddress;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.messages.Browse;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.messages.Consumer;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.messages.Producer;
|
||||||
import org.apache.activemq.artemis.cli.commands.migration1x.Migrate1X;
|
import org.apache.activemq.artemis.cli.commands.migration1x.Migrate1X;
|
||||||
import org.apache.activemq.artemis.cli.commands.queue.CreateQueue;
|
import org.apache.activemq.artemis.cli.commands.queue.CreateQueue;
|
||||||
import org.apache.activemq.artemis.cli.commands.queue.DeleteQueue;
|
import org.apache.activemq.artemis.cli.commands.queue.DeleteQueue;
|
||||||
import org.apache.activemq.artemis.cli.commands.queue.HelpQueue;
|
import org.apache.activemq.artemis.cli.commands.queue.HelpQueue;
|
||||||
import org.apache.activemq.artemis.cli.commands.messages.Browse;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.messages.Consumer;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.messages.Producer;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.queue.UpdateQueue;
|
import org.apache.activemq.artemis.cli.commands.queue.UpdateQueue;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.CompactJournal;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.HelpData;
|
import org.apache.activemq.artemis.cli.commands.tools.HelpData;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.PrintData;
|
import org.apache.activemq.artemis.cli.commands.tools.PrintData;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.PerfJournal;
|
import org.apache.activemq.artemis.cli.commands.tools.journal.CompactJournal;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;
|
import org.apache.activemq.artemis.cli.commands.tools.journal.DecodeJournal;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
|
import org.apache.activemq.artemis.cli.commands.tools.journal.EncodeJournal;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.journal.PerfJournal;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataImporter;
|
||||||
import org.apache.activemq.artemis.cli.commands.user.AddUser;
|
import org.apache.activemq.artemis.cli.commands.user.AddUser;
|
||||||
import org.apache.activemq.artemis.cli.commands.user.HelpUser;
|
import org.apache.activemq.artemis.cli.commands.user.HelpUser;
|
||||||
import org.apache.activemq.artemis.cli.commands.user.ListUser;
|
import org.apache.activemq.artemis.cli.commands.user.ListUser;
|
||||||
|
@ -126,7 +124,7 @@ public class Artemis {
|
||||||
* This method is used to validate exception returns.
|
* This method is used to validate exception returns.
|
||||||
* Useful on test cases
|
* Useful on test cases
|
||||||
*/
|
*/
|
||||||
public static Object internalExecute(File artemisHome, File artemisInstance, String[] args) throws Exception {
|
private static Object internalExecute(File artemisHome, File artemisInstance, String[] args) throws Exception {
|
||||||
return internalExecute(artemisHome, artemisInstance, args, ActionContext.system());
|
return internalExecute(artemisHome, artemisInstance, args, ActionContext.system());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,18 +172,4 @@ public class Artemis {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printBanner() throws Exception {
|
|
||||||
copy(Artemis.class.getResourceAsStream("banner.txt"), System.out);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long copy(InputStream in, OutputStream out) throws Exception {
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int len = in.read(buffer);
|
|
||||||
while (len != -1) {
|
|
||||||
out.write(buffer, 0, len);
|
|
||||||
len = in.read(buffer);
|
|
||||||
}
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.util.OptionsUtil;
|
|
||||||
|
|
||||||
public abstract class ActionAbstract implements Action {
|
public abstract class ActionAbstract implements Action {
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,10 @@ import io.airlift.airline.Option;
|
||||||
import io.airlift.airline.model.CommandGroupMetadata;
|
import io.airlift.airline.model.CommandGroupMetadata;
|
||||||
import io.airlift.airline.model.CommandMetadata;
|
import io.airlift.airline.model.CommandMetadata;
|
||||||
import io.airlift.airline.model.GlobalMetadata;
|
import io.airlift.airline.model.GlobalMetadata;
|
||||||
|
import org.apache.activemq.artemis.cli.factory.BrokerFactory;
|
||||||
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
||||||
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||||
import org.apache.activemq.artemis.dto.BrokerDTO;
|
import org.apache.activemq.artemis.dto.BrokerDTO;
|
||||||
import org.apache.activemq.artemis.factory.BrokerFactory;
|
|
||||||
import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
|
import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
|
||||||
import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
|
import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,9 @@ public class Create extends InputAbstract {
|
||||||
|
|
||||||
public static final String ETC_ARTEMIS_ROLES_PROPERTIES = "etc/artemis-roles.properties";
|
public static final String ETC_ARTEMIS_ROLES_PROPERTIES = "etc/artemis-roles.properties";
|
||||||
public static final String ETC_ARTEMIS_USERS_PROPERTIES = "etc/artemis-users.properties";
|
public static final String ETC_ARTEMIS_USERS_PROPERTIES = "etc/artemis-users.properties";
|
||||||
public static final String ETC_LOGIN_CONFIG = "etc/login.config";
|
private static final String ETC_LOGIN_CONFIG = "etc/login.config";
|
||||||
public static final String ETC_LOGIN_CONFIG_WITH_GUEST = "etc/login-with-guest.config";
|
private static final String ETC_LOGIN_CONFIG_WITH_GUEST = "etc/login-with-guest.config";
|
||||||
public static final String ETC_LOGIN_CONFIG_WITHOUT_GUEST = "etc/login-without-guest.config";
|
private static final String ETC_LOGIN_CONFIG_WITHOUT_GUEST = "etc/login-without-guest.config";
|
||||||
public static final String ETC_REPLICATED_SETTINGS_TXT = "etc/replicated-settings.txt";
|
public static final String ETC_REPLICATED_SETTINGS_TXT = "etc/replicated-settings.txt";
|
||||||
public static final String ETC_SHARED_STORE_SETTINGS_TXT = "etc/shared-store-settings.txt";
|
public static final String ETC_SHARED_STORE_SETTINGS_TXT = "etc/shared-store-settings.txt";
|
||||||
public static final String ETC_CLUSTER_SECURITY_SETTINGS_TXT = "etc/cluster-security-settings.txt";
|
public static final String ETC_CLUSTER_SECURITY_SETTINGS_TXT = "etc/cluster-security-settings.txt";
|
||||||
|
@ -105,213 +105,162 @@ public class Create extends InputAbstract {
|
||||||
public static final String ETC_GLOBAL_MAX_DEFAULT_TXT = "etc/global-max-default.txt";
|
public static final String ETC_GLOBAL_MAX_DEFAULT_TXT = "etc/global-max-default.txt";
|
||||||
|
|
||||||
@Arguments(description = "The instance directory to hold the broker's configuration and data. Path must be writable.", required = true)
|
@Arguments(description = "The instance directory to hold the broker's configuration and data. Path must be writable.", required = true)
|
||||||
File directory;
|
private File directory;
|
||||||
|
|
||||||
@Option(name = "--host", description = "The host name of the broker (Default: 0.0.0.0 or input if clustered)")
|
@Option(name = "--host", description = "The host name of the broker (Default: 0.0.0.0 or input if clustered)")
|
||||||
String host;
|
private String host;
|
||||||
|
|
||||||
@Option(name = "--http-host", description = "The host name to use for embedded web server (Default: localhost)")
|
@Option(name = "--http-host", description = "The host name to use for embedded web server (Default: localhost)")
|
||||||
String httpHost = HTTP_HOST;
|
private String httpHost = HTTP_HOST;
|
||||||
|
|
||||||
@Option(name = "--ping", description = "A comma separated string to be passed on to the broker config as network-check-list. The broker will shutdown when all these addresses are unreachable.")
|
@Option(name = "--ping", description = "A comma separated string to be passed on to the broker config as network-check-list. The broker will shutdown when all these addresses are unreachable.")
|
||||||
String ping;
|
private String ping;
|
||||||
|
|
||||||
@Option(name = "--default-port", description = "The port number to use for the main 'artemis' acceptor (Default: 61616)")
|
@Option(name = "--default-port", description = "The port number to use for the main 'artemis' acceptor (Default: 61616)")
|
||||||
int defaultPort = DEFAULT_PORT;
|
private int defaultPort = DEFAULT_PORT;
|
||||||
|
|
||||||
@Option(name = "--http-port", description = "The port number to use for embedded web server (Default: 8161)")
|
@Option(name = "--http-port", description = "The port number to use for embedded web server (Default: 8161)")
|
||||||
int httpPort = HTTP_PORT;
|
private int httpPort = HTTP_PORT;
|
||||||
|
|
||||||
@Option(name = "--ssl-key", description = "The key store path for embedded web server")
|
@Option(name = "--ssl-key", description = "The key store path for embedded web server")
|
||||||
String sslKey;
|
private String sslKey;
|
||||||
|
|
||||||
@Option(name = "--ssl-key-password", description = "The key store password")
|
@Option(name = "--ssl-key-password", description = "The key store password")
|
||||||
String sslKeyPassword;
|
private String sslKeyPassword;
|
||||||
|
|
||||||
@Option(name = "--use-client-auth", description = "If the embedded server requires client authentication")
|
@Option(name = "--use-client-auth", description = "If the embedded server requires client authentication")
|
||||||
boolean useClientAuth;
|
private boolean useClientAuth;
|
||||||
|
|
||||||
@Option(name = "--ssl-trust", description = "The trust store path in case of client authentication")
|
@Option(name = "--ssl-trust", description = "The trust store path in case of client authentication")
|
||||||
String sslTrust;
|
private String sslTrust;
|
||||||
|
|
||||||
@Option(name = "--ssl-trust-password", description = "The trust store password")
|
@Option(name = "--ssl-trust-password", description = "The trust store password")
|
||||||
String sslTrustPassword;
|
private String sslTrustPassword;
|
||||||
|
|
||||||
@Option(name = "--name", description = "The name of the broker (Default: same as host)")
|
@Option(name = "--name", description = "The name of the broker (Default: same as host)")
|
||||||
String name;
|
private String name;
|
||||||
|
|
||||||
@Option(name = "--port-offset", description = "Off sets the ports of every acceptor")
|
@Option(name = "--port-offset", description = "Off sets the ports of every acceptor")
|
||||||
int portOffset;
|
private int portOffset;
|
||||||
|
|
||||||
@Option(name = "--force", description = "Overwrite configuration at destination directory")
|
@Option(name = "--force", description = "Overwrite configuration at destination directory")
|
||||||
boolean force;
|
private boolean force;
|
||||||
|
|
||||||
@Option(name = "--home", description = "Directory where ActiveMQ Artemis is installed")
|
@Option(name = "--home", description = "Directory where ActiveMQ Artemis is installed")
|
||||||
File home;
|
private File home;
|
||||||
|
|
||||||
@Option(name = "--data", description = "Directory where ActiveMQ Data is used. Paths are relative to artemis.instance")
|
@Option(name = "--data", description = "Directory where ActiveMQ Data is used. Paths are relative to artemis.instance")
|
||||||
String data = "./data";
|
private String data = "./data";
|
||||||
|
|
||||||
@Option(name = "--clustered", description = "Enable clustering")
|
@Option(name = "--clustered", description = "Enable clustering")
|
||||||
boolean clustered = false;
|
private boolean clustered = false;
|
||||||
|
|
||||||
@Option(name = "--max-hops", description = "Number of hops on the cluster configuration")
|
@Option(name = "--max-hops", description = "Number of hops on the cluster configuration")
|
||||||
int maxHops = 0;
|
private int maxHops = 0;
|
||||||
|
|
||||||
@Option(name = "--message-load-balancing", description = "Load balancing policy on cluster. [ON_DEMAND (default) | STRICT | OFF]")
|
@Option(name = "--message-load-balancing", description = "Load balancing policy on cluster. [ON_DEMAND (default) | STRICT | OFF]")
|
||||||
MessageLoadBalancingType messageLoadBalancing = MessageLoadBalancingType.ON_DEMAND;
|
private MessageLoadBalancingType messageLoadBalancing = MessageLoadBalancingType.ON_DEMAND;
|
||||||
|
|
||||||
@Option(name = "--replicated", description = "Enable broker replication")
|
@Option(name = "--replicated", description = "Enable broker replication")
|
||||||
boolean replicated = false;
|
private boolean replicated = false;
|
||||||
|
|
||||||
@Option(name = "--shared-store", description = "Enable broker shared store")
|
@Option(name = "--shared-store", description = "Enable broker shared store")
|
||||||
boolean sharedStore = false;
|
private boolean sharedStore = false;
|
||||||
|
|
||||||
@Option(name = "--slave", description = "Valid for shared store or replication: this is a slave server?")
|
@Option(name = "--slave", description = "Valid for shared store or replication: this is a slave server?")
|
||||||
boolean slave;
|
private boolean slave;
|
||||||
|
|
||||||
@Option(name = "--failover-on-shutdown", description = "Valid for shared store: will shutdown trigger a failover? (Default: false)")
|
@Option(name = "--failover-on-shutdown", description = "Valid for shared store: will shutdown trigger a failover? (Default: false)")
|
||||||
boolean failoverOnShutodwn;
|
private boolean failoverOnShutodwn;
|
||||||
|
|
||||||
@Option(name = "--cluster-user", description = "The cluster user to use for clustering. (Default: input)")
|
@Option(name = "--cluster-user", description = "The cluster user to use for clustering. (Default: input)")
|
||||||
String clusterUser = null;
|
private String clusterUser = null;
|
||||||
|
|
||||||
@Option(name = "--cluster-password", description = "The cluster password to use for clustering. (Default: input)")
|
@Option(name = "--cluster-password", description = "The cluster password to use for clustering. (Default: input)")
|
||||||
String clusterPassword = null;
|
private String clusterPassword = null;
|
||||||
|
|
||||||
@Option(name = "--encoding", description = "The encoding that text files should use")
|
@Option(name = "--encoding", description = "The encoding that text files should use")
|
||||||
String encoding = "UTF-8";
|
private String encoding = "UTF-8";
|
||||||
|
|
||||||
@Option(name = "--java-options", description = "Extra java options to be passed to the profile")
|
@Option(name = "--java-options", description = "Extra java options to be passed to the profile")
|
||||||
String javaOptions = "";
|
private String javaOptions = "";
|
||||||
|
|
||||||
@Option(name = "--allow-anonymous", description = "Enables anonymous configuration on security, opposite of --require-login (Default: input)")
|
@Option(name = "--allow-anonymous", description = "Enables anonymous configuration on security, opposite of --require-login (Default: input)")
|
||||||
Boolean allowAnonymous = null;
|
private Boolean allowAnonymous = null;
|
||||||
|
|
||||||
@Option(name = "--require-login", description = "This will configure security to require user / password, opposite of --allow-anonymous")
|
@Option(name = "--require-login", description = "This will configure security to require user / password, opposite of --allow-anonymous")
|
||||||
Boolean requireLogin = null;
|
private Boolean requireLogin = null;
|
||||||
|
|
||||||
@Option(name = "--paging", description = "Page messages to disk when address becomes full, opposite of --blocking (Default: true)")
|
@Option(name = "--paging", description = "Page messages to disk when address becomes full, opposite of --blocking (Default: true)")
|
||||||
Boolean paging;
|
private Boolean paging;
|
||||||
|
|
||||||
@Option(name = "--blocking", description = "Block producers when address becomes full, opposite of --paging (Default: false)")
|
@Option(name = "--blocking", description = "Block producers when address becomes full, opposite of --paging (Default: false)")
|
||||||
Boolean blocking;
|
private Boolean blocking;
|
||||||
|
|
||||||
@Option(name = "--no-autotune", description = "Disable auto tuning on the journal.")
|
@Option(name = "--no-autotune", description = "Disable auto tuning on the journal.")
|
||||||
boolean noAutoTune;
|
private boolean noAutoTune;
|
||||||
|
|
||||||
@Option(name = "--no-autocreate", description = "Disable Auto create addresses.")
|
@Option(name = "--no-autocreate", description = "Disable Auto create addresses.")
|
||||||
Boolean noAutoCreate;
|
private Boolean noAutoCreate;
|
||||||
|
|
||||||
@Option(name = "--autocreate", description = "Auto create addresses. (default: true)")
|
@Option(name = "--autocreate", description = "Auto create addresses. (default: true)")
|
||||||
Boolean autoCreate;
|
private Boolean autoCreate;
|
||||||
|
|
||||||
@Option(name = "--user", description = "The username (Default: input)")
|
@Option(name = "--user", description = "The username (Default: input)")
|
||||||
String user;
|
private String user;
|
||||||
|
|
||||||
@Option(name = "--password", description = "The user's password (Default: input)")
|
@Option(name = "--password", description = "The user's password (Default: input)")
|
||||||
String password;
|
private String password;
|
||||||
|
|
||||||
@Option(name = "--role", description = "The name for the role created (Default: amq)")
|
@Option(name = "--role", description = "The name for the role created (Default: amq)")
|
||||||
String role = "amq";
|
private String role = "amq";
|
||||||
|
|
||||||
@Option(name = "--no-web", description = "Remove the web-server definition from bootstrap.xml")
|
@Option(name = "--no-web", description = "Remove the web-server definition from bootstrap.xml")
|
||||||
boolean noWeb;
|
private boolean noWeb;
|
||||||
|
|
||||||
@Option(name = "--queues", description = "Comma separated list of queues.")
|
@Option(name = "--queues", description = "Comma separated list of queues.")
|
||||||
String queues;
|
private String queues;
|
||||||
|
|
||||||
@Option(name = "--addresses", description = "Comma separated list of addresses ")
|
@Option(name = "--addresses", description = "Comma separated list of addresses ")
|
||||||
String addresses;
|
private String addresses;
|
||||||
|
|
||||||
@Option(name = "--aio", description = "Sets the journal as asyncio.")
|
@Option(name = "--aio", description = "Sets the journal as asyncio.")
|
||||||
boolean aio;
|
private boolean aio;
|
||||||
|
|
||||||
@Option(name = "--nio", description = "Sets the journal as nio.")
|
@Option(name = "--nio", description = "Sets the journal as nio.")
|
||||||
boolean nio;
|
private boolean nio;
|
||||||
|
|
||||||
@Option(name = "--mapped", description = "Sets the journal as mapped.")
|
@Option(name = "--mapped", description = "Sets the journal as mapped.")
|
||||||
boolean mapped;
|
private boolean mapped;
|
||||||
|
|
||||||
// this is used by the setupJournalType method
|
// this is used by the setupJournalType method
|
||||||
private JournalType journalType;
|
private JournalType journalType;
|
||||||
|
|
||||||
@Option(name = "--disable-persistence", description = "Disable message persistence to the journal")
|
@Option(name = "--disable-persistence", description = "Disable message persistence to the journal")
|
||||||
boolean disablePersistence;
|
private boolean disablePersistence;
|
||||||
|
|
||||||
@Option(name = "--no-amqp-acceptor", description = "Disable the AMQP specific acceptor.")
|
@Option(name = "--no-amqp-acceptor", description = "Disable the AMQP specific acceptor.")
|
||||||
boolean noAmqpAcceptor;
|
private boolean noAmqpAcceptor;
|
||||||
|
|
||||||
@Option(name = "--no-mqtt-acceptor", description = "Disable the MQTT specific acceptor.")
|
@Option(name = "--no-mqtt-acceptor", description = "Disable the MQTT specific acceptor.")
|
||||||
boolean noMqttAcceptor;
|
private boolean noMqttAcceptor;
|
||||||
|
|
||||||
@Option(name = "--no-stomp-acceptor", description = "Disable the STOMP specific acceptor.")
|
@Option(name = "--no-stomp-acceptor", description = "Disable the STOMP specific acceptor.")
|
||||||
boolean noStompAcceptor;
|
private boolean noStompAcceptor;
|
||||||
|
|
||||||
@Option(name = "--no-hornetq-acceptor", description = "Disable the HornetQ specific acceptor.")
|
@Option(name = "--no-hornetq-acceptor", description = "Disable the HornetQ specific acceptor.")
|
||||||
boolean noHornetQAcceptor;
|
private boolean noHornetQAcceptor;
|
||||||
|
|
||||||
@Option(name = "--no-fsync", description = "Disable usage of fdatasync (channel.force(false) from java nio) on the journal")
|
@Option(name = "--no-fsync", description = "Disable usage of fdatasync (channel.force(false) from java nio) on the journal")
|
||||||
boolean noJournalSync;
|
private boolean noJournalSync;
|
||||||
|
|
||||||
@Option(name = "--global-max-size", description = "Maximum amount of memory which message data may consume (Default: Undefined, half of the system's memory)")
|
@Option(name = "--global-max-size", description = "Maximum amount of memory which message data may consume (Default: Undefined, half of the system's memory)")
|
||||||
String globalMaxSize;
|
private String globalMaxSize;
|
||||||
|
|
||||||
boolean IS_WINDOWS;
|
private boolean IS_WINDOWS;
|
||||||
|
private boolean IS_CYGWIN;
|
||||||
|
|
||||||
boolean IS_CYGWIN;
|
private boolean isAutoCreate() {
|
||||||
|
|
||||||
public int getMaxHops() {
|
|
||||||
return maxHops;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaxHops(int maxHops) {
|
|
||||||
this.maxHops = maxHops;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNoWeb() {
|
|
||||||
return noWeb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoWeb(boolean noWeb) {
|
|
||||||
this.noWeb = noWeb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPortOffset() {
|
|
||||||
return portOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPortOffset(int portOffset) {
|
|
||||||
this.portOffset = portOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageLoadBalancingType getMessageLoadBalancing() {
|
|
||||||
return messageLoadBalancing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageLoadBalancing(MessageLoadBalancingType messageLoadBalancing) {
|
|
||||||
this.messageLoadBalancing = messageLoadBalancing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getAutoCreate() {
|
|
||||||
return autoCreate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Create setAutoCreate(Boolean autoCreate) {
|
|
||||||
this.autoCreate = autoCreate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getNoAutoCreate() {
|
|
||||||
return noAutoCreate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Create setNoAutoCreate(Boolean noAutoCreate) {
|
|
||||||
this.noAutoCreate = noAutoCreate;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAutoCreate() {
|
|
||||||
if (autoCreate == null) {
|
if (autoCreate == null) {
|
||||||
if (noAutoCreate != null) {
|
if (noAutoCreate != null) {
|
||||||
autoCreate = !noAutoCreate.booleanValue();
|
autoCreate = !noAutoCreate.booleanValue();
|
||||||
|
@ -325,14 +274,6 @@ public class Create extends InputAbstract {
|
||||||
return autoCreate;
|
return autoCreate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJavaOptions() {
|
|
||||||
return javaOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setJavaOptions(String javaOptions) {
|
|
||||||
this.javaOptions = javaOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getInstance() {
|
public File getInstance() {
|
||||||
return directory;
|
return directory;
|
||||||
}
|
}
|
||||||
|
@ -348,7 +289,7 @@ public class Create extends InputAbstract {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHostForClustered() {
|
private String getHostForClustered() {
|
||||||
if (getHost().equals("0.0.0.0")) {
|
if (getHost().equals("0.0.0.0")) {
|
||||||
host = input("--host", "Host " + host + " is not valid for clustering, please provide a valid IP or hostname", "localhost");
|
host = input("--host", "Host " + host + " is not valid for clustering, please provide a valid IP or hostname", "localhost");
|
||||||
}
|
}
|
||||||
|
@ -379,14 +320,6 @@ public class Create extends InputAbstract {
|
||||||
this.home = home;
|
this.home = home;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isClustered() {
|
|
||||||
return clustered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClustered(boolean clustered) {
|
|
||||||
this.clustered = clustered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReplicated() {
|
public boolean isReplicated() {
|
||||||
return replicated;
|
return replicated;
|
||||||
}
|
}
|
||||||
|
@ -399,10 +332,6 @@ public class Create extends InputAbstract {
|
||||||
return sharedStore;
|
return sharedStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSharedStore(boolean sharedStore) {
|
|
||||||
this.sharedStore = sharedStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEncoding() {
|
public String getEncoding() {
|
||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
|
@ -419,50 +348,42 @@ public class Create extends InputAbstract {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getClusterUser() {
|
private String getClusterUser() {
|
||||||
if (clusterUser == null) {
|
if (clusterUser == null) {
|
||||||
clusterUser = input("--cluster-user", "Please provide the username:", "cluster-admin");
|
clusterUser = input("--cluster-user", "Please provide the username:", "cluster-admin");
|
||||||
}
|
}
|
||||||
return clusterUser;
|
return clusterUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusterUser(String clusterUser) {
|
private String getClusterPassword() {
|
||||||
this.clusterUser = clusterUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClusterPassword() {
|
|
||||||
if (clusterPassword == null) {
|
if (clusterPassword == null) {
|
||||||
clusterPassword = inputPassword("--cluster-password", "Please enter the password:", "password-admin");
|
clusterPassword = inputPassword("--cluster-password", "Please enter the password:", "password-admin");
|
||||||
}
|
}
|
||||||
return clusterPassword;
|
return clusterPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSslKeyPassword() {
|
private String getSslKeyPassword() {
|
||||||
if (sslKeyPassword == null) {
|
if (sslKeyPassword == null) {
|
||||||
sslKeyPassword = inputPassword("--ssl-key-password", "Please enter the keystore password:", "password");
|
sslKeyPassword = inputPassword("--ssl-key-password", "Please enter the keystore password:", "password");
|
||||||
}
|
}
|
||||||
return sslKeyPassword;
|
return sslKeyPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSslTrust() {
|
private String getSslTrust() {
|
||||||
if (sslTrust == null) {
|
if (sslTrust == null) {
|
||||||
sslTrust = input("--ssl-trust", "Please enter the trust store path:", "/etc/truststore.jks");
|
sslTrust = input("--ssl-trust", "Please enter the trust store path:", "/etc/truststore.jks");
|
||||||
}
|
}
|
||||||
return sslTrust;
|
return sslTrust;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSslTrustPassword() {
|
private String getSslTrustPassword() {
|
||||||
if (sslTrustPassword == null) {
|
if (sslTrustPassword == null) {
|
||||||
sslTrustPassword = inputPassword("--ssl-key-password", "Please enter the keystore password:", "password");
|
sslTrustPassword = inputPassword("--ssl-key-password", "Please enter the keystore password:", "password");
|
||||||
}
|
}
|
||||||
return sslTrustPassword;
|
return sslTrustPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClusterPassword(String clusterPassword) {
|
private boolean isAllowAnonymous() {
|
||||||
this.clusterPassword = clusterPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllowAnonymous() {
|
|
||||||
if (allowAnonymous == null) {
|
if (allowAnonymous == null) {
|
||||||
allowAnonymous = inputBoolean("--allow-anonymous | --require-login", "Allow anonymous access?", true);
|
allowAnonymous = inputBoolean("--allow-anonymous | --require-login", "Allow anonymous access?", true);
|
||||||
}
|
}
|
||||||
|
@ -473,21 +394,6 @@ public class Create extends InputAbstract {
|
||||||
return paging;
|
return paging;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAllowAnonymous(boolean allowAnonymous) {
|
|
||||||
this.allowAnonymous = Boolean.valueOf(allowAnonymous);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getRequireLogin() {
|
|
||||||
if (requireLogin == null) {
|
|
||||||
requireLogin = !isAllowAnonymous();
|
|
||||||
}
|
|
||||||
return requireLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequireLogin(Boolean requireLogin) {
|
|
||||||
this.requireLogin = requireLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
|
|
||||||
if (password == null) {
|
if (password == null) {
|
||||||
|
@ -522,45 +428,18 @@ public class Create extends InputAbstract {
|
||||||
this.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGlobalMaxSize() {
|
private boolean isSlave() {
|
||||||
return globalMaxSize;
|
|
||||||
}
|
|
||||||
public void setGlobalMaxSize(String globalMaxSize) {
|
|
||||||
this.globalMaxSize = globalMaxSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSlave() {
|
|
||||||
return slave;
|
return slave;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSlave(boolean slave) {
|
private boolean isFailoverOnShutodwn() {
|
||||||
this.slave = slave;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFailoverOnShutodwn() {
|
|
||||||
return failoverOnShutodwn;
|
return failoverOnShutodwn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFailoverOnShutodwn(boolean failoverOnShutodwn) {
|
private boolean isDisablePersistence() {
|
||||||
this.failoverOnShutodwn = failoverOnShutodwn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getAllowAnonymous() {
|
|
||||||
return allowAnonymous;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAllowAnonymous(Boolean allowAnonymous) {
|
|
||||||
this.allowAnonymous = allowAnonymous;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDisablePersistence() {
|
|
||||||
return disablePersistence;
|
return disablePersistence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisablePersistence(boolean disablePersistence) {
|
|
||||||
this.disablePersistence = disablePersistence;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ActionContext context) throws Exception {
|
public Object execute(ActionContext context) throws Exception {
|
||||||
this.checkDirectory();
|
this.checkDirectory();
|
||||||
|
@ -589,6 +468,7 @@ public class Create extends InputAbstract {
|
||||||
throw new RuntimeException(String.format("The path '%s' is not writable.", directory));
|
throw new RuntimeException(String.format("The path '%s' is not writable.", directory));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object run(ActionContext context) throws Exception {
|
public Object run(ActionContext context) throws Exception {
|
||||||
|
|
||||||
IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win");
|
IS_WINDOWS = System.getProperty("os.name").toLowerCase().trim().startsWith("win");
|
||||||
|
@ -860,7 +740,6 @@ public class Create extends InputAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static int countBoolean(boolean...b) {
|
private static int countBoolean(boolean...b) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
|
@ -889,23 +768,6 @@ public class Create extends InputAbstract {
|
||||||
return logManager;
|
return logManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* It will create the jms configurations
|
|
||||||
*/
|
|
||||||
private void applyJMSObjects(HashMap<String, String> filters) {
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
PrintWriter printWriter = new PrintWriter(writer);
|
|
||||||
printWriter.println();
|
|
||||||
|
|
||||||
for (String str : getQueueList()) {
|
|
||||||
printWriter.println(" <queue name=\"" + str + "\"/>");
|
|
||||||
}
|
|
||||||
for (String str : getAddressList()) {
|
|
||||||
printWriter.println(" <topic name=\"" + str + "\"/>");
|
|
||||||
}
|
|
||||||
filters.put("${jms-list.settings}", writer.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It will create the address and queue configurations
|
* It will create the address and queue configurations
|
||||||
*/
|
*/
|
||||||
|
@ -1004,7 +866,7 @@ public class Create extends InputAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String path(String value, boolean unixPaths) throws IOException {
|
private String path(String value, boolean unixPaths) throws IOException {
|
||||||
return path(new File(value), unixPaths);
|
return path(new File(value), unixPaths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.activemq.artemis.cli.commands;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import io.airlift.airline.Help;
|
import io.airlift.airline.Help;
|
||||||
import org.apache.activemq.artemis.util.OptionsUtil;
|
|
||||||
|
|
||||||
public class HelpAction extends Help implements Action {
|
public class HelpAction extends Help implements Action {
|
||||||
|
|
||||||
|
|
|
@ -37,15 +37,10 @@ public class InputAbstract extends ActionAbstract {
|
||||||
@Option(name = "--silent", description = "It will disable all the inputs, and it would make a best guess for any required input")
|
@Option(name = "--silent", description = "It will disable all the inputs, and it would make a best guess for any required input")
|
||||||
private boolean silentInput = false;
|
private boolean silentInput = false;
|
||||||
|
|
||||||
public boolean isSilentInput() {
|
private boolean isSilentInput() {
|
||||||
return silentInput || !inputEnabled;
|
return silentInput || !inputEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSilentInput(boolean silentInput) {
|
|
||||||
this.silentInput = silentInput;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected boolean inputBoolean(String propertyName, String prompt, boolean silentDefault) {
|
protected boolean inputBoolean(String propertyName, String prompt, boolean silentDefault) {
|
||||||
if (isSilentInput()) {
|
if (isSilentInput()) {
|
||||||
return silentDefault;
|
return silentDefault;
|
||||||
|
|
|
@ -16,17 +16,16 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands;
|
package org.apache.activemq.artemis.cli.commands;
|
||||||
|
|
||||||
import io.airlift.airline.Arguments;
|
|
||||||
import io.airlift.airline.Command;
|
|
||||||
import io.airlift.airline.Option;
|
|
||||||
import org.apache.activemq.artemis.util.OptionsUtil;
|
|
||||||
import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
|
|
||||||
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import io.airlift.airline.Arguments;
|
||||||
|
import io.airlift.airline.Command;
|
||||||
|
import io.airlift.airline.Option;
|
||||||
|
import org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec;
|
||||||
|
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
|
||||||
|
|
||||||
@Command(name = "mask", description = "mask a password and print it out")
|
@Command(name = "mask", description = "mask a password and print it out")
|
||||||
public class Mask implements Action {
|
public class Mask implements Action {
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,17 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.activemq.artemis.util;
|
package org.apache.activemq.artemis.cli.commands;
|
||||||
|
|
||||||
import io.airlift.airline.Option;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.Action;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import io.airlift.airline.Option;
|
||||||
|
|
||||||
public class OptionsUtil {
|
public class OptionsUtil {
|
||||||
|
|
||||||
public static void findAllOptions(Set<String> options, Class<? extends Action> command) {
|
private static void findAllOptions(Set<String> options, Class<? extends Action> command) {
|
||||||
for (Field field : command.getDeclaredFields()) {
|
for (Field field : command.getDeclaredFields()) {
|
||||||
if (field.isAnnotationPresent(Option.class)) {
|
if (field.isAnnotationPresent(Option.class)) {
|
||||||
Option annotation = field.getAnnotation(Option.class);
|
Option annotation = field.getAnnotation(Option.class);
|
||||||
|
@ -43,7 +41,7 @@ public class OptionsUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> findCommandOptions(Class<? extends Action> command) {
|
private static Set<String> findCommandOptions(Class<? extends Action> command) {
|
||||||
Set<String> options = new HashSet<>();
|
Set<String> options = new HashSet<>();
|
||||||
findAllOptions(options, command);
|
findAllOptions(options, command);
|
||||||
|
|
|
@ -22,13 +22,13 @@ import java.util.TimerTask;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.Artemis;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.LockAbstract;
|
import org.apache.activemq.artemis.cli.commands.tools.LockAbstract;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.PrintData;
|
||||||
|
import org.apache.activemq.artemis.cli.factory.BrokerFactory;
|
||||||
|
import org.apache.activemq.artemis.cli.factory.security.SecurityManagerFactory;
|
||||||
import org.apache.activemq.artemis.components.ExternalComponent;
|
import org.apache.activemq.artemis.components.ExternalComponent;
|
||||||
import org.apache.activemq.artemis.dto.BrokerDTO;
|
import org.apache.activemq.artemis.dto.BrokerDTO;
|
||||||
import org.apache.activemq.artemis.dto.ComponentDTO;
|
import org.apache.activemq.artemis.dto.ComponentDTO;
|
||||||
import org.apache.activemq.artemis.factory.BrokerFactory;
|
|
||||||
import org.apache.activemq.artemis.factory.SecurityManagerFactory;
|
|
||||||
import org.apache.activemq.artemis.integration.Broker;
|
import org.apache.activemq.artemis.integration.Broker;
|
||||||
import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
|
import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
|
||||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
||||||
|
@ -40,7 +40,7 @@ public class Run extends LockAbstract {
|
||||||
@Option(name = "--allow-kill", description = "This will allow the server to kill itself. Useful for tests (failover tests for instance)")
|
@Option(name = "--allow-kill", description = "This will allow the server to kill itself. Useful for tests (failover tests for instance)")
|
||||||
boolean allowKill;
|
boolean allowKill;
|
||||||
|
|
||||||
static boolean embedded = false;
|
private static boolean embedded = false;
|
||||||
|
|
||||||
public static final ReusableLatch latchRunning = new ReusableLatch(0);
|
public static final ReusableLatch latchRunning = new ReusableLatch(0);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class Run extends LockAbstract {
|
||||||
public Object execute(ActionContext context) throws Exception {
|
public Object execute(ActionContext context) throws Exception {
|
||||||
super.execute(context);
|
super.execute(context);
|
||||||
|
|
||||||
Artemis.printBanner();
|
PrintData.printBanner();
|
||||||
|
|
||||||
BrokerDTO broker = getBrokerDTO();
|
BrokerDTO broker = getBrokerDTO();
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import io.airlift.airline.Help;
|
||||||
import org.apache.activemq.artemis.cli.commands.Action;
|
import org.apache.activemq.artemis.cli.commands.Action;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
||||||
import org.apache.activemq.artemis.util.OptionsUtil;
|
import org.apache.activemq.artemis.cli.commands.OptionsUtil;
|
||||||
|
|
||||||
public class HelpAddress extends Help implements Action {
|
public class HelpAddress extends Help implements Action {
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import javax.jms.Session;
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.ConsumerThread;
|
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import javax.jms.Session;
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.ConsumerThread;
|
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.util;
|
package org.apache.activemq.artemis.cli.commands.messages;
|
||||||
|
|
||||||
import javax.jms.BytesMessage;
|
import javax.jms.BytesMessage;
|
||||||
import javax.jms.Destination;
|
import javax.jms.Destination;
|
|
@ -24,7 +24,6 @@ import javax.jms.Session;
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.ProducerThread;
|
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||||
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.util;
|
package org.apache.activemq.artemis.cli.commands.messages;
|
||||||
|
|
||||||
import javax.jms.BytesMessage;
|
import javax.jms.BytesMessage;
|
||||||
import javax.jms.DeliveryMode;
|
import javax.jms.DeliveryMode;
|
|
@ -25,7 +25,7 @@ import io.airlift.airline.Help;
|
||||||
import org.apache.activemq.artemis.cli.commands.Action;
|
import org.apache.activemq.artemis.cli.commands.Action;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
||||||
import org.apache.activemq.artemis.util.OptionsUtil;
|
import org.apache.activemq.artemis.cli.commands.OptionsUtil;
|
||||||
|
|
||||||
public class HelpQueue extends Help implements Action {
|
public class HelpQueue extends Help implements Action {
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import io.airlift.airline.Help;
|
||||||
import org.apache.activemq.artemis.cli.commands.Action;
|
import org.apache.activemq.artemis.cli.commands.Action;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
||||||
import org.apache.activemq.artemis.util.OptionsUtil;
|
import org.apache.activemq.artemis.cli.commands.OptionsUtil;
|
||||||
|
|
||||||
public class HelpData extends Help implements Action {
|
public class HelpData extends Help implements Action {
|
||||||
|
|
||||||
|
|
|
@ -32,15 +32,6 @@ public abstract class LockAbstract extends DataAbstract {
|
||||||
private static RandomAccessFile serverLockFile = null;
|
private static RandomAccessFile serverLockFile = null;
|
||||||
private static FileLock serverLockLock = null;
|
private static FileLock serverLockLock = null;
|
||||||
|
|
||||||
protected File getLockPlace() throws Exception {
|
|
||||||
String brokerInstance = getBrokerInstance();
|
|
||||||
if (brokerInstance != null) {
|
|
||||||
return new File(new File(brokerInstance), "lock");
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unlock() {
|
public static void unlock() {
|
||||||
try {
|
try {
|
||||||
if (serverLockFile != null) {
|
if (serverLockFile != null) {
|
||||||
|
@ -70,7 +61,7 @@ public abstract class LockAbstract extends DataAbstract {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void lockCLI(File lockPlace) throws Exception {
|
void lockCLI(File lockPlace) throws Exception {
|
||||||
if (lockPlace != null) {
|
if (lockPlace != null) {
|
||||||
lockPlace.mkdirs();
|
lockPlace.mkdirs();
|
||||||
if (serverLockFile == null) {
|
if (serverLockFile == null) {
|
||||||
|
@ -89,4 +80,12 @@ public abstract class LockAbstract extends DataAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File getLockPlace() throws Exception {
|
||||||
|
String brokerInstance = getBrokerInstance();
|
||||||
|
if (brokerInstance != null) {
|
||||||
|
return new File(new File(brokerInstance), "lock");
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -31,7 +33,6 @@ import io.airlift.airline.Command;
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
|
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
import org.apache.activemq.artemis.cli.Artemis;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||||
import org.apache.activemq.artemis.core.message.impl.CoreMessagePersister;
|
import org.apache.activemq.artemis.core.message.impl.CoreMessagePersister;
|
||||||
|
@ -81,7 +82,7 @@ public class PrintData extends OptionalLocking {
|
||||||
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory) throws Exception {
|
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory) throws Exception {
|
||||||
// Having the version on the data report is an information very useful to understand what happened
|
// Having the version on the data report is an information very useful to understand what happened
|
||||||
// When debugging stuff
|
// When debugging stuff
|
||||||
Artemis.printBanner();
|
printBanner();
|
||||||
|
|
||||||
File serverLockFile = new File(messagesDirectory, "server.lock");
|
File serverLockFile = new File(messagesDirectory, "server.lock");
|
||||||
|
|
||||||
|
@ -135,6 +136,20 @@ public class PrintData extends OptionalLocking {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void printBanner() throws Exception {
|
||||||
|
copy(PrintData.class.getResourceAsStream("banner.txt"), System.out);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static long copy(InputStream in, OutputStream out) throws Exception {
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int len = in.read(buffer);
|
||||||
|
while (len != -1) {
|
||||||
|
out.write(buffer, 0, len);
|
||||||
|
len = in.read(buffer);
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
private static void printPages(File pageDirectory, DescribeJournal describeJournal) {
|
private static void printPages(File pageDirectory, DescribeJournal describeJournal) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -214,12 +229,9 @@ public class PrintData extends OptionalLocking {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
msgID++;
|
msgID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pgid++;
|
pgid++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -228,7 +240,7 @@ public class PrintData extends OptionalLocking {
|
||||||
/**
|
/**
|
||||||
* Calculate the acks on the page system
|
* Calculate the acks on the page system
|
||||||
*/
|
*/
|
||||||
protected static PageCursorsInfo calculateCursorsInfo(List<RecordInfo> records) throws Exception {
|
private static PageCursorsInfo calculateCursorsInfo(List<RecordInfo> records) throws Exception {
|
||||||
|
|
||||||
PageCursorsInfo cursorInfo = new PageCursorsInfo();
|
PageCursorsInfo cursorInfo = new PageCursorsInfo();
|
||||||
|
|
||||||
|
@ -293,25 +305,18 @@ public class PrintData extends OptionalLocking {
|
||||||
/**
|
/**
|
||||||
* @return the pgTXs
|
* @return the pgTXs
|
||||||
*/
|
*/
|
||||||
public Set<Long> getPgTXs() {
|
Set<Long> getPgTXs() {
|
||||||
return pgTXs;
|
return pgTXs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the cursorRecords
|
* @return the cursorRecords
|
||||||
*/
|
*/
|
||||||
public Map<Long, Set<PagePosition>> getCursorRecords() {
|
Map<Long, Set<PagePosition>> getCursorRecords() {
|
||||||
return cursorRecords;
|
return cursorRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
Set<Long> getCompletePages(Long queueID) {
|
||||||
* @return the completePages
|
|
||||||
*/
|
|
||||||
public Map<Long, Set<Long>> getCompletePages() {
|
|
||||||
return completePages;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Long> getCompletePages(Long queueID) {
|
|
||||||
Set<Long> completePagesSet = completePages.get(queueID);
|
Set<Long> completePagesSet = completePages.get(queueID);
|
||||||
|
|
||||||
if (completePagesSet == null) {
|
if (completePagesSet == null) {
|
||||||
|
|
|
@ -1,129 +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.cli.commands.tools;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The constants shared by <code>org.apache.activemq.tools.XmlDataImporter</code> and
|
|
||||||
* <code>org.apache.activemq.tools.XmlDataExporter</code>.
|
|
||||||
*/
|
|
||||||
public final class XmlDataConstants {
|
|
||||||
|
|
||||||
private XmlDataConstants() {
|
|
||||||
// Utility
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String XML_VERSION = "1.0";
|
|
||||||
public static final String DOCUMENT_PARENT = "activemq-journal";
|
|
||||||
public static final String BINDINGS_PARENT = "bindings";
|
|
||||||
|
|
||||||
public static final String QUEUE_BINDINGS_CHILD = "queue-binding";
|
|
||||||
public static final String QUEUE_BINDING_ADDRESS = "address";
|
|
||||||
public static final String QUEUE_BINDING_FILTER_STRING = "filter-string";
|
|
||||||
public static final String QUEUE_BINDING_NAME = "name";
|
|
||||||
public static final String QUEUE_BINDING_ID = "id";
|
|
||||||
public static final String QUEUE_BINDING_ROUTING_TYPE = "routing-type";
|
|
||||||
|
|
||||||
public static final String ADDRESS_BINDINGS_CHILD = "address-binding";
|
|
||||||
public static final String ADDRESS_BINDING_NAME = "name";
|
|
||||||
public static final String ADDRESS_BINDING_ID = "id";
|
|
||||||
public static final String ADDRESS_BINDING_ROUTING_TYPE = "routing-types";
|
|
||||||
|
|
||||||
public static final String MESSAGES_PARENT = "messages";
|
|
||||||
public static final String MESSAGES_CHILD = "message";
|
|
||||||
public static final String MESSAGE_ID = "id";
|
|
||||||
public static final String MESSAGE_PRIORITY = "priority";
|
|
||||||
public static final String MESSAGE_EXPIRATION = "expiration";
|
|
||||||
public static final String MESSAGE_TIMESTAMP = "timestamp";
|
|
||||||
public static final String DEFAULT_TYPE_PRETTY = "default";
|
|
||||||
public static final String BYTES_TYPE_PRETTY = "bytes";
|
|
||||||
public static final String MAP_TYPE_PRETTY = "map";
|
|
||||||
public static final String OBJECT_TYPE_PRETTY = "object";
|
|
||||||
public static final String STREAM_TYPE_PRETTY = "stream";
|
|
||||||
public static final String TEXT_TYPE_PRETTY = "text";
|
|
||||||
public static final String MESSAGE_TYPE = "type";
|
|
||||||
public static final String MESSAGE_IS_LARGE = "isLarge";
|
|
||||||
public static final String MESSAGE_USER_ID = "user-id";
|
|
||||||
public static final String MESSAGE_BODY = "body";
|
|
||||||
public static final String PROPERTIES_PARENT = "properties";
|
|
||||||
public static final String PROPERTIES_CHILD = "property";
|
|
||||||
public static final String PROPERTY_NAME = "name";
|
|
||||||
public static final String PROPERTY_VALUE = "value";
|
|
||||||
public static final String PROPERTY_TYPE = "type";
|
|
||||||
public static final String QUEUES_PARENT = "queues";
|
|
||||||
public static final String QUEUES_CHILD = "queue";
|
|
||||||
public static final String QUEUE_NAME = "name";
|
|
||||||
public static final String PROPERTY_TYPE_BOOLEAN = "boolean";
|
|
||||||
public static final String PROPERTY_TYPE_BYTE = "byte";
|
|
||||||
public static final String PROPERTY_TYPE_BYTES = "bytes";
|
|
||||||
public static final String PROPERTY_TYPE_SHORT = "short";
|
|
||||||
public static final String PROPERTY_TYPE_INTEGER = "integer";
|
|
||||||
public static final String PROPERTY_TYPE_LONG = "long";
|
|
||||||
public static final String PROPERTY_TYPE_FLOAT = "float";
|
|
||||||
public static final String PROPERTY_TYPE_DOUBLE = "double";
|
|
||||||
public static final String PROPERTY_TYPE_STRING = "string";
|
|
||||||
public static final String PROPERTY_TYPE_SIMPLE_STRING = "simple-string";
|
|
||||||
|
|
||||||
static final String JMS_CONNECTION_FACTORY_NAME = "name";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CLIENT_ID = "client-id";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CALL_FAILOVER_TIMEOUT = "call-failover-timeout";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CALL_TIMEOUT = "call-timeout";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CLIENT_FAILURE_CHECK_PERIOD = "client-failure-check-period";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CONFIRMATION_WINDOW_SIZE = "confirmation-window-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CONNECTION_TTL = "connection-ttl";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CONSUMER_MAX_RATE = "consumer-max-rate";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CONSUMER_WINDOW_SIZE = "consumer-window-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_DISCOVERY_GROUP_NAME = "discovery-group-name";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_DUPS_OK_BATCH_SIZE = "dups-ok-batch-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_TYPE = "type";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_GROUP_ID = "group-id";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_LOAD_BALANCING_POLICY_CLASS_NAME = "load-balancing-policy-class-name";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_MAX_RETRY_INTERVAL = "max-retry-interval";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_MIN_LARGE_MESSAGE_SIZE = "min-large-message-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_PRODUCER_MAX_RATE = "producer-max-rate";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_PRODUCER_WINDOW_SIZE = "producer-window-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_RECONNECT_ATTEMPTS = "reconnect-attempts";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_RETRY_INTERVAL = "retry-interval";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_RETRY_INTERVAL_MULTIPLIER = "retry-interval-multiplier";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_SCHEDULED_THREAD_POOL_MAX_SIZE = "scheduled-thread-pool-max-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_THREAD_POOL_MAX_SIZE = "thread-pool-max-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_TRANSACTION_BATCH_SIZE = "transaction-batch-size";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CONNECTORS = "connectors";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CONNECTOR = "connector";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_AUTO_GROUP = "auto-group";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_BLOCK_ON_ACKNOWLEDGE = "block-on-acknowledge";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_BLOCK_ON_DURABLE_SEND = "block-on-durable-send";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_BLOCK_ON_NON_DURABLE_SEND = "block-on-non-durable-send";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_CACHE_LARGE_MESSAGES_CLIENT = "cache-large-messages-client";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_COMPRESS_LARGE_MESSAGES = "compress-large-messages";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_FAILOVER_ON_INITIAL_CONNECTION = "failover-on-initial-connection";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_HA = "ha";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_PREACKNOWLEDGE = "preacknowledge";
|
|
||||||
static final String JMS_CONNECTION_FACTORY_USE_GLOBAL_POOLS = "use-global-pools";
|
|
||||||
|
|
||||||
static final String JMS_DESTINATIONS = "jms-destinations";
|
|
||||||
static final String JMS_DESTINATION = "jms-destination";
|
|
||||||
static final String JMS_DESTINATION_NAME = "name";
|
|
||||||
static final String JMS_DESTINATION_SELECTOR = "selector";
|
|
||||||
static final String JMS_DESTINATION_TYPE = "type";
|
|
||||||
|
|
||||||
static final String JMS_JNDI_ENTRIES = "entries";
|
|
||||||
static final String JMS_JNDI_ENTRY = "entry";
|
|
||||||
|
|
||||||
public static final String JNDI_COMPATIBILITY_PREFIX = "java:jboss/exported/";
|
|
||||||
|
|
||||||
static final String NULL = "_AMQ_NULL";
|
|
||||||
}
|
|
|
@ -14,12 +14,13 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools.journal;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.LockAbstract;
|
||||||
import org.apache.activemq.artemis.core.config.Configuration;
|
import org.apache.activemq.artemis.core.config.Configuration;
|
||||||
import org.apache.activemq.artemis.core.io.IOCriticalErrorListener;
|
import org.apache.activemq.artemis.core.io.IOCriticalErrorListener;
|
||||||
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
|
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
|
||||||
|
@ -44,7 +45,7 @@ public final class CompactJournal extends LockAbstract {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void compactJournal(final File directory,
|
private void compactJournal(final File directory,
|
||||||
final String journalPrefix,
|
final String journalPrefix,
|
||||||
final String journalSuffix,
|
final String journalSuffix,
|
||||||
final int minFiles,
|
final int minFiles,
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools.journal;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.LockAbstract;
|
||||||
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
|
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
|
||||||
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||||
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
|
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
|
||||||
|
@ -79,7 +80,7 @@ public class DecodeJournal extends LockAbstract {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void importJournal(final String directory,
|
private static void importJournal(final String directory,
|
||||||
final String journalPrefix,
|
final String journalPrefix,
|
||||||
final String journalSuffix,
|
final String journalSuffix,
|
||||||
final int minFiles,
|
final int minFiles,
|
||||||
|
@ -216,8 +217,7 @@ public class DecodeJournal extends LockAbstract {
|
||||||
journal.stop();
|
journal.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static AtomicInteger getCounter(final Long txID, final Map<Long, AtomicInteger> txCounters) {
|
private static AtomicInteger getCounter(final Long txID, final Map<Long, AtomicInteger> txCounters) {
|
||||||
|
|
||||||
AtomicInteger counter = txCounters.get(txID);
|
AtomicInteger counter = txCounters.get(txID);
|
||||||
if (counter == null) {
|
if (counter == null) {
|
||||||
counter = new AtomicInteger(0);
|
counter = new AtomicInteger(0);
|
||||||
|
@ -227,7 +227,7 @@ public class DecodeJournal extends LockAbstract {
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static RecordInfo parseRecord(final Properties properties) throws Exception {
|
private static RecordInfo parseRecord(final Properties properties) throws Exception {
|
||||||
long id = parseLong("id", properties);
|
long id = parseLong("id", properties);
|
||||||
byte userRecordType = parseByte("userRecordType", properties);
|
byte userRecordType = parseByte("userRecordType", properties);
|
||||||
boolean isUpdate = parseBoolean("isUpdate", properties);
|
boolean isUpdate = parseBoolean("isUpdate", properties);
|
||||||
|
@ -241,10 +241,6 @@ public class DecodeJournal extends LockAbstract {
|
||||||
return decode(value);
|
return decode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param properties
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static int parseInt(final String name, final Properties properties) throws Exception {
|
private static int parseInt(final String name, final Properties properties) throws Exception {
|
||||||
String value = parseString(name, properties);
|
String value = parseString(name, properties);
|
||||||
|
|
||||||
|
@ -269,12 +265,6 @@ public class DecodeJournal extends LockAbstract {
|
||||||
return Byte.parseByte(value);
|
return Byte.parseByte(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param name
|
|
||||||
* @param properties
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private static String parseString(final String name, final Properties properties) throws Exception {
|
private static String parseString(final String name, final Properties properties) throws Exception {
|
||||||
String value = properties.getProperty(name);
|
String value = properties.getProperty(name);
|
||||||
|
|
||||||
|
@ -284,7 +274,7 @@ public class DecodeJournal extends LockAbstract {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Properties parseLine(final String[] splitLine) {
|
private static Properties parseLine(final String[] splitLine) {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
|
||||||
for (String el : splitLine) {
|
for (String el : splitLine) {
|
||||||
|
@ -303,16 +293,4 @@ public class DecodeJournal extends LockAbstract {
|
||||||
return Base64.decode(data, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
|
return Base64.decode(data, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printUsage() {
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
System.err.println();
|
|
||||||
}
|
|
||||||
System.err.println("This method will export the journal at low level record.");
|
|
||||||
System.err.println();
|
|
||||||
System.err.println();
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
System.err.println();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools.journal;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -25,6 +25,7 @@ import java.util.List;
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.LockAbstract;
|
||||||
import org.apache.activemq.artemis.core.io.SequentialFileFactory;
|
import org.apache.activemq.artemis.core.io.SequentialFileFactory;
|
||||||
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
|
import org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory;
|
||||||
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||||
|
@ -64,7 +65,7 @@ public class EncodeJournal extends LockAbstract {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void exportJournal(final String directory,
|
private static void exportJournal(final String directory,
|
||||||
final String journalPrefix,
|
final String journalPrefix,
|
||||||
final String journalSuffix,
|
final String journalSuffix,
|
||||||
final int minFiles,
|
final int minFiles,
|
||||||
|
@ -105,13 +106,7 @@ public class EncodeJournal extends LockAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private static void exportJournalFile(final PrintStream out,
|
||||||
* @param out
|
|
||||||
* @param fileFactory
|
|
||||||
* @param file
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public static void exportJournalFile(final PrintStream out,
|
|
||||||
final SequentialFileFactory fileFactory,
|
final SequentialFileFactory fileFactory,
|
||||||
final JournalFile file) throws Exception {
|
final JournalFile file) throws Exception {
|
||||||
JournalImpl.readJournalFile(fileFactory, file, new JournalReaderCallback() {
|
JournalImpl.readJournalFile(fileFactory, file, new JournalReaderCallback() {
|
||||||
|
@ -193,16 +188,4 @@ public class EncodeJournal extends LockAbstract {
|
||||||
return Base64.encodeBytes(data, 0, data.length, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
|
return Base64.encodeBytes(data, 0, data.length, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printUsage() {
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
System.err.println();
|
|
||||||
}
|
|
||||||
System.err.println("This method will export the journal at low level record.");
|
|
||||||
System.err.println();
|
|
||||||
System.err.println();
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
System.err.println();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,13 +15,14 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools.journal;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.LockAbstract;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.SyncCalculation;
|
import org.apache.activemq.artemis.cli.commands.util.SyncCalculation;
|
||||||
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||||
import org.apache.activemq.artemis.core.server.JournalType;
|
import org.apache.activemq.artemis.core.server.JournalType;
|
||||||
|
@ -33,7 +34,6 @@ public class PerfJournal extends LockAbstract {
|
||||||
@Option(name = "--block-size", description = "The block size for each write (default 4096)")
|
@Option(name = "--block-size", description = "The block size for each write (default 4096)")
|
||||||
public int size = 4 * 1024;
|
public int size = 4 * 1024;
|
||||||
|
|
||||||
|
|
||||||
@Option(name = "--writes", description = "The number of writes to be performed (default 250)")
|
@Option(name = "--writes", description = "The number of writes to be performed (default 250)")
|
||||||
public int writes = 250;
|
public int writes = 250;
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*
|
||||||
|
* 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.cli.commands.tools.xml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constants shared by <code>org.apache.activemq.tools.XmlDataImporter</code> and
|
||||||
|
* <code>org.apache.activemq.tools.XmlDataExporter</code>.
|
||||||
|
*/
|
||||||
|
public final class XmlDataConstants {
|
||||||
|
|
||||||
|
private XmlDataConstants() {
|
||||||
|
// Utility
|
||||||
|
}
|
||||||
|
|
||||||
|
static final String XML_VERSION = "1.0";
|
||||||
|
static final String DOCUMENT_PARENT = "activemq-journal";
|
||||||
|
static final String BINDINGS_PARENT = "bindings";
|
||||||
|
|
||||||
|
static final String QUEUE_BINDINGS_CHILD = "queue-binding";
|
||||||
|
static final String QUEUE_BINDING_ADDRESS = "address";
|
||||||
|
static final String QUEUE_BINDING_FILTER_STRING = "filter-string";
|
||||||
|
static final String QUEUE_BINDING_NAME = "name";
|
||||||
|
static final String QUEUE_BINDING_ID = "id";
|
||||||
|
static final String QUEUE_BINDING_ROUTING_TYPE = "routing-type";
|
||||||
|
|
||||||
|
static final String ADDRESS_BINDINGS_CHILD = "address-binding";
|
||||||
|
static final String ADDRESS_BINDING_NAME = "name";
|
||||||
|
static final String ADDRESS_BINDING_ID = "id";
|
||||||
|
static final String ADDRESS_BINDING_ROUTING_TYPE = "routing-types";
|
||||||
|
|
||||||
|
static final String MESSAGES_PARENT = "messages";
|
||||||
|
static final String MESSAGES_CHILD = "message";
|
||||||
|
static final String MESSAGE_ID = "id";
|
||||||
|
static final String MESSAGE_PRIORITY = "priority";
|
||||||
|
static final String MESSAGE_EXPIRATION = "expiration";
|
||||||
|
static final String MESSAGE_TIMESTAMP = "timestamp";
|
||||||
|
static final String DEFAULT_TYPE_PRETTY = "default";
|
||||||
|
static final String BYTES_TYPE_PRETTY = "bytes";
|
||||||
|
static final String MAP_TYPE_PRETTY = "map";
|
||||||
|
static final String OBJECT_TYPE_PRETTY = "object";
|
||||||
|
static final String STREAM_TYPE_PRETTY = "stream";
|
||||||
|
static final String TEXT_TYPE_PRETTY = "text";
|
||||||
|
static final String MESSAGE_TYPE = "type";
|
||||||
|
static final String MESSAGE_IS_LARGE = "isLarge";
|
||||||
|
static final String MESSAGE_USER_ID = "user-id";
|
||||||
|
static final String MESSAGE_BODY = "body";
|
||||||
|
static final String PROPERTIES_PARENT = "properties";
|
||||||
|
static final String PROPERTIES_CHILD = "property";
|
||||||
|
static final String PROPERTY_NAME = "name";
|
||||||
|
static final String PROPERTY_VALUE = "value";
|
||||||
|
static final String PROPERTY_TYPE = "type";
|
||||||
|
static final String QUEUES_PARENT = "queues";
|
||||||
|
static final String QUEUES_CHILD = "queue";
|
||||||
|
public static final String QUEUE_NAME = "name";
|
||||||
|
static final String PROPERTY_TYPE_BOOLEAN = "boolean";
|
||||||
|
static final String PROPERTY_TYPE_BYTE = "byte";
|
||||||
|
static final String PROPERTY_TYPE_BYTES = "bytes";
|
||||||
|
static final String PROPERTY_TYPE_SHORT = "short";
|
||||||
|
static final String PROPERTY_TYPE_INTEGER = "integer";
|
||||||
|
static final String PROPERTY_TYPE_LONG = "long";
|
||||||
|
static final String PROPERTY_TYPE_FLOAT = "float";
|
||||||
|
static final String PROPERTY_TYPE_DOUBLE = "double";
|
||||||
|
static final String PROPERTY_TYPE_STRING = "string";
|
||||||
|
static final String PROPERTY_TYPE_SIMPLE_STRING = "simple-string";
|
||||||
|
|
||||||
|
static final String NULL = "_AMQ_NULL";
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools.xml;
|
||||||
|
|
||||||
import javax.xml.stream.XMLOutputFactory;
|
import javax.xml.stream.XMLOutputFactory;
|
||||||
import javax.xml.stream.XMLStreamException;
|
import javax.xml.stream.XMLStreamException;
|
||||||
|
@ -45,6 +45,7 @@ import org.apache.activemq.artemis.api.core.Message;
|
||||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.tools.OptionalLocking;
|
||||||
import org.apache.activemq.artemis.core.config.Configuration;
|
import org.apache.activemq.artemis.core.config.Configuration;
|
||||||
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
||||||
import org.apache.activemq.artemis.core.journal.Journal;
|
import org.apache.activemq.artemis.core.journal.Journal;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools.xml;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||||
|
@ -27,7 +27,7 @@ import org.apache.activemq.artemis.utils.Base64;
|
||||||
*/
|
*/
|
||||||
public class XmlDataExporterUtil {
|
public class XmlDataExporterUtil {
|
||||||
|
|
||||||
public static String convertProperty(final Object value) {
|
static String convertProperty(final Object value) {
|
||||||
if (value instanceof byte[]) {
|
if (value instanceof byte[]) {
|
||||||
return encode((byte[]) value);
|
return encode((byte[]) value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,7 +35,7 @@ public class XmlDataExporterUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPropertyType(final Object value) {
|
static String getPropertyType(final Object value) {
|
||||||
String stringValue = null;
|
String stringValue = null;
|
||||||
|
|
||||||
// if the value is null then we can't really know what it is so just set
|
// if the value is null then we can't really know what it is so just set
|
||||||
|
@ -87,11 +87,8 @@ public class XmlDataExporterUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base64 encode a ServerMessage body into the proper XML format
|
* Base64 encode a ServerMessage body into the proper XML format
|
||||||
*
|
|
||||||
* @param message
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static String encodeMessageBody(final Message message) throws Exception {
|
static String encodeMessageBody(final Message message) throws Exception {
|
||||||
Preconditions.checkNotNull(message, "ServerMessage can not be null");
|
Preconditions.checkNotNull(message, "ServerMessage can not be null");
|
||||||
|
|
||||||
ActiveMQBuffer byteBuffer = message.toCore().getReadOnlyBodyBuffer();
|
ActiveMQBuffer byteBuffer = message.toCore().getReadOnlyBodyBuffer();
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.tools;
|
package org.apache.activemq.artemis.cli.commands.tools.xml;
|
||||||
|
|
||||||
import javax.xml.XMLConstants;
|
import javax.xml.XMLConstants;
|
||||||
import javax.xml.stream.XMLInputFactory;
|
import javax.xml.stream.XMLInputFactory;
|
||||||
|
@ -77,12 +77,9 @@ import org.jboss.logging.Logger;
|
||||||
*/
|
*/
|
||||||
@Command(name = "imp", description = "Import all message-data using an XML that could be interpreted by any system.")
|
@Command(name = "imp", description = "Import all message-data using an XML that could be interpreted by any system.")
|
||||||
public final class XmlDataImporter extends ActionAbstract {
|
public final class XmlDataImporter extends ActionAbstract {
|
||||||
// Constants -----------------------------------------------------
|
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(XmlDataImporter.class);
|
private static final Logger logger = Logger.getLogger(XmlDataImporter.class);
|
||||||
|
|
||||||
// Attributes ----------------------------------------------------
|
|
||||||
|
|
||||||
private XMLStreamReader reader;
|
private XMLStreamReader reader;
|
||||||
|
|
||||||
// this session is really only needed if the "session" variable does not auto-commit sends
|
// this session is really only needed if the "session" variable does not auto-commit sends
|
||||||
|
@ -151,7 +148,6 @@ public final class XmlDataImporter extends ActionAbstract {
|
||||||
*
|
*
|
||||||
* @param inputStream the stream from which to read the XML for import
|
* @param inputStream the stream from which to read the XML for import
|
||||||
* @param session used for sending messages, must use auto-commit for sends
|
* @param session used for sending messages, must use auto-commit for sends
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public void process(InputStream inputStream, ClientSession session) throws Exception {
|
public void process(InputStream inputStream, ClientSession session) throws Exception {
|
||||||
this.process(inputStream, session, null);
|
this.process(inputStream, session, null);
|
||||||
|
@ -413,8 +409,6 @@ public final class XmlDataImporter extends ActionAbstract {
|
||||||
String key = "";
|
String key = "";
|
||||||
String value = "";
|
String value = "";
|
||||||
String propertyType = "";
|
String propertyType = "";
|
||||||
String realStringValue = null;
|
|
||||||
SimpleString realSimpleStringValue = null;
|
|
||||||
|
|
||||||
for (int i = 0; i < reader.getAttributeCount(); i++) {
|
for (int i = 0; i < reader.getAttributeCount(); i++) {
|
||||||
String attributeName = reader.getAttributeLocalName(i);
|
String attributeName = reader.getAttributeLocalName(i);
|
||||||
|
@ -515,8 +509,6 @@ public final class XmlDataImporter extends ActionAbstract {
|
||||||
* CDATA has to be decoded in its entirety.
|
* CDATA has to be decoded in its entirety.
|
||||||
*
|
*
|
||||||
* @param processor used to deal with the decoded CDATA elements
|
* @param processor used to deal with the decoded CDATA elements
|
||||||
* @throws IOException
|
|
||||||
* @throws XMLStreamException
|
|
||||||
*/
|
*/
|
||||||
private void getMessageBodyBytes(MessageBodyBytesProcessor processor) throws IOException, XMLStreamException {
|
private void getMessageBodyBytes(MessageBodyBytesProcessor processor) throws IOException, XMLStreamException {
|
||||||
int currentEventType;
|
int currentEventType;
|
||||||
|
@ -612,79 +604,11 @@ public final class XmlDataImporter extends ActionAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getEntries() throws Exception {
|
|
||||||
StringBuilder entry = new StringBuilder();
|
|
||||||
boolean endLoop = false;
|
|
||||||
|
|
||||||
while (reader.hasNext()) {
|
|
||||||
int eventType = reader.getEventType();
|
|
||||||
switch (eventType) {
|
|
||||||
case XMLStreamConstants.START_ELEMENT:
|
|
||||||
if (XmlDataConstants.JMS_JNDI_ENTRY.equals(reader.getLocalName())) {
|
|
||||||
String elementText = reader.getElementText();
|
|
||||||
entry.append(elementText).append(", ");
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("JMS admin object JNDI entry: " + entry.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case XMLStreamConstants.END_ELEMENT:
|
|
||||||
if (XmlDataConstants.JMS_JNDI_ENTRIES.equals(reader.getLocalName())) {
|
|
||||||
endLoop = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (endLoop) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
reader.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry.delete(entry.length() - 2, entry.length()).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getConnectors() throws Exception {
|
|
||||||
StringBuilder entry = new StringBuilder();
|
|
||||||
boolean endLoop = false;
|
|
||||||
|
|
||||||
while (reader.hasNext()) {
|
|
||||||
int eventType = reader.getEventType();
|
|
||||||
switch (eventType) {
|
|
||||||
case XMLStreamConstants.START_ELEMENT:
|
|
||||||
if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTOR.equals(reader.getLocalName())) {
|
|
||||||
entry.append(reader.getElementText()).append(", ");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case XMLStreamConstants.END_ELEMENT:
|
|
||||||
if (XmlDataConstants.JMS_CONNECTION_FACTORY_CONNECTORS.equals(reader.getLocalName())) {
|
|
||||||
endLoop = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (endLoop) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
reader.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry.delete(entry.length() - 2, entry.length()).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Package protected ---------------------------------------------
|
|
||||||
|
|
||||||
// Protected -----------------------------------------------------
|
|
||||||
|
|
||||||
// Private -------------------------------------------------------
|
|
||||||
|
|
||||||
private static byte[] decode(String data) {
|
private static byte[] decode(String data) {
|
||||||
return Base64.decode(data, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
|
return Base64.decode(data, Base64.DONT_BREAK_LINES | Base64.URL_SAFE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface MessageBodyBytesProcessor {
|
private interface MessageBodyBytesProcessor {
|
||||||
|
|
||||||
void processBodyBytes(byte[] bytes) throws IOException;
|
void processBodyBytes(byte[] bytes) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inner classes -------------------------------------------------
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -20,7 +20,6 @@ import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.HashUtil;
|
import org.apache.activemq.artemis.cli.commands.util.HashUtil;
|
||||||
import org.apache.activemq.artemis.util.FileBasedSecStoreConfig;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +52,7 @@ public class AddUser extends PasswordAction {
|
||||||
* @param role the role
|
* @param role the role
|
||||||
* @throws IllegalArgumentException if user exists
|
* @throws IllegalArgumentException if user exists
|
||||||
*/
|
*/
|
||||||
protected void add(String hash, String... role) throws Exception {
|
private void add(String hash, String... role) throws Exception {
|
||||||
FileBasedSecStoreConfig config = getConfiguration();
|
FileBasedSecStoreConfig config = getConfiguration();
|
||||||
config.addNewUser(username, hash, role);
|
config.addNewUser(username, hash, role);
|
||||||
config.save();
|
config.save();
|
||||||
|
|
|
@ -14,7 +14,12 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.util;
|
package org.apache.activemq.artemis.cli.commands.user;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.Pair;
|
import org.apache.activemq.artemis.api.core.Pair;
|
||||||
import org.apache.activemq.artemis.utils.StringUtil;
|
import org.apache.activemq.artemis.utils.StringUtil;
|
||||||
|
@ -22,12 +27,7 @@ import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||||
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
|
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
|
||||||
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
||||||
|
|
||||||
import java.io.File;
|
class FileBasedSecStoreConfig {
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class FileBasedSecStoreConfig {
|
|
||||||
|
|
||||||
private static final String LICENSE_HEADER =
|
private static final String LICENSE_HEADER =
|
||||||
"## ---------------------------------------------------------------------------\n" +
|
"## ---------------------------------------------------------------------------\n" +
|
||||||
|
@ -51,7 +51,7 @@ public class FileBasedSecStoreConfig {
|
||||||
private PropertiesConfiguration userConfig;
|
private PropertiesConfiguration userConfig;
|
||||||
private PropertiesConfiguration roleConfig;
|
private PropertiesConfiguration roleConfig;
|
||||||
|
|
||||||
public FileBasedSecStoreConfig(File userFile, File roleFile) throws Exception {
|
FileBasedSecStoreConfig(File userFile, File roleFile) throws Exception {
|
||||||
Configurations configs = new Configurations();
|
Configurations configs = new Configurations();
|
||||||
userBuilder = configs.propertiesBuilder(userFile);
|
userBuilder = configs.propertiesBuilder(userFile);
|
||||||
roleBuilder = configs.propertiesBuilder(roleFile);
|
roleBuilder = configs.propertiesBuilder(roleFile);
|
||||||
|
@ -78,7 +78,7 @@ public class FileBasedSecStoreConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNewUser(String username, String hash, String... roles) throws Exception {
|
void addNewUser(String username, String hash, String... roles) throws Exception {
|
||||||
if (userConfig.getString(username) != null) {
|
if (userConfig.getString(username) != null) {
|
||||||
throw new IllegalArgumentException("User already exist: " + username);
|
throw new IllegalArgumentException("User already exist: " + username);
|
||||||
}
|
}
|
||||||
|
@ -86,12 +86,12 @@ public class FileBasedSecStoreConfig {
|
||||||
addRoles(username, roles);
|
addRoles(username, roles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() throws Exception {
|
void save() throws Exception {
|
||||||
userBuilder.save();
|
userBuilder.save();
|
||||||
roleBuilder.save();
|
roleBuilder.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUser(String username) throws Exception {
|
void removeUser(String username) throws Exception {
|
||||||
if (userConfig.getProperty(username) == null) {
|
if (userConfig.getProperty(username) == null) {
|
||||||
throw new IllegalArgumentException("user " + username + " doesn't exist.");
|
throw new IllegalArgumentException("user " + username + " doesn't exist.");
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class FileBasedSecStoreConfig {
|
||||||
removeRoles(username);
|
removeRoles(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> listUser(String username) {
|
List<String> listUser(String username) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
result.add("--- \"user\"(roles) ---\n");
|
result.add("--- \"user\"(roles) ---\n");
|
||||||
|
|
||||||
|
@ -121,6 +121,23 @@ public class FileBasedSecStoreConfig {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateUser(String username, String password, String[] roles) {
|
||||||
|
String oldPassword = (String) userConfig.getProperty(username);
|
||||||
|
if (oldPassword == null) {
|
||||||
|
throw new IllegalArgumentException("user " + username + " doesn't exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password != null) {
|
||||||
|
userConfig.setProperty(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roles != null && roles.length > 0) {
|
||||||
|
|
||||||
|
removeRoles(username);
|
||||||
|
addRoles(username, roles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String findRoles(String uname) {
|
private String findRoles(String uname) {
|
||||||
Iterator<String> iter = roleConfig.getKeys();
|
Iterator<String> iter = roleConfig.getKeys();
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -146,23 +163,6 @@ public class FileBasedSecStoreConfig {
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateUser(String username, String password, String[] roles) {
|
|
||||||
String oldPassword = (String) userConfig.getProperty(username);
|
|
||||||
if (oldPassword == null) {
|
|
||||||
throw new IllegalArgumentException("user " + username + " doesn't exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (password != null) {
|
|
||||||
userConfig.setProperty(username, password);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roles != null && roles.length > 0) {
|
|
||||||
|
|
||||||
removeRoles(username);
|
|
||||||
addRoles(username, roles);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addRoles(String username, String[] roles) {
|
private void addRoles(String username, String[] roles) {
|
||||||
for (String role : roles) {
|
for (String role : roles) {
|
||||||
List<String> users = roleConfig.getList(String.class, role);
|
List<String> users = roleConfig.getList(String.class, role);
|
|
@ -16,15 +16,15 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.user;
|
package org.apache.activemq.artemis.cli.commands.user;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import io.airlift.airline.Help;
|
import io.airlift.airline.Help;
|
||||||
import org.apache.activemq.artemis.cli.commands.Action;
|
import org.apache.activemq.artemis.cli.commands.Action;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
import org.apache.activemq.artemis.cli.commands.InvalidOptionsError;
|
||||||
import org.apache.activemq.artemis.util.OptionsUtil;
|
import org.apache.activemq.artemis.cli.commands.OptionsUtil;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class HelpUser extends Help implements Action {
|
public class HelpUser extends Help implements Action {
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.util.List;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.util.FileBasedSecStoreConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list existing users, example:
|
* list existing users, example:
|
||||||
|
@ -42,7 +41,7 @@ public class ListUser extends UserAction {
|
||||||
* list a single user or all users
|
* list a single user or all users
|
||||||
* if username is not specified
|
* if username is not specified
|
||||||
*/
|
*/
|
||||||
protected void list() throws Exception {
|
private void list() throws Exception {
|
||||||
FileBasedSecStoreConfig config = getConfiguration();
|
FileBasedSecStoreConfig config = getConfiguration();
|
||||||
List<String> result = config.listUser(username);
|
List<String> result = config.listUser(username);
|
||||||
for (String str : result) {
|
for (String str : result) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class PasswordAction extends UserAction {
|
||||||
@Option(name = "--password", description = "the password (Default: input)")
|
@Option(name = "--password", description = "the password (Default: input)")
|
||||||
String password;
|
String password;
|
||||||
|
|
||||||
protected void checkInputPassword() {
|
void checkInputPassword() {
|
||||||
if (password == null) {
|
if (password == null) {
|
||||||
password = inputPassword("--password", "Please provide the password:", null);
|
password = inputPassword("--password", "Please provide the password:", null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.activemq.artemis.cli.commands.user;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.util.FileBasedSecStoreConfig;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a user, example:
|
* Remove a user, example:
|
||||||
|
@ -35,7 +34,7 @@ public class RemoveUser extends UserAction {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void remove() throws Exception {
|
private void remove() throws Exception {
|
||||||
FileBasedSecStoreConfig config = getConfiguration();
|
FileBasedSecStoreConfig config = getConfiguration();
|
||||||
config.removeUser(username);
|
config.removeUser(username);
|
||||||
config.save();
|
config.save();
|
||||||
|
|
|
@ -20,7 +20,6 @@ import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.cli.commands.util.HashUtil;
|
import org.apache.activemq.artemis.cli.commands.util.HashUtil;
|
||||||
import org.apache.activemq.artemis.util.FileBasedSecStoreConfig;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +52,7 @@ public class ResetUser extends PasswordAction {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reset(String password, String[] roles) throws Exception {
|
private void reset(String password, String[] roles) throws Exception {
|
||||||
if (password == null && roles == null) {
|
if (password == null && roles == null) {
|
||||||
context.err.println("Nothing to update.");
|
context.err.println("Nothing to update.");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,15 +16,14 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands.user;
|
package org.apache.activemq.artemis.cli.commands.user;
|
||||||
|
|
||||||
import io.airlift.airline.Option;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.InputAbstract;
|
|
||||||
import org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule;
|
|
||||||
import org.apache.activemq.artemis.util.FileBasedSecStoreConfig;
|
|
||||||
|
|
||||||
import javax.security.auth.login.AppConfigurationEntry;
|
import javax.security.auth.login.AppConfigurationEntry;
|
||||||
import javax.security.auth.login.Configuration;
|
import javax.security.auth.login.Configuration;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import io.airlift.airline.Option;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.InputAbstract;
|
||||||
|
import org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule;
|
||||||
|
|
||||||
import static org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule.ROLE_FILE_PROP_NAME;
|
import static org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule.ROLE_FILE_PROP_NAME;
|
||||||
import static org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule.USER_FILE_PROP_NAME;
|
import static org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule.USER_FILE_PROP_NAME;
|
||||||
|
|
||||||
|
@ -39,23 +38,19 @@ public abstract class UserAction extends InputAbstract {
|
||||||
@Option(name = "--entry", description = "The appConfigurationEntry (default: activemq)")
|
@Option(name = "--entry", description = "The appConfigurationEntry (default: activemq)")
|
||||||
String entry = "activemq";
|
String entry = "activemq";
|
||||||
|
|
||||||
protected void checkInputUser() {
|
void checkInputUser() {
|
||||||
if (username == null) {
|
if (username == null) {
|
||||||
username = input("--user", "Please provider the userName:", null);
|
username = input("--user", "Please provider the userName:", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRole(String role) {
|
void checkInputRole() {
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkInputRole() {
|
|
||||||
if (role == null) {
|
if (role == null) {
|
||||||
role = input("--role", "type a comma separated list of roles", null);
|
role = input("--role", "type a comma separated list of roles", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected FileBasedSecStoreConfig getConfiguration() throws Exception {
|
FileBasedSecStoreConfig getConfiguration() throws Exception {
|
||||||
|
|
||||||
Configuration securityConfig = Configuration.getConfiguration();
|
Configuration securityConfig = Configuration.getConfiguration();
|
||||||
AppConfigurationEntry[] entries = securityConfig.getAppConfigurationEntry(entry);
|
AppConfigurationEntry[] entries = securityConfig.getAppConfigurationEntry(entry);
|
||||||
|
@ -82,4 +77,8 @@ public abstract class UserAction extends InputAbstract {
|
||||||
public void setUsername(String username) {
|
public void setUsername(String username) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRole(String role) {
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -28,11 +28,7 @@ import org.apache.activemq.artemis.utils.FactoryFinder;
|
||||||
|
|
||||||
public class BrokerFactory {
|
public class BrokerFactory {
|
||||||
|
|
||||||
public static BrokerDTO createBrokerConfiguration(URI configURI) throws Exception {
|
private static BrokerDTO createBrokerConfiguration(URI configURI,
|
||||||
return createBrokerConfiguration(configURI, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BrokerDTO createBrokerConfiguration(URI configURI,
|
|
||||||
String artemisHome,
|
String artemisHome,
|
||||||
String artemisInstance,
|
String artemisInstance,
|
||||||
URI artemisURIInstance) throws Exception {
|
URI artemisURIInstance) throws Exception {
|
||||||
|
@ -47,14 +43,9 @@ public class BrokerFactory {
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new ConfigurationException("Invalid configuration URI, can't find configuration scheme: " + configURI.getScheme());
|
throw new ConfigurationException("Invalid configuration URI, can't find configuration scheme: " + configURI.getScheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
return factory.createBroker(configURI, artemisHome, artemisInstance, artemisURIInstance);
|
return factory.createBroker(configURI, artemisHome, artemisInstance, artemisURIInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BrokerDTO createBrokerConfiguration(String configuration) throws Exception {
|
|
||||||
return createBrokerConfiguration(new URI(configuration), null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BrokerDTO createBrokerConfiguration(String configuration,
|
public static BrokerDTO createBrokerConfiguration(String configuration,
|
||||||
String artemisHome,
|
String artemisHome,
|
||||||
String artemisInstance,
|
String artemisInstance,
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
@ -22,7 +22,5 @@ import org.apache.activemq.artemis.dto.BrokerDTO;
|
||||||
|
|
||||||
public interface BrokerFactoryHandler {
|
public interface BrokerFactoryHandler {
|
||||||
|
|
||||||
BrokerDTO createBroker(URI brokerURI) throws Exception;
|
|
||||||
|
|
||||||
BrokerDTO createBroker(URI brokerURI, String artemisHome, String artemisInstance, URI artemisURIInstance) throws Exception;
|
BrokerDTO createBroker(URI brokerURI, String artemisHome, String artemisInstance, URI artemisURIInstance) throws Exception;
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.dto.ServerDTO;
|
import org.apache.activemq.artemis.dto.ServerDTO;
|
||||||
import org.apache.activemq.artemis.integration.Broker;
|
import org.apache.activemq.artemis.integration.Broker;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.dto.ServerDTO;
|
import org.apache.activemq.artemis.dto.ServerDTO;
|
||||||
import org.apache.activemq.artemis.integration.Broker;
|
import org.apache.activemq.artemis.integration.Broker;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory.security;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.dto.JaasSecurityDTO;
|
import org.apache.activemq.artemis.dto.JaasSecurityDTO;
|
||||||
import org.apache.activemq.artemis.dto.SecurityDTO;
|
import org.apache.activemq.artemis.dto.SecurityDTO;
|
||||||
|
@ -26,7 +26,6 @@ public class JaasSecurityHandler implements SecurityHandler {
|
||||||
@Override
|
@Override
|
||||||
public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) throws Exception {
|
public ActiveMQSecurityManager createSecurityManager(SecurityDTO security) throws Exception {
|
||||||
JaasSecurityDTO jaasSecurity = (JaasSecurityDTO) security;
|
JaasSecurityDTO jaasSecurity = (JaasSecurityDTO) security;
|
||||||
ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager(jaasSecurity.domain, jaasSecurity.certificateDomain);
|
return new ActiveMQJAASSecurityManager(jaasSecurity.domain, jaasSecurity.certificateDomain);
|
||||||
return securityManager;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory.security;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.dto.SecurityDTO;
|
import org.apache.activemq.artemis.dto.SecurityDTO;
|
||||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory.security;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@ -25,13 +25,11 @@ import org.apache.activemq.artemis.utils.FactoryFinder;
|
||||||
public class SecurityManagerFactory {
|
public class SecurityManagerFactory {
|
||||||
|
|
||||||
public static ActiveMQSecurityManager create(SecurityDTO config) throws Exception {
|
public static ActiveMQSecurityManager create(SecurityDTO config) throws Exception {
|
||||||
if (config != null) {
|
if (config == null) {
|
||||||
|
throw new Exception("No security manager configured!");
|
||||||
|
}
|
||||||
FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/security/");
|
FactoryFinder finder = new FactoryFinder("META-INF/services/org/apache/activemq/artemis/broker/security/");
|
||||||
SecurityHandler securityHandler = (SecurityHandler) finder.newInstance(config.getClass().getAnnotation(XmlRootElement.class).name());
|
SecurityHandler securityHandler = (SecurityHandler) finder.newInstance(config.getClass().getAnnotation(XmlRootElement.class).name());
|
||||||
return securityHandler.createSecurityManager(config);
|
return securityHandler.createSecurityManager(config);
|
||||||
} else {
|
|
||||||
throw new Exception("No security manager configured!");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,22 +14,18 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.cli.factory.xml;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.cli.ConfigurationException;
|
import org.apache.activemq.artemis.cli.ConfigurationException;
|
||||||
|
import org.apache.activemq.artemis.cli.factory.BrokerFactoryHandler;
|
||||||
import org.apache.activemq.artemis.dto.BrokerDTO;
|
import org.apache.activemq.artemis.dto.BrokerDTO;
|
||||||
import org.apache.activemq.artemis.dto.XmlUtil;
|
import org.apache.activemq.artemis.dto.XmlUtil;
|
||||||
|
|
||||||
public class XmlBrokerFactoryHandler implements BrokerFactoryHandler {
|
public class XmlBrokerFactoryHandler implements BrokerFactoryHandler {
|
||||||
|
|
||||||
@Override
|
|
||||||
public BrokerDTO createBroker(URI brokerURI) throws Exception {
|
|
||||||
return createBroker(brokerURI, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BrokerDTO createBroker(URI brokerURI, String artemisHome, String artemisInstance, URI artemisURIInstance) throws Exception {
|
public BrokerDTO createBroker(URI brokerURI, String artemisHome, String artemisInstance, URI artemisURIInstance) throws Exception {
|
||||||
File file = new File(brokerURI.getSchemeSpecificPart());
|
File file = new File(brokerURI.getSchemeSpecificPart());
|
|
@ -21,13 +21,13 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||||
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
||||||
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
|
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
|
||||||
import org.apache.activemq.artemis.core.server.ServiceComponent;
|
import org.apache.activemq.artemis.core.server.ServiceComponent;
|
||||||
import org.apache.activemq.artemis.dto.ServerDTO;
|
import org.apache.activemq.artemis.dto.ServerDTO;
|
||||||
import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
|
import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger;
|
||||||
|
@ -161,7 +161,7 @@ public class FileBroker implements Broker {
|
||||||
* this makes sure the components are started in the correct order. Its simple at the mo as e only have core and jms but
|
* this makes sure the components are started in the correct order. Its simple at the mo as e only have core and jms but
|
||||||
* will need impproving if we get more.
|
* will need impproving if we get more.
|
||||||
* */
|
* */
|
||||||
public ArrayList<ActiveMQComponent> getComponentsByStartOrder(Map<String, ActiveMQComponent> components) {
|
private ArrayList<ActiveMQComponent> getComponentsByStartOrder(Map<String, ActiveMQComponent> components) {
|
||||||
ArrayList<ActiveMQComponent> activeMQComponents = new ArrayList<>();
|
ArrayList<ActiveMQComponent> activeMQComponents = new ArrayList<>();
|
||||||
ActiveMQComponent jmsComponent = components.get("jms");
|
ActiveMQComponent jmsComponent = components.get("jms");
|
||||||
if (jmsComponent != null) {
|
if (jmsComponent != null) {
|
||||||
|
|
|
@ -40,7 +40,6 @@ public class ServerUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param artemisInstance
|
* @param artemisInstance
|
||||||
* @param serverName it will be used on logs
|
* @param serverName it will be used on logs
|
||||||
* @param id it will be used to add on the port
|
* @param id it will be used to add on the port
|
||||||
|
@ -94,7 +93,8 @@ public class ServerUtil {
|
||||||
try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) {
|
try (ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactory(uri, null)) {
|
||||||
cf.createConnection().close();
|
cf.createConnection().close();
|
||||||
System.out.println("server " + uri + " started");
|
System.out.println("server " + uri + " started");
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e) {
|
||||||
System.out.println("awaiting server " + uri + " start at ");
|
System.out.println("awaiting server " + uri + " start at ");
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -14,4 +14,4 @@
|
||||||
## See the License for the specific language governing permissions and
|
## See the License for the specific language governing permissions and
|
||||||
## limitations under the License.
|
## limitations under the License.
|
||||||
## ---------------------------------------------------------------------------
|
## ---------------------------------------------------------------------------
|
||||||
class=org.apache.activemq.artemis.factory.JaasSecurityHandler
|
class=org.apache.activemq.artemis.cli.factory.security.JaasSecurityHandler
|
||||||
|
|
|
@ -14,4 +14,4 @@
|
||||||
## See the License for the specific language governing permissions and
|
## See the License for the specific language governing permissions and
|
||||||
## limitations under the License.
|
## limitations under the License.
|
||||||
## ---------------------------------------------------------------------------
|
## ---------------------------------------------------------------------------
|
||||||
class=org.apache.activemq.artemis.factory.FileBrokerHandler
|
class=org.apache.activemq.artemis.cli.factory.FileBrokerHandler
|
||||||
|
|
|
@ -14,4 +14,4 @@
|
||||||
## See the License for the specific language governing permissions and
|
## See the License for the specific language governing permissions and
|
||||||
## limitations under the License.
|
## limitations under the License.
|
||||||
## ---------------------------------------------------------------------------
|
## ---------------------------------------------------------------------------
|
||||||
class=org.apache.activemq.artemis.factory.XmlBrokerFactoryHandler
|
class=org.apache.activemq.artemis.cli.factory.xml.XmlBrokerFactoryHandler
|
||||||
|
|
|
@ -24,8 +24,8 @@ 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.ClientSession;
|
||||||
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
||||||
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal;
|
import org.apache.activemq.artemis.cli.commands.tools.journal.DecodeJournal;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal;
|
import org.apache.activemq.artemis.cli.commands.tools.journal.EncodeJournal;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.api.core.Message;
|
import org.apache.activemq.artemis.api.core.Message;
|
||||||
|
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
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.ActiveMQClient;
|
||||||
|
@ -42,14 +43,13 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
|
||||||
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
||||||
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
||||||
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;
|
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
|
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataImporter;
|
||||||
import org.apache.activemq.artemis.core.persistence.impl.journal.BatchingIDGenerator;
|
import org.apache.activemq.artemis.core.persistence.impl.journal.BatchingIDGenerator;
|
||||||
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
|
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
|
||||||
import org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl;
|
import org.apache.activemq.artemis.core.persistence.impl.journal.LargeServerMessageImpl;
|
||||||
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
|
||||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||||
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
import org.apache.activemq.artemis.jms.server.JMSServerManager;
|
||||||
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
import org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl;
|
||||||
|
|
|
@ -27,8 +27,8 @@ 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.ClientSession;
|
||||||
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
|
||||||
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;
|
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
|
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataImporter;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -27,8 +27,8 @@ import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.DecodeJournal;
|
import org.apache.activemq.artemis.cli.commands.tools.journal.DecodeJournal;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal;
|
import org.apache.activemq.artemis.cli.commands.tools.journal.EncodeJournal;
|
||||||
import org.apache.activemq.artemis.core.io.SequentialFileFactory;
|
import org.apache.activemq.artemis.core.io.SequentialFileFactory;
|
||||||
import org.apache.activemq.artemis.core.journal.EncodingSupport;
|
import org.apache.activemq.artemis.core.journal.EncodingSupport;
|
||||||
import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
|
import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
|
||||||
|
|
Loading…
Reference in New Issue