ARTEMIS-139 data.folder related to artemis
https://issues.apache.org/jira/browse/ARTEMIS-139 I'm using the constructors on File(parent, filename) now with the home directory
This commit is contained in:
parent
7de88ef87a
commit
4388923527
|
@ -124,7 +124,7 @@ public abstract class Configurable extends ActionAbstract
|
|||
{
|
||||
if (getBrokerInstance() == null)
|
||||
{
|
||||
final String defaultLocation = "../data";
|
||||
final String defaultLocation = "./data";
|
||||
fileConfiguration = new FileConfiguration();
|
||||
// These will be the default places in case the file can't be loaded
|
||||
fileConfiguration.setBindingsDirectory(defaultLocation + "/bindings");
|
||||
|
|
|
@ -98,8 +98,8 @@ public class Create extends InputAbstract
|
|||
@Option(name = "--home", description = "Directory where ActiveMQ Artemis is installed")
|
||||
File home;
|
||||
|
||||
@Option(name = "--data", description = "Directory where ActiveMQ Data is used. Path are relative to artemis.instance/bin")
|
||||
String data = "../data";
|
||||
@Option(name = "--data", description = "Directory where ActiveMQ Data is used. Path are relative to artemis.instance")
|
||||
String data = "./data";
|
||||
|
||||
@Option(name = "--clustered", description = "Enable clustering")
|
||||
boolean clustered = false;
|
||||
|
@ -131,7 +131,7 @@ public class Create extends InputAbstract
|
|||
@Option(name = "--allow-anonymous", description = "Enables anonymous configuration on security (Default: input)")
|
||||
Boolean allowAnonymous = null;
|
||||
|
||||
@Option(name = "--require-login", description = "This will configure security to require user / password. Compliment --allow-anonymous")
|
||||
@Option(name = "--require-login", description = "This will configure security to require user / password. Compliments --allow-anonymous")
|
||||
Boolean requireLogin = null;
|
||||
|
||||
@Option(name = "--user", description = "The username (Default: input)")
|
||||
|
|
|
@ -84,10 +84,10 @@ public class Run extends Configurable
|
|||
|
||||
private void createDirectories(FileConfiguration fileConfiguration)
|
||||
{
|
||||
new File(fileConfiguration.getBindingsDirectory()).mkdirs();
|
||||
new File(fileConfiguration.getJournalDirectory()).mkdirs();
|
||||
new File(fileConfiguration.getPagingDirectory()).mkdirs();
|
||||
new File(fileConfiguration.getLargeMessagesDirectory()).mkdirs();
|
||||
fileConfiguration.getPagingLocation().mkdirs();
|
||||
fileConfiguration.getJournalLocation().mkdirs();
|
||||
fileConfiguration.getBindingsLocation().mkdirs();
|
||||
fileConfiguration.getLargeMessagesLocation().mkdirs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,7 +137,6 @@ public class Run extends Configurable
|
|||
{
|
||||
try
|
||||
{
|
||||
//TODO stop components
|
||||
server.stop();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
|
@ -42,7 +42,7 @@ public abstract class DataAbstract extends Configurable
|
|||
{
|
||||
if (largeMessges == null)
|
||||
{
|
||||
largeMessges = getFileConfiguration().getLargeMessagesDirectory();
|
||||
largeMessges = getFileConfiguration().getLargeMessagesLocation().getAbsolutePath();
|
||||
}
|
||||
|
||||
checkIfDirectoryExists(largeMessges);
|
||||
|
@ -55,7 +55,7 @@ public abstract class DataAbstract extends Configurable
|
|||
{
|
||||
if (binding == null)
|
||||
{
|
||||
binding = getFileConfiguration().getBindingsDirectory();
|
||||
binding = getFileConfiguration().getBindingsLocation().getAbsolutePath();
|
||||
}
|
||||
|
||||
checkIfDirectoryExists(binding);
|
||||
|
@ -67,7 +67,7 @@ public abstract class DataAbstract extends Configurable
|
|||
{
|
||||
if (journal == null)
|
||||
{
|
||||
journal = getFileConfiguration().getJournalDirectory();
|
||||
journal = getFileConfiguration().getJournalLocation().getAbsolutePath();
|
||||
}
|
||||
|
||||
checkIfDirectoryExists(journal);
|
||||
|
@ -79,7 +79,7 @@ public abstract class DataAbstract extends Configurable
|
|||
{
|
||||
if (paging == null)
|
||||
{
|
||||
paging = getFileConfiguration().getPagingDirectory();
|
||||
paging = getFileConfiguration().getPagingLocation().getAbsolutePath();
|
||||
}
|
||||
|
||||
checkIfDirectoryExists(paging);
|
||||
|
|
|
@ -117,7 +117,7 @@ public class DecodeJournal extends Configurable implements Action
|
|||
System.err.println("Could not create directory " + directory);
|
||||
}
|
||||
|
||||
NIOSequentialFileFactory nio = new NIOSequentialFileFactory(directory, null);
|
||||
NIOSequentialFileFactory nio = new NIOSequentialFileFactory(new File(directory), null);
|
||||
|
||||
JournalImpl journal = new JournalImpl(fileSize, minFiles, 0, 0, nio, journalPrefix, journalSuffix, 1);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.activemq.artemis.cli.commands.tools;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
|
@ -112,7 +113,7 @@ public class EncodeJournal extends Configurable implements Action
|
|||
final int fileSize,
|
||||
final PrintStream out) throws Exception
|
||||
{
|
||||
NIOSequentialFileFactory nio = new NIOSequentialFileFactory(directory, null);
|
||||
NIOSequentialFileFactory nio = new NIOSequentialFileFactory(new File(directory), null);
|
||||
|
||||
JournalImpl journal = new JournalImpl(fileSize, minFiles, 0, 0, nio, journalPrefix, journalSuffix, 1);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class PrintData extends DataAbstract implements Action
|
|||
super.execute(context);
|
||||
try
|
||||
{
|
||||
printData(getBinding(), getJournal(), getPaging());
|
||||
printData(new File(getBinding()), new File(getJournal()), new File(getPaging()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ public class PrintData extends DataAbstract implements Action
|
|||
return null;
|
||||
}
|
||||
|
||||
public static void printData(String bindingsDirectory, String messagesDirectory, String 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
|
||||
// When debugging stuff
|
||||
|
@ -148,7 +148,7 @@ public class PrintData extends DataAbstract implements Action
|
|||
}
|
||||
|
||||
|
||||
private static void printPages(String pageDirectory, DescribeJournal describeJournal)
|
||||
private static void printPages(File pageDirectory, DescribeJournal describeJournal)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ public class PrintData extends DataAbstract implements Action
|
|||
for (SimpleString store : stores)
|
||||
{
|
||||
PagingStore pgStore = manager.getPageStore(store);
|
||||
String folder = null;
|
||||
File folder = null;
|
||||
|
||||
if (pgStore != null)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.activemq.artemis.cli.commands.tools;
|
|||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -344,7 +345,7 @@ public final class XmlDataExporter extends DataAbstract implements Action
|
|||
|
||||
private void getJmsBindings() throws Exception
|
||||
{
|
||||
SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(config.getBindingsDirectory());
|
||||
SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(config.getBindingsLocation());
|
||||
|
||||
Journal jmsJournal = new JournalImpl(1024 * 1024,
|
||||
2,
|
||||
|
@ -764,7 +765,7 @@ public final class XmlDataExporter extends DataAbstract implements Action
|
|||
}
|
||||
};
|
||||
PagingStoreFactory pageStoreFactory =
|
||||
new PagingStoreFactoryNIO(storageManager, config.getPagingDirectory(), 1000L, scheduled, executorFactory, true,
|
||||
new PagingStoreFactoryNIO(storageManager, config.getPagingLocation(), 1000L, scheduled, executorFactory, true,
|
||||
null);
|
||||
HierarchicalRepository<AddressSettings> addressSettingsRepository = new HierarchicalObjectRepository<>();
|
||||
addressSettingsRepository.setDefault(new AddressSettings());
|
||||
|
@ -780,7 +781,7 @@ public final class XmlDataExporter extends DataAbstract implements Action
|
|||
|
||||
if (pageStore != null)
|
||||
{
|
||||
String folder = pageStore.getFolder();
|
||||
File folder = pageStore.getFolder();
|
||||
ActiveMQServerLogger.LOGGER.debug("Reading page store " + store + " folder = " + folder);
|
||||
|
||||
int pageId = (int) pageStore.getFirstPage();
|
||||
|
|
|
@ -57,8 +57,6 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
|
|||
|
||||
private final IDGenerator idGenerator;
|
||||
|
||||
private final String journalDir;
|
||||
|
||||
private final boolean createDir;
|
||||
|
||||
private final Journal jmsJournal;
|
||||
|
@ -71,6 +69,8 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
|
|||
|
||||
private final Map<Pair<PersistedType, String>, PersistedBindings> mapBindings = new ConcurrentHashMap<Pair<PersistedType, String>, PersistedBindings>();
|
||||
|
||||
private final Configuration config;
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
@ -83,17 +83,11 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
|
|||
throw new IllegalArgumentException("Only NIO and AsyncIO are supported journals");
|
||||
}
|
||||
|
||||
// Will use the same place as the bindings directory from the core journal
|
||||
journalDir = config.getBindingsDirectory();
|
||||
|
||||
if (journalDir == null)
|
||||
{
|
||||
throw new NullPointerException("bindings-dir is null");
|
||||
}
|
||||
this.config = config;
|
||||
|
||||
createDir = config.isCreateBindingsDir();
|
||||
|
||||
SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(journalDir);
|
||||
SequentialFileFactory bindingsJMS = new NIOSequentialFileFactory(config.getJournalLocation());
|
||||
|
||||
Journal localJMS = new JournalImpl(1024 * 1024,
|
||||
2,
|
||||
|
@ -265,7 +259,7 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
|
|||
public void start() throws Exception
|
||||
{
|
||||
|
||||
checkAndCreateDir(journalDir, createDir);
|
||||
checkAndCreateDir(config.getJournalLocation(), createDir);
|
||||
|
||||
jmsJournal.start();
|
||||
|
||||
|
@ -335,15 +329,14 @@ public final class JMSJournalStorageManagerImpl implements JMSStorageManager
|
|||
// Private -------------------------------------------------------
|
||||
|
||||
|
||||
private void checkAndCreateDir(final String dir, final boolean create)
|
||||
private void checkAndCreateDir(final File dir, final boolean create)
|
||||
{
|
||||
File f = new File(dir);
|
||||
|
||||
if (!f.exists())
|
||||
if (!dir.exists())
|
||||
{
|
||||
if (create)
|
||||
{
|
||||
if (!f.mkdirs())
|
||||
if (!dir.mkdirs())
|
||||
{
|
||||
throw new IllegalStateException("Failed to create directory " + dir);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.journal;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -71,7 +72,7 @@ public interface SequentialFileFactory
|
|||
|
||||
int calculateBlockSize(int bytes);
|
||||
|
||||
String getDirectory();
|
||||
File getDirectory();
|
||||
|
||||
void clearBuffer(ByteBuffer buffer);
|
||||
|
||||
|
|
|
@ -46,14 +46,14 @@ public class AIOSequentialFile extends AbstractSequentialFile implements IOExcep
|
|||
public AIOSequentialFile(final SequentialFileFactory factory,
|
||||
final int bufferSize,
|
||||
final long bufferTimeoutMilliseconds,
|
||||
final String directory,
|
||||
final File directory,
|
||||
final String fileName,
|
||||
final int maxIO,
|
||||
final BufferCallback bufferCallback,
|
||||
final Executor writerExecutor,
|
||||
final Executor pollerExecutor)
|
||||
{
|
||||
super(directory, new File(directory + "/" + fileName), factory, writerExecutor);
|
||||
super(directory, fileName, factory, writerExecutor);
|
||||
this.maxIO = maxIO;
|
||||
this.bufferCallback = bufferCallback;
|
||||
this.pollerExecutor = pollerExecutor;
|
||||
|
@ -85,8 +85,8 @@ public class AIOSequentialFile extends AbstractSequentialFile implements IOExcep
|
|||
return new AIOSequentialFile(factory,
|
||||
-1,
|
||||
-1,
|
||||
getFile().getParent(),
|
||||
getFileName(),
|
||||
getFile().getParentFile(),
|
||||
getFile().getName(),
|
||||
maxIO,
|
||||
bufferCallback,
|
||||
writerExecutor,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.journal.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
@ -49,7 +50,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
|
|||
ActiveMQJournalLogger.LOGGER.trace(message);
|
||||
}
|
||||
|
||||
public AIOSequentialFileFactory(final String journalDir)
|
||||
public AIOSequentialFileFactory(final File journalDir)
|
||||
{
|
||||
this(journalDir,
|
||||
JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
|
||||
|
@ -58,7 +59,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
|
|||
null);
|
||||
}
|
||||
|
||||
public AIOSequentialFileFactory(final String journalDir, final IOCriticalErrorListener listener)
|
||||
public AIOSequentialFileFactory(final File journalDir, final IOCriticalErrorListener listener)
|
||||
{
|
||||
this(journalDir,
|
||||
JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
|
||||
|
@ -67,7 +68,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
|
|||
listener);
|
||||
}
|
||||
|
||||
public AIOSequentialFileFactory(final String journalDir,
|
||||
public AIOSequentialFileFactory(final File journalDir,
|
||||
final int bufferSize,
|
||||
final int bufferTimeout,
|
||||
final boolean logRates)
|
||||
|
@ -75,7 +76,7 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
|
|||
this(journalDir, bufferSize, bufferTimeout, logRates, null);
|
||||
}
|
||||
|
||||
public AIOSequentialFileFactory(final String journalDir,
|
||||
public AIOSequentialFileFactory(final File journalDir,
|
||||
final int bufferSize,
|
||||
final int bufferTimeout,
|
||||
final boolean logRates,
|
||||
|
|
|
@ -41,7 +41,7 @@ public abstract class AbstractSequentialFile implements SequentialFile
|
|||
|
||||
private File file;
|
||||
|
||||
private final String directory;
|
||||
protected final File directory;
|
||||
|
||||
protected final SequentialFileFactory factory;
|
||||
|
||||
|
@ -66,13 +66,13 @@ public abstract class AbstractSequentialFile implements SequentialFile
|
|||
* @param file
|
||||
* @param directory
|
||||
*/
|
||||
public AbstractSequentialFile(final String directory,
|
||||
final File file,
|
||||
public AbstractSequentialFile(final File directory,
|
||||
final String file,
|
||||
final SequentialFileFactory factory,
|
||||
final Executor writerExecutor)
|
||||
{
|
||||
super();
|
||||
this.file = file;
|
||||
this.file = new File(directory, file);
|
||||
this.directory = directory;
|
||||
this.factory = factory;
|
||||
this.writerExecutor = writerExecutor;
|
||||
|
|
|
@ -45,7 +45,7 @@ abstract class AbstractSequentialFileFactory implements SequentialFileFactory
|
|||
// Timeout used to wait executors to shutdown
|
||||
protected static final int EXECUTOR_TIMEOUT = 60;
|
||||
|
||||
protected final String journalDir;
|
||||
protected final File journalDir;
|
||||
|
||||
protected final TimedBuffer timedBuffer;
|
||||
|
||||
|
@ -62,7 +62,7 @@ abstract class AbstractSequentialFileFactory implements SequentialFileFactory
|
|||
* */
|
||||
protected ExecutorService writeExecutor;
|
||||
|
||||
AbstractSequentialFileFactory(final String journalDir,
|
||||
AbstractSequentialFileFactory(final File journalDir,
|
||||
final boolean buffered,
|
||||
final int bufferSize,
|
||||
final int bufferTimeout,
|
||||
|
@ -109,7 +109,8 @@ abstract class AbstractSequentialFileFactory implements SequentialFileFactory
|
|||
}
|
||||
}
|
||||
|
||||
public String getDirectory()
|
||||
@Override
|
||||
public File getDirectory()
|
||||
{
|
||||
return journalDir;
|
||||
}
|
||||
|
@ -175,8 +176,7 @@ abstract class AbstractSequentialFileFactory implements SequentialFileFactory
|
|||
*/
|
||||
public void createDirs() throws Exception
|
||||
{
|
||||
File file = new File(journalDir);
|
||||
boolean ok = file.mkdirs();
|
||||
boolean ok = journalDir.mkdirs();
|
||||
if (!ok)
|
||||
{
|
||||
throw new IOException("Failed to create directory " + journalDir);
|
||||
|
@ -185,8 +185,6 @@ abstract class AbstractSequentialFileFactory implements SequentialFileFactory
|
|||
|
||||
public List<String> listFiles(final String extension) throws Exception
|
||||
{
|
||||
File dir = new File(journalDir);
|
||||
|
||||
FilenameFilter fnf = new FilenameFilter()
|
||||
{
|
||||
public boolean accept(final File file, final String name)
|
||||
|
@ -195,7 +193,7 @@ abstract class AbstractSequentialFileFactory implements SequentialFileFactory
|
|||
}
|
||||
};
|
||||
|
||||
String[] fileNames = dir.list(fnf);
|
||||
String[] fileNames = journalDir.list(fnf);
|
||||
|
||||
if (fileNames == null)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.journal.impl;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.journal.IOCriticalErrorListener;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +40,7 @@ public final class CompactJournal // NO_UCD
|
|||
|
||||
try
|
||||
{
|
||||
CompactJournal.compactJournal(arg[0], arg[1], arg[2], 2, Integer.parseInt(arg[3]), null);
|
||||
CompactJournal.compactJournal(new File(arg[0]), arg[1], arg[2], 2, Integer.parseInt(arg[3]), null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -47,7 +49,7 @@ public final class CompactJournal // NO_UCD
|
|||
|
||||
}
|
||||
|
||||
static void compactJournal(final String directory,
|
||||
static void compactJournal(final File directory,
|
||||
final String journalPrefix,
|
||||
final String journalSuffix,
|
||||
final int minFiles,
|
||||
|
|
|
@ -51,21 +51,12 @@ public final class NIOSequentialFile extends AbstractSequentialFile
|
|||
private int maxIO;
|
||||
|
||||
public NIOSequentialFile(final SequentialFileFactory factory,
|
||||
final String directory,
|
||||
final String fileName,
|
||||
final File directory,
|
||||
final String file,
|
||||
final int maxIO,
|
||||
final Executor writerExecutor)
|
||||
{
|
||||
super(directory, new File(directory + "/" + fileName), factory, writerExecutor);
|
||||
defaultMaxIO = maxIO;
|
||||
}
|
||||
|
||||
public NIOSequentialFile(final SequentialFileFactory factory,
|
||||
final File file,
|
||||
final int maxIO,
|
||||
final Executor writerExecutor)
|
||||
{
|
||||
super(file.getParent(), new File(file.getPath()), factory, writerExecutor);
|
||||
super(directory, file, factory, writerExecutor);
|
||||
defaultMaxIO = maxIO;
|
||||
}
|
||||
|
||||
|
@ -284,7 +275,7 @@ public final class NIOSequentialFile extends AbstractSequentialFile
|
|||
|
||||
public SequentialFile cloneFile()
|
||||
{
|
||||
return new NIOSequentialFile(factory, getFile(), maxIO, writerExecutor);
|
||||
return new NIOSequentialFile(factory, directory, getFileName(), maxIO, writerExecutor);
|
||||
}
|
||||
|
||||
public void writeDirect(final ByteBuffer bytes, final boolean sync, final IOAsyncTask callback)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.journal.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
@ -24,12 +25,12 @@ import org.apache.activemq.artemis.core.journal.SequentialFile;
|
|||
|
||||
public class NIOSequentialFileFactory extends AbstractSequentialFileFactory
|
||||
{
|
||||
public NIOSequentialFileFactory(final String journalDir)
|
||||
public NIOSequentialFileFactory(final File journalDir)
|
||||
{
|
||||
this(journalDir, null);
|
||||
}
|
||||
|
||||
public NIOSequentialFileFactory(final String journalDir, final IOCriticalErrorListener listener)
|
||||
public NIOSequentialFileFactory(final File journalDir, final IOCriticalErrorListener listener)
|
||||
{
|
||||
this(journalDir,
|
||||
false,
|
||||
|
@ -39,12 +40,12 @@ public class NIOSequentialFileFactory extends AbstractSequentialFileFactory
|
|||
listener);
|
||||
}
|
||||
|
||||
public NIOSequentialFileFactory(final String journalDir, final boolean buffered)
|
||||
public NIOSequentialFileFactory(final File journalDir, final boolean buffered)
|
||||
{
|
||||
this(journalDir, buffered, null);
|
||||
}
|
||||
|
||||
public NIOSequentialFileFactory(final String journalDir,
|
||||
public NIOSequentialFileFactory(final File journalDir,
|
||||
final boolean buffered,
|
||||
final IOCriticalErrorListener listener)
|
||||
{
|
||||
|
@ -56,7 +57,7 @@ public class NIOSequentialFileFactory extends AbstractSequentialFileFactory
|
|||
listener);
|
||||
}
|
||||
|
||||
public NIOSequentialFileFactory(final String journalDir,
|
||||
public NIOSequentialFileFactory(final File journalDir,
|
||||
final boolean buffered,
|
||||
final int bufferSize,
|
||||
final int bufferTimeout,
|
||||
|
@ -65,7 +66,7 @@ public class NIOSequentialFileFactory extends AbstractSequentialFileFactory
|
|||
this(journalDir, buffered, bufferSize, bufferTimeout, logRates, null);
|
||||
}
|
||||
|
||||
public NIOSequentialFileFactory(final String journalDir,
|
||||
public NIOSequentialFileFactory(final File journalDir,
|
||||
final boolean buffered,
|
||||
final int bufferSize,
|
||||
final int bufferTimeout,
|
||||
|
|
|
@ -59,11 +59,11 @@ public class SyncSpeedTest
|
|||
{
|
||||
if (AIO)
|
||||
{
|
||||
fileFactory = new AIOSequentialFileFactory(".", 0, 0, false, null);
|
||||
fileFactory = new AIOSequentialFileFactory(new File("."), 0, 0, false, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
fileFactory = new NIOSequentialFileFactory(".", false, 0, 0, false, null);
|
||||
fileFactory = new NIOSequentialFileFactory(new File("."), false, 0, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class SyncSpeedTest
|
|||
return new AIOSequentialFile(fileFactory,
|
||||
0,
|
||||
0,
|
||||
".",
|
||||
new File("."),
|
||||
fileName,
|
||||
100000,
|
||||
null,
|
||||
|
@ -83,7 +83,7 @@ public class SyncSpeedTest
|
|||
}
|
||||
else
|
||||
{
|
||||
return new NIOSequentialFile(fileFactory, new File(fileName), 1000, null);
|
||||
return new NIOSequentialFile(fileFactory, new File("."), fileName, 1000, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.activemq.artemis.maven;
|
|||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.server.NodeManager;
|
||||
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
||||
|
@ -65,7 +67,7 @@ public final class InVMNodeManagerServer extends ActiveMQServerImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NodeManager createNodeManager(final String directory, boolean replicatingBackup)
|
||||
protected NodeManager createNodeManager(final File directory, boolean replicatingBackup)
|
||||
{
|
||||
return nodeManager;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ public class ActiveMQBootstrap
|
|||
if (nodeManager == null)
|
||||
{
|
||||
boolean replicatedBackup = configuration.getHAPolicyConfiguration().getType() == HAPolicyConfiguration.TYPE.REPLICA;
|
||||
nodeManager = new InVMNodeManager(replicatedBackup, configuration.getJournalDirectory());
|
||||
nodeManager = new InVMNodeManager(replicatedBackup, configuration.getJournalLocation());
|
||||
managerMap.put(nodeId, nodeManager);
|
||||
}
|
||||
server = new InVMNodeManagerServer(configuration, ManagementFactory.getPlatformMBeanServer(),
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -434,6 +435,11 @@ public interface Configuration
|
|||
*/
|
||||
String getBindingsDirectory();
|
||||
|
||||
/**
|
||||
* The binding location related to artemis.instance.
|
||||
*/
|
||||
File getBindingsLocation();
|
||||
|
||||
/**
|
||||
* Sets the file system directory used to store bindings.
|
||||
*/
|
||||
|
@ -459,6 +465,12 @@ public interface Configuration
|
|||
*/
|
||||
String getJournalDirectory();
|
||||
|
||||
/**
|
||||
* The location of the journal related to artemis.instance.
|
||||
* @return
|
||||
*/
|
||||
File getJournalLocation();
|
||||
|
||||
/**
|
||||
* Sets the file system directory used to store journal log.
|
||||
*/
|
||||
|
@ -675,6 +687,12 @@ public interface Configuration
|
|||
*/
|
||||
Configuration setPagingDirectory(String dir);
|
||||
|
||||
|
||||
/**
|
||||
* The paging location related to artemis.instance
|
||||
*/
|
||||
File getPagingLocation();
|
||||
|
||||
// Large Messages Properties ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@ -683,6 +701,9 @@ public interface Configuration
|
|||
*/
|
||||
String getLargeMessagesDirectory();
|
||||
|
||||
/** The large message location related to artemis.instance */
|
||||
File getLargeMessagesLocation();
|
||||
|
||||
/**
|
||||
* Sets the file system directory used to store large messages.
|
||||
*/
|
||||
|
@ -864,4 +885,15 @@ public interface Configuration
|
|||
HAPolicyConfiguration getHAPolicyConfiguration();
|
||||
|
||||
Configuration setHAPolicyConfiguration(HAPolicyConfiguration haPolicyConfiguration);
|
||||
|
||||
/**
|
||||
* Set the Artemis instance relative folder for data and stuff.
|
||||
*/
|
||||
void setArtemisInstance(File directory);
|
||||
|
||||
/**
|
||||
* Set the Artemis instance relative folder for data and stuff.
|
||||
*/
|
||||
File getArtemisInstance();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,9 +18,11 @@ package org.apache.activemq.artemis.core.config.impl;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -217,6 +219,11 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
|
||||
private HAPolicyConfiguration haPolicyConfiguration;
|
||||
|
||||
/**
|
||||
* Parent folder for all data folders.
|
||||
*/
|
||||
private File artemisInstance;
|
||||
|
||||
// Public -------------------------------------------------------------------------
|
||||
|
||||
public boolean isClustered()
|
||||
|
@ -524,6 +531,11 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
return this;
|
||||
}
|
||||
|
||||
public File getBindingsLocation()
|
||||
{
|
||||
return subFolder(getBindingsDirectory());
|
||||
}
|
||||
|
||||
public String getBindingsDirectory()
|
||||
{
|
||||
return bindingsDirectory;
|
||||
|
@ -549,6 +561,10 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
return this;
|
||||
}
|
||||
|
||||
public File getJournalLocation()
|
||||
{
|
||||
return subFolder(getJournalDirectory());
|
||||
}
|
||||
|
||||
public String getJournalDirectory()
|
||||
{
|
||||
|
@ -572,6 +588,11 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
return this;
|
||||
}
|
||||
|
||||
public File getPagingLocation()
|
||||
{
|
||||
return subFolder(getPagingDirectory());
|
||||
}
|
||||
|
||||
public String getPagingDirectory()
|
||||
{
|
||||
return pagingDirectory;
|
||||
|
@ -797,6 +818,11 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
return largeMessagesDirectory;
|
||||
}
|
||||
|
||||
public File getLargeMessagesLocation()
|
||||
{
|
||||
return subFolder(getLargeMessagesDirectory());
|
||||
}
|
||||
|
||||
public ConfigurationImpl setLargeMessagesDirectory(final String directory)
|
||||
{
|
||||
largeMessagesDirectory = directory;
|
||||
|
@ -1077,6 +1103,30 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
return this.connectorServiceConfigurations;
|
||||
}
|
||||
|
||||
public File getArtemisInstance()
|
||||
{
|
||||
if (artemisInstance != null)
|
||||
{
|
||||
return artemisInstance;
|
||||
}
|
||||
|
||||
String strartemisInstance = System.getProperty("artemis.instance");
|
||||
|
||||
if (strartemisInstance == null)
|
||||
{
|
||||
strartemisInstance = System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
artemisInstance = new File(strartemisInstance);
|
||||
|
||||
return artemisInstance;
|
||||
}
|
||||
|
||||
public void setArtemisInstance(File directory)
|
||||
{
|
||||
this.artemisInstance = directory;
|
||||
}
|
||||
|
||||
public boolean isCheckForLiveServer()
|
||||
{
|
||||
if (haPolicyConfiguration instanceof ReplicaPolicyConfiguration)
|
||||
|
@ -1568,4 +1618,23 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
this.haPolicyConfiguration = haPolicyConfiguration;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* It will find the right location of a subFolder, related to artemisInstance
|
||||
*/
|
||||
private File subFolder(String subFolder)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Resolve wont work without "/" as the last character
|
||||
URI artemisHome = new URI(getArtemisInstance().toURI() + "/");
|
||||
URI relative = artemisHome.resolve(subFolder);
|
||||
return new File(relative.getPath());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.paging;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public interface PagingStore extends ActiveMQComponent
|
|||
|
||||
SimpleString getStoreName();
|
||||
|
||||
String getFolder();
|
||||
File getFolder();
|
||||
|
||||
AddressFullMessagePolicy getAddressFullMessagePolicy();
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory
|
|||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
private final String directory;
|
||||
private final File directory;
|
||||
|
||||
private final ExecutorFactory executorFactory;
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory
|
|||
|
||||
private final IOCriticalErrorListener critialErrorListener;
|
||||
|
||||
public PagingStoreFactoryNIO(final StorageManager storageManager, final String directory,
|
||||
public PagingStoreFactoryNIO(final StorageManager storageManager, final File directory,
|
||||
final long syncTimeout,
|
||||
final ScheduledExecutorService scheduledExecutor,
|
||||
final ExecutorFactory executorFactory,
|
||||
|
@ -118,7 +118,7 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory
|
|||
|
||||
factory.createDirs();
|
||||
|
||||
File fileWithID = new File(directory + File.separatorChar +
|
||||
File fileWithID = new File(directory,
|
||||
guid +
|
||||
File.separatorChar +
|
||||
PagingStoreFactoryNIO.ADDRESS_FILE);
|
||||
|
@ -145,9 +145,7 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory
|
|||
|
||||
public List<PagingStore> reloadStores(final HierarchicalRepository<AddressSettings> addressSettingsRepository) throws Exception
|
||||
{
|
||||
File pageDirectory = new File(directory);
|
||||
|
||||
File[] files = pageDirectory.listFiles();
|
||||
File[] files = directory.listFiles();
|
||||
|
||||
if (files == null)
|
||||
{
|
||||
|
@ -210,6 +208,6 @@ public class PagingStoreFactoryNIO implements PagingStoreFactory
|
|||
|
||||
private SequentialFileFactory newFileFactory(final String directoryName)
|
||||
{
|
||||
return new NIOSequentialFileFactory(directory + File.separatorChar + directoryName, false, critialErrorListener);
|
||||
return new NIOSequentialFileFactory(new File(directory, directoryName), false, critialErrorListener);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.paging.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -264,7 +265,7 @@ public class PagingStoreImpl implements PagingStore
|
|||
return pageSize;
|
||||
}
|
||||
|
||||
public String getFolder()
|
||||
public File getFolder()
|
||||
{
|
||||
SequentialFileFactory factoryUsed = this.fileFactory;
|
||||
if (factoryUsed != null)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.activemq.artemis.core.persistence.impl.journal;
|
||||
|
||||
import javax.transaction.xa.Xid;
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
@ -105,7 +106,7 @@ public final class DescribeJournal
|
|||
return preparedTransactions;
|
||||
}
|
||||
|
||||
public static void describeBindingsJournal(final String bindingsDir) throws Exception
|
||||
public static void describeBindingsJournal(final File bindingsDir) throws Exception
|
||||
{
|
||||
|
||||
SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir, null);
|
||||
|
@ -114,7 +115,7 @@ public final class DescribeJournal
|
|||
describeJournal(bindingsFF, bindings, bindingsDir);
|
||||
}
|
||||
|
||||
public static DescribeJournal describeMessagesJournal(final String messagesDir) throws Exception
|
||||
public static DescribeJournal describeMessagesJournal(final File messagesDir) throws Exception
|
||||
{
|
||||
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(messagesDir, null);
|
||||
|
@ -139,7 +140,7 @@ public final class DescribeJournal
|
|||
* @param journal
|
||||
* @throws Exception
|
||||
*/
|
||||
private static DescribeJournal describeJournal(SequentialFileFactory fileFactory, JournalImpl journal, final String path) throws Exception
|
||||
private static DescribeJournal describeJournal(SequentialFileFactory fileFactory, JournalImpl journal, final File path) throws Exception
|
||||
{
|
||||
List<JournalFile> files = journal.orderFiles();
|
||||
|
||||
|
|
|
@ -201,18 +201,12 @@ public class JournalStorageManager implements StorageManager
|
|||
|
||||
private final int perfBlastPages;
|
||||
|
||||
private final boolean createBindingsDir;
|
||||
|
||||
private final String bindingsDir;
|
||||
|
||||
private final boolean createJournalDir;
|
||||
|
||||
private final String journalDir;
|
||||
|
||||
private final String largeMessagesDirectory;
|
||||
|
||||
private boolean journalLoaded = false;
|
||||
|
||||
private final Configuration config;
|
||||
|
||||
// Persisted core configuration
|
||||
private final Map<SimpleString, PersistedRoles> mapPersistedRoles =
|
||||
new ConcurrentHashMap<SimpleString, PersistedRoles>();
|
||||
|
@ -232,6 +226,8 @@ public class JournalStorageManager implements StorageManager
|
|||
{
|
||||
this.executorFactory = executorFactory;
|
||||
|
||||
this.config = config;
|
||||
|
||||
executor = executorFactory.getExecutor();
|
||||
|
||||
if (config.getJournalType() != JournalType.NIO && config.getJournalType() != JournalType.ASYNCIO)
|
||||
|
@ -239,17 +235,8 @@ public class JournalStorageManager implements StorageManager
|
|||
throw ActiveMQMessageBundle.BUNDLE.invalidJournal();
|
||||
}
|
||||
|
||||
bindingsDir = config.getBindingsDirectory();
|
||||
if (bindingsDir == null)
|
||||
{
|
||||
throw new NullPointerException("bindings-dir is null");
|
||||
}
|
||||
|
||||
createBindingsDir = config.isCreateBindingsDir();
|
||||
|
||||
journalDir = config.getJournalDirectory();
|
||||
|
||||
SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(bindingsDir, criticalErrorListener);
|
||||
SequentialFileFactory bindingsFF = new NIOSequentialFileFactory(config.getBindingsLocation(), criticalErrorListener);
|
||||
|
||||
Journal localBindings = new JournalImpl(1024 * 1024,
|
||||
2,
|
||||
|
@ -263,13 +250,6 @@ public class JournalStorageManager implements StorageManager
|
|||
bindingsJournal = localBindings;
|
||||
originalBindingsJournal = localBindings;
|
||||
|
||||
if (journalDir == null)
|
||||
{
|
||||
throw new NullPointerException("journal-dir is null");
|
||||
}
|
||||
|
||||
createJournalDir = config.isCreateJournalDir();
|
||||
|
||||
syncNonTransactional = config.isJournalSyncNonTransactional();
|
||||
|
||||
syncTransactional = config.isJournalSyncTransactional();
|
||||
|
@ -278,7 +258,7 @@ public class JournalStorageManager implements StorageManager
|
|||
{
|
||||
ActiveMQServerLogger.LOGGER.journalUseAIO();
|
||||
|
||||
journalFF = new AIOSequentialFileFactory(journalDir,
|
||||
journalFF = new AIOSequentialFileFactory(config.getJournalLocation(),
|
||||
config.getJournalBufferSize_AIO(),
|
||||
config.getJournalBufferTimeout_AIO(),
|
||||
config.isLogJournalWriteRate(),
|
||||
|
@ -287,7 +267,7 @@ public class JournalStorageManager implements StorageManager
|
|||
else if (config.getJournalType() == JournalType.NIO)
|
||||
{
|
||||
ActiveMQServerLogger.LOGGER.journalUseNIO();
|
||||
journalFF = new NIOSequentialFileFactory(journalDir,
|
||||
journalFF = new NIOSequentialFileFactory(config.getJournalLocation(),
|
||||
true,
|
||||
config.getJournalBufferSize_NIO(),
|
||||
config.getJournalBufferTimeout_NIO(),
|
||||
|
@ -316,7 +296,7 @@ public class JournalStorageManager implements StorageManager
|
|||
|
||||
largeMessagesDirectory = config.getLargeMessagesDirectory();
|
||||
|
||||
largeMessagesFactory = new NIOSequentialFileFactory(largeMessagesDirectory, false, criticalErrorListener);
|
||||
largeMessagesFactory = new NIOSequentialFileFactory(config.getLargeMessagesLocation(), false, criticalErrorListener);
|
||||
|
||||
perfBlastPages = config.getJournalPerfBlastPages();
|
||||
|
||||
|
@ -2242,11 +2222,11 @@ public class JournalStorageManager implements StorageManager
|
|||
return;
|
||||
}
|
||||
|
||||
checkAndCreateDir(bindingsDir, createBindingsDir);
|
||||
checkAndCreateDir(config.getBindingsLocation(), config.isCreateBindingsDir());
|
||||
|
||||
checkAndCreateDir(journalDir, createJournalDir);
|
||||
checkAndCreateDir(config.getJournalLocation(), config.isCreateJournalDir());
|
||||
|
||||
checkAndCreateDir(largeMessagesDirectory, createJournalDir);
|
||||
checkAndCreateDir(config.getLargeMessagesLocation(), config.isCreateJournalDir());
|
||||
|
||||
cleanupIncompleteFiles();
|
||||
|
||||
|
@ -2524,22 +2504,20 @@ public class JournalStorageManager implements StorageManager
|
|||
|
||||
// Private ----------------------------------------------------------------------------------
|
||||
|
||||
private void checkAndCreateDir(final String dir, final boolean create)
|
||||
private void checkAndCreateDir(final File dir, final boolean create)
|
||||
{
|
||||
File f = new File(dir);
|
||||
|
||||
if (!f.exists())
|
||||
if (!dir.exists())
|
||||
{
|
||||
if (create)
|
||||
{
|
||||
if (!f.mkdirs())
|
||||
if (!dir.mkdirs())
|
||||
{
|
||||
throw new IllegalStateException("Failed to create directory " + dir);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ActiveMQMessageBundle.BUNDLE.cannotCreateDir(dir);
|
||||
throw ActiveMQMessageBundle.BUNDLE.cannotCreateDir(dir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon
|
|||
}
|
||||
|
||||
pageManager =
|
||||
new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, config.getPagingDirectory(),
|
||||
new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, config.getPagingLocation(),
|
||||
config.getJournalBufferSize_NIO(),
|
||||
server.getScheduledPool(),
|
||||
server.getExecutorFactory(),
|
||||
|
|
|
@ -34,7 +34,7 @@ public abstract class NodeManager implements ActiveMQComponent
|
|||
private static final String ACCESS_MODE = "rw";
|
||||
|
||||
protected final boolean replicatedBackup;
|
||||
private final String directory;
|
||||
private final File directory;
|
||||
private final Object nodeIDGuard = new Object();
|
||||
private SimpleString nodeID;
|
||||
private UUID uuid;
|
||||
|
@ -42,7 +42,7 @@ public abstract class NodeManager implements ActiveMQComponent
|
|||
|
||||
protected FileChannel channel;
|
||||
|
||||
public NodeManager(final boolean replicatedBackup, final String directory)
|
||||
public NodeManager(final boolean replicatedBackup, final File directory)
|
||||
{
|
||||
this.directory = directory;
|
||||
this.replicatedBackup = replicatedBackup;
|
||||
|
|
|
@ -39,12 +39,12 @@ public final class AIOFileLockNodeManager extends FileLockNodeManager
|
|||
* @param directory
|
||||
* @param replicatingBackup
|
||||
*/
|
||||
public AIOFileLockNodeManager(final String directory, boolean replicatingBackup)
|
||||
public AIOFileLockNodeManager(final File directory, boolean replicatingBackup)
|
||||
{
|
||||
super(directory, replicatingBackup);
|
||||
}
|
||||
|
||||
public AIOFileLockNodeManager(final String directory, boolean replicatingBackup, long lockAcquisitionTimeout)
|
||||
public AIOFileLockNodeManager(final File directory, boolean replicatingBackup, long lockAcquisitionTimeout)
|
||||
{
|
||||
super(directory, replicatingBackup);
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ public class ActiveMQServerImpl implements ActiveMQServer
|
|||
/*
|
||||
* Can be overridden for tests
|
||||
*/
|
||||
protected NodeManager createNodeManager(final String directory, boolean replicatingBackup)
|
||||
protected NodeManager createNodeManager(final File directory, boolean replicatingBackup)
|
||||
{
|
||||
NodeManager manager;
|
||||
if (!configuration.isPersistenceEnabled())
|
||||
|
@ -396,7 +396,7 @@ public class ActiveMQServerImpl implements ActiveMQServer
|
|||
{
|
||||
checkJournalDirectory();
|
||||
|
||||
nodeManager = createNodeManager(configuration.getJournalDirectory(), false);
|
||||
nodeManager = createNodeManager(configuration.getJournalLocation(), false);
|
||||
|
||||
nodeManager.start();
|
||||
|
||||
|
@ -500,7 +500,7 @@ public class ActiveMQServerImpl implements ActiveMQServer
|
|||
{
|
||||
nodeManager.stop();
|
||||
nodeManager =
|
||||
createNodeManager(configuration.getJournalDirectory(), true);
|
||||
createNodeManager(configuration.getJournalLocation(), true);
|
||||
}
|
||||
|
||||
public Activation getActivation()
|
||||
|
@ -1603,7 +1603,7 @@ public class ActiveMQServerImpl implements ActiveMQServer
|
|||
private PagingManager createPagingManager()
|
||||
{
|
||||
|
||||
return new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, configuration.getPagingDirectory(),
|
||||
return new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, configuration.getPagingLocation(),
|
||||
configuration.getJournalBufferTimeout_NIO(),
|
||||
scheduledPool,
|
||||
executorFactory,
|
||||
|
@ -2240,7 +2240,7 @@ public class ActiveMQServerImpl implements ActiveMQServer
|
|||
*/
|
||||
void checkJournalDirectory()
|
||||
{
|
||||
File journalDir = new File(configuration.getJournalDirectory());
|
||||
File journalDir = configuration.getJournalLocation();
|
||||
|
||||
if (!journalDir.exists() && configuration.isPersistenceEnabled())
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.server.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileLock;
|
||||
|
@ -50,12 +51,12 @@ public class FileLockNodeManager extends NodeManager
|
|||
|
||||
protected boolean interrupted = false;
|
||||
|
||||
public FileLockNodeManager(final String directory, boolean replicatedBackup)
|
||||
public FileLockNodeManager(final File directory, boolean replicatedBackup)
|
||||
{
|
||||
super(replicatedBackup, directory);
|
||||
}
|
||||
|
||||
public FileLockNodeManager(final String directory, boolean replicatedBackup, long lockAcquisitionTimeout)
|
||||
public FileLockNodeManager(final File directory, boolean replicatedBackup, long lockAcquisitionTimeout)
|
||||
{
|
||||
super(replicatedBackup, directory);
|
||||
|
||||
|
|
|
@ -16,11 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.core.server.impl;
|
||||
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.LIVE;
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.FAILING_BACK;
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.NOT_STARTED;
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.PAUSED;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
|
@ -29,6 +25,11 @@ import org.apache.activemq.artemis.api.core.SimpleString;
|
|||
import org.apache.activemq.artemis.core.server.NodeManager;
|
||||
import org.apache.activemq.artemis.utils.UUIDGenerator;
|
||||
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.FAILING_BACK;
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.LIVE;
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.NOT_STARTED;
|
||||
import static org.apache.activemq.artemis.core.server.impl.InVMNodeManager.State.PAUSED;
|
||||
|
||||
/**
|
||||
* NodeManager used to run multiple servers in the same VM.
|
||||
* <p>
|
||||
|
@ -59,7 +60,7 @@ public final class InVMNodeManager extends NodeManager
|
|||
throw new RuntimeException("if replicated-backup, we need its journal directory");
|
||||
}
|
||||
|
||||
public InVMNodeManager(boolean replicatedBackup, String directory)
|
||||
public InVMNodeManager(boolean replicatedBackup, File directory)
|
||||
{
|
||||
super(replicatedBackup, directory);
|
||||
liveLock = new Semaphore(1);
|
||||
|
|
|
@ -897,6 +897,11 @@ public abstract class ActiveMQTestBase extends Assert
|
|||
return testDir;
|
||||
}
|
||||
|
||||
protected final File getTestDirfile()
|
||||
{
|
||||
return new File(testDir);
|
||||
}
|
||||
|
||||
protected final void setTestDir(String testDir)
|
||||
{
|
||||
this.testDir = testDir;
|
||||
|
@ -983,6 +988,12 @@ public abstract class ActiveMQTestBase extends Assert
|
|||
return getPageDir(getTestDir());
|
||||
}
|
||||
|
||||
protected File getPageDirFile()
|
||||
{
|
||||
return new File(getPageDir());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pageDir
|
||||
*/
|
||||
|
@ -1883,7 +1894,7 @@ public abstract class ActiveMQTestBase extends Assert
|
|||
JournalImpl messagesJournal = null;
|
||||
try
|
||||
{
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(getJournalDir(), null);
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(new File(getJournalDir()), null);
|
||||
|
||||
messagesJournal = new JournalImpl(config.getJournalFileSize(),
|
||||
config.getJournalMinFiles(),
|
||||
|
@ -1929,7 +1940,7 @@ public abstract class ActiveMQTestBase extends Assert
|
|||
protected HashMap<Integer, AtomicInteger> countJournal(Configuration config) throws Exception
|
||||
{
|
||||
final HashMap<Integer, AtomicInteger> recordsType = new HashMap<Integer, AtomicInteger>();
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(config.getJournalDirectory(), null);
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(config.getJournalLocation(), null);
|
||||
|
||||
JournalImpl messagesJournal = new JournalImpl(config.getJournalFileSize(),
|
||||
config.getJournalMinFiles(),
|
||||
|
@ -1977,7 +1988,7 @@ public abstract class ActiveMQTestBase extends Assert
|
|||
|
||||
if (messageJournal)
|
||||
{
|
||||
ff = new NIOSequentialFileFactory(config.getJournalDirectory(), null);
|
||||
ff = new NIOSequentialFileFactory(config.getJournalLocation(), null);
|
||||
journal = new JournalImpl(config.getJournalFileSize(),
|
||||
config.getJournalMinFiles(),
|
||||
0,
|
||||
|
@ -1989,7 +2000,7 @@ public abstract class ActiveMQTestBase extends Assert
|
|||
}
|
||||
else
|
||||
{
|
||||
ff = new NIOSequentialFileFactory(config.getBindingsDirectory(), null);
|
||||
ff = new NIOSequentialFileFactory(config.getJournalLocation(), null);
|
||||
journal = new JournalImpl(1024 * 1024,
|
||||
2,
|
||||
config.getJournalCompactMinFiles(),
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.activemq.artemis.tests.util;
|
|||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.impl.FileConfiguration;
|
||||
|
@ -62,7 +64,7 @@ public class ColocatedActiveMQServer extends ActiveMQServerImpl
|
|||
|
||||
@Override
|
||||
protected NodeManager
|
||||
createNodeManager(final String directory, boolean replicatingBackup)
|
||||
createNodeManager(final File directory, boolean replicatingBackup)
|
||||
{
|
||||
if (replicatingBackup)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.activemq.artemis.tests.util;
|
|||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.server.NodeManager;
|
||||
import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
||||
|
@ -65,7 +67,7 @@ public final class InVMNodeManagerServer extends ActiveMQServerImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
protected NodeManager createNodeManager(final String directory, boolean replicatingBackup)
|
||||
protected NodeManager createNodeManager(final File directory, boolean replicatingBackup)
|
||||
{
|
||||
return nodeManager;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,15 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.client;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.Interceptor;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
|
@ -62,15 +71,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.LinkedList;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* This test will simulate a consumer hanging on the delivery packet due to unbehaved clients
|
||||
* and it will make sure we can still perform certain operations on the queue such as produce
|
||||
|
@ -480,7 +480,7 @@ public class HangConsumerTest extends ActiveMQTestBase
|
|||
|
||||
server.stop();
|
||||
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(server.getConfiguration().getBindingsDirectory(), null);
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(server.getConfiguration().getBindingsLocation(), null);
|
||||
|
||||
JournalImpl messagesJournal = new JournalImpl(1024 * 1024,
|
||||
2,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
@ -220,7 +221,7 @@ public class JournalCrashTest extends ActiveMQTestBase
|
|||
*/
|
||||
private void printJournal() throws Exception
|
||||
{
|
||||
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(getJournalDir());
|
||||
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(new File(getJournalDir()));
|
||||
JournalImpl journal = new JournalImpl(ActiveMQDefaultConfiguration.getDefaultJournalFileSize(),
|
||||
2,
|
||||
0,
|
||||
|
|
|
@ -16,6 +16,23 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.client;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import javax.transaction.xa.Xid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
|
||||
|
@ -62,23 +79,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import javax.transaction.xa.Xid;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class PagingTest extends ActiveMQTestBase
|
||||
{
|
||||
private ServerLocator locator;
|
||||
|
@ -1734,7 +1734,7 @@ public class PagingTest extends ActiveMQTestBase
|
|||
2,
|
||||
0,
|
||||
0,
|
||||
new NIOSequentialFileFactory(server.getConfiguration().getJournalDirectory()),
|
||||
new NIOSequentialFileFactory(server.getConfiguration().getJournalLocation()),
|
||||
"activemq-data",
|
||||
"amq",
|
||||
1);
|
||||
|
|
|
@ -297,7 +297,7 @@ public class RedeliveryConsumerTest extends ActiveMQTestBase
|
|||
2,
|
||||
0,
|
||||
0,
|
||||
new NIOSequentialFileFactory(server.getConfiguration().getJournalDirectory()),
|
||||
new NIOSequentialFileFactory(server.getConfiguration().getJournalLocation()),
|
||||
"activemq-data",
|
||||
"amq",
|
||||
1);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.cluster;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.server.NodeManager;
|
||||
import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager;
|
||||
|
||||
|
@ -128,7 +130,7 @@ public class NodeManagerAction
|
|||
|
||||
}
|
||||
NodeManagerAction nodeManagerAction = new NodeManagerAction(work1);
|
||||
FileLockNodeManager nodeManager = new FileLockNodeManager(".", false);
|
||||
FileLockNodeManager nodeManager = new FileLockNodeManager(new File("."), false);
|
||||
nodeManager.start();
|
||||
try
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.cluster;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class RealNodeManagerTest extends NodeManagerTest
|
|||
@Test
|
||||
public void testId() throws Exception
|
||||
{
|
||||
NodeManager nodeManager = new FileLockNodeManager(getTemporaryDir(), false);
|
||||
NodeManager nodeManager = new FileLockNodeManager(new File(getTemporaryDir()), false);
|
||||
nodeManager.start();
|
||||
UUID id1 = nodeManager.getUUID();
|
||||
nodeManager.stop();
|
||||
|
|
|
@ -16,6 +16,18 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.cluster.bridge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.Interceptor;
|
||||
|
@ -67,18 +79,6 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@RunWith(value = Parameterized.class)
|
||||
public class BridgeTest extends ActiveMQTestBase
|
||||
{
|
||||
|
@ -1926,7 +1926,7 @@ public class BridgeTest extends ActiveMQTestBase
|
|||
protected Map<Long, AtomicInteger> loadQueues(ActiveMQServer serverToInvestigate) throws Exception
|
||||
{
|
||||
SequentialFileFactory messagesFF = new NIOSequentialFileFactory(serverToInvestigate.getConfiguration()
|
||||
.getJournalDirectory());
|
||||
.getJournalLocation());
|
||||
|
||||
JournalImpl messagesJournal = new JournalImpl(serverToInvestigate.getConfiguration().getJournalFileSize(),
|
||||
serverToInvestigate.getConfiguration().getJournalMinFiles(),
|
||||
|
|
|
@ -16,6 +16,22 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.cluster.distribution;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration;
|
||||
|
@ -68,21 +84,6 @@ import org.junit.After;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class ClusterTestBase extends ActiveMQTestBase
|
||||
{
|
||||
private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
|
||||
|
@ -152,7 +153,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase
|
|||
|
||||
for (int i = 0, nodeManagersLength = nodeManagers.length; i < nodeManagersLength; i++)
|
||||
{
|
||||
nodeManagers[i] = new InVMNodeManager(isSharedStore(), getJournalDir(i, true));
|
||||
nodeManagers[i] = new InVMNodeManager(isSharedStore(), new File(getJournalDir(i, true)));
|
||||
}
|
||||
|
||||
locators = new ServerLocator[ClusterTestBase.MAX_SERVERS];
|
||||
|
@ -1717,7 +1718,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase
|
|||
* backup case.
|
||||
* <br>
|
||||
* Use
|
||||
* {@link #setupClusterConnectionWithBackups(String, String, boolean, int, boolean, int, int[])}
|
||||
* {@link #setupClusterConnectionWithBackups(String, String, org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType, int, boolean, int, int[])}
|
||||
* to add it.
|
||||
*
|
||||
* @param node
|
||||
|
@ -2169,11 +2170,6 @@ public abstract class ClusterTestBase extends ActiveMQTestBase
|
|||
clusterConfs.add(clusterConf);
|
||||
}
|
||||
|
||||
/**
|
||||
* XXX waitForPrevious actually masks what can be considered a bug: that even controlling for
|
||||
* {@link org.apache.activemq.artemis.core.server.ActiveMQServer#waitForInitialization} we still need to wait between starting a shared
|
||||
* store backup and its live.
|
||||
*/
|
||||
protected void startServers(final int... nodes) throws Exception
|
||||
{
|
||||
for (int node : nodes)
|
||||
|
|
|
@ -16,6 +16,14 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.cluster.failover;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.Pair;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
|
@ -40,14 +48,6 @@ import org.apache.activemq.artemis.utils.UUID;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BackupSyncJournalTest extends FailoverTestBase
|
||||
{
|
||||
protected static final int BACKUP_WAIT_TIME = 20;
|
||||
|
@ -227,9 +227,9 @@ public class BackupSyncJournalTest extends FailoverTestBase
|
|||
{
|
||||
System.out.println("\n\n BINDINGS JOURNAL\n\n");
|
||||
Configuration config = server.getServer().getConfiguration();
|
||||
DescribeJournal.describeBindingsJournal(config.getBindingsDirectory());
|
||||
DescribeJournal.describeBindingsJournal(config.getBindingsLocation());
|
||||
System.out.println("\n\n MESSAGES JOURNAL\n\n");
|
||||
DescribeJournal.describeMessagesJournal(config.getJournalDirectory());
|
||||
DescribeJournal.describeMessagesJournal(config.getJournalLocation());
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
|
|
|
@ -16,6 +16,13 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.cluster.failover;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
|
@ -40,19 +47,12 @@ import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
|
|||
import org.apache.activemq.artemis.core.server.impl.InVMNodeManager;
|
||||
import org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer;
|
||||
import org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer;
|
||||
import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class FailoverTestBase extends ActiveMQTestBase
|
||||
{
|
||||
// Constants -----------------------------------------------------
|
||||
|
@ -213,7 +213,7 @@ public abstract class FailoverTestBase extends ActiveMQTestBase
|
|||
.setSecurityEnabled(false);
|
||||
|
||||
setupHAPolicyConfiguration();
|
||||
nodeManager = new InVMNodeManager(true, backupConfig.getJournalDirectory());
|
||||
nodeManager = new InVMNodeManager(true, backupConfig.getJournalLocation());
|
||||
|
||||
backupServer = createTestableServer(backupConfig);
|
||||
|
||||
|
|
|
@ -40,6 +40,6 @@ public class AIOImportExportTest extends NIOImportExportTest
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new AIOSequentialFileFactory(getTestDir());
|
||||
return new AIOSequentialFileFactory(getTestDirfile());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class AIOJournalCompactTest extends NIOJournalCompactTest
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new AIOSequentialFileFactory(getTestDir(),
|
||||
return new AIOSequentialFileFactory(getTestDirfile(),
|
||||
JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
|
||||
100000,
|
||||
false);
|
||||
|
|
|
@ -66,7 +66,7 @@ public class AIOJournalImplTest extends JournalImplTestUnit
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new AIOSequentialFileFactory(getTestDir(),
|
||||
return new AIOSequentialFileFactory(getTestDirfile(),
|
||||
JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO, 1000000,
|
||||
false);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.journal;
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.SequentialFileFactoryTestBase;
|
||||
|
@ -37,7 +38,7 @@ public class AIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase
|
|||
@Override
|
||||
protected SequentialFileFactory createFactory(String folder)
|
||||
{
|
||||
return new AIOSequentialFileFactory(folder);
|
||||
return new AIOSequentialFileFactory(new File(folder));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,238 +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.tests.integration.journal;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.core.journal.EncodingSupport;
|
||||
import org.apache.activemq.artemis.core.journal.IOCompletion;
|
||||
import org.apache.activemq.artemis.core.journal.Journal;
|
||||
import org.apache.activemq.artemis.core.journal.LoaderCallback;
|
||||
import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
|
||||
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
|
||||
import org.apache.activemq.artemis.utils.DataConstants;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore
|
||||
public class JournalPerfTuneTest extends ActiveMQTestBase
|
||||
{
|
||||
private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
|
||||
|
||||
private Journal journal;
|
||||
|
||||
static final class LoaderCB implements LoaderCallback
|
||||
{
|
||||
|
||||
public void addPreparedTransaction(PreparedTransactionInfo preparedTransaction)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
public void addRecord(RecordInfo info)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
public void deleteRecord(long id)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
public void updateRecord(RecordInfo info)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
public void failedTransaction(long transactionID, List<RecordInfo> records, List<RecordInfo> recordsToDelete)
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
final int fileSize = 1024 * 1024 * 10;
|
||||
final int minFiles = 10;
|
||||
final int compactMinFiles = 20;
|
||||
final int compactPercentage = 30;
|
||||
final String filePrefix = "data";
|
||||
final String extension = "amq";
|
||||
final int maxIO = 500;
|
||||
|
||||
final String journalDir = getTestDir();
|
||||
final int bufferSize = 490 * 1024;
|
||||
final int bufferTimeout = (int)(1000000000d / 2000);
|
||||
final boolean logRates = true;
|
||||
|
||||
recreateDirectory(journalDir);
|
||||
|
||||
SequentialFileFactory fileFactory = new AIOSequentialFileFactory(journalDir, bufferSize, bufferTimeout, logRates);
|
||||
|
||||
journal = new JournalImpl(fileSize,
|
||||
minFiles,
|
||||
compactMinFiles,
|
||||
compactPercentage,
|
||||
fileFactory,
|
||||
filePrefix,
|
||||
extension,
|
||||
maxIO);
|
||||
addActiveMQComponent(journal);
|
||||
journal.start();
|
||||
|
||||
journal.load(new LoaderCB());
|
||||
}
|
||||
|
||||
static final class TestCallback implements IOCompletion
|
||||
{
|
||||
private final CountDownLatch latch;
|
||||
|
||||
TestCallback(final int counts)
|
||||
{
|
||||
this.latch = new CountDownLatch(counts);
|
||||
}
|
||||
|
||||
public void await() throws Exception
|
||||
{
|
||||
waitForLatch(latch);
|
||||
}
|
||||
|
||||
public void storeLineUp()
|
||||
{
|
||||
}
|
||||
|
||||
public void done()
|
||||
{
|
||||
latch.countDown();
|
||||
|
||||
log.info(latch.getCount());
|
||||
}
|
||||
|
||||
public void onError(int errorCode, String errorMessage)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1() throws Exception
|
||||
{
|
||||
final int itersPerThread = 10000000;
|
||||
|
||||
final int numThreads = 1;
|
||||
|
||||
this.callback = new TestCallback(2 * itersPerThread * numThreads);
|
||||
|
||||
Worker[] workers = new Worker[numThreads];
|
||||
|
||||
for (int i = 0; i < numThreads; i++)
|
||||
{
|
||||
workers[i] = new Worker(itersPerThread);
|
||||
|
||||
workers[i].start();
|
||||
}
|
||||
|
||||
for (int i = 0; i < numThreads; i++)
|
||||
{
|
||||
workers[i].join();
|
||||
}
|
||||
|
||||
callback.await();
|
||||
}
|
||||
|
||||
private final AtomicLong idGen = new AtomicLong(0);
|
||||
|
||||
private TestCallback callback;
|
||||
|
||||
class Worker extends Thread
|
||||
{
|
||||
final int iters;
|
||||
|
||||
Worker(final int iters)
|
||||
{
|
||||
this.iters = iters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
Record record = new Record(new byte[1024]);
|
||||
|
||||
for (int i = 0; i < iters; i++)
|
||||
{
|
||||
long id = idGen.getAndIncrement();
|
||||
|
||||
journal.appendAddRecord(id, (byte)0, record, true, callback);
|
||||
|
||||
journal.appendDeleteRecord(id, true, callback);
|
||||
|
||||
// log.info("did " + i);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("Failed", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class Record implements EncodingSupport
|
||||
{
|
||||
private byte[] bytes;
|
||||
|
||||
Record(byte[] bytes)
|
||||
{
|
||||
this.bytes = bytes;
|
||||
}
|
||||
|
||||
public void decode(ActiveMQBuffer buffer)
|
||||
{
|
||||
int length = buffer.readInt();
|
||||
|
||||
bytes = new byte[length];
|
||||
|
||||
buffer.readBytes(bytes);
|
||||
}
|
||||
|
||||
public void encode(ActiveMQBuffer buffer)
|
||||
{
|
||||
buffer.writeInt(bytes.length);
|
||||
|
||||
buffer.writeBytes(bytes);
|
||||
}
|
||||
|
||||
public int getEncodeSize()
|
||||
{
|
||||
return DataConstants.SIZE_INT + bytes.length;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ public class NIOBufferedJournalCompactTest extends NIOJournalCompactTest
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new NIOSequentialFileFactory(getTestDir(), true);
|
||||
return new NIOSequentialFileFactory(getTestDirfile(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.journal;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.journal.EncodingSupport;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||
|
@ -24,8 +26,6 @@ import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEnco
|
|||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class NIOImportExportTest extends JournalImplTestBase
|
||||
{
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class NIOImportExportTest extends JournalImplTestBase
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new NIOSequentialFileFactory(getTestDir(), true);
|
||||
return new NIOSequentialFileFactory(getTestDirfile(), true);
|
||||
}
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
|
|
@ -1939,7 +1939,7 @@ public class NIOJournalCompactTest extends JournalImplTestBase
|
|||
@Override
|
||||
protected SequentialFileFactory getFileFactory() throws Exception
|
||||
{
|
||||
return new NIOSequentialFileFactory(getTestDir());
|
||||
return new NIOSequentialFileFactory(getTestDirfile());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class NIOJournalImplTest extends JournalImplTestUnit
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new NIOSequentialFileFactory(getTestDir(), true);
|
||||
return new NIOSequentialFileFactory(getTestDirfile(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ public class NIONoBufferJournalImplTest extends JournalImplTestUnit
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new NIOSequentialFileFactory(getTestDir(), false);
|
||||
return new NIOSequentialFileFactory(new File(getTestDir()), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.journal;
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.SequentialFileFactoryTestBase;
|
||||
|
@ -25,7 +27,7 @@ public class NIONonBufferedSequentialFileFactoryTest extends SequentialFileFacto
|
|||
@Override
|
||||
protected SequentialFileFactory createFactory(String folder)
|
||||
{
|
||||
return new NIOSequentialFileFactory(folder, false);
|
||||
return new NIOSequentialFileFactory(new File(folder), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.journal;
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.SequentialFileFactoryTestBase;
|
||||
|
@ -25,7 +27,7 @@ public class NIOSequentialFileFactoryTest extends SequentialFileFactoryTestBase
|
|||
@Override
|
||||
protected SequentialFileFactory createFactory(String folder)
|
||||
{
|
||||
return new NIOSequentialFileFactory(folder, true);
|
||||
return new NIOSequentialFileFactory(new File(folder), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,148 +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.tests.integration.journal;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFile;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
|
||||
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.JournalImplTestBase;
|
||||
import org.apache.activemq.artemis.utils.DataConstants;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OldFormatTest extends JournalImplTestBase
|
||||
{
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
// This will generate records using the Version 1 format, and reading at the current version
|
||||
@Test
|
||||
public void testFormatOne() throws Exception
|
||||
{
|
||||
setup(2, 100 * 1024, true);
|
||||
|
||||
SequentialFile file = fileFactory.createSequentialFile("amq-1.amq", 1);
|
||||
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(100 * 1024);
|
||||
|
||||
initHeader(buffer, 1);
|
||||
|
||||
byte[] record = new byte[1];
|
||||
|
||||
for (long i = 0; i < 10; i++)
|
||||
{
|
||||
add(buffer, 1, i, record);
|
||||
|
||||
update(buffer, 1, i, record);
|
||||
}
|
||||
|
||||
file.open(1, false);
|
||||
|
||||
buffer.rewind();
|
||||
|
||||
file.writeDirect(buffer, true);
|
||||
|
||||
file.close();
|
||||
|
||||
createJournal();
|
||||
startJournal();
|
||||
loadAndCheck();
|
||||
|
||||
startCompact();
|
||||
finishCompact();
|
||||
|
||||
stopJournal();
|
||||
createJournal();
|
||||
startJournal();
|
||||
loadAndCheck();
|
||||
}
|
||||
|
||||
private void add(ByteBuffer buffer, int fileID, long id, byte[] record)
|
||||
{
|
||||
int pos = buffer.position();
|
||||
|
||||
buffer.put(JournalImpl.ADD_RECORD);
|
||||
|
||||
buffer.putInt(fileID);
|
||||
|
||||
buffer.putLong(id);
|
||||
|
||||
buffer.putInt(record.length);
|
||||
|
||||
buffer.put((byte) 0);
|
||||
|
||||
buffer.put(record);
|
||||
|
||||
buffer.putInt(buffer.position() - pos + DataConstants.SIZE_INT);
|
||||
|
||||
records.add(new RecordInfo(id, (byte) 0, record, false, (short) 0));
|
||||
}
|
||||
|
||||
private void update(ByteBuffer buffer, int fileID, long id, byte[] record)
|
||||
{
|
||||
int pos = buffer.position();
|
||||
|
||||
buffer.put(JournalImpl.UPDATE_RECORD);
|
||||
|
||||
buffer.putInt(fileID);
|
||||
|
||||
buffer.putLong(id);
|
||||
|
||||
buffer.putInt(record.length);
|
||||
|
||||
buffer.put((byte) 0);
|
||||
|
||||
buffer.put(record);
|
||||
|
||||
buffer.putInt(buffer.position() - pos + DataConstants.SIZE_INT);
|
||||
|
||||
records.add(new RecordInfo(id, (byte) 0, record, true, (short) 0));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param buffer
|
||||
*/
|
||||
private void initHeader(ByteBuffer buffer, int fileID)
|
||||
{
|
||||
buffer.putInt(1);
|
||||
|
||||
buffer.putInt(0);
|
||||
|
||||
buffer.putLong(fileID);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see JournalImplTestBase#getFileFactory()
|
||||
*/
|
||||
@Override
|
||||
protected SequentialFileFactory getFileFactory() throws Exception
|
||||
{
|
||||
return new NIOSequentialFileFactory(getTestDir());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* 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.tests.integration.journal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.server.ActiveMQServer;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RelativePathTest extends ActiveMQTestBase
|
||||
{
|
||||
@Test
|
||||
public void testRelativePathOnDefaultConfig() throws Exception
|
||||
{
|
||||
Configuration configuration = createDefaultConfig(false);
|
||||
ActiveMQServer server = createServer(true, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap<String, AddressSettings>());
|
||||
|
||||
server.start();
|
||||
server.stop();
|
||||
|
||||
checkData(new File(configuration.getJournalDirectory()), ".amq");
|
||||
checkData(new File(configuration.getBindingsDirectory()), ".bindings");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataOutsideHome() throws Exception
|
||||
{
|
||||
Configuration configuration = createDefaultConfig(false);
|
||||
|
||||
File instanceHome = new File(getTemporaryDir(), "artemisHome");
|
||||
|
||||
configuration.setArtemisInstance(instanceHome);
|
||||
|
||||
// the journal should be outside of the artemisInstance on this case
|
||||
File journalOutside = new File(getTemporaryDir(), "./journalOut").getAbsoluteFile();
|
||||
configuration.setJournalDirectory(journalOutside.getAbsolutePath());
|
||||
|
||||
// Somewhere inside artemis.instance
|
||||
configuration.setBindingsDirectory("./bind");
|
||||
|
||||
File bindingsInside = new File(instanceHome, "bind");
|
||||
|
||||
// configuration.setJournal
|
||||
|
||||
System.out.println("Journal dir::" + configuration.getJournalDirectory());
|
||||
System.out.println("Journal loc::" + configuration.getJournalLocation());
|
||||
|
||||
ActiveMQServer server = createServer(true, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap<String, AddressSettings>());
|
||||
|
||||
server.start();
|
||||
server.stop();
|
||||
|
||||
checkData(journalOutside, ".amq");
|
||||
// Checking if the journal created the lock as well
|
||||
checkData(journalOutside, "server.lock");
|
||||
checkData(bindingsInside, ".bindings");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelativePath() throws Exception
|
||||
{
|
||||
Configuration configuration = createDefaultConfig(false);
|
||||
|
||||
File instanceHome = new File(getTemporaryDir(), "artemisHome");
|
||||
File dataHome = new File(instanceHome, "data");
|
||||
// One folder up for testing
|
||||
File bindingsHome = new File(instanceHome, "../binx");
|
||||
|
||||
System.out.println("InstanceHome->" + instanceHome);
|
||||
instanceHome.mkdirs();
|
||||
configuration.setArtemisInstance(instanceHome);
|
||||
|
||||
configuration.setJournalDirectory("./data");
|
||||
configuration.setPagingDirectory("./paging");
|
||||
configuration.setBindingsDirectory("../binx");
|
||||
// one folder up from instance home
|
||||
configuration.setLargeMessagesDirectory("./large");
|
||||
|
||||
ActiveMQServer server = createServer(true, configuration, AddressSettings.DEFAULT_PAGE_SIZE, AddressSettings.DEFAULT_MAX_SIZE_BYTES, new HashMap<String, AddressSettings>());
|
||||
|
||||
server.start();
|
||||
server.stop();
|
||||
|
||||
checkData(dataHome, ".amq");
|
||||
checkData(bindingsHome, ".bindings");
|
||||
}
|
||||
|
||||
public void checkData(File dataHome, final String extension)
|
||||
{
|
||||
Assert.assertTrue("Folder " + dataHome + " doesn't exist", dataHome.exists());
|
||||
|
||||
File[] files = dataHome.listFiles(new FileFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File pathname)
|
||||
{
|
||||
return (extension == null || pathname.toString().endsWith(extension));
|
||||
}
|
||||
});
|
||||
|
||||
Assert.assertNotNull(files);
|
||||
|
||||
Assert.assertTrue(files.length > 0);
|
||||
}
|
||||
}
|
|
@ -378,18 +378,18 @@ public class ValidateTransactionHealthTest extends ActiveMQTestBase
|
|||
{
|
||||
if (factoryType.equals("aio"))
|
||||
{
|
||||
return new AIOSequentialFileFactory(directory,
|
||||
return new AIOSequentialFileFactory(new File(directory),
|
||||
JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
|
||||
JournalConstants.DEFAULT_JOURNAL_BUFFER_TIMEOUT_AIO,
|
||||
false);
|
||||
}
|
||||
else if (factoryType.equals("nio2"))
|
||||
{
|
||||
return new NIOSequentialFileFactory(directory, true);
|
||||
return new NIOSequentialFileFactory(new File(directory), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new NIOSequentialFileFactory(directory, false);
|
||||
return new NIOSequentialFileFactory(new File(directory), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,20 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.replication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
|
@ -67,8 +81,8 @@ import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
|
|||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
|
||||
import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.tests.util.ReplicatedBackupUtils;
|
||||
import org.apache.activemq.artemis.tests.util.TransportConfigurationUtils;
|
||||
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;
|
||||
import org.apache.activemq.artemis.utils.ExecutorFactory;
|
||||
|
@ -78,20 +92,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public final class ReplicationTest extends ActiveMQTestBase
|
||||
{
|
||||
|
||||
|
@ -653,7 +653,7 @@ public final class ReplicationTest extends ActiveMQTestBase
|
|||
final HierarchicalRepository<AddressSettings> addressSettingsRepository) throws Exception
|
||||
{
|
||||
|
||||
PagingManager paging = new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, configuration.getPagingDirectory(),
|
||||
PagingManager paging = new PagingManagerImpl(new PagingStoreFactoryNIO(storageManager, configuration.getPagingLocation(),
|
||||
1000, null,
|
||||
executorFactory, false, null),
|
||||
addressSettingsRepository);
|
||||
|
|
|
@ -1,158 +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.tests.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
|
||||
import org.apache.activemq.artemis.core.journal.RecordInfo;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.JournalImpl;
|
||||
import org.apache.activemq.artemis.utils.TimeAndCounterIDGenerator;
|
||||
|
||||
/**
|
||||
* A JournalExample: Just an example on how to use the Journal Directly
|
||||
* <br>
|
||||
* TODO: find a better place to store this example
|
||||
*/
|
||||
public class JournalExample
|
||||
{
|
||||
|
||||
// Constants -----------------------------------------------------
|
||||
|
||||
// Attributes ----------------------------------------------------
|
||||
|
||||
// Static --------------------------------------------------------
|
||||
|
||||
// Constructors --------------------------------------------------
|
||||
|
||||
// Public --------------------------------------------------------
|
||||
|
||||
// Package protected ---------------------------------------------
|
||||
|
||||
// Protected -----------------------------------------------------
|
||||
|
||||
// Private -------------------------------------------------------
|
||||
|
||||
// Inner classes -------------------------------------------------
|
||||
|
||||
public static void main(final String[] arg)
|
||||
{
|
||||
TimeAndCounterIDGenerator idgenerator = new TimeAndCounterIDGenerator();
|
||||
try
|
||||
{
|
||||
SequentialFileFactory fileFactory = new AIOSequentialFileFactory("/tmp"); // any dir you want
|
||||
// SequentialFileFactory fileFactory = new NIOSequentialFileFactory("/tmp"); // any dir you want
|
||||
JournalImpl journalExample = new JournalImpl(10 * 1024 * 1024, // 10M.. we believe that's the usual cilinder
|
||||
// bufferSize.. not an exact science here
|
||||
2, // number of files pre-allocated
|
||||
0,
|
||||
0,
|
||||
fileFactory, // AIO or NIO
|
||||
"exjournal", // file name
|
||||
"dat", // extension
|
||||
10000); // it's like a semaphore for callback on the AIO layer
|
||||
|
||||
ArrayList<RecordInfo> committedRecords = new ArrayList<RecordInfo>();
|
||||
ArrayList<PreparedTransactionInfo> preparedTransactions = new ArrayList<PreparedTransactionInfo>();
|
||||
journalExample.start();
|
||||
System.out.println("Loading records and creating data files");
|
||||
journalExample.load(committedRecords, preparedTransactions, null);
|
||||
|
||||
System.out.println("Loaded Record List:");
|
||||
|
||||
for (RecordInfo record : committedRecords)
|
||||
{
|
||||
System.out.println("Record id = " + record.id +
|
||||
" userType = " +
|
||||
record.userRecordType +
|
||||
" with " +
|
||||
record.data.length +
|
||||
" bytes is stored on the journal");
|
||||
}
|
||||
|
||||
System.out.println("Adding Records:");
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
journalExample.appendAddRecord(idgenerator.generateID(), (byte) 1, new byte[]{
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2}, false);
|
||||
}
|
||||
|
||||
long tx = idgenerator.generateID(); // some id generation system
|
||||
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
journalExample.appendAddRecordTransactional(tx, idgenerator.generateID(), (byte) 2, new byte[]{0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
5});
|
||||
}
|
||||
|
||||
// After this is complete, you're sure the records are there
|
||||
journalExample.appendCommitRecord(tx, true);
|
||||
|
||||
System.out.println("Done!");
|
||||
|
||||
journalExample.stop();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -51,7 +51,7 @@ public class RealJournalImplAIOTest extends JournalImplTestUnit
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new AIOSequentialFileFactory(getTestDir());
|
||||
return new AIOSequentialFileFactory(getTestDirfile());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class RealJournalImplNIOTest extends JournalImplTestUnit
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new NIOSequentialFileFactory(getTestDir());
|
||||
return new NIOSequentialFileFactory(getTestDirfile());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class AIOAllPossibilitiesCompactStressTest extends AllPossibilitiesCompac
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new AIOSequentialFileFactory(getTestDir(),
|
||||
return new AIOSequentialFileFactory(getTestDirfile(),
|
||||
JournalConstants.DEFAULT_JOURNAL_BUFFER_SIZE_AIO,
|
||||
1000000,
|
||||
false);
|
||||
|
|
|
@ -76,7 +76,7 @@ public class AddAndRemoveStressTest extends ActiveMQTestBase
|
|||
public void testInsertAndLoad() throws Exception
|
||||
{
|
||||
|
||||
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDir());
|
||||
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDirfile());
|
||||
JournalImpl impl = new JournalImpl(10 * 1024 * 1024,
|
||||
AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL,
|
||||
0,
|
||||
|
@ -101,7 +101,7 @@ public class AddAndRemoveStressTest extends ActiveMQTestBase
|
|||
|
||||
impl.stop();
|
||||
|
||||
factory = new AIOSequentialFileFactory(getTestDir());
|
||||
factory = new AIOSequentialFileFactory(getTestDirfile());
|
||||
impl = new JournalImpl(10 * 1024 * 1024,
|
||||
AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL,
|
||||
0,
|
||||
|
@ -127,7 +127,7 @@ public class AddAndRemoveStressTest extends ActiveMQTestBase
|
|||
|
||||
impl.stop();
|
||||
|
||||
factory = new AIOSequentialFileFactory(getTestDir());
|
||||
factory = new AIOSequentialFileFactory(getTestDirfile());
|
||||
impl = new JournalImpl(10 * 1024 * 1024,
|
||||
AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL,
|
||||
0,
|
||||
|
@ -164,7 +164,7 @@ public class AddAndRemoveStressTest extends ActiveMQTestBase
|
|||
public void testInsertUpdateAndLoad() throws Exception
|
||||
{
|
||||
|
||||
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDir());
|
||||
SequentialFileFactory factory = new AIOSequentialFileFactory(getTestDirfile());
|
||||
JournalImpl impl = new JournalImpl(10 * 1024 * 1024,
|
||||
AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL,
|
||||
0,
|
||||
|
@ -190,7 +190,7 @@ public class AddAndRemoveStressTest extends ActiveMQTestBase
|
|||
|
||||
impl.stop();
|
||||
|
||||
factory = new AIOSequentialFileFactory(getTestDir());
|
||||
factory = new AIOSequentialFileFactory(getTestDirfile());
|
||||
impl = new JournalImpl(10 * 1024 * 1024, 10, 0, 0, factory, "amq", "amq", 1000);
|
||||
|
||||
impl.start();
|
||||
|
@ -209,7 +209,7 @@ public class AddAndRemoveStressTest extends ActiveMQTestBase
|
|||
|
||||
impl.stop();
|
||||
|
||||
factory = new AIOSequentialFileFactory(getTestDir());
|
||||
factory = new AIOSequentialFileFactory(getTestDirfile());
|
||||
impl = new JournalImpl(10 * 1024 * 1024,
|
||||
AddAndRemoveStressTest.NUMBER_OF_FILES_ON_JOURNAL,
|
||||
0,
|
||||
|
|
|
@ -114,12 +114,12 @@ public class JournalCleanupCompactStressTest extends ActiveMQTestBase
|
|||
int maxAIO;
|
||||
if (AsynchronousFileImpl.isLoaded())
|
||||
{
|
||||
factory = new AIOSequentialFileFactory(dir.getPath());
|
||||
factory = new AIOSequentialFileFactory(dir);
|
||||
maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio();
|
||||
}
|
||||
else
|
||||
{
|
||||
factory = new NIOSequentialFileFactory(dir.getPath(), true);
|
||||
factory = new NIOSequentialFileFactory(dir, true);
|
||||
maxAIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio();
|
||||
}
|
||||
|
||||
|
|
|
@ -241,6 +241,6 @@ public abstract class MixupCompactorTestBase extends JournalImplTestBase
|
|||
@Override
|
||||
protected SequentialFileFactory getFileFactory() throws Exception
|
||||
{
|
||||
return new NIOSequentialFileFactory(getTestDir());
|
||||
return new NIOSequentialFileFactory(getTestDirfile());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,13 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.stress.journal;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import javax.transaction.xa.Xid;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQException;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
|
@ -38,12 +45,6 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.transaction.xa.XAResource;
|
||||
import javax.transaction.xa.Xid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class NIOMultiThreadCompactorStressTest extends ActiveMQTestBase
|
||||
{
|
||||
|
||||
|
@ -89,7 +90,7 @@ public class NIOMultiThreadCompactorStressTest extends ActiveMQTestBase
|
|||
internalTestProduceAndConsume();
|
||||
stopServer();
|
||||
|
||||
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(getJournalDir());
|
||||
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(new File(getJournalDir()));
|
||||
JournalImpl journal = new JournalImpl(ActiveMQDefaultConfiguration.getDefaultJournalFileSize(),
|
||||
2,
|
||||
0,
|
||||
|
|
|
@ -39,7 +39,7 @@ public class AIOJournalImplTest extends JournalImplTestUnit
|
|||
|
||||
file.mkdir();
|
||||
|
||||
return new AIOSequentialFileFactory(getTestDir());
|
||||
return new AIOSequentialFileFactory(getTestDirfile());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.activemq.artemis.tests.timing.core.journal.impl;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.unit.UnitTestLogger;
|
||||
|
@ -27,20 +26,12 @@ public class NIOJournalImplTest extends JournalImplTestUnit
|
|||
{
|
||||
private static final UnitTestLogger log = UnitTestLogger.LOGGER;
|
||||
|
||||
protected String journalDir = System.getProperty("java.io.tmpdir", "/tmp") + "/journal-test";
|
||||
|
||||
@Override
|
||||
protected SequentialFileFactory getFileFactory() throws Exception
|
||||
{
|
||||
File file = new File(journalDir);
|
||||
File file = new File(getTemporaryDir());
|
||||
|
||||
NIOJournalImplTest.log.debug("deleting directory " + journalDir);
|
||||
|
||||
ActiveMQTestBase.deleteDirectory(file);
|
||||
|
||||
file.mkdir();
|
||||
|
||||
return new NIOSequentialFileFactory(journalDir);
|
||||
return new NIOSequentialFileFactory(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,18 +16,17 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.unit.core.journal.impl;
|
||||
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.AIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CleanBufferTest extends ActiveMQTestBase
|
||||
{
|
||||
|
@ -45,7 +44,7 @@ public class CleanBufferTest extends ActiveMQTestBase
|
|||
@Test
|
||||
public void testCleanOnNIO()
|
||||
{
|
||||
SequentialFileFactory factory = new NIOSequentialFileFactory("Whatever");
|
||||
SequentialFileFactory factory = new NIOSequentialFileFactory(new File("Whatever"));
|
||||
|
||||
testBuffer(factory);
|
||||
}
|
||||
|
@ -55,7 +54,7 @@ public class CleanBufferTest extends ActiveMQTestBase
|
|||
{
|
||||
if (AsynchronousFileImpl.isLoaded())
|
||||
{
|
||||
SequentialFileFactory factory = new AIOSequentialFileFactory("Whatever");
|
||||
SequentialFileFactory factory = new AIOSequentialFileFactory(new File("Whatever"));
|
||||
|
||||
testBuffer(factory);
|
||||
}
|
||||
|
|
|
@ -728,7 +728,7 @@ public class FakeSequentialFileFactory implements SequentialFileFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getDirectory()
|
||||
public File getDirectory()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.util.List;
|
|||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFile;
|
||||
import org.apache.activemq.artemis.core.journal.SequentialFileFactory;
|
||||
import org.apache.activemq.artemis.core.journal.impl.NIOSequentialFileFactory;
|
||||
|
@ -33,6 +31,8 @@ import org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl;
|
|||
import org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager;
|
||||
import org.apache.activemq.artemis.core.server.ServerMessage;
|
||||
import org.apache.activemq.artemis.core.server.impl.ServerMessageImpl;
|
||||
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -52,14 +52,14 @@ public class PageTest extends ActiveMQTestBase
|
|||
public void testPageWithNIO() throws Exception
|
||||
{
|
||||
recreateDirectory(getTestDir());
|
||||
testAdd(new NIOSequentialFileFactory(getTestDir()), 1000);
|
||||
testAdd(new NIOSequentialFileFactory(getTestDirfile()), 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDamagedDataWithNIO() throws Exception
|
||||
{
|
||||
recreateDirectory(getTestDir());
|
||||
testDamagedPage(new NIOSequentialFileFactory(getTestDir()), 1000);
|
||||
testDamagedPage(new NIOSequentialFileFactory(getTestDirfile()), 1000);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -57,7 +57,7 @@ public class PagingManagerImplTest extends ActiveMQTestBase
|
|||
final StorageManager storageManager = new NullStorageManager();
|
||||
|
||||
PagingStoreFactoryNIO storeFactory =
|
||||
new PagingStoreFactoryNIO(storageManager, getPageDir(), 100, null, getOrderedExecutor(), true, null);
|
||||
new PagingStoreFactoryNIO(storageManager, getPageDirFile(), 100, null, getOrderedExecutor(), true, null);
|
||||
|
||||
PagingManagerImpl managerImpl = new PagingManagerImpl(storeFactory, addressSettings);
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.unit.core.paging.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -128,7 +129,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase
|
|||
public void testPageWithNIO() throws Exception
|
||||
{
|
||||
ActiveMQTestBase.recreateDirectory(getTestDir());
|
||||
testConcurrentPaging(new NIOSequentialFileFactory(getTestDir()), 1);
|
||||
testConcurrentPaging(new NIOSequentialFileFactory(new File(getTestDir())), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -644,7 +645,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase
|
|||
public void testRestartPage() throws Throwable
|
||||
{
|
||||
clearDataRecreateServerDirs();
|
||||
SequentialFileFactory factory = new NIOSequentialFileFactory(getPageDir());
|
||||
SequentialFileFactory factory = new NIOSequentialFileFactory(new File(getPageDir()));
|
||||
|
||||
PagingStoreFactory storeFactory = new FakeStoreFactory(factory);
|
||||
|
||||
|
@ -681,7 +682,7 @@ public class PagingStoreImplTest extends ActiveMQTestBase
|
|||
public void testOrderOnPaging() throws Throwable
|
||||
{
|
||||
clearDataRecreateServerDirs();
|
||||
SequentialFileFactory factory = new NIOSequentialFileFactory(getPageDir());
|
||||
SequentialFileFactory factory = new NIOSequentialFileFactory(new File(getPageDir()));
|
||||
|
||||
PagingStoreFactory storeFactory = new FakeStoreFactory(factory);
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.unit.core.persistence.impl;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
|
||||
|
@ -38,7 +39,7 @@ public class BatchIDGeneratorUnitTest extends ActiveMQTestBase
|
|||
@Test
|
||||
public void testSequence() throws Exception
|
||||
{
|
||||
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(getTestDir());
|
||||
NIOSequentialFileFactory factory = new NIOSequentialFileFactory(new File(getTestDir()));
|
||||
Journal journal = new JournalImpl(10 * 1024, 2, 0, 0, factory, "activemq-bindings", "bindings", 1);
|
||||
|
||||
journal.start();
|
||||
|
|
|
@ -15,16 +15,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.artemis.tests.unit.core.server.impl;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Before;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.core.asyncio.impl.AsynchronousFileImpl;
|
||||
import org.apache.activemq.artemis.core.server.impl.AIOFileLockNodeManager;
|
||||
import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FileLockTest extends ActiveMQTestBase
|
||||
{
|
||||
|
@ -42,7 +40,7 @@ public class FileLockTest extends ActiveMQTestBase
|
|||
@Test
|
||||
public void testNIOLock() throws Exception
|
||||
{
|
||||
doTestLock(new FileLockNodeManager(getTestDir(), false), new FileLockNodeManager(getTestDir(), false));
|
||||
doTestLock(new FileLockNodeManager(getTestDirfile(), false), new FileLockNodeManager(getTestDirfile(), false));
|
||||
|
||||
}
|
||||
|
||||
|
@ -51,7 +49,7 @@ public class FileLockTest extends ActiveMQTestBase
|
|||
{
|
||||
if (AsynchronousFileImpl.isLoaded())
|
||||
{
|
||||
doTestLock(new AIOFileLockNodeManager(getTestDir(), false), new AIOFileLockNodeManager(getTestDir(), false));
|
||||
doTestLock(new AIOFileLockNodeManager(getTestDirfile(), false), new AIOFileLockNodeManager(getTestDirfile(), false));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue