ARTEMIS-145 moving compact command under tools
https://issues.apache.org/jira/browse/ARTEMIS-145
This commit is contained in:
parent
6a59443d2d
commit
33b81c91a6
|
@ -31,6 +31,7 @@ import org.apache.activemq.artemis.cli.commands.Kill;
|
||||||
import org.apache.activemq.artemis.cli.commands.Producer;
|
import org.apache.activemq.artemis.cli.commands.Producer;
|
||||||
import org.apache.activemq.artemis.cli.commands.Run;
|
import org.apache.activemq.artemis.cli.commands.Run;
|
||||||
import org.apache.activemq.artemis.cli.commands.Stop;
|
import org.apache.activemq.artemis.cli.commands.Stop;
|
||||||
|
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.DecodeJournal;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.EncodeJournal;
|
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;
|
||||||
|
@ -101,9 +102,10 @@ public class Artemis
|
||||||
|
|
||||||
|
|
||||||
builder.withGroup("data")
|
builder.withGroup("data")
|
||||||
.withDescription("data tools group (print|exp|imp|exp|encode|decode) (example ./artemis data print)").
|
.withDescription("data tools group (print|exp|imp|exp|encode|decode|compact) (example ./artemis data print)").
|
||||||
withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class,
|
withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class,
|
||||||
XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class);
|
XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class,
|
||||||
|
CompactJournal.class);
|
||||||
|
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,42 +14,40 @@
|
||||||
* 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.core.journal.impl;
|
package org.apache.activemq.artemis.cli.commands.tools;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import io.airlift.airline.Command;
|
||||||
|
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.journal.IOCriticalErrorListener;
|
import org.apache.activemq.artemis.core.journal.IOCriticalErrorListener;
|
||||||
|
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
|
||||||
|
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||||
|
|
||||||
/**
|
@Command(name = "compact", description = "Compacts the journal of a non running server")
|
||||||
* This is an undocumented class, that will open a journal and force compacting on it.
|
public final class CompactJournal extends DataAbstract implements Action
|
||||||
* <p>
|
|
||||||
* It may be used under special cases, but it shouldn't be needed under regular circumstances as the
|
|
||||||
* system should detect the need for compacting. The regular use is to configure min-compact
|
|
||||||
* parameters.
|
|
||||||
*/
|
|
||||||
public final class CompactJournal // NO_UCD
|
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public static void main(final String[] arg)
|
public Object execute(ActionContext context) throws Exception
|
||||||
{
|
{
|
||||||
if (arg.length != 4)
|
super.execute(context);
|
||||||
{
|
|
||||||
System.err.println("Use: java -cp activemq-core.jar org.apache.activemq.artemis.core.journal.impl.CompactJournal <JournalDirectory> <JournalPrefix> <FileExtension> <FileSize>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CompactJournal.compactJournal(new File(arg[0]), arg[1], arg[2], 2, Integer.parseInt(arg[3]), null);
|
Configuration configuration = getFileConfiguration();
|
||||||
|
compactJournal(new File(getJournal()), "activemq-data", "amq", configuration.getJournalMinFiles(), configuration.getJournalFileSize(), null);
|
||||||
|
compactJournal(new File(getBinding()), "activemq-bindings", "bindings", 2, 1048576, null);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
treatError(e, "data", "compact");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void compactJournal(final File directory,
|
void compactJournal(final File directory,
|
||||||
final String journalPrefix,
|
final String journalPrefix,
|
||||||
final String journalSuffix,
|
final String journalSuffix,
|
||||||
final int minFiles,
|
final int minFiles,
|
|
@ -1459,7 +1459,7 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal
|
||||||
* Note: only synchronized methods on journal are methods responsible for the life-cycle such as
|
* Note: only synchronized methods on journal are methods responsible for the life-cycle such as
|
||||||
* stop, start records will still come as this is being executed
|
* stop, start records will still come as this is being executed
|
||||||
*/
|
*/
|
||||||
protected synchronized void compact() throws Exception
|
public synchronized void compact() throws Exception
|
||||||
{
|
{
|
||||||
if (compactor != null)
|
if (compactor != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue