Improving tools to use configuration
PrintData / Export and other tools are now reading default configuration from broker.xml I also did some refactoring so Stop and Run will share some of the basic functions
This commit is contained in:
parent
7965cb71cd
commit
cff9f5b785
|
@ -0,0 +1,134 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import io.airlift.airline.Arguments;
|
||||||
|
import io.airlift.airline.Option;
|
||||||
|
import org.apache.activemq.artemis.core.config.FileDeploymentManager;
|
||||||
|
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||||
|
import org.apache.activemq.artemis.dto.BrokerDTO;
|
||||||
|
import org.apache.activemq.artemis.factory.BrokerFactory;
|
||||||
|
import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract class where we can replace the configuration in various places *
|
||||||
|
*/
|
||||||
|
public abstract class Configurable
|
||||||
|
{
|
||||||
|
@Arguments(description = "Broker Configuration URI, default 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'")
|
||||||
|
String configuration;
|
||||||
|
|
||||||
|
@Option(name = "--broker", description = "This would override the broker configuration from the bootstrap")
|
||||||
|
String brokerConfig;
|
||||||
|
|
||||||
|
private BrokerDTO brokerDTO = null;
|
||||||
|
|
||||||
|
private String brokerInstance;
|
||||||
|
|
||||||
|
private FileConfiguration fileConfiguration;
|
||||||
|
|
||||||
|
protected String getBrokerInstance()
|
||||||
|
{
|
||||||
|
if (brokerInstance == null)
|
||||||
|
{
|
||||||
|
/* We use File URI for locating files. The ARTEMIS_HOME variable is used to determine file paths. For Windows
|
||||||
|
the ARTEMIS_HOME variable will include back slashes (An invalid file URI character path separator). For this
|
||||||
|
reason we overwrite the ARTEMIS_HOME variable with backslashes replaced with forward slashes. */
|
||||||
|
brokerInstance = System.getProperty("artemis.instance");
|
||||||
|
if (brokerInstance != null)
|
||||||
|
{
|
||||||
|
brokerInstance = brokerInstance.replace("\\", "/");
|
||||||
|
System.setProperty("artemis.instance", brokerInstance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return brokerInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected FileConfiguration getFileConfiguration() throws Exception
|
||||||
|
{
|
||||||
|
if (fileConfiguration == null)
|
||||||
|
{
|
||||||
|
if (getBrokerInstance() == null)
|
||||||
|
{
|
||||||
|
fileConfiguration = new FileConfiguration();
|
||||||
|
// These will be the default places in case the file can't be loaded
|
||||||
|
fileConfiguration.setBindingsDirectory("../data/bindings");
|
||||||
|
fileConfiguration.setJournalDirectory("../data/journal");
|
||||||
|
fileConfiguration.setLargeMessagesDirectory("../data/largemessages");
|
||||||
|
fileConfiguration.setPagingDirectory("../data/paging");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fileConfiguration = new FileConfiguration();
|
||||||
|
FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration();
|
||||||
|
|
||||||
|
String serverConfiguration = getBrokerDTO().server.configuration;
|
||||||
|
FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(serverConfiguration);
|
||||||
|
fileDeploymentManager.addDeployable(fileConfiguration).addDeployable(jmsConfiguration);
|
||||||
|
fileDeploymentManager.readConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected BrokerDTO getBrokerDTO() throws Exception
|
||||||
|
{
|
||||||
|
if (brokerDTO == null)
|
||||||
|
{
|
||||||
|
getConfiguration();
|
||||||
|
|
||||||
|
|
||||||
|
brokerDTO = BrokerFactory.createBrokerConfiguration(configuration);
|
||||||
|
|
||||||
|
if (brokerConfig != null)
|
||||||
|
{
|
||||||
|
if (!brokerConfig.startsWith("file:"))
|
||||||
|
{
|
||||||
|
brokerConfig = "file:" + brokerConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
brokerDTO.server.configuration = brokerConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return brokerDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getConfiguration()
|
||||||
|
{
|
||||||
|
if (configuration == null)
|
||||||
|
{
|
||||||
|
File xmlFile = new File(new File(new File(getBrokerInstance()), "etc"), "bootstrap.xml");
|
||||||
|
configuration = "xml:" + xmlFile.toURI().toString().substring("file:".length());
|
||||||
|
|
||||||
|
// To support Windows paths as explained above.
|
||||||
|
configuration = configuration.replace("\\", "/");
|
||||||
|
|
||||||
|
System.out.println("Loading configuration file: " + configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -16,9 +16,12 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands;
|
package org.apache.activemq.artemis.cli.commands;
|
||||||
|
|
||||||
import io.airlift.airline.Arguments;
|
import java.io.File;
|
||||||
import io.airlift.airline.Command;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import io.airlift.airline.Command;
|
||||||
import org.apache.activemq.artemis.cli.Artemis;
|
import org.apache.activemq.artemis.cli.Artemis;
|
||||||
import org.apache.activemq.artemis.components.ExternalComponent;
|
import org.apache.activemq.artemis.components.ExternalComponent;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
|
import org.apache.activemq.artemis.core.server.ActiveMQComponent;
|
||||||
|
@ -30,31 +33,13 @@ 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;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
@Command(name = "run", description = "runs the broker instance")
|
@Command(name = "run", description = "runs the broker instance")
|
||||||
public class Run implements Action
|
public class Run extends Configurable implements Action
|
||||||
{
|
{
|
||||||
|
|
||||||
@Arguments(description = "Broker Configuration URI, default 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'")
|
|
||||||
String configuration;
|
|
||||||
private ArrayList<ActiveMQComponent> components = new ArrayList<>();
|
|
||||||
|
|
||||||
private Broker server;
|
private Broker server;
|
||||||
|
|
||||||
static String fixupFileURI(String value)
|
private ArrayList<ActiveMQComponent> components = new ArrayList<>();
|
||||||
{
|
|
||||||
if (value != null && value.startsWith("file:"))
|
|
||||||
{
|
|
||||||
value = value.substring("file:".length());
|
|
||||||
value = new File(value).toURI().toString();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ActionContext context) throws Exception
|
public Object execute(ActionContext context) throws Exception
|
||||||
|
@ -62,26 +47,9 @@ public class Run implements Action
|
||||||
|
|
||||||
Artemis.printBanner();
|
Artemis.printBanner();
|
||||||
|
|
||||||
/* We use File URI for locating files. The ARTEMIS_HOME variable is used to determine file paths. For Windows
|
BrokerDTO broker = getBrokerDTO();
|
||||||
the ARTEMIS_HOME variable will include back slashes (An invalid file URI character path separator). For this
|
|
||||||
reason we overwrite the ARTEMIS_HOME variable with backslashes replaced with forward slashes. */
|
|
||||||
String activemqInstance = System.getProperty("artemis.instance").replace("\\", "/");
|
|
||||||
System.setProperty("artemis.instance", activemqInstance);
|
|
||||||
|
|
||||||
if (configuration == null)
|
addShutdownHook(broker.server.getConfigurationFile().getParentFile());
|
||||||
{
|
|
||||||
File xmlFile = new File(new File(new File(activemqInstance), "etc"), "bootstrap.xml");
|
|
||||||
configuration = "xml:" + xmlFile.toURI().toString().substring("file:".length());
|
|
||||||
}
|
|
||||||
|
|
||||||
// To support Windows paths as explained above.
|
|
||||||
System.out.println("Loading configuration file: " + configuration);
|
|
||||||
|
|
||||||
BrokerDTO broker = BrokerFactory.createBrokerConfiguration(configuration);
|
|
||||||
|
|
||||||
String fileName = new URI(fixupFileURI(broker.server.configuration)).getSchemeSpecificPart();
|
|
||||||
|
|
||||||
addShutdownHook(new File(fileName).getParentFile());
|
|
||||||
|
|
||||||
ActiveMQSecurityManager security = SecurityManagerFactory.create(broker.security);
|
ActiveMQSecurityManager security = SecurityManagerFactory.create(broker.security);
|
||||||
|
|
||||||
|
@ -98,7 +66,7 @@ public class Run implements Action
|
||||||
{
|
{
|
||||||
Class clazz = this.getClass().getClassLoader().loadClass(componentDTO.componentClassName);
|
Class clazz = this.getClass().getClassLoader().loadClass(componentDTO.componentClassName);
|
||||||
ExternalComponent component = (ExternalComponent)clazz.newInstance();
|
ExternalComponent component = (ExternalComponent)clazz.newInstance();
|
||||||
component.configure(componentDTO, activemqInstance);
|
component.configure(componentDTO, getBrokerInstance());
|
||||||
component.start();
|
component.start();
|
||||||
components.add(component);
|
components.add(component);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,42 +16,21 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.cli.commands;
|
package org.apache.activemq.artemis.cli.commands;
|
||||||
|
|
||||||
import io.airlift.airline.Arguments;
|
import java.io.File;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import org.apache.activemq.artemis.dto.BrokerDTO;
|
import org.apache.activemq.artemis.dto.BrokerDTO;
|
||||||
import org.apache.activemq.artemis.factory.BrokerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
@Command(name = "stop", description = "stops the broker instance")
|
@Command(name = "stop", description = "stops the broker instance")
|
||||||
public class Stop implements Action
|
public class Stop extends Configurable implements Action
|
||||||
{
|
{
|
||||||
@Arguments(description = "Broker Configuration URI, default 'xml:${ARTEMIS_INSTANCE}/etc/bootstrap.xml'")
|
|
||||||
String configuration;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ActionContext context) throws Exception
|
public Object execute(ActionContext context) throws Exception
|
||||||
|
|
||||||
{
|
{
|
||||||
/* We use File URI for locating files. The ARTEMIS_HOME variable is used to determine file paths. For Windows
|
BrokerDTO broker = getBrokerDTO();
|
||||||
the ARTEMIS_HOME variable will include back slashes (An invalid file URI character path separator). For this
|
|
||||||
reason we overwrite the ARTEMIS_HOME variable with backslashes replaced with forward slashes. */
|
|
||||||
String activemqHome = System.getProperty("artemis.instance").replace("\\", "/");
|
|
||||||
System.setProperty("artemis.instance", activemqHome);
|
|
||||||
|
|
||||||
if (configuration == null)
|
File file = broker.server.getConfigurationFile().getParentFile();
|
||||||
{
|
|
||||||
configuration = "xml:" + activemqHome + "/etc/bootstrap.xml";
|
|
||||||
}
|
|
||||||
|
|
||||||
// To support Windows paths as explained above.
|
|
||||||
configuration = configuration.replace("\\", "/");
|
|
||||||
|
|
||||||
BrokerDTO broker = BrokerFactory.createBrokerConfiguration(configuration);
|
|
||||||
|
|
||||||
String fileName = new URI(broker.server.configuration).getSchemeSpecificPart();
|
|
||||||
|
|
||||||
File file = new File(fileName).getParentFile();
|
|
||||||
|
|
||||||
File stopFile = new File(file, "STOP_ME");
|
File stopFile = new File(file, "STOP_ME");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import io.airlift.airline.Option;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.Configurable;
|
||||||
|
|
||||||
|
/** Abstract class for places where you need bindings, journal paging and large messages configuration */
|
||||||
|
public abstract class DataAbstract extends Configurable
|
||||||
|
{
|
||||||
|
@Option(name = "--bindings", description = "The folder used for bindings (default from broker.xml)")
|
||||||
|
public String binding;
|
||||||
|
|
||||||
|
@Option(name = "--journal", description = "The folder used for messages journal (default from broker.xml)")
|
||||||
|
public String journal;
|
||||||
|
|
||||||
|
@Option(name = "--paging", description = "The folder used for paging (default from broker.xml)")
|
||||||
|
public String paging;
|
||||||
|
|
||||||
|
@Option(name = "--large-messages", description = "The folder used for large-messages (default from broker.xml)")
|
||||||
|
public String largeMessges;
|
||||||
|
|
||||||
|
|
||||||
|
public String getLargeMessages() throws Exception
|
||||||
|
{
|
||||||
|
if (largeMessges == null)
|
||||||
|
{
|
||||||
|
largeMessges = getFileConfiguration().getLargeMessagesDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return largeMessges;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getBinding() throws Exception
|
||||||
|
{
|
||||||
|
if (binding == null)
|
||||||
|
{
|
||||||
|
binding = getFileConfiguration().getBindingsDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJournal() throws Exception
|
||||||
|
{
|
||||||
|
if (journal == null)
|
||||||
|
{
|
||||||
|
journal = getFileConfiguration().getJournalDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return journal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPaging() throws Exception
|
||||||
|
{
|
||||||
|
if (paging == null)
|
||||||
|
{
|
||||||
|
paging = getFileConfiguration().getPagingDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
|
return paging;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,11 +27,11 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import io.airlift.airline.Arguments;
|
|
||||||
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.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.Configurable;
|
||||||
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;
|
||||||
import org.apache.activemq.artemis.core.journal.impl.JournalRecord;
|
import org.apache.activemq.artemis.core.journal.impl.JournalRecord;
|
||||||
|
@ -39,13 +39,13 @@ import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||||
import org.apache.activemq.artemis.utils.Base64;
|
import org.apache.activemq.artemis.utils.Base64;
|
||||||
|
|
||||||
@Command(name = "decode", description = "Decode a journal's internal format into a new journal set of files")
|
@Command(name = "decode", description = "Decode a journal's internal format into a new journal set of files")
|
||||||
public class DecodeJournal implements Action
|
public class DecodeJournal extends Configurable implements Action
|
||||||
{
|
{
|
||||||
|
|
||||||
@Option(name = "--directory", description = "The journal folder (default ../data/journal)")
|
@Option(name = "--directory", description = "The journal folder (default journal folder from broker.xml)")
|
||||||
public String directory = "../data/journal";
|
public String directory;
|
||||||
|
|
||||||
@Option(name = "--prefix", description = "The journal prefix (default activemq-datal)")
|
@Option(name = "--prefix", description = "The journal prefix (default activemq-data)")
|
||||||
public String prefix = "activemq-data";
|
public String prefix = "activemq-data";
|
||||||
|
|
||||||
@Option(name = "--suffix", description = "The journal suffix (default amq)")
|
@Option(name = "--suffix", description = "The journal suffix (default amq)")
|
||||||
|
@ -54,13 +54,17 @@ public class DecodeJournal implements Action
|
||||||
@Option(name = "--file-size", description = "The journal size (default 10485760)")
|
@Option(name = "--file-size", description = "The journal size (default 10485760)")
|
||||||
public int size = 10485760;
|
public int size = 10485760;
|
||||||
|
|
||||||
@Arguments(description = "The input file name (default=exp.dmp)", required = true)
|
@Option(name = "--input", description = "The input file name (default=exp.dmp)", required = true)
|
||||||
public String input;
|
public String input = "exp.dmp";
|
||||||
|
|
||||||
public Object execute(ActionContext context) throws Exception
|
public Object execute(ActionContext context) throws Exception
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (directory == null)
|
||||||
|
{
|
||||||
|
directory = getFileConfiguration().getJournalDirectory();
|
||||||
|
}
|
||||||
importJournal(directory, prefix, suffix, 2, size, input);
|
importJournal(directory, prefix, suffix, 2, size, input);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
import io.airlift.airline.Option;
|
||||||
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.Configurable;
|
||||||
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||||
import org.apache.activemq.artemis.core.journal.impl.JournalFile;
|
import org.apache.activemq.artemis.core.journal.impl.JournalFile;
|
||||||
|
@ -34,13 +35,13 @@ import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||||
import org.apache.activemq.artemis.utils.Base64;
|
import org.apache.activemq.artemis.utils.Base64;
|
||||||
|
|
||||||
@Command(name = "encode", description = "Encode a set of journal files into an internal encoded data format")
|
@Command(name = "encode", description = "Encode a set of journal files into an internal encoded data format")
|
||||||
public class EncodeJournal implements Action
|
public class EncodeJournal extends Configurable implements Action
|
||||||
{
|
{
|
||||||
|
|
||||||
@Option(name = "--directory", description = "The journal folder (default ../data/journal)")
|
@Option(name = "--directory", description = "The journal folder (default the journal folder from broker.xml)")
|
||||||
public String directory = "../data/journal";
|
public String directory;
|
||||||
|
|
||||||
@Option(name = "--prefix", description = "The journal prefix (default activemq-datal)")
|
@Option(name = "--prefix", description = "The journal prefix (default activemq-data)")
|
||||||
public String prefix = "activemq-data";
|
public String prefix = "activemq-data";
|
||||||
|
|
||||||
@Option(name = "--suffix", description = "The journal suffix (default amq)")
|
@Option(name = "--suffix", description = "The journal suffix (default amq)")
|
||||||
|
@ -54,6 +55,11 @@ public class EncodeJournal implements Action
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (directory == null)
|
||||||
|
{
|
||||||
|
directory = getFileConfiguration().getJournalDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
exportJournal(directory, prefix, suffix, 2, size);
|
exportJournal(directory, prefix, suffix, 2, size);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -28,10 +28,10 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
|
||||||
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.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.core.journal.RecordInfo;
|
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||||
|
@ -57,27 +57,22 @@ import org.apache.activemq.artemis.core.settings.impl.HierarchicalObjectReposito
|
||||||
import org.apache.activemq.artemis.utils.ExecutorFactory;
|
import org.apache.activemq.artemis.utils.ExecutorFactory;
|
||||||
|
|
||||||
@Command(name = "print", description = "Print data records information (WARNING: don't use while a production server is running)")
|
@Command(name = "print", description = "Print data records information (WARNING: don't use while a production server is running)")
|
||||||
public class PrintData implements Action
|
public class PrintData extends DataAbstract implements Action
|
||||||
{
|
{
|
||||||
@Option(name = "--bindings", description = "The folder used for bindings (default ../data/bindings)")
|
|
||||||
public String binding = "../data/bindings";
|
|
||||||
|
|
||||||
@Option(name = "--journal", description = "The folder used for messages journal (default ../data/journal)")
|
|
||||||
public String journal = "../data/journal";
|
|
||||||
|
|
||||||
@Option(name = "--paging", description = "The folder used for paging (default ../data/paging)")
|
|
||||||
public String paging = "../data/paging";
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ActionContext context) throws Exception
|
public Object execute(ActionContext context) throws Exception
|
||||||
{
|
{
|
||||||
printData(binding, journal, paging);
|
printData(getBinding(), getJournal(), getPaging());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printData(String bindingsDirectory, String messagesDirectory, String pagingDirectory)
|
public static void printData(String bindingsDirectory, String messagesDirectory, String pagingDirectory) throws Exception
|
||||||
{
|
{
|
||||||
|
// Having the version on the data report is an information very useful to understand what happened
|
||||||
|
// When debugging stuff
|
||||||
|
Artemis.printBanner();
|
||||||
|
|
||||||
File serverLockFile = new File(messagesDirectory, "server.lock");
|
File serverLockFile = new File(messagesDirectory, "server.lock");
|
||||||
|
|
||||||
if (serverLockFile.isFile())
|
if (serverLockFile.isFile())
|
||||||
|
|
|
@ -37,9 +37,6 @@ import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import io.airlift.airline.Command;
|
import io.airlift.airline.Command;
|
||||||
import io.airlift.airline.Option;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.Action;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
|
||||||
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.ActiveMQException;
|
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||||
|
@ -47,6 +44,8 @@ import org.apache.activemq.artemis.api.core.Message;
|
||||||
import org.apache.activemq.artemis.api.core.Pair;
|
import org.apache.activemq.artemis.api.core.Pair;
|
||||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.Action;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
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;
|
||||||
|
@ -92,7 +91,7 @@ import org.apache.activemq.artemis.utils.Base64;
|
||||||
import org.apache.activemq.artemis.utils.ExecutorFactory;
|
import org.apache.activemq.artemis.utils.ExecutorFactory;
|
||||||
|
|
||||||
@Command(name = "exp", description = "Export all message-data using an XML that could be interpreted by any system.")
|
@Command(name = "exp", description = "Export all message-data using an XML that could be interpreted by any system.")
|
||||||
public final class XmlDataExporter implements Action
|
public final class XmlDataExporter extends DataAbstract implements Action
|
||||||
{
|
{
|
||||||
private static final Long LARGE_MESSAGE_CHUNK_SIZE = 1000L;
|
private static final Long LARGE_MESSAGE_CHUNK_SIZE = 1000L;
|
||||||
|
|
||||||
|
@ -120,18 +119,6 @@ public final class XmlDataExporter implements Action
|
||||||
|
|
||||||
private final Map<Pair<PersistedType, String>, PersistedBindings> jmsJNDI = new ConcurrentHashMap<>();
|
private final Map<Pair<PersistedType, String>, PersistedBindings> jmsJNDI = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Option(name = "--bindings", description = "The folder used for bindings (default ../data/bindings)")
|
|
||||||
public String binding = "../data/bindings";
|
|
||||||
|
|
||||||
@Option(name = "--journal", description = "The folder used for messages journal (default ../data/journal)")
|
|
||||||
public String journal = "../data/journal";
|
|
||||||
|
|
||||||
@Option(name = "--paging", description = "The folder used for paging (default ../data/paging)")
|
|
||||||
public String paging = "../data/paging";
|
|
||||||
|
|
||||||
@Option(name = "--large-messages", description = "The folder used for large-messages (default ../data/largemessages)")
|
|
||||||
public String largeMessges = "../data/paging";
|
|
||||||
|
|
||||||
long messagesPrinted = 0L;
|
long messagesPrinted = 0L;
|
||||||
|
|
||||||
long bindingsPrinted = 0L;
|
long bindingsPrinted = 0L;
|
||||||
|
@ -139,7 +126,7 @@ public final class XmlDataExporter implements Action
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ActionContext context) throws Exception
|
public Object execute(ActionContext context) throws Exception
|
||||||
{
|
{
|
||||||
process(System.out, binding, journal, paging, largeMessges);
|
process(System.out, getBinding(), getJournal(), getPaging(), getLargeMessages());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,8 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import io.airlift.airline.Arguments;
|
|
||||||
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.Action;
|
|
||||||
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
|
||||||
import org.apache.activemq.artemis.api.core.Message;
|
import org.apache.activemq.artemis.api.core.Message;
|
||||||
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;
|
||||||
|
@ -51,6 +48,8 @@ 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.core.management.ManagementHelper;
|
import org.apache.activemq.artemis.api.core.management.ManagementHelper;
|
||||||
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
import org.apache.activemq.artemis.api.core.management.ResourceNames;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.Action;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
import org.apache.activemq.artemis.core.message.impl.MessageImpl;
|
import org.apache.activemq.artemis.core.message.impl.MessageImpl;
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
|
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
|
||||||
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
|
||||||
|
@ -100,10 +99,8 @@ public final class XmlDataImporter implements Action
|
||||||
@Option(name = "--password", description = "User name used to import the data. (default null)")
|
@Option(name = "--password", description = "User name used to import the data. (default null)")
|
||||||
public String password = null;
|
public String password = null;
|
||||||
|
|
||||||
@Arguments(description = "The input file name (default=exp.dmp)", required = true)
|
@Option(name = "--input", description = "The input file name (default=exp.dmp)", required = true)
|
||||||
public String input;
|
public String input = "exp.dmp";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.artemis.factory;
|
package org.apache.activemq.artemis.factory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import org.apache.activemq.artemis.cli.ConfigurationException;
|
import org.apache.activemq.artemis.cli.ConfigurationException;
|
||||||
import org.apache.activemq.artemis.dto.BrokerDTO;
|
import org.apache.activemq.artemis.dto.BrokerDTO;
|
||||||
import org.apache.activemq.artemis.dto.ServerDTO;
|
import org.apache.activemq.artemis.dto.ServerDTO;
|
||||||
|
@ -23,10 +27,6 @@ import org.apache.activemq.artemis.integration.Broker;
|
||||||
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
|
||||||
import org.apache.activemq.artemis.utils.FactoryFinder;
|
import org.apache.activemq.artemis.utils.FactoryFinder;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
public class BrokerFactory
|
public class BrokerFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class BrokerFactory
|
||||||
if (brokerDTO.configuration != null)
|
if (brokerDTO.configuration != null)
|
||||||
{
|
{
|
||||||
BrokerHandler handler;
|
BrokerHandler handler;
|
||||||
URI configURI = new URI(fixupFileURI(brokerDTO.configuration));
|
URI configURI = brokerDTO.getConfigurationURI();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,6 @@ public class BrokerDTO
|
||||||
@XmlElementRef
|
@XmlElementRef
|
||||||
public ServerDTO server;
|
public ServerDTO server;
|
||||||
|
|
||||||
|
|
||||||
@XmlElementRef(required = false)
|
@XmlElementRef(required = false)
|
||||||
public WebServerDTO web;
|
public WebServerDTO web;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.io.File;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
@XmlRootElement(name = "server")
|
@XmlRootElement(name = "server")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
|
@ -29,4 +31,41 @@ public class ServerDTO
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
public String configuration;
|
public String configuration;
|
||||||
|
|
||||||
|
|
||||||
|
private File configurationFile;
|
||||||
|
|
||||||
|
private URI configurationURI;
|
||||||
|
|
||||||
|
|
||||||
|
public URI getConfigurationURI() throws Exception
|
||||||
|
{
|
||||||
|
if (configurationURI == null)
|
||||||
|
{
|
||||||
|
configurationURI = new URI(fixupFileURI(configuration));
|
||||||
|
}
|
||||||
|
|
||||||
|
return configurationURI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getConfigurationFile() throws Exception
|
||||||
|
{
|
||||||
|
if (configurationFile == null)
|
||||||
|
{
|
||||||
|
configurationFile = new File(new URI(fixupFileURI(configuration)).getSchemeSpecificPart());
|
||||||
|
}
|
||||||
|
return configurationFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String fixupFileURI(String value)
|
||||||
|
{
|
||||||
|
if (value != null && value.startsWith("file:"))
|
||||||
|
{
|
||||||
|
value = value.substring("file:".length());
|
||||||
|
value = new File(value).toURI().toString();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue