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++;
}
}
}
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();
}
}
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);
}
}
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();
}
}
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;
}
}
Aggregations