Skip to content

Commit

Permalink
remote rename failure: NullPointerException (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
gangliao committed Jun 10, 2020
1 parent e4dd3f9 commit 0e49c6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,8 @@ public void remoteLogOpenFile(INodeFile newNode, String nameNodeAddress) {
INodeSection.INode r = INodeSection.INode.newBuilder()
.setId(newNode.getId())
.setName(ByteString.copyFrom(newNode.getLocalNameBytes()))
.setType(INodeSection.INode.Type.FILE).setFile(b).build();
.setType(INodeSection.INode.Type.FILE).setFile(b)
.setParent(newNode.getParentId()).build();

byte[] data = r.toByteArray();
FSEditLogProtocol proxy = (FSEditLogProtocol) RPC.getProxy(
Expand Down Expand Up @@ -972,7 +973,8 @@ public void remoteLogMkDir(INodeDirectory newNode, String nameNodeAddress) {
INodeSection.INode r = INodeSection.INode.newBuilder()
.setId(newNode.getId())
.setName(ByteString.copyFrom(newNode.getLocalNameBytes()))
.setType(INodeSection.INode.Type.DIRECTORY).setDirectory(b).build();
.setType(INodeSection.INode.Type.DIRECTORY).setDirectory(b)
.setParent(newNode.getParentId()).build();

byte[] data = r.toByteArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public INodeFile loadINodeFile(INodeSection.INode n) {
file.setBlock(file.numBlocks() - 1, ucBlk);
}
}

// set parent
file.setParent(f.getParent());
return file;
}

Expand All @@ -153,6 +156,9 @@ public INodeDirectory loadINodeDirectory(INodeSection.INode n) {
if (d.hasXAttrs()) {
dir.addXAttrFeature(new XAttrFeature(dir.getId(), loadXAttrs(d.getXAttrs(), null)));
}

// set parent
dir.setParent(d.getParent());
return dir;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,19 @@ public final INodeDirectory getParent() {
INode dir = INodeKeyedObjects.getCache().getIfPresent(Long.class, id);
if (dir == null) {
dir = new INodeDirectory(id);
DatabaseINode.LoadINode node = new DatabaseINode().loadINode(id);
byte[] name = (node.name != null && node.name.length() > 0) ? DFSUtil.string2Bytes(node.name) : null;
dir
.asDirectory()
.InitINodeDirectory(
node.parent,
node.id,
name,
node.permission,
node.modificationTime,
node.accessTime,
node.header);

INodeKeyedObjects.getCache().put(
new CompositeKey((Long)id,
new ImmutablePair<>(dir.getParentId(), dir.getLocalName())), dir.asDirectory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ public void localRename(INode node) {
}

public void remoteRename(INode node, String address) {
String name = DFSUtil.bytes2String(node.getLocalNameBytes());
// String name = DFSUtil.bytes2String(node.getLocalNameBytes());
if (node.isDirectory()) {
INodeDirectory inode = node.asDirectory().copyINodeDirectory();
inode.setId(node.getId() + NameNode.getId());
Expand Down

0 comments on commit 0e49c6d

Please sign in to comment.