Search in sources :

Example 26 with SequentialFile

use of org.apache.activemq.artemis.core.io.SequentialFile in project activemq-artemis by apache.

the class LargeServerMessageImpl method copy.

@Override
public Message copy() {
    SequentialFile newfile = storageManager.createFileForLargeMessage(messageID, durable);
    Message newMessage = new LargeServerMessageImpl(this, properties, newfile, messageID);
    return newMessage;
}
Also used : SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) LargeServerMessage(org.apache.activemq.artemis.core.server.LargeServerMessage) Message(org.apache.activemq.artemis.api.core.Message)

Example 27 with SequentialFile

use of org.apache.activemq.artemis.core.io.SequentialFile in project activemq-artemis by apache.

the class LargeServerMessageImpl method getBodySize.

private long getBodySize() throws ActiveMQException {
    try {
        if (bodySize < 0) {
            if (file != null) {
                bodySize = file.size();
            } else {
                SequentialFile tmpFile = createFile();
                bodySize = tmpFile.size();
                tmpFile.close();
            }
        }
        return bodySize;
    } catch (Exception e) {
        ActiveMQIOErrorException errorException = new ActiveMQIOErrorException();
        errorException.initCause(e);
        throw errorException;
    }
}
Also used : SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile) ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) ActiveMQIOErrorException(org.apache.activemq.artemis.api.core.ActiveMQIOErrorException) ActiveMQException(org.apache.activemq.artemis.api.core.ActiveMQException) ActiveMQInternalErrorException(org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException)

Example 28 with SequentialFile

use of org.apache.activemq.artemis.core.io.SequentialFile in project activemq-artemis by apache.

the class PagingStoreFactoryDatabase method newFileFactory.

@Override
public synchronized SequentialFileFactory newFileFactory(final SimpleString address) throws Exception {
    String tableName = "" + storageManager.generateID();
    SequentialFileFactory factory = newFileFactory(tableName, true);
    factory.start();
    SequentialFile file = factory.createSequentialFile(PagingStoreFactoryDatabase.ADDRESS_FILE);
    file.open();
    ActiveMQBuffer buffer = ActiveMQBuffers.fixedBuffer(SimpleString.sizeofNullableString(address));
    buffer.writeSimpleString(address);
    file.write(buffer, true);
    file.close();
    return factory;
}
Also used : SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile) JDBCSequentialFile(org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFile) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) JDBCSequentialFileFactory(org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFileFactory) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer)

Example 29 with SequentialFile

use of org.apache.activemq.artemis.core.io.SequentialFile in project activemq-artemis by apache.

the class PagingStoreImpl method createPage.

@Override
public Page createPage(final int pageNumber) throws Exception {
    String fileName = createFileName(pageNumber);
    checkFileFactory();
    SequentialFile file = fileFactory.createSequentialFile(fileName);
    Page page = new Page(storeName, storageManager, fileFactory, file, pageNumber);
    // To create the file
    file.open();
    file.position(0);
    file.close();
    return page;
}
Also used : SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile) SimpleString(org.apache.activemq.artemis.api.core.SimpleString)

Example 30 with SequentialFile

use of org.apache.activemq.artemis.core.io.SequentialFile in project activemq-artemis by apache.

the class PagingStoreImpl method sendPages.

@Override
public void sendPages(ReplicationManager replicator, Collection<Integer> pageIds) throws Exception {
    for (Integer id : pageIds) {
        SequentialFile sFile = fileFactory.createSequentialFile(createFileName(id));
        if (!sFile.exists()) {
            continue;
        }
        ActiveMQServerLogger.LOGGER.replicaSyncFile(sFile, sFile.size());
        replicator.syncPages(sFile, id, getAddress());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SequentialFile(org.apache.activemq.artemis.core.io.SequentialFile)

Aggregations

SequentialFile (org.apache.activemq.artemis.core.io.SequentialFile)53 Test (org.junit.Test)21 ByteBuffer (java.nio.ByteBuffer)15 ArrayList (java.util.ArrayList)10 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)9 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)7 Pair (org.apache.activemq.artemis.api.core.Pair)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 SequentialFileFactory (org.apache.activemq.artemis.core.io.SequentialFileFactory)4 NIOSequentialFileFactory (org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory)4 Page (org.apache.activemq.artemis.core.paging.impl.Page)4 JDBCSequentialFile (org.apache.activemq.artemis.jdbc.store.file.JDBCSequentialFile)4 SimpleEncoding (org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.SimpleEncoding)4 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)3 IOCriticalErrorListener (org.apache.activemq.artemis.core.io.IOCriticalErrorListener)3 PagedMessage (org.apache.activemq.artemis.core.paging.PagedMessage)3 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2