提交 54f91e94 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Improved logging

上级 67ea49f6
...@@ -113,9 +113,9 @@ public class MVStoreTool { ...@@ -113,9 +113,9 @@ public class MVStoreTool {
block.rewind(); block.rewind();
int headerType = block.get(); int headerType = block.get();
if (headerType == 'H') { if (headerType == 'H') {
String header = new String(block.array(), DataUtils.LATIN).trim();
pw.printf("%0" + len + "x fileHeader %s%n", pw.printf("%0" + len + "x fileHeader %s%n",
pos, pos, header);
new String(block.array(), DataUtils.LATIN).trim());
pos += blockSize; pos += blockSize;
continue; continue;
} }
......
...@@ -311,6 +311,50 @@ public class StreamStore { ...@@ -311,6 +311,50 @@ public class StreamStore {
} }
} }
/**
* Convert the id to a human readable string.
*
* @param id the stream id
* @return the string
*/
public static String toString(byte[] id) {
StringBuilder buff = new StringBuilder();
ByteBuffer idBuffer = ByteBuffer.wrap(id);
long length = 0;
while (idBuffer.hasRemaining()) {
long block;
int len;
switch (idBuffer.get()) {
case 0:
// in-place: 0, len (int), data
len = DataUtils.readVarInt(idBuffer);
idBuffer.position(idBuffer.position() + len);
buff.append("data len=").append(len);
length += len;
break;
case 1:
// block: 1, len (int), blockId (long)
len = DataUtils.readVarInt(idBuffer);
length += len;
block = DataUtils.readVarLong(idBuffer);
buff.append("block ").append(block).append(" len=").append(len);
break;
case 2:
// indirect: 2, total len (long), blockId (long)
len = DataUtils.readVarInt(idBuffer);
length += DataUtils.readVarLong(idBuffer);
block = DataUtils.readVarLong(idBuffer);
buff.append("indirect block ").append(block).append(" len=").append(len);
break;
default:
buff.append("error");
}
buff.append(", ");
}
buff.append("length=").append(length);
return buff.toString();
}
/** /**
* Calculate the number of data bytes for the given id. As the length is * Calculate the number of data bytes for the given id. As the length is
* encoded in the id, this operation does not cause any reads in the map. * encoded in the id, this operation does not cause any reads in the map.
......
...@@ -691,11 +691,13 @@ public class Recover extends Tool implements DataHandler { ...@@ -691,11 +691,13 @@ public class Recover extends Tool implements DataHandler {
MVMap<Long, byte[]> lobData = mv.openMap("lobData"); MVMap<Long, byte[]> lobData = mv.openMap("lobData");
StreamStore streamStore = new StreamStore(lobData); StreamStore streamStore = new StreamStore(lobData);
MVMap<Long, Object[]> lobMap = mv.openMap("lobMap"); MVMap<Long, Object[]> lobMap = mv.openMap("lobMap");
writer.println("-- LOB"); writer.println("-- LOB (lobMap.id=0x" + Integer.toHexString(lobMap.getId()) +
", lobData.id=0x" + Integer.toHexString(lobData.getId()) + ")");
writer.println("CREATE TABLE IF NOT EXISTS " + writer.println("CREATE TABLE IF NOT EXISTS " +
"INFORMATION_SCHEMA.LOB_BLOCKS(" + "INFORMATION_SCHEMA.LOB_BLOCKS(" +
"LOB_ID BIGINT, SEQ INT, DATA BINARY, " + "LOB_ID BIGINT, SEQ INT, DATA BINARY, " +
"PRIMARY KEY(LOB_ID, SEQ));"); "PRIMARY KEY(LOB_ID, SEQ));");
boolean hasErrors = false;
for (Entry<Long, Object[]> e : lobMap.entrySet()) { for (Entry<Long, Object[]> e : lobMap.entrySet()) {
long lobId = e.getKey(); long lobId = e.getKey();
Object[] value = e.getValue(); Object[] value = e.getValue();
...@@ -717,6 +719,19 @@ public class Recover extends Tool implements DataHandler { ...@@ -717,6 +719,19 @@ public class Recover extends Tool implements DataHandler {
} }
} catch (IOException ex) { } catch (IOException ex) {
writeError(writer, ex); writeError(writer, ex);
hasErrors = true;
}
}
if (hasErrors) {
writer.println("-- lobMap");
for (Long k : lobMap.keyList()) {
Object[] value = lobMap.get(k);
byte[] streamStoreId = (byte[]) value[0];
writer.println("-- " + k + " " + StreamStore.toString(streamStoreId));
}
writer.println("-- lobData");
for (Long k : lobData.keyList()) {
writer.println("-- " + k + " len " + lobData.get(k).length);
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论