Search in sources :

Example 26 with PagingStore

use of org.apache.activemq.artemis.core.paging.PagingStore in project activemq-artemis by apache.

the class PrintData method printPages.

private static void printPages(DescribeJournal describeJournal, StorageManager sm, PagingManager manager, PrintStream out, boolean safe) throws Exception {
    PageCursorsInfo cursorACKs = calculateCursorsInfo(describeJournal.getRecords());
    Set<Long> pgTXs = cursorACKs.getPgTXs();
    manager.start();
    SimpleString[] stores = manager.getStoreNames();
    for (SimpleString store : stores) {
        PagingStore pgStore = manager.getPageStore(store);
        File folder = null;
        if (pgStore != null) {
            folder = pgStore.getFolder();
        }
        out.println("####################################################################################################");
        out.println("Exploring store " + store + " folder = " + folder);
        int pgid = (int) pgStore.getFirstPage();
        for (int pg = 0; pg < pgStore.getNumberOfPages(); pg++) {
            out.println("*******   Page " + pgid);
            Page page = pgStore.createPage(pgid);
            page.open();
            List<PagedMessage> msgs = page.read(sm);
            page.close();
            int msgID = 0;
            for (PagedMessage msg : msgs) {
                msg.initMessage(sm);
                if (safe) {
                    try {
                        out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ", msg=" + msg.getMessage().getClass().getSimpleName() + "(safe data, size=" + msg.getMessage().getPersistentSize() + ")");
                    } catch (Exception e) {
                        out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ", msg=" + msg.getMessage().getClass().getSimpleName() + "(safe data)");
                    }
                } else {
                    out.print("pg=" + pgid + ", msg=" + msgID + ",pgTX=" + msg.getTransactionID() + ",userMessageID=" + (msg.getMessage().getUserID() != null ? msg.getMessage().getUserID() : "") + ", msg=" + msg.getMessage());
                }
                out.print(",Queues = ");
                long[] q = msg.getQueueIDs();
                for (int i = 0; i < q.length; i++) {
                    out.print(q[i]);
                    PagePosition posCheck = new PagePositionImpl(pgid, msgID);
                    boolean acked = false;
                    Set<PagePosition> positions = cursorACKs.getCursorRecords().get(q[i]);
                    if (positions != null) {
                        acked = positions.contains(posCheck);
                    }
                    if (acked) {
                        out.print(" (ACK)");
                    }
                    if (cursorACKs.getCompletePages(q[i]).contains(Long.valueOf(pgid))) {
                        out.println(" (PG-COMPLETE)");
                    }
                    if (i + 1 < q.length) {
                        out.print(",");
                    }
                }
                if (msg.getTransactionID() >= 0 && !pgTXs.contains(msg.getTransactionID())) {
                    out.print(", **PG_TX_NOT_FOUND**");
                }
                out.println();
                msgID++;
            }
            pgid++;
        }
    }
}
Also used : PagedMessage(org.apache.activemq.artemis.core.paging.PagedMessage) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Page(org.apache.activemq.artemis.core.paging.impl.Page) PagePositionImpl(org.apache.activemq.artemis.core.paging.cursor.impl.PagePositionImpl) PagePosition(org.apache.activemq.artemis.core.paging.cursor.PagePosition) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore) File(java.io.File)

Example 27 with PagingStore

use of org.apache.activemq.artemis.core.paging.PagingStore in project activemq-artemis by apache.

the class PagingManagerImpl method newStore.

private PagingStore newStore(final SimpleString address) throws Exception {
    syncLock.readLock().lock();
    try {
        PagingStore store = stores.get(address);
        if (store == null) {
            store = pagingStoreFactory.newStore(address, addressSettingsRepository.getMatch(address.toString()));
            store.start();
            if (!cleanupEnabled) {
                store.disableCleanup();
            }
            stores.put(address, store);
        }
        return store;
    } finally {
        syncLock.readLock().unlock();
    }
}
Also used : PagingStore(org.apache.activemq.artemis.core.paging.PagingStore)

