private void verifyTokenFailWithRetry(DelegationTokenManager tm, Token<DelegationTokenIdentifier> token, int retryCount) throws IOException, InterruptedException { try { tm.verifyToken(token); } catch (SecretManager.InvalidToken er) { throw er; } if (retryCount > 0) { Thread.sleep(RETRY_WAIT); verifyTokenFailWithRetry(tm, token, retryCount - 1); } }
@Test public void testNodeHeartBeatResponse() throws IOException { NodeHeartbeatResponse record = Records.newRecord(NodeHeartbeatResponse.class); Map<ApplicationId, ByteBuffer> appCredentials = new HashMap<ApplicationId, ByteBuffer>(); Credentials app1Cred = new Credentials(); Token<DelegationTokenIdentifier> token1 = new Token<DelegationTokenIdentifier>(); token1.setKind(new Text("kind1")); app1Cred.addToken(new Text("token1"), token1); Token<DelegationTokenIdentifier> token2 = new Token<DelegationTokenIdentifier>(); token2.setKind(new Text("kind2")); app1Cred.addToken(new Text("token2"), token2); DataOutputBuffer dob = new DataOutputBuffer(); app1Cred.writeTokenStorageToStream(dob); ByteBuffer byteBuffer1 = ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); appCredentials.put(ApplicationId.newInstance(1234, 1), byteBuffer1); record.setSystemCredentialsForApps(appCredentials); NodeHeartbeatResponse proto = new NodeHeartbeatResponsePBImpl( ((NodeHeartbeatResponsePBImpl) record).getProto()); Assert.assertEquals(appCredentials, proto.getSystemCredentialsForApps()); }
public MyResourceTracker4(Context context) { // create app Credentials org.apache.hadoop.security.token.Token<DelegationTokenIdentifier> token1 = new org.apache.hadoop.security.token.Token<DelegationTokenIdentifier>(); token1.setKind(new Text("kind1")); expectedCredentials.addToken(new Text("token1"), token1); this.context = context; }
private void verifyTokenFail(DelegationTokenManager tm, Token<DelegationTokenIdentifier> token) throws IOException, InterruptedException { verifyTokenFailWithRetry(tm, token, RETRY_COUNT); }