@Override public Long run() throws Exception { InetSocketAddress serviceAddr = SecurityUtil .getTokenServiceAddr(token); return DelegationTokenFetcher.renewDelegationToken(connectionFactory, DFSUtil.createUri(getUnderlyingProtocol(), serviceAddr), (Token<DelegationTokenIdentifier>) token); } });
@Override public Long run() throws Exception { InetSocketAddress serviceAddr = SecurityUtil .getTokenServiceAddr(token); return DelegationTokenFetcher.renewDelegationToken(connectionFactory, DFSUtil.createUri(getUnderlyingProtocol(), serviceAddr), (Token<DelegationTokenIdentifier>) token); } });
/** * try to fetch token without http server with IOException */ @Test public void testTokenRenewFail() throws AuthenticationException { try { DelegationTokenFetcher.renewDelegationToken(connectionFactory, serviceUrl, testToken); fail("Token fetcher shouldn't be able to renew tokens in absense of NN"); } catch (IOException ex) { } }
/** * Call renew token using http server return new expiration time */ @Test public void testRenewTokenFromHttp() throws IOException, NumberFormatException, AuthenticationException { bootstrap = startHttpServer(httpPort, testToken, serviceUrl); assertTrue("testRenewTokenFromHttp error", Long.parseLong(EXP_DATE) == DelegationTokenFetcher.renewDelegationToken( connectionFactory, serviceUrl, testToken)); if (assertionError != null) throw assertionError; }
/** * try fetch token and get http response with error */ @Test public void expectedTokenRenewErrorHttpResponse() throws AuthenticationException, URISyntaxException { bootstrap = startHttpServer(httpPort, testToken, serviceUrl); try { DelegationTokenFetcher.renewDelegationToken(connectionFactory, new URI( serviceUrl.toString() + "/exception"), createToken(serviceUrl)); fail("Token fetcher shouldn't be able to renew tokens using an invalid" + " NN URL"); } catch (IOException ex) { } if (assertionError != null) throw assertionError; }