@@ -209,8 +209,7 @@ public synchronized void addPersistedDelegationToken(
209209 currentTokens .put (identifier , new DelegationTokenInformation (renewDate ,
210210 password , getTrackingIdIfEnabled (identifier )));
211211 } else {
212- throw new IOException (
213- "Same delegation token being added twice." );
212+ throw new IOException ("Same delegation token being added twice." );
214213 }
215214 }
216215
@@ -355,27 +354,24 @@ public synchronized void verifyToken(TokenIdent identifier, byte[] password)
355354 */
356355 public synchronized long renewToken (Token <TokenIdent > token ,
357356 String renewer ) throws InvalidToken , IOException {
358- long now = Time .now ();
359357 ByteArrayInputStream buf = new ByteArrayInputStream (token .getIdentifier ());
360358 DataInputStream in = new DataInputStream (buf );
361359 TokenIdent id = createIdentifier ();
362360 id .readFields (in );
363- LOG .info ("Token renewal requested for identifier: " +id );
364-
361+ LOG .info ("Token renewal for identifier: " + id + "; total currentTokens "
362+ + currentTokens .size ());
363+
364+ long now = Time .now ();
365365 if (id .getMaxDate () < now ) {
366- throw new InvalidToken ("User " + renewer +
367- " tried to renew an expired token" );
366+ throw new InvalidToken (renewer + " tried to renew an expired token" );
368367 }
369368 if ((id .getRenewer () == null ) || (id .getRenewer ().toString ().isEmpty ())) {
370- throw new AccessControlException ("User " + renewer +
371- " tried to renew a token without " +
372- "a renewer" );
369+ throw new AccessControlException (renewer +
370+ " tried to renew a token without a renewer" );
373371 }
374372 if (!id .getRenewer ().toString ().equals (renewer )) {
375- throw new AccessControlException ("Client " + renewer +
376- " tries to renew a token with " +
377- "renewer specified as " +
378- id .getRenewer ());
373+ throw new AccessControlException (renewer +
374+ " tries to renew a token with renewer " + id .getRenewer ());
379375 }
380376 DelegationKey key = allKeys .get (id .getMasterKeyId ());
381377 if (key == null ) {
@@ -386,8 +382,8 @@ public synchronized long renewToken(Token<TokenIdent> token,
386382 }
387383 byte [] password = createPassword (token .getIdentifier (), key .getKey ());
388384 if (!Arrays .equals (password , token .getPassword ())) {
389- throw new AccessControlException ("Client " + renewer
390- + " is trying to renew a token with " + " wrong password" );
385+ throw new AccessControlException (renewer +
386+ " is trying to renew a token with wrong password" );
391387 }
392388 long renewTime = Math .min (id .getMaxDate (), now + tokenRenewInterval );
393389 String trackingId = getTrackingIdIfEnabled (id );
@@ -429,8 +425,7 @@ public synchronized TokenIdent cancelToken(Token<TokenIdent> token,
429425 throw new AccessControlException (canceller
430426 + " is not authorized to cancel the token" );
431427 }
432- DelegationTokenInformation info = null ;
433- info = currentTokens .remove (id );
428+ DelegationTokenInformation info = currentTokens .remove (id );
434429 if (info == null ) {
435430 throw new InvalidToken ("Token not found" );
436431 }
@@ -554,14 +549,11 @@ public void run() {
554549 try {
555550 Thread .sleep (Math .min (5000 , keyUpdateInterval )); // 5 seconds
556551 } catch (InterruptedException ie ) {
557- LOG
558- .error ("InterruptedExcpetion recieved for ExpiredTokenRemover thread "
559- + ie );
552+ LOG .error ("ExpiredTokenRemover received " + ie );
560553 }
561554 }
562555 } catch (Throwable t ) {
563- LOG .error ("ExpiredTokenRemover thread received unexpected exception. "
564- + t );
556+ LOG .error ("ExpiredTokenRemover thread received unexpected exception" , t );
565557 Runtime .getRuntime ().exit (-1 );
566558 }
567559 }
0 commit comments