HDFS-6168. Remove a deprecated constructor and the deprecated methods reportChecksumFailure, getDelegationToken(Text), renewDelegationToken and cancelDelegationToken from DistributedFileSystem.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1582856 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
640a72efbe
commit
3f7aa79e58
@ -249,6 +249,10 @@ Release 2.5.0 - UNRELEASED
|
|||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
||||||
|
HDFS-6168. Remove a deprecated constructor and the deprecated methods reportChecksumFailure,
|
||||||
|
getDelegationToken(Text), renewDelegationToken and cancelDelegationToken from
|
||||||
|
DistributedFileSystem. (szetszwo)
|
||||||
|
|
||||||
NEW FEATURES
|
NEW FEATURES
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
@ -124,12 +124,6 @@ public String getScheme() {
|
|||||||
return HdfsConstants.HDFS_URI_SCHEME;
|
return HdfsConstants.HDFS_URI_SCHEME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public DistributedFileSystem(InetSocketAddress namenode,
|
|
||||||
Configuration conf) throws IOException {
|
|
||||||
initialize(NameNode.getUri(namenode), conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI getUri() { return uri; }
|
public URI getUri() { return uri; }
|
||||||
|
|
||||||
@ -1016,55 +1010,6 @@ public FsServerDefaults getServerDefaults() throws IOException {
|
|||||||
return dfs.getServerDefaults();
|
return dfs.getServerDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* We need to find the blocks that didn't match. Likely only one
|
|
||||||
* is corrupt but we will report both to the namenode. In the future,
|
|
||||||
* we can consider figuring out exactly which block is corrupt.
|
|
||||||
*/
|
|
||||||
// We do not see a need for user to report block checksum errors and do not
|
|
||||||
// want to rely on user to report block corruptions.
|
|
||||||
@Deprecated
|
|
||||||
public boolean reportChecksumFailure(Path f,
|
|
||||||
FSDataInputStream in, long inPos,
|
|
||||||
FSDataInputStream sums, long sumsPos) {
|
|
||||||
|
|
||||||
if(!(in instanceof HdfsDataInputStream && sums instanceof HdfsDataInputStream))
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Input streams must be types of HdfsDataInputStream");
|
|
||||||
|
|
||||||
LocatedBlock lblocks[] = new LocatedBlock[2];
|
|
||||||
|
|
||||||
// Find block in data stream.
|
|
||||||
HdfsDataInputStream dfsIn = (HdfsDataInputStream) in;
|
|
||||||
ExtendedBlock dataBlock = dfsIn.getCurrentBlock();
|
|
||||||
if (dataBlock == null) {
|
|
||||||
LOG.error("Error: Current block in data stream is null! ");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DatanodeInfo[] dataNode = {dfsIn.getCurrentDatanode()};
|
|
||||||
lblocks[0] = new LocatedBlock(dataBlock, dataNode);
|
|
||||||
LOG.info("Found checksum error in data stream at "
|
|
||||||
+ dataBlock + " on datanode="
|
|
||||||
+ dataNode[0]);
|
|
||||||
|
|
||||||
// Find block in checksum stream
|
|
||||||
HdfsDataInputStream dfsSums = (HdfsDataInputStream) sums;
|
|
||||||
ExtendedBlock sumsBlock = dfsSums.getCurrentBlock();
|
|
||||||
if (sumsBlock == null) {
|
|
||||||
LOG.error("Error: Current block in checksum stream is null! ");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
DatanodeInfo[] sumsNode = {dfsSums.getCurrentDatanode()};
|
|
||||||
lblocks[1] = new LocatedBlock(sumsBlock, sumsNode);
|
|
||||||
LOG.info("Found checksum error in checksum stream at "
|
|
||||||
+ sumsBlock + " on datanode=" + sumsNode[0]);
|
|
||||||
|
|
||||||
// Ask client to delete blocks.
|
|
||||||
dfs.reportChecksumFailure(f.toString(), lblocks);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the stat information about the file.
|
* Returns the stat information about the file.
|
||||||
* @throws FileNotFoundException if the file does not exist.
|
* @throws FileNotFoundException if the file does not exist.
|
||||||
@ -1282,66 +1227,13 @@ protected int getDefaultPort() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public
|
public Token<DelegationTokenIdentifier> getDelegationToken(String renewer)
|
||||||
Token<DelegationTokenIdentifier> getDelegationToken(String renewer
|
throws IOException {
|
||||||
) throws IOException {
|
|
||||||
Token<DelegationTokenIdentifier> result =
|
Token<DelegationTokenIdentifier> result =
|
||||||
dfs.getDelegationToken(renewer == null ? null : new Text(renewer));
|
dfs.getDelegationToken(renewer == null ? null : new Text(renewer));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Delegation Token Operations
|
|
||||||
* These are DFS only operations.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a valid Delegation Token.
|
|
||||||
*
|
|
||||||
* @param renewer Name of the designated renewer for the token
|
|
||||||
* @return Token<DelegationTokenIdentifier>
|
|
||||||
* @throws IOException
|
|
||||||
* @deprecated use {@link #getDelegationToken(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
|
|
||||||
throws IOException {
|
|
||||||
return getDelegationToken(renewer.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renew an existing delegation token.
|
|
||||||
*
|
|
||||||
* @param token delegation token obtained earlier
|
|
||||||
* @return the new expiration time
|
|
||||||
* @throws IOException
|
|
||||||
* @deprecated Use Token.renew instead.
|
|
||||||
*/
|
|
||||||
public long renewDelegationToken(Token<DelegationTokenIdentifier> token)
|
|
||||||
throws InvalidToken, IOException {
|
|
||||||
try {
|
|
||||||
return token.renew(getConf());
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
throw new RuntimeException("Caught interrupted", ie);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cancel an existing delegation token.
|
|
||||||
*
|
|
||||||
* @param token delegation token
|
|
||||||
* @throws IOException
|
|
||||||
* @deprecated Use Token.cancel instead.
|
|
||||||
*/
|
|
||||||
public void cancelDelegationToken(Token<DelegationTokenIdentifier> token)
|
|
||||||
throws IOException {
|
|
||||||
try {
|
|
||||||
token.cancel(getConf());
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
throw new RuntimeException("Caught interrupted", ie);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests the namenode to tell all datanodes to use a new, non-persistent
|
* Requests the namenode to tell all datanodes to use a new, non-persistent
|
||||||
* bandwidth value for dfs.balance.bandwidthPerSec.
|
* bandwidth value for dfs.balance.bandwidthPerSec.
|
||||||
|
@ -195,7 +195,6 @@ public WebHdfsFileSystem run() throws Exception {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelegationTokenWithDoAs() throws Exception {
|
public void testDelegationTokenWithDoAs() throws Exception {
|
||||||
final DistributedFileSystem dfs = cluster.getFileSystem();
|
final DistributedFileSystem dfs = cluster.getFileSystem();
|
||||||
@ -212,11 +211,9 @@ public void testDelegationTokenWithDoAs() throws Exception {
|
|||||||
longUgi.doAs(new PrivilegedExceptionAction<Object>() {
|
longUgi.doAs(new PrivilegedExceptionAction<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object run() throws IOException {
|
public Object run() throws IOException {
|
||||||
final DistributedFileSystem dfs = cluster.getFileSystem();
|
|
||||||
try {
|
try {
|
||||||
//try renew with long name
|
token.renew(config);
|
||||||
dfs.renewDelegationToken(token);
|
} catch (Exception e) {
|
||||||
} catch (IOException e) {
|
|
||||||
Assert.fail("Could not renew delegation token for user "+longUgi);
|
Assert.fail("Could not renew delegation token for user "+longUgi);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -224,20 +221,17 @@ public Object run() throws IOException {
|
|||||||
});
|
});
|
||||||
shortUgi.doAs(new PrivilegedExceptionAction<Object>() {
|
shortUgi.doAs(new PrivilegedExceptionAction<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object run() throws IOException {
|
public Object run() throws Exception {
|
||||||
final DistributedFileSystem dfs = cluster.getFileSystem();
|
token.renew(config);
|
||||||
dfs.renewDelegationToken(token);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
longUgi.doAs(new PrivilegedExceptionAction<Object>() {
|
longUgi.doAs(new PrivilegedExceptionAction<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object run() throws IOException {
|
public Object run() throws IOException {
|
||||||
final DistributedFileSystem dfs = cluster.getFileSystem();
|
|
||||||
try {
|
try {
|
||||||
//try cancel with long name
|
token.cancel(config);
|
||||||
dfs.cancelDelegationToken(token);
|
} catch (Exception e) {
|
||||||
} catch (IOException e) {
|
|
||||||
Assert.fail("Could not cancel delegation token for user "+longUgi);
|
Assert.fail("Could not cancel delegation token for user "+longUgi);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -99,6 +99,9 @@ public void setupCluster() throws Exception {
|
|||||||
.build();
|
.build();
|
||||||
cluster.waitActive();
|
cluster.waitActive();
|
||||||
|
|
||||||
|
String logicalName = HATestUtil.getLogicalHostname(cluster);
|
||||||
|
HATestUtil.setFailoverConfigurations(cluster, conf, logicalName, 0);
|
||||||
|
|
||||||
nn0 = cluster.getNameNode(0);
|
nn0 = cluster.getNameNode(0);
|
||||||
nn1 = cluster.getNameNode(1);
|
nn1 = cluster.getNameNode(1);
|
||||||
fs = HATestUtil.configureFailoverFs(cluster, conf);
|
fs = HATestUtil.configureFailoverFs(cluster, conf);
|
||||||
@ -247,7 +250,6 @@ public void run() {
|
|||||||
doRenewOrCancel(token, clientConf, TokenTestAction.CANCEL);
|
doRenewOrCancel(token, clientConf, TokenTestAction.CANCEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
@Test
|
||||||
public void testDelegationTokenWithDoAs() throws Exception {
|
public void testDelegationTokenWithDoAs() throws Exception {
|
||||||
final Token<DelegationTokenIdentifier> token =
|
final Token<DelegationTokenIdentifier> token =
|
||||||
@ -259,29 +261,22 @@ public void testDelegationTokenWithDoAs() throws Exception {
|
|||||||
longUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
longUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void run() throws Exception {
|
public Void run() throws Exception {
|
||||||
DistributedFileSystem dfs = (DistributedFileSystem)
|
|
||||||
HATestUtil.configureFailoverFs(cluster, conf);
|
|
||||||
// try renew with long name
|
// try renew with long name
|
||||||
dfs.renewDelegationToken(token);
|
token.renew(conf);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
shortUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
shortUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void run() throws Exception {
|
public Void run() throws Exception {
|
||||||
DistributedFileSystem dfs = (DistributedFileSystem)
|
token.renew(conf);
|
||||||
HATestUtil.configureFailoverFs(cluster, conf);
|
|
||||||
dfs.renewDelegationToken(token);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
longUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
longUgi.doAs(new PrivilegedExceptionAction<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void run() throws Exception {
|
public Void run() throws Exception {
|
||||||
DistributedFileSystem dfs = (DistributedFileSystem)
|
token.cancel(conf);;
|
||||||
HATestUtil.configureFailoverFs(cluster, conf);
|
|
||||||
// try cancel with long name
|
|
||||||
dfs.cancelDelegationToken(token);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -62,7 +62,6 @@ public void init() throws URISyntaxException, IOException {
|
|||||||
* Verify that when the DelegationTokenFetcher runs, it talks to the Namenode,
|
* Verify that when the DelegationTokenFetcher runs, it talks to the Namenode,
|
||||||
* pulls out the correct user's token and successfully serializes it to disk.
|
* pulls out the correct user's token and successfully serializes it to disk.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Test
|
@Test
|
||||||
public void expectedTokenIsRetrievedFromDFS() throws Exception {
|
public void expectedTokenIsRetrievedFromDFS() throws Exception {
|
||||||
final byte[] ident = new DelegationTokenIdentifier(new Text("owner"),
|
final byte[] ident = new DelegationTokenIdentifier(new Text("owner"),
|
||||||
@ -83,7 +82,6 @@ public Token<?>[] answer(InvocationOnMock invocation) {
|
|||||||
return new Token<?>[]{t};
|
return new Token<?>[]{t};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
when(dfs.renewDelegationToken(eq(t))).thenReturn(1000L);
|
|
||||||
when(dfs.getUri()).thenReturn(uri);
|
when(dfs.getUri()).thenReturn(uri);
|
||||||
FakeRenewer.reset();
|
FakeRenewer.reset();
|
||||||
|
|
||||||
|
@ -271,8 +271,8 @@ public void close() {}
|
|||||||
public void initialize(URI uri, Configuration conf) throws IOException {}
|
public void initialize(URI uri, Configuration conf) throws IOException {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MyToken getDelegationToken(Text renewer) throws IOException {
|
public MyToken getDelegationToken(String renewer) throws IOException {
|
||||||
MyToken result = createTokens(renewer);
|
MyToken result = createTokens(new Text(renewer));
|
||||||
LOG.info("Called MYDFS.getdelegationtoken " + result);
|
LOG.info("Called MYDFS.getdelegationtoken " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -329,9 +329,9 @@ public void testDTRenewal () throws Exception {
|
|||||||
|
|
||||||
// get the delegation tokens
|
// get the delegation tokens
|
||||||
MyToken token1, token2, token3;
|
MyToken token1, token2, token3;
|
||||||
token1 = dfs.getDelegationToken(new Text("user1"));
|
token1 = dfs.getDelegationToken("user1");
|
||||||
token2 = dfs.getDelegationToken(new Text("user2"));
|
token2 = dfs.getDelegationToken("user2");
|
||||||
token3 = dfs.getDelegationToken(new Text("user3"));
|
token3 = dfs.getDelegationToken("user3");
|
||||||
|
|
||||||
//to cause this one to be set for renew in 2 secs
|
//to cause this one to be set for renew in 2 secs
|
||||||
Renewer.tokenToRenewIn2Sec = token1;
|
Renewer.tokenToRenewIn2Sec = token1;
|
||||||
@ -381,7 +381,7 @@ public void testDTRenewal () throws Exception {
|
|||||||
// time is up.
|
// time is up.
|
||||||
// Wait for 3 secs , and make sure no renews were called
|
// Wait for 3 secs , and make sure no renews were called
|
||||||
ts = new Credentials();
|
ts = new Credentials();
|
||||||
MyToken token4 = dfs.getDelegationToken(new Text("user4"));
|
MyToken token4 = dfs.getDelegationToken("user4");
|
||||||
|
|
||||||
//to cause this one to be set for renew in 2 secs
|
//to cause this one to be set for renew in 2 secs
|
||||||
Renewer.tokenToRenewIn2Sec = token4;
|
Renewer.tokenToRenewIn2Sec = token4;
|
||||||
@ -420,7 +420,7 @@ public void testAppRejectionWithCancelledDelegationToken() throws Exception {
|
|||||||
MyFS dfs = (MyFS)FileSystem.get(conf);
|
MyFS dfs = (MyFS)FileSystem.get(conf);
|
||||||
LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode());
|
LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode());
|
||||||
|
|
||||||
MyToken token = dfs.getDelegationToken(new Text("user1"));
|
MyToken token = dfs.getDelegationToken("user1");
|
||||||
token.cancelToken();
|
token.cancelToken();
|
||||||
|
|
||||||
Credentials ts = new Credentials();
|
Credentials ts = new Credentials();
|
||||||
@ -461,7 +461,7 @@ public void testDTRenewalWithNoCancel () throws Exception {
|
|||||||
LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode());
|
LOG.info("dfs="+(Object)dfs.hashCode() + ";conf="+conf.hashCode());
|
||||||
|
|
||||||
Credentials ts = new Credentials();
|
Credentials ts = new Credentials();
|
||||||
MyToken token1 = dfs.getDelegationToken(new Text("user1"));
|
MyToken token1 = dfs.getDelegationToken("user1");
|
||||||
|
|
||||||
//to cause this one to be set for renew in 2 secs
|
//to cause this one to be set for renew in 2 secs
|
||||||
Renewer.tokenToRenewIn2Sec = token1;
|
Renewer.tokenToRenewIn2Sec = token1;
|
||||||
@ -532,7 +532,7 @@ public void testDTKeepAlive1 () throws Exception {
|
|||||||
|
|
||||||
Credentials ts = new Credentials();
|
Credentials ts = new Credentials();
|
||||||
// get the delegation tokens
|
// get the delegation tokens
|
||||||
MyToken token1 = dfs.getDelegationToken(new Text("user1"));
|
MyToken token1 = dfs.getDelegationToken("user1");
|
||||||
|
|
||||||
String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
|
String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
|
||||||
ts.addToken(new Text(nn1), token1);
|
ts.addToken(new Text(nn1), token1);
|
||||||
@ -609,7 +609,7 @@ public void testDTKeepAlive2() throws Exception {
|
|||||||
|
|
||||||
Credentials ts = new Credentials();
|
Credentials ts = new Credentials();
|
||||||
// get the delegation tokens
|
// get the delegation tokens
|
||||||
MyToken token1 = dfs.getDelegationToken(new Text("user1"));
|
MyToken token1 = dfs.getDelegationToken("user1");
|
||||||
|
|
||||||
String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
|
String nn1 = DelegationTokenRenewer.SCHEME + "://host1:0";
|
||||||
ts.addToken(new Text(nn1), token1);
|
ts.addToken(new Text(nn1), token1);
|
||||||
|
Loading…
Reference in New Issue
Block a user