dump an index

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@634490 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-03-07 01:01:18 +00:00
parent 88fbb05af5
commit bb763f5f7a
1 changed files with 22 additions and 2 deletions

View File

@ -17,12 +17,11 @@
package org.apache.activemq.kaha.impl.index.hash;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.activemq.kaha.Marshaller;
import org.apache.activemq.kaha.StoreEntry;
import org.apache.activemq.kaha.impl.index.Index;
@ -210,6 +209,26 @@ public class HashIndex implements Index, HashIndexMBean {
}
}
public void dump() throws IOException {
long offset = 0;
readBuffer = new byte[pageSize];
dataIn = new DataByteArrayInputStream();
dataOut = new DataByteArrayOutputStream(pageSize);
int count = 0;
while ((offset + pageSize) <= indexFile.length()) {
indexFile.seek(offset);
HashPage page = getFullPage(offset);
if (page.isActive()) {
for (HashEntry entry : page.getEntries()) {
count++;
System.out.println("PAGE( " + count + ") " + page.getId() + ": " + entry);
}
}
offset += pageSize;
}
}
public synchronized void unload() throws IOException {
@ -454,6 +473,7 @@ public class HashIndex implements Index, HashIndexMBean {
backIndex.size++;
}
}
page=null;
offset += pageSize;
}
backIndex.unload();