HDFS-2073. Add @Override annotation to NameNode. Contributed by Suresh Srinivas.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1136230 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2011-06-15 22:41:46 +00:00
parent 4c290b51fa
commit 53268e2155
2 changed files with 82 additions and 139 deletions

View File

@ -508,6 +508,8 @@ Trunk (unreleased changes)
HDFS-2046. Force entropy to come from non-true random for tests. (todd)
HDFS-2073. Add @Override annotation to NameNode. (suresh)
OPTIMIZATIONS
HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

View File

@ -194,7 +194,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
}
@Override
@Override // VersionedProtocol
public ProtocolSignature getProtocolSignature(String protocol,
long clientVersion, int clientMethodsHash) throws IOException {
return ProtocolSignature.getProtocolSignature(
@ -694,7 +694,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return namesystem.getBlocks(datanode, size);
}
/** {@inheritDoc} */
@Override // NamenodeProtocol
public ExportedBlockKeys getBlockKeys() throws IOException {
return namesystem.getBlockKeys();
}
@ -742,39 +742,34 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return namesystem.getEditLogSize();
}
/*
* Active name-node cannot journal.
*/
@Override // NamenodeProtocol
public void journal(NamenodeRegistration registration,
int jAction,
int length,
byte[] args) throws IOException {
// Active name-node cannot journal.
throw new UnsupportedActionException("journal");
}
/////////////////////////////////////////////////////
// ClientProtocol
/////////////////////////////////////////////////////
@Override // ClientProtocol
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
throws IOException {
return namesystem.getDelegationToken(renewer);
}
@Override
@Override // ClientProtocol
public long renewDelegationToken(Token<DelegationTokenIdentifier> token)
throws InvalidToken, IOException {
return namesystem.renewDelegationToken(token);
}
@Override
@Override // ClientProtocol
public void cancelDelegationToken(Token<DelegationTokenIdentifier> token)
throws IOException {
namesystem.cancelDelegationToken(token);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public LocatedBlocks getBlockLocations(String src,
long offset,
long length)
@ -784,20 +779,12 @@ public class NameNode implements NamenodeProtocols, FSConstants {
src, offset, length);
}
private static String getClientMachine() {
String clientMachine = Server.getRemoteAddress();
if (clientMachine == null) {
clientMachine = "";
}
return clientMachine;
}
/** {@inheritDoc} */
@Override // ClientProtocol
public FsServerDefaults getServerDefaults() throws IOException {
return namesystem.getServerDefaults();
}
/** {@inheritDoc} */
@Override // ClientProtocol
public void create(String src,
FsPermission masked,
String clientName,
@ -822,7 +809,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
metrics.incrCreateFileOps();
}
/** {@inheritDoc} */
@Override // ClientProtocol
public LocatedBlock append(String src, String clientName)
throws IOException {
String clientMachine = getClientMachine();
@ -835,31 +822,31 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return info;
}
/** {@inheritDoc} */
@Override // ClientProtocol
public boolean recoverLease(String src, String clientName) throws IOException {
String clientMachine = getClientMachine();
return namesystem.recoverLease(src, clientName, clientMachine);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public boolean setReplication(String src, short replication)
throws IOException {
return namesystem.setReplication(src, replication);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public void setPermission(String src, FsPermission permissions)
throws IOException {
namesystem.setPermission(src, permissions);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public void setOwner(String src, String username, String groupname)
throws IOException {
namesystem.setOwner(src, username, groupname);
}
@Override
@Override // ClientProtocol
public LocatedBlock addBlock(String src,
String clientName,
ExtendedBlock previous,
@ -883,7 +870,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return locatedBlock;
}
@Override
@Override // ClientProtocol
public LocatedBlock getAdditionalDatanode(final String src, final ExtendedBlock blk,
final DatanodeInfo[] existings, final DatanodeInfo[] excludes,
final int numAdditionalNodes, final String clientName
@ -924,7 +911,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
}
}
/** {@inheritDoc} */
@Override // ClientProtocol
public boolean complete(String src, String clientName, ExtendedBlock last)
throws IOException {
if(stateChangeLog.isDebugEnabled()) {
@ -940,6 +927,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
* mark the block as corrupt. In the future we might
* check the blocks are actually corrupt.
*/
@Override
public void reportBadBlocks(LocatedBlock[] blocks) throws IOException {
stateChangeLog.info("*DIR* NameNode.reportBadBlocks");
for (int i = 0; i < blocks.length; i++) {
@ -952,22 +940,21 @@ public class NameNode implements NamenodeProtocols, FSConstants {
}
}
/** {@inheritDoc} */
@Override
@Override // ClientProtocol
public LocatedBlock updateBlockForPipeline(ExtendedBlock block, String clientName)
throws IOException {
return namesystem.updateBlockForPipeline(block, clientName);
}
@Override
@Override // ClientProtocol
public void updatePipeline(String clientName, ExtendedBlock oldBlock,
ExtendedBlock newBlock, DatanodeID[] newNodes)
throws IOException {
namesystem.updatePipeline(clientName, oldBlock, newBlock, newNodes);
}
/** {@inheritDoc} */
@Override // DatanodeProtocol
public void commitBlockSynchronization(ExtendedBlock block,
long newgenerationstamp, long newlength,
boolean closeFile, boolean deleteblock, DatanodeID[] newtargets)
@ -976,14 +963,14 @@ public class NameNode implements NamenodeProtocols, FSConstants {
newgenerationstamp, newlength, closeFile, deleteblock, newtargets);
}
@Override // ClientProtocol
public long getPreferredBlockSize(String filename)
throws IOException {
return namesystem.getPreferredBlockSize(filename);
}
/** {@inheritDoc} */
@Deprecated
@Override
@Override // ClientProtocol
public boolean rename(String src, String dst) throws IOException {
if(stateChangeLog.isDebugEnabled()) {
stateChangeLog.debug("*DIR* NameNode.rename: " + src + " to " + dst);
@ -999,15 +986,12 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return ret;
}
/**
* {@inheritDoc}
*/
@Override // ClientProtocol
public void concat(String trg, String[] src) throws IOException {
namesystem.concat(trg, src);
}
/** {@inheritDoc} */
@Override
@Override // ClientProtocol
public void rename(String src, String dst, Options.Rename... options)
throws IOException {
if(stateChangeLog.isDebugEnabled()) {
@ -1021,14 +1005,13 @@ public class NameNode implements NamenodeProtocols, FSConstants {
metrics.incrFilesRenamed();
}
/**
*/
@Deprecated
@Override // ClientProtocol
public boolean delete(String src) throws IOException {
return delete(src, true);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public boolean delete(String src, boolean recursive) throws IOException {
if (stateChangeLog.isDebugEnabled()) {
stateChangeLog.debug("*DIR* Namenode.delete: src=" + src
@ -1044,7 +1027,6 @@ public class NameNode implements NamenodeProtocols, FSConstants {
* Check path length does not exceed maximum. Returns true if
* length and depth are okay. Returns false if length is too long
* or depth is too great.
*
*/
private boolean checkPathLength(String src) {
Path srcPath = new Path(src);
@ -1052,7 +1034,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
srcPath.depth() <= MAX_PATH_DEPTH);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public boolean mkdirs(String src, FsPermission masked, boolean createParent)
throws IOException {
if(stateChangeLog.isDebugEnabled()) {
@ -1067,15 +1049,12 @@ public class NameNode implements NamenodeProtocols, FSConstants {
null, masked), createParent);
}
/**
*/
@Override // ClientProtocol
public void renewLease(String clientName) throws IOException {
namesystem.renewLease(clientName);
}
/**
*/
@Override
@Override // ClientProtocol
public DirectoryListing getListing(String src, byte[] startAfter,
boolean needLocation)
throws IOException {
@ -1088,24 +1067,13 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return files;
}
/**
* Get the file info for a specific file.
* @param src The string representation of the path to the file
* @return object containing information regarding the file
* or null if file not found
*/
@Override // ClientProtocol
public HdfsFileStatus getFileInfo(String src) throws IOException {
metrics.incrFileInfoOps();
return namesystem.getFileInfo(src, true);
}
/**
* Get the file info for a specific file. If the path refers to a
* symlink then the FileStatus of the symlink is returned.
* @param src The string representation of the path to the file
* @return object containing information regarding the file
* or null if file not found
*/
@Override // ClientProtocol
public HdfsFileStatus getFileLinkInfo(String src) throws IOException {
metrics.incrFileInfoOps();
return namesystem.getFileInfo(src, false);
@ -1116,8 +1084,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return namesystem.getStats();
}
/**
*/
@Override // ClientProtocol
public DatanodeInfo[] getDatanodeReport(DatanodeReportType type)
throws IOException {
DatanodeInfo results[] = namesystem.datanodeReport(type);
@ -1127,7 +1094,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return results;
}
@Override
@Override // ClientProtocol
public boolean setSafeMode(SafeModeAction action) throws IOException {
return namesystem.setSafeMode(action);
}
@ -1139,73 +1106,58 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return namesystem.isInSafeMode();
}
@Override
@Override // ClientProtocol
public boolean restoreFailedStorage(String arg)
throws AccessControlException {
return namesystem.restoreFailedStorage(arg);
}
@Override
@Override // ClientProtocol
public void saveNamespace() throws IOException {
namesystem.saveNamespace();
}
/**
* Refresh the list of datanodes that the namenode should allow to
* connect. Re-reads conf by creating new HdfsConfiguration object and
* uses the files list in the configuration to update the list.
*/
@Override // ClientProtocol
public void refreshNodes() throws IOException {
namesystem.refreshNodes(new HdfsConfiguration());
}
/**
* Returns the size of the current edit log.
*/
@Deprecated
@Deprecated // NamenodeProtocol
public long getEditLogSize() throws IOException {
return namesystem.getEditLogSize();
}
/**
* Roll the edit log.
*/
@Deprecated
@Override // NamenodeProtocol
public CheckpointSignature rollEditLog() throws IOException {
return namesystem.rollEditLog();
}
/**
* Roll the image
*/
@Deprecated @Override
@Deprecated
@Override // NamenodeProtocol
public void rollFsImage(CheckpointSignature sig) throws IOException {
namesystem.rollFSImage(sig);
}
@Override // ClientProtocol
public void finalizeUpgrade() throws IOException {
namesystem.finalizeUpgrade();
}
@Override // ClientProtocol
public UpgradeStatusReport distributedUpgradeProgress(UpgradeAction action)
throws IOException {
return namesystem.distributedUpgradeProgress(action);
}
/**
* Dumps namenode state into specified file
*/
@Override // ClientProtocol
public void metaSave(String filename) throws IOException {
namesystem.metaSave(filename);
}
/**
* {@inheritDoc}
*/
@Override
public CorruptFileBlocks
listCorruptFileBlocks(String path, String cookie)
throws IOException {
@Override // ClientProtocol
public CorruptFileBlocks listCorruptFileBlocks(String path, String cookie)
throws IOException {
Collection<FSNamesystem.CorruptFileBlockInfo> fbs =
namesystem.listCorruptFileBlocks(path, cookie);
@ -1219,32 +1171,31 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return new CorruptFileBlocks(files, lastCookie);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public ContentSummary getContentSummary(String path) throws IOException {
return namesystem.getContentSummary(path);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public void setQuota(String path, long namespaceQuota, long diskspaceQuota)
throws IOException {
namesystem.setQuota(path, namespaceQuota, diskspaceQuota);
}
/** {@inheritDoc} */
@Override // ClientProtocol
public void fsync(String src, String clientName) throws IOException {
namesystem.fsync(src, clientName);
}
@Override
@Override // ClientProtocol
public void setTimes(String src, long mtime, long atime)
throws IOException {
namesystem.setTimes(src, mtime, atime);
}
@Override
public void createSymlink(String target, String link, FsPermission dirPerms,
boolean createParent)
throws IOException {
@Override // ClientProtocol
public void createSymlink(String target, String link, FsPermission dirPerms,
boolean createParent) throws IOException {
metrics.incrCreateSymlinkOps();
/* We enforce the MAX_PATH_LENGTH limit even though a symlink target
* URI may refer to a non-HDFS file system.
@ -1262,7 +1213,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
new PermissionStatus(ugi.getShortUserName(), null, dirPerms), createParent);
}
@Override
@Override // ClientProtocol
public String getLinkTarget(String path) throws IOException {
metrics.incrGetLinkTargetOps();
/* Resolves the first symlink in the given path, returning a
@ -1285,11 +1236,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
}
////////////////////////////////////////////////////////////////
// DatanodeProtocol
////////////////////////////////////////////////////////////////
/**
*/
@Override // DatanodeProtocol
public DatanodeRegistration registerDatanode(DatanodeRegistration nodeReg)
throws IOException {
verifyVersion(nodeReg.getVersion());
@ -1298,32 +1245,19 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return nodeReg;
}
/**
* Data node notify the name node that it is alive
* Return an array of block-oriented commands for the datanode to execute.
* This will be either a transfer or a delete operation.
*/
@Override // DatanodeProtocol
public DatanodeCommand[] sendHeartbeat(DatanodeRegistration nodeReg,
long capacity,
long dfsUsed,
long remaining,
long blockPoolUsed,
int xmitsInProgress,
int xceiverCount,
int failedVolumes) throws IOException {
long capacity, long dfsUsed, long remaining, long blockPoolUsed,
int xmitsInProgress, int xceiverCount, int failedVolumes)
throws IOException {
verifyRequest(nodeReg);
return namesystem.handleHeartbeat(nodeReg, capacity, dfsUsed, remaining,
blockPoolUsed, xceiverCount, xmitsInProgress, failedVolumes);
}
/**
* sends block report to the corresponding namenode (for the poolId)
* @return DataNodeCommand from the namenode
* @throws IOException
*/
@Override // DatanodeProtocol
public DatanodeCommand blockReport(DatanodeRegistration nodeReg,
String poolId,
long[] blocks) throws IOException {
String poolId, long[] blocks) throws IOException {
verifyRequest(nodeReg);
BlockListAsLongs blist = new BlockListAsLongs(blocks);
if(stateChangeLog.isDebugEnabled()) {
@ -1338,10 +1272,9 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return null;
}
public void blockReceived(DatanodeRegistration nodeReg,
String poolId,
Block blocks[],
String delHints[]) throws IOException {
@Override // DatanodeProtocol
public void blockReceived(DatanodeRegistration nodeReg, String poolId,
Block blocks[], String delHints[]) throws IOException {
verifyRequest(nodeReg);
if(stateChangeLog.isDebugEnabled()) {
stateChangeLog.debug("*BLOCK* NameNode.blockReceived: "
@ -1352,9 +1285,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
}
}
/**
* Handle an error report from a datanode.
*/
@Override // DatanodeProtocol
public void errorReport(DatanodeRegistration nodeReg,
int errorCode, String msg) throws IOException {
String dnName = (nodeReg == null ? "unknown DataNode" : nodeReg.getName());
@ -1375,10 +1306,12 @@ public class NameNode implements NamenodeProtocols, FSConstants {
}
}
@Override // DatanodeProtocol, NamenodeProtocol
public NamespaceInfo versionRequest() throws IOException {
return namesystem.getNamespaceInfo();
}
@Override // DatanodeProtocol
public UpgradeCommand processUpgradeCommand(UpgradeCommand comm) throws IOException {
return namesystem.processDistributedUpgradeCommand(comm);
}
@ -1539,7 +1472,7 @@ public class NameNode implements NamenodeProtocols, FSConstants {
return false;
}
@Override
@Override // RefreshAuthorizationPolicyProtocol
public void refreshServiceAcl() throws IOException {
if (!serviceAuthEnabled) {
throw new AuthorizationException("Service Level Authorization not enabled!");
@ -1551,21 +1484,21 @@ public class NameNode implements NamenodeProtocols, FSConstants {
}
}
@Override
@Override // RefreshAuthorizationPolicyProtocol
public void refreshUserToGroupsMappings() throws IOException {
LOG.info("Refreshing all user-to-groups mappings. Requested by user: " +
UserGroupInformation.getCurrentUser().getShortUserName());
Groups.getUserToGroupsMappingService().refresh();
}
@Override
@Override // RefreshAuthorizationPolicyProtocol
public void refreshSuperUserGroupsConfiguration() {
LOG.info("Refreshing SuperUser proxy group mapping list ");
ProxyUsers.refreshSuperUserGroupsConfiguration();
}
@Override
@Override // GetUserMappingsProtocol
public String[] getGroupsForUser(String user) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("Getting groups for user " + user);
@ -1744,4 +1677,12 @@ public class NameNode implements NamenodeProtocols, FSConstants {
System.exit(-1);
}
}
private static String getClientMachine() {
String clientMachine = Server.getRemoteAddress();
if (clientMachine == null) {
clientMachine = "";
}
return clientMachine;
}
}