You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/06/26 19:58:18 UTC
[1/2] activemq-artemis git commit: ARTEMIS-145 moving compact command
under tools
Repository: activemq-artemis
Updated Branches:
refs/heads/master 6a59443d2 -> a94cfd541
ARTEMIS-145 moving compact command under tools
https://issues.apache.org/jira/browse/ARTEMIS-145
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/33b81c91
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/33b81c91
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/33b81c91
Branch: refs/heads/master
Commit: 33b81c91a6139f2cea0810183313a3bd68165c17
Parents: 6a59443
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Jun 26 13:16:09 2015 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Jun 26 13:18:15 2015 -0400
----------------------------------------------------------------------
.../apache/activemq/artemis/cli/Artemis.java | 6 +-
.../cli/commands/tools/CompactJournal.java | 69 +++++++++++++++++++
.../core/journal/impl/CompactJournal.java | 71 --------------------
.../artemis/core/journal/impl/JournalImpl.java | 2 +-
4 files changed, 74 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/33b81c91/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index 1f4710e..1b09ea4 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -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.Run;
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.EncodeJournal;
import org.apache.activemq.artemis.cli.commands.tools.HelpData;
@@ -101,9 +102,10 @@ public class Artemis
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,
- XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class);
+ XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class,
+ CompactJournal.class);
if (instance != null)
{
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/33b81c91/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java
new file mode 100644
index 0000000..0239998
--- /dev/null
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/tools/CompactJournal.java
@@ -0,0 +1,69 @@
+/*
+ * 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 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.impl.JournalImpl;
+import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
+
+@Command(name = "compact", description = "Compacts the journal of a non running server")
+public final class CompactJournal extends DataAbstract implements Action
+{
+ @Override
+ public Object execute(ActionContext context) throws Exception
+ {
+ super.execute(context);
+ try
+ {
+ 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)
+ {
+ treatError(e, "data", "compact");
+ }
+ return null;
+ }
+
+
+ void compactJournal(final File directory,
+ final String journalPrefix,
+ final String journalSuffix,
+ final int minFiles,
+ final int fileSize,
+ final IOCriticalErrorListener listener) throws Exception
+ {
+ NIOSequentialFileFactory nio = new NIOSequentialFileFactory(directory, listener);
+
+ JournalImpl journal = new JournalImpl(fileSize, minFiles, 0, 0, nio, journalPrefix, journalSuffix, 1);
+
+ journal.start();
+
+ journal.loadInternalOnly();
+
+ journal.compact();
+
+ journal.stop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/33b81c91/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/CompactJournal.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/CompactJournal.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/CompactJournal.java
deleted file mode 100644
index 6f5b75c..0000000
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/CompactJournal.java
+++ /dev/null
@@ -1,71 +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.core.journal.impl;
-
-import java.io.File;
-
-import org.apache.activemq.artemis.core.journal.IOCriticalErrorListener;
-
-/**
- * This is an undocumented class, that will open a journal and force compacting on it.
- * <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
-{
-
- public static void main(final String[] arg)
- {
- if (arg.length != 4)
- {
- System.err.println("Use: java -cp activemq-core.jar org.apache.activemq.artemis.core.journal.impl.CompactJournal <JournalDirectory> <JournalPrefix> <FileExtension> <FileSize>");
- return;
- }
-
- try
- {
- CompactJournal.compactJournal(new File(arg[0]), arg[1], arg[2], 2, Integer.parseInt(arg[3]), null);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- }
-
- static void compactJournal(final File directory,
- final String journalPrefix,
- final String journalSuffix,
- final int minFiles,
- final int fileSize,
- final IOCriticalErrorListener listener) throws Exception
- {
- NIOSequentialFileFactory nio = new NIOSequentialFileFactory(directory, listener);
-
- JournalImpl journal = new JournalImpl(fileSize, minFiles, 0, 0, nio, journalPrefix, journalSuffix, 1);
-
- journal.start();
-
- journal.loadInternalOnly();
-
- journal.compact();
-
- journal.stop();
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/33b81c91/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
index f394202..6f411eb 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
@@ -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
* 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)
{
[2/2] activemq-artemis git commit: This closes #53 compact
Posted by cl...@apache.org.
This closes #53 compact
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/a94cfd54
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/a94cfd54
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/a94cfd54
Branch: refs/heads/master
Commit: a94cfd541675a2815f6583c6af4f4cbd4f3e772f
Parents: 6a59443 33b81c9
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Jun 26 13:56:29 2015 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Jun 26 13:56:29 2015 -0400
----------------------------------------------------------------------
.../apache/activemq/artemis/cli/Artemis.java | 6 +-
.../cli/commands/tools/CompactJournal.java | 69 +++++++++++++++++++
.../core/journal/impl/CompactJournal.java | 71 --------------------
.../artemis/core/journal/impl/JournalImpl.java | 2 +-
4 files changed, 74 insertions(+), 74 deletions(-)
----------------------------------------------------------------------