HDFS-10265. OEV tool fails to read edit xml file if OP_UPDATE_BLOCKS has no BLOCK tag (Wan Chang via cmccabe)
(cherry picked from commitcb3ca460ef
) (cherry picked from commita69b6b1e8b
)
This commit is contained in:
parent
92e45b8321
commit
e1d9e5ab82
|
@ -1113,7 +1113,8 @@ public abstract class FSEditLogOp {
|
||||||
|
|
||||||
@Override void fromXml(Stanza st) throws InvalidXmlException {
|
@Override void fromXml(Stanza st) throws InvalidXmlException {
|
||||||
this.path = st.getValue("PATH");
|
this.path = st.getValue("PATH");
|
||||||
List<Stanza> blocks = st.getChildren("BLOCK");
|
List<Stanza> blocks = st.hasChildren("BLOCK") ?
|
||||||
|
st.getChildren("BLOCK") : new ArrayList<Stanza>();
|
||||||
this.blocks = new Block[blocks.size()];
|
this.blocks = new Block[blocks.size()];
|
||||||
for (int i = 0; i < blocks.size(); i++) {
|
for (int i = 0; i < blocks.size(); i++) {
|
||||||
this.blocks[i] = FSEditLogOp.blockFromXml(blocks.get(i));
|
this.blocks[i] = FSEditLogOp.blockFromXml(blocks.get(i));
|
||||||
|
|
|
@ -1267,6 +1267,18 @@ public class DFSTestUtil {
|
||||||
// OP_APPEND 47
|
// OP_APPEND 47
|
||||||
FSDataOutputStream s2 = filesystem.append(pathFileCreate, 4096, null);
|
FSDataOutputStream s2 = filesystem.append(pathFileCreate, 4096, null);
|
||||||
s2.close();
|
s2.close();
|
||||||
|
|
||||||
|
// OP_UPDATE_BLOCKS 25
|
||||||
|
final String updateBlockFile = "/update_blocks";
|
||||||
|
FSDataOutputStream fout = filesystem.create(new Path(updateBlockFile), true, 4096, (short)1, 4096L);
|
||||||
|
fout.write(1);
|
||||||
|
fout.hflush();
|
||||||
|
long fileId = ((DFSOutputStream)fout.getWrappedStream()).getFileId();
|
||||||
|
DFSClient dfsclient = DFSClientAdapter.getDFSClient(filesystem);
|
||||||
|
LocatedBlocks blocks = dfsclient.getNamenode().getBlockLocations(updateBlockFile, 0, Integer.MAX_VALUE);
|
||||||
|
dfsclient.getNamenode().abandonBlock(blocks.get(0).getBlock(), fileId, updateBlockFile, dfsclient.clientName);
|
||||||
|
fout.close();
|
||||||
|
|
||||||
// OP_SET_STORAGE_POLICY 45
|
// OP_SET_STORAGE_POLICY 45
|
||||||
filesystem.setStoragePolicy(pathFileCreate,
|
filesystem.setStoragePolicy(pathFileCreate,
|
||||||
HdfsConstants.HOT_STORAGE_POLICY_NAME);
|
HdfsConstants.HOT_STORAGE_POLICY_NAME);
|
||||||
|
|
Loading…
Reference in New Issue