|
@@ -49,7 +49,7 @@ import static org.apache.hadoop.hdfs.tools.offlineEditsViewer.Tokenizer.EmptyTok
|
|
|
class EditsLoaderCurrent implements EditsLoader {
|
|
|
|
|
|
private static int [] supportedVersions = {
|
|
|
- -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28 };
|
|
|
+ -18, -19, -20, -21, -22, -23, -24, -25, -26, -27 };
|
|
|
|
|
|
private EditsVisitor v;
|
|
|
private int editsVersion = 0;
|
|
@@ -77,9 +77,7 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_INVALID
|
|
|
*/
|
|
|
private void visit_OP_INVALID() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
+ ; // nothing to do, this op code has no data
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -103,9 +101,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
*/
|
|
|
private void visit_OP_ADD_or_OP_CLOSE(FSEditLogOpCodes editsOpCode)
|
|
|
throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
|
|
|
IntToken opAddLength = v.visitInt(EditsElement.LENGTH);
|
|
|
// this happens if the edits is not properly ended (-1 op code),
|
|
@@ -149,10 +144,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_RENAME_OLD
|
|
|
*/
|
|
|
private void visit_OP_RENAME_OLD() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitInt( EditsElement.LENGTH);
|
|
|
v.visitStringUTF8( EditsElement.SOURCE);
|
|
|
v.visitStringUTF8( EditsElement.DESTINATION);
|
|
@@ -163,10 +154,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_DELETE
|
|
|
*/
|
|
|
private void visit_OP_DELETE() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitInt( EditsElement.LENGTH);
|
|
|
v.visitStringUTF8( EditsElement.PATH);
|
|
|
v.visitStringUTF8( EditsElement.TIMESTAMP);
|
|
@@ -176,10 +163,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_MKDIR
|
|
|
*/
|
|
|
private void visit_OP_MKDIR() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitInt( EditsElement.LENGTH);
|
|
|
v.visitStringUTF8( EditsElement.PATH);
|
|
|
v.visitStringUTF8( EditsElement.TIMESTAMP);
|
|
@@ -198,10 +181,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_SET_REPLICATION
|
|
|
*/
|
|
|
private void visit_OP_SET_REPLICATION() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitStringUTF8(EditsElement.PATH);
|
|
|
v.visitStringUTF8(EditsElement.REPLICATION);
|
|
|
}
|
|
@@ -210,10 +189,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_SET_PERMISSIONS
|
|
|
*/
|
|
|
private void visit_OP_SET_PERMISSIONS() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitStringUTF8( EditsElement.PATH);
|
|
|
v.visitShort( EditsElement.FS_PERMISSIONS);
|
|
|
}
|
|
@@ -222,10 +197,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_SET_OWNER
|
|
|
*/
|
|
|
private void visit_OP_SET_OWNER() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitStringUTF8(EditsElement.PATH);
|
|
|
v.visitStringUTF8(EditsElement.USERNAME);
|
|
|
v.visitStringUTF8(EditsElement.GROUPNAME);
|
|
@@ -235,10 +206,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_SET_GENSTAMP
|
|
|
*/
|
|
|
private void visit_OP_SET_GENSTAMP() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitLong(EditsElement.GENERATION_STAMP);
|
|
|
}
|
|
|
|
|
@@ -246,10 +213,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_TIMES
|
|
|
*/
|
|
|
private void visit_OP_TIMES() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitInt( EditsElement.LENGTH);
|
|
|
v.visitStringUTF8( EditsElement.PATH);
|
|
|
v.visitStringUTF8( EditsElement.MTIME);
|
|
@@ -260,10 +223,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_SET_QUOTA
|
|
|
*/
|
|
|
private void visit_OP_SET_QUOTA() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitStringUTF8( EditsElement.PATH);
|
|
|
v.visitLong( EditsElement.NS_QUOTA);
|
|
|
v.visitLong( EditsElement.DS_QUOTA);
|
|
@@ -273,10 +232,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_RENAME
|
|
|
*/
|
|
|
private void visit_OP_RENAME() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
if(editsVersion > -21) {
|
|
|
throw new IOException("Unexpected op code " + FSEditLogOpCodes.OP_RENAME
|
|
|
+ " for edit log version " + editsVersion
|
|
@@ -293,10 +248,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_CONCAT_DELETE
|
|
|
*/
|
|
|
private void visit_OP_CONCAT_DELETE() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
if(editsVersion > -22) {
|
|
|
throw new IOException("Unexpected op code "
|
|
|
+ FSEditLogOpCodes.OP_CONCAT_DELETE
|
|
@@ -317,10 +268,6 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_SYMLINK
|
|
|
*/
|
|
|
private void visit_OP_SYMLINK() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
v.visitInt( EditsElement.LENGTH);
|
|
|
v.visitStringUTF8( EditsElement.SOURCE);
|
|
|
v.visitStringUTF8( EditsElement.DESTINATION);
|
|
@@ -340,25 +287,21 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
* Visit OP_GET_DELEGATION_TOKEN
|
|
|
*/
|
|
|
private void visit_OP_GET_DELEGATION_TOKEN() throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
- if(editsVersion > -24) {
|
|
|
- throw new IOException("Unexpected op code "
|
|
|
+ if(editsVersion > -24) {
|
|
|
+ throw new IOException("Unexpected op code "
|
|
|
+ FSEditLogOpCodes.OP_GET_DELEGATION_TOKEN
|
|
|
+ " for edit log version " + editsVersion
|
|
|
+ " (op code 18 only expected for 24 and later)");
|
|
|
- }
|
|
|
- v.visitByte( EditsElement.T_VERSION);
|
|
|
- v.visitStringText( EditsElement.T_OWNER);
|
|
|
- v.visitStringText( EditsElement.T_RENEWER);
|
|
|
- v.visitStringText( EditsElement.T_REAL_USER);
|
|
|
- v.visitVLong( EditsElement.T_ISSUE_DATE);
|
|
|
- v.visitVLong( EditsElement.T_MAX_DATE);
|
|
|
- v.visitVInt( EditsElement.T_SEQUENCE_NUMBER);
|
|
|
- v.visitVInt( EditsElement.T_MASTER_KEY_ID);
|
|
|
- v.visitStringUTF8( EditsElement.T_EXPIRY_TIME);
|
|
|
+ }
|
|
|
+ v.visitByte( EditsElement.T_VERSION);
|
|
|
+ v.visitStringText( EditsElement.T_OWNER);
|
|
|
+ v.visitStringText( EditsElement.T_RENEWER);
|
|
|
+ v.visitStringText( EditsElement.T_REAL_USER);
|
|
|
+ v.visitVLong( EditsElement.T_ISSUE_DATE);
|
|
|
+ v.visitVLong( EditsElement.T_MAX_DATE);
|
|
|
+ v.visitVInt( EditsElement.T_SEQUENCE_NUMBER);
|
|
|
+ v.visitVInt( EditsElement.T_MASTER_KEY_ID);
|
|
|
+ v.visitStringUTF8( EditsElement.T_EXPIRY_TIME);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -366,25 +309,22 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
*/
|
|
|
private void visit_OP_RENEW_DELEGATION_TOKEN()
|
|
|
throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
|
|
|
- if(editsVersion > -24) {
|
|
|
- throw new IOException("Unexpected op code "
|
|
|
+ if(editsVersion > -24) {
|
|
|
+ throw new IOException("Unexpected op code "
|
|
|
+ FSEditLogOpCodes.OP_RENEW_DELEGATION_TOKEN
|
|
|
+ " for edit log version " + editsVersion
|
|
|
+ " (op code 19 only expected for 24 and later)");
|
|
|
- }
|
|
|
- v.visitByte( EditsElement.T_VERSION);
|
|
|
- v.visitStringText( EditsElement.T_OWNER);
|
|
|
- v.visitStringText( EditsElement.T_RENEWER);
|
|
|
- v.visitStringText( EditsElement.T_REAL_USER);
|
|
|
- v.visitVLong( EditsElement.T_ISSUE_DATE);
|
|
|
- v.visitVLong( EditsElement.T_MAX_DATE);
|
|
|
- v.visitVInt( EditsElement.T_SEQUENCE_NUMBER);
|
|
|
- v.visitVInt( EditsElement.T_MASTER_KEY_ID);
|
|
|
- v.visitStringUTF8( EditsElement.T_EXPIRY_TIME);
|
|
|
+ }
|
|
|
+ v.visitByte( EditsElement.T_VERSION);
|
|
|
+ v.visitStringText( EditsElement.T_OWNER);
|
|
|
+ v.visitStringText( EditsElement.T_RENEWER);
|
|
|
+ v.visitStringText( EditsElement.T_REAL_USER);
|
|
|
+ v.visitVLong( EditsElement.T_ISSUE_DATE);
|
|
|
+ v.visitVLong( EditsElement.T_MAX_DATE);
|
|
|
+ v.visitVInt( EditsElement.T_SEQUENCE_NUMBER);
|
|
|
+ v.visitVInt( EditsElement.T_MASTER_KEY_ID);
|
|
|
+ v.visitStringUTF8( EditsElement.T_EXPIRY_TIME);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -392,24 +332,21 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
*/
|
|
|
private void visit_OP_CANCEL_DELEGATION_TOKEN()
|
|
|
throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
|
|
|
- if(editsVersion > -24) {
|
|
|
- throw new IOException("Unexpected op code "
|
|
|
+ if(editsVersion > -24) {
|
|
|
+ throw new IOException("Unexpected op code "
|
|
|
+ FSEditLogOpCodes.OP_CANCEL_DELEGATION_TOKEN
|
|
|
+ " for edit log version " + editsVersion
|
|
|
+ " (op code 20 only expected for 24 and later)");
|
|
|
- }
|
|
|
- v.visitByte( EditsElement.T_VERSION);
|
|
|
- v.visitStringText( EditsElement.T_OWNER);
|
|
|
- v.visitStringText( EditsElement.T_RENEWER);
|
|
|
- v.visitStringText( EditsElement.T_REAL_USER);
|
|
|
- v.visitVLong( EditsElement.T_ISSUE_DATE);
|
|
|
- v.visitVLong( EditsElement.T_MAX_DATE);
|
|
|
- v.visitVInt( EditsElement.T_SEQUENCE_NUMBER);
|
|
|
- v.visitVInt( EditsElement.T_MASTER_KEY_ID);
|
|
|
+ }
|
|
|
+ v.visitByte( EditsElement.T_VERSION);
|
|
|
+ v.visitStringText( EditsElement.T_OWNER);
|
|
|
+ v.visitStringText( EditsElement.T_RENEWER);
|
|
|
+ v.visitStringText( EditsElement.T_REAL_USER);
|
|
|
+ v.visitVLong( EditsElement.T_ISSUE_DATE);
|
|
|
+ v.visitVLong( EditsElement.T_MAX_DATE);
|
|
|
+ v.visitVInt( EditsElement.T_SEQUENCE_NUMBER);
|
|
|
+ v.visitVInt( EditsElement.T_MASTER_KEY_ID);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -417,20 +354,17 @@ class EditsLoaderCurrent implements EditsLoader {
|
|
|
*/
|
|
|
private void visit_OP_UPDATE_MASTER_KEY()
|
|
|
throws IOException {
|
|
|
- if(editsVersion <= -28) {
|
|
|
- v.visitLong(EditsElement.TRANSACTION_ID);
|
|
|
- }
|
|
|
-
|
|
|
- if(editsVersion > -24) {
|
|
|
- throw new IOException("Unexpected op code "
|
|
|
+
|
|
|
+ if(editsVersion > -24) {
|
|
|
+ throw new IOException("Unexpected op code "
|
|
|
+ FSEditLogOpCodes.OP_UPDATE_MASTER_KEY
|
|
|
+ " for edit log version " + editsVersion
|
|
|
+ "(op code 21 only expected for 24 and later)");
|
|
|
- }
|
|
|
- v.visitVInt( EditsElement.KEY_ID);
|
|
|
- v.visitVLong( EditsElement.KEY_EXPIRY_DATE);
|
|
|
- VIntToken blobLengthToken = v.visitVInt(EditsElement.KEY_LENGTH);
|
|
|
- v.visitBlob(EditsElement.KEY_BLOB, blobLengthToken.value);
|
|
|
+ }
|
|
|
+ v.visitVInt( EditsElement.KEY_ID);
|
|
|
+ v.visitVLong( EditsElement.KEY_EXPIRY_DATE);
|
|
|
+ VIntToken blobLengthToken = v.visitVInt(EditsElement.KEY_LENGTH);
|
|
|
+ v.visitBlob(EditsElement.KEY_BLOB, blobLengthToken.value);
|
|
|
}
|
|
|
|
|
|
private void visitOpCode(FSEditLogOpCodes editsOpCode)
|