ARTEMIS-3595 PrintData option helping on visualization of data
I need to filter out some of the data when looking for issues. Like I will not need to print every single page. and some times I need to find the records that are not acked on Page
This commit is contained in:
parent
e04f3214cb
commit
4196faf7ce
|
@ -73,6 +73,15 @@ public class PrintData extends DBOption {
|
||||||
@Option(name = "--reclaimed", description = "This option will try to print as many records as possible from reclaimed files")
|
@Option(name = "--reclaimed", description = "This option will try to print as many records as possible from reclaimed files")
|
||||||
private boolean reclaimed = false;
|
private boolean reclaimed = false;
|
||||||
|
|
||||||
|
@Option(name = "--max-pages", description = "It will print your data structure without showing your data")
|
||||||
|
private int maxPages = -1;
|
||||||
|
|
||||||
|
@Option(name = "--skip-bindings", description = "It will ignore printing the bindings journal")
|
||||||
|
private boolean skipBindings = false;
|
||||||
|
|
||||||
|
@Option(name = "--skip-journal", description = "It will ignore printing the messages journal")
|
||||||
|
private boolean skipJournal = false;
|
||||||
|
|
||||||
private static final String BINDINGS_BANNER = "B I N D I N G S J O U R N A L";
|
private static final String BINDINGS_BANNER = "B I N D I N G S J O U R N A L";
|
||||||
private static final String MESSAGES_BANNER = "M E S S A G E S J O U R N A L";
|
private static final String MESSAGES_BANNER = "M E S S A G E S J O U R N A L";
|
||||||
static {
|
static {
|
||||||
|
@ -89,7 +98,7 @@ public class PrintData extends DBOption {
|
||||||
if (configuration.isJDBC()) {
|
if (configuration.isJDBC()) {
|
||||||
printDataJDBC(configuration, context.out);
|
printDataJDBC(configuration, context.out);
|
||||||
} else {
|
} else {
|
||||||
printData(new File(getBinding()), new File(getJournal()), new File(getPaging()), context.out, safe, reclaimed);
|
printData(new File(getBinding()), new File(getJournal()), new File(getPaging()), context.out, safe, reclaimed, skipBindings, skipJournal, maxPages);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
treatError(e, "data", "print");
|
treatError(e, "data", "print");
|
||||||
|
@ -111,7 +120,7 @@ public class PrintData extends DBOption {
|
||||||
|
|
||||||
DescribeJournal describeJournal = DescribeJournal.printSurvivingRecords(storageManager.getMessageJournal(), out, safe);
|
DescribeJournal describeJournal = DescribeJournal.printSurvivingRecords(storageManager.getMessageJournal(), out, safe);
|
||||||
|
|
||||||
printPages(describeJournal, storageManager, pagingmanager, out, safe);
|
printPages(describeJournal, storageManager, pagingmanager, out, safe, maxPages);
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
|
@ -121,14 +130,19 @@ public class PrintData extends DBOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory, boolean secret) throws Exception {
|
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory, boolean secret) throws Exception {
|
||||||
printData(bindingsDirectory, messagesDirectory, pagingDirectory, System.out, secret, false);
|
printData(bindingsDirectory, messagesDirectory, pagingDirectory, System.out, secret, false, false, false, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory, PrintStream out, boolean secret) throws Exception {
|
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory, PrintStream out, boolean secret) throws Exception {
|
||||||
printData(bindingsDirectory, messagesDirectory, pagingDirectory, out, secret, false);
|
printData(bindingsDirectory, messagesDirectory, pagingDirectory, out, secret, false, false, false, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory, PrintStream out, boolean safe, boolean reclaimed) throws Exception {
|
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory, PrintStream out, boolean safe, boolean reclaimed) throws Exception {
|
||||||
|
printData(bindingsDirectory, messagesDirectory, pagingDirectory, out, safe, reclaimed, false, false, -1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printData(File bindingsDirectory, File messagesDirectory, File pagingDirectory, PrintStream out, boolean safe, boolean reclaimed, boolean skipBindings, boolean skipJournal, int maxPages) throws Exception {
|
||||||
// printing the banner and version
|
// printing the banner and version
|
||||||
Artemis.printBanner(out);
|
Artemis.printBanner(out);
|
||||||
|
|
||||||
|
@ -146,21 +160,33 @@ public class PrintData extends DBOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
printBanner(out, BINDINGS_BANNER);
|
printBanner(out, BINDINGS_BANNER);
|
||||||
|
if (skipBindings) {
|
||||||
printBindings(bindingsDirectory, out, safe, true, true, reclaimed);
|
out.println(".... skipping");
|
||||||
|
out.println();
|
||||||
|
} else {
|
||||||
|
printBindings(bindingsDirectory, out, safe, true, true, reclaimed);
|
||||||
|
}
|
||||||
|
|
||||||
printBanner(out, MESSAGES_BANNER);
|
printBanner(out, MESSAGES_BANNER);
|
||||||
|
if (skipJournal) {
|
||||||
|
out.println(".... skipping");
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
DescribeJournal describeJournal = null;
|
DescribeJournal describeJournal = null;
|
||||||
describeJournal = printMessages(messagesDirectory, out, safe, true, true, reclaimed);
|
describeJournal = printMessages(messagesDirectory, out, safe, !skipJournal, !skipJournal, reclaimed);
|
||||||
|
|
||||||
if (describeJournal == null) {
|
if (describeJournal == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
printBanner(out, "P A G I N G");
|
printBanner(out, "P A G I N G");
|
||||||
|
if (maxPages == 0) {
|
||||||
printPages(pagingDirectory, describeJournal, out, safe);
|
out.println(".... skipping");
|
||||||
|
out.println();
|
||||||
|
} else {
|
||||||
|
printPages(pagingDirectory, describeJournal, out, safe, maxPages);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
|
@ -195,6 +221,10 @@ public class PrintData extends DBOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printPages(File pageDirectory, DescribeJournal describeJournal, PrintStream out, boolean safe) {
|
private static void printPages(File pageDirectory, DescribeJournal describeJournal, PrintStream out, boolean safe) {
|
||||||
|
printPages(pageDirectory, describeJournal, out, safe, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printPages(File pageDirectory, DescribeJournal describeJournal, PrintStream out, boolean safe, int maxPages) {
|
||||||
ActiveMQThreadFactory daemonFactory = new ActiveMQThreadFactory("cli", true, PrintData.class.getClassLoader());
|
ActiveMQThreadFactory daemonFactory = new ActiveMQThreadFactory("cli", true, PrintData.class.getClassLoader());
|
||||||
final ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1, daemonFactory);
|
final ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(1, daemonFactory);
|
||||||
final ExecutorService executor = Executors.newFixedThreadPool(10, daemonFactory);
|
final ExecutorService executor = Executors.newFixedThreadPool(10, daemonFactory);
|
||||||
|
@ -212,7 +242,7 @@ public class PrintData extends DBOption {
|
||||||
addressSettingsRepository.setDefault(new AddressSettings());
|
addressSettingsRepository.setDefault(new AddressSettings());
|
||||||
PagingManager manager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository);
|
PagingManager manager = new PagingManagerImpl(pageStoreFactory, addressSettingsRepository);
|
||||||
|
|
||||||
printPages(describeJournal, sm, manager, out, safe);
|
printPages(describeJournal, sm, manager, out, safe, maxPages);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -225,7 +255,7 @@ public class PrintData extends DBOption {
|
||||||
StorageManager sm,
|
StorageManager sm,
|
||||||
PagingManager manager,
|
PagingManager manager,
|
||||||
PrintStream out,
|
PrintStream out,
|
||||||
boolean safe) throws Exception {
|
boolean safe, int maxPages) throws Exception {
|
||||||
PageCursorsInfo cursorACKs = calculateCursorsInfo(describeJournal.getRecords());
|
PageCursorsInfo cursorACKs = calculateCursorsInfo(describeJournal.getRecords());
|
||||||
|
|
||||||
Set<Long> pgTXs = cursorACKs.getPgTXs();
|
Set<Long> pgTXs = cursorACKs.getPgTXs();
|
||||||
|
@ -244,6 +274,10 @@ public class PrintData extends DBOption {
|
||||||
out.println("Exploring store " + store + " folder = " + folder);
|
out.println("Exploring store " + store + " folder = " + folder);
|
||||||
int pgid = (int) pgStore.getFirstPage();
|
int pgid = (int) pgStore.getFirstPage();
|
||||||
for (int pg = 0; pg < pgStore.getNumberOfPages(); pg++) {
|
for (int pg = 0; pg < pgStore.getNumberOfPages(); pg++) {
|
||||||
|
if (maxPages >= 0 && pg > maxPages) {
|
||||||
|
out.println("******* Giving up at Page " + pgid + ", System has a total of " + pgStore.getNumberOfPages() + " pages");
|
||||||
|
break;
|
||||||
|
}
|
||||||
out.println("******* Page " + pgid);
|
out.println("******* Page " + pgid);
|
||||||
Page page = pgStore.createPage(pgid);
|
Page page = pgStore.createPage(pgid);
|
||||||
page.open();
|
page.open();
|
||||||
|
@ -265,6 +299,7 @@ public class PrintData extends DBOption {
|
||||||
}
|
}
|
||||||
out.print(",Queues = ");
|
out.print(",Queues = ");
|
||||||
long[] q = msg.getQueueIDs();
|
long[] q = msg.getQueueIDs();
|
||||||
|
int ackCount = 0;
|
||||||
for (int i = 0; i < q.length; i++) {
|
for (int i = 0; i < q.length; i++) {
|
||||||
out.print(q[i]);
|
out.print(q[i]);
|
||||||
|
|
||||||
|
@ -282,9 +317,14 @@ public class PrintData extends DBOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursorACKs.getCompletePages(q[i]).contains(Long.valueOf(pgid))) {
|
if (cursorACKs.getCompletePages(q[i]).contains(Long.valueOf(pgid))) {
|
||||||
|
acked = true;
|
||||||
out.print(" (PG-COMPLETE)");
|
out.print(" (PG-COMPLETE)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (acked) {
|
||||||
|
ackCount++;
|
||||||
|
}
|
||||||
|
|
||||||
if (i + 1 < q.length) {
|
if (i + 1 < q.length) {
|
||||||
out.print(",");
|
out.print(",");
|
||||||
}
|
}
|
||||||
|
@ -293,6 +333,11 @@ public class PrintData extends DBOption {
|
||||||
out.print(", **PG_TX_NOT_FOUND**");
|
out.print(", **PG_TX_NOT_FOUND**");
|
||||||
}
|
}
|
||||||
out.println();
|
out.println();
|
||||||
|
|
||||||
|
if (ackCount != q.length) {
|
||||||
|
out.println("^^^ Previous record has " + ackCount + " acked queues and " + q.length + " queues routed");
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
msgID++;
|
msgID++;
|
||||||
}
|
}
|
||||||
pgid++;
|
pgid++;
|
||||||
|
|
Loading…
Reference in New Issue