Example 28 with PagingStore

use of org.apache.activemq.artemis.core.paging.PagingStore in project activemq-artemis by apache.

the class PagingManagerImpl method reapplySettings.

private void reapplySettings() {
    for (PagingStore store : stores.values()) {
        AddressSettings settings = this.addressSettingsRepository.getMatch(store.getAddress().toString());
        store.applySetting(settings);
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore)

Example 29 with PagingStore

use of org.apache.activemq.artemis.core.paging.PagingStore in project activemq-artemis by apache.

the class PagingManagerImpl method reloadStores.

@Override
public void reloadStores() throws Exception {
    lock();
    try {
        List<PagingStore> reloadedStores = pagingStoreFactory.reloadStores(addressSettingsRepository);
        for (PagingStore store : reloadedStores) {
            // when reloading, we need to close the previously loaded version of this
            // store
            PagingStore oldStore = stores.remove(store.getStoreName());
            if (oldStore != null) {
                oldStore.stop();
                oldStore = null;
            }
            store.start();
            stores.put(store.getStoreName(), store);
        }
    } finally {
        unlock();
    }
}
Also used : PagingStore(org.apache.activemq.artemis.core.paging.PagingStore)

Example 30 with PagingStore

use of org.apache.activemq.artemis.core.paging.PagingStore in project activemq-artemis by apache.

the class PagingStoreFactoryNIO method reloadStores.

@Override
public List<PagingStore> reloadStores(final HierarchicalRepository<AddressSettings> addressSettingsRepository) throws Exception {
    File[] files = directory.listFiles();
    if (files == null) {
        return Collections.<PagingStore>emptyList();
    } else {
        ArrayList<PagingStore> storesReturn = new ArrayList<>(files.length);
        for (File file : files) {
            final String guid = file.getName();
            final File addressFile = new File(file, PagingStoreFactoryNIO.ADDRESS_FILE);
            if (!addressFile.exists()) {
                // This means this folder is from a replication copy, nothing to worry about it, we just skip it
                if (!file.getName().contains(FileMoveManager.PREFIX)) {
                    ActiveMQServerLogger.LOGGER.pageStoreFactoryNoIdFile(file.toString(), PagingStoreFactoryNIO.ADDRESS_FILE);
                }
                continue;
            }
            String addressString;
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(addressFile)))) {
                addressString = reader.readLine();
            }
            SimpleString address = new SimpleString(addressString);
            SequentialFileFactory factory = newFileFactory(guid);
            AddressSettings settings = addressSettingsRepository.getMatch(address.toString());
            PagingStore store = new PagingStoreImpl(address, scheduledExecutor, syncTimeout, pagingManager, storageManager, factory, this, address, settings, executorFactory.getExecutor(), syncNonTransactional);
            storesReturn.add(store);
        }
        return storesReturn;
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) InputStreamReader(java.io.InputStreamReader) ArrayList(java.util.ArrayList) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) FileInputStream(java.io.FileInputStream) SequentialFileFactory(org.apache.activemq.artemis.core.io.SequentialFileFactory) NIOSequentialFileFactory(org.apache.activemq.artemis.core.io.nio.NIOSequentialFileFactory) BufferedReader(java.io.BufferedReader) File(java.io.File) PagingStore(org.apache.activemq.artemis.core.paging.PagingStore)

Aggregations

PagingStore (org.apache.activemq.artemis.core.paging.PagingStore)48 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)31 Test (org.junit.Test)24 Configuration (org.apache.activemq.artemis.core.config.Configuration)19 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)17 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)17 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)17 DatabaseStorageConfiguration (org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration)17 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)16 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)15 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)15 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)15 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)11 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)11 HashMap (java.util.HashMap)9 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)9 Queue (org.apache.activemq.artemis.core.server.Queue)9 PagedMessage (org.apache.activemq.artemis.core.paging.PagedMessage)8 ArrayList (java.util.ArrayList)7 Page (org.apache.activemq.artemis.core.paging.impl.Page)6