ARTEMIS-935 Sync tool
This commit is contained in:
parent
2e5f458209
commit
cc3fd11df2
|
@ -50,6 +50,7 @@ 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;
|
||||||
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.SyncRecalc;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;
|
import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter;
|
||||||
import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
|
import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
|
||||||
import org.apache.activemq.artemis.cli.commands.user.AddUser;
|
import org.apache.activemq.artemis.cli.commands.user.AddUser;
|
||||||
|
@ -162,7 +163,7 @@ public class Artemis {
|
||||||
withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class, XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class, CompactJournal.class);
|
withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class, XmlDataImporter.class, DecodeJournal.class, EncodeJournal.class, CompactJournal.class);
|
||||||
builder.withGroup("user").withDescription("default file-based user management (add|rm|list|reset) (example ./artemis user list)").
|
builder.withGroup("user").withDescription("default file-based user management (add|rm|list|reset) (example ./artemis user list)").
|
||||||
withDefaultCommand(HelpUser.class).withCommands(ListUser.class, AddUser.class, RemoveUser.class, ResetUser.class);
|
withDefaultCommand(HelpUser.class).withCommands(ListUser.class, AddUser.class, RemoveUser.class, ResetUser.class);
|
||||||
builder = builder.withCommands(Run.class, Stop.class, Kill.class);
|
builder = builder.withCommands(Run.class, Stop.class, Kill.class, SyncRecalc.class);
|
||||||
} else {
|
} else {
|
||||||
builder.withGroup("data").withDescription("data tools group (print) (example ./artemis data print)").
|
builder.withGroup("data").withDescription("data tools group (print) (example ./artemis data print)").
|
||||||
withDefaultCommand(HelpData.class).withCommands(PrintData.class);
|
withDefaultCommand(HelpData.class).withCommands(PrintData.class);
|
||||||
|
|
|
@ -868,7 +868,7 @@ public class Create extends InputAbstract {
|
||||||
System.out.println("Auto tuning journal ...");
|
System.out.println("Auto tuning journal ...");
|
||||||
|
|
||||||
long time = SyncCalculation.syncTest(dataFolder, 4096, writes, 5, verbose, !noJournalSync, aio);
|
long time = SyncCalculation.syncTest(dataFolder, 4096, writes, 5, verbose, !noJournalSync, aio);
|
||||||
long nanoseconds = SyncCalculation.toNanos(time, writes);
|
long nanoseconds = SyncCalculation.toNanos(time, writes, verbose);
|
||||||
double writesPerMillisecond = (double) writes / (double) time;
|
double writesPerMillisecond = (double) writes / (double) time;
|
||||||
|
|
||||||
String writesPerMillisecondStr = new DecimalFormat("###.##").format(writesPerMillisecond);
|
String writesPerMillisecondStr = new DecimalFormat("###.##").format(writesPerMillisecond);
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* 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.text.DecimalFormat;
|
||||||
|
|
||||||
|
import io.airlift.airline.Command;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.ActionContext;
|
||||||
|
import org.apache.activemq.artemis.cli.commands.util.SyncCalculation;
|
||||||
|
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||||
|
import org.apache.activemq.artemis.core.server.JournalType;
|
||||||
|
|
||||||
|
@Command(name = "sync", description = "Calculates the journal-buffer-timeout you should use with the current data folder")
|
||||||
|
public class SyncRecalc extends LockAbstract {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object execute(ActionContext context) throws Exception {
|
||||||
|
super.execute(context);
|
||||||
|
|
||||||
|
FileConfiguration fileConfiguration = getFileConfiguration();
|
||||||
|
|
||||||
|
int writes = 250;
|
||||||
|
System.out.println("");
|
||||||
|
System.out.println("Auto tuning journal ...");
|
||||||
|
|
||||||
|
long time = SyncCalculation.syncTest(fileConfiguration.getJournalLocation(), 4096, writes, 5, verbose, fileConfiguration.isJournalDatasync(), fileConfiguration.getJournalType() == JournalType.ASYNCIO);
|
||||||
|
long nanosecondsWait = SyncCalculation.toNanos(time, writes, verbose);
|
||||||
|
double writesPerMillisecond = (double) writes / (double) time;
|
||||||
|
|
||||||
|
String writesPerMillisecondStr = new DecimalFormat("###.##").format(writesPerMillisecond);
|
||||||
|
|
||||||
|
context.out.println("Your system can execute " + writesPerMillisecondStr + " syncs per millisecond");
|
||||||
|
context.out.println("Your journal-buffer-timeout should be:" + nanosecondsWait);
|
||||||
|
context.out.println("You should use this following configuration:");
|
||||||
|
context.out.println();
|
||||||
|
context.out.println("<journal-buffer-timeout>" + nanosecondsWait + "</journal-buffer-timeout>");
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,6 +49,10 @@ public class SyncCalculation {
|
||||||
boolean fsync,
|
boolean fsync,
|
||||||
boolean aio) throws Exception {
|
boolean aio) throws Exception {
|
||||||
SequentialFileFactory factory = newFactory(datafolder, fsync, aio);
|
SequentialFileFactory factory = newFactory(datafolder, fsync, aio);
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
System.out.println("Using " + factory.getClass().getName() + " to calculate sync times");
|
||||||
|
}
|
||||||
SequentialFile file = factory.createSequentialFile("test.tmp");
|
SequentialFile file = factory.createSequentialFile("test.tmp");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -106,9 +110,9 @@ public class SyncCalculation {
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
double writesPerMillisecond = (double) blocks / (double) result[ntry];
|
double writesPerMillisecond = (double) blocks / (double) result[ntry];
|
||||||
System.out.println("Time = " + result[ntry]);
|
System.out.println("Time = " + result[ntry] + " milliseconds");
|
||||||
System.out.println("Writes / millisecond = " + dcformat.format(writesPerMillisecond));
|
System.out.println("Writes / millisecond = " + dcformat.format(writesPerMillisecond));
|
||||||
System.out.println("bufferTimeout = " + toNanos(result[ntry], blocks));
|
System.out.println("bufferTimeout = " + toNanos(result[ntry], blocks, verbose));
|
||||||
System.out.println("**************************************************");
|
System.out.println("**************************************************");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,14 +143,22 @@ public class SyncCalculation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long toNanos(long time, long blocks) {
|
public static long toNanos(long time, long blocks, boolean verbose) {
|
||||||
|
|
||||||
double blocksPerMillisecond = (double) blocks / (double) (time);
|
double blocksPerMillisecond = (double) blocks / (double) (time);
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
System.out.println("Blocks per millisecond::" + blocksPerMillisecond);
|
||||||
|
}
|
||||||
|
|
||||||
long nanoSeconds = TimeUnit.NANOSECONDS.convert(1, TimeUnit.MILLISECONDS);
|
long nanoSeconds = TimeUnit.NANOSECONDS.convert(1, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
long timeWait = (long) (nanoSeconds / blocksPerMillisecond);
|
long timeWait = (long) (nanoSeconds / blocksPerMillisecond);
|
||||||
|
|
||||||
|
if (verbose) {
|
||||||
|
System.out.println("your system could make a sync every " + timeWait + " nanoseconds, and this will be your timeout");
|
||||||
|
}
|
||||||
|
|
||||||
return timeWait;
|
return timeWait;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class ArtemisTest extends CliTestBase {
|
||||||
long totalAvg = SyncCalculation.syncTest(temporaryFolder.getRoot(), 4096, writes, tries, true, true, true);
|
long totalAvg = SyncCalculation.syncTest(temporaryFolder.getRoot(), 4096, writes, tries, true, true, true);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("TotalAvg = " + totalAvg);
|
System.out.println("TotalAvg = " + totalAvg);
|
||||||
long nanoTime = SyncCalculation.toNanos(totalAvg, writes);
|
long nanoTime = SyncCalculation.toNanos(totalAvg, writes, false);
|
||||||
System.out.println("nanoTime avg = " + nanoTime);
|
System.out.println("nanoTime avg = " + nanoTime);
|
||||||
assertEquals(0, LibaioContext.getTotalMaxIO());
|
assertEquals(0, LibaioContext.getTotalMaxIO());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue