diff --git a/hadoop-hdfs-project/hadoop-hdfs-db/src/main/java/org/apache/hadoop/hdfs/db/DatabaseINode.java b/hadoop-hdfs-project/hadoop-hdfs-db/src/main/java/org/apache/hadoop/hdfs/db/DatabaseINode.java index 9cdf58f05f7..06214405d89 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-db/src/main/java/org/apache/hadoop/hdfs/db/DatabaseINode.java +++ b/hadoop-hdfs-project/hadoop-hdfs-db/src/main/java/org/apache/hadoop/hdfs/db/DatabaseINode.java @@ -79,7 +79,7 @@ long getHeader() { } } - public static LoadINode loadINode(final long id) { + public LoadINode loadINode(final long id) { LoadINode res = null; try { DatabaseConnection obj = Database.getInstance().getConnection(); @@ -135,7 +135,7 @@ public static LoadINode loadINode(final long id) { return res; } - public static LoadINode loadINode(final long parentId, final String childName) { + public LoadINode loadINode(final long parentId, final String childName) { LoadINode res = null; try { DatabaseConnection obj = Database.getInstance().getConnection(); @@ -165,7 +165,8 @@ public static LoadINode loadINode(final long parentId, final String childName) { String sql = "SELECT parent, id, name, permission, modificationTime, accessTime, header FROM inodes WHERE parent = ? AND name = ?;"; PreparedStatement pst = conn.prepareStatement(sql); - pst.setLong(1, id); + pst.setLong(1, parentId); + pst.setString(2, childName); ResultSet rs = pst.executeQuery(); while (rs.next()) { res = @@ -187,7 +188,7 @@ public static LoadINode loadINode(final long parentId, final String childName) { } if (LOG.isInfoEnabled()) { - LOG.info("Load INode [GET]: (" + id + ")"); + LOG.info("Load INode [GET]: (" + parentId + ", " + childName + ")"); } return res; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java index 5e5e28f5c91..8516ed0f8c6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java @@ -55,7 +55,7 @@ public long size() { public INode get(long id) { INode inode = INodeKeyedObjects.getCache().getIfPresent(Long.class, id); if (inode == null) { - DatabaseINode.LoadINode node = DatabaseINode.loadINode(id); + DatabaseINode.LoadINode node = new DatabaseINode().loadINode(id); byte[] name = (node.name != null) ? DFSUtil.string2Bytes(node.name) : null; if (node.header != 0L) { inode = new INodeFile(node.id); @@ -96,7 +96,7 @@ public INode get(long parentId, String childName) { INodeKeyedObjects.getCache() .getIfPresent(Pair.class, new ImmutablePair<>((Long) parentId, childName)); if (inode == null) { - DatabaseINode.LoadINode node = DatabaseINode.loadINode(parentId, childName); + DatabaseINode.LoadINode node = new DatabaseINode().loadINode(parentId, childName); byte[] name = (node.name != null) ? DFSUtil.string2Bytes(node.name) : null; if (node.header != 0L) { inode = new INodeFile(node.id);