LoadBalancingKMSClientProvider extends KeyProvider implements
    CryptoExtension,
    KeyProviderDelegationTokenExtension.DelegationTokenExtension { @Override public List<String> getKeys() throws IOException { return doOp(new ProviderCallable<List<String>>() { @Override public List<String> call(KMSClientProvider provider) throws IOException { return provider.getKeys(); } }, nextIdx(), true); } LoadBalancingKMSClientProvider(URI providerUri,
      KMSClientProvider[] providers, Configuration conf); @VisibleForTesting  LoadBalancingKMSClientProvider(KMSClientProvider[] providers, long seed,
      Configuration conf); private  LoadBalancingKMSClientProvider(URI uri,
      KMSClientProvider[] providers, long seed, Configuration conf); @VisibleForTesting KMSClientProvider[] getProviders(); @Override org.apache.hadoop.security.token.Token<? extends TokenIdentifier> selectDelegationToken(Credentials creds); @Override String getCanonicalServiceName(); @Override Token<?> getDelegationToken(String renewer); @Override long renewDelegationToken(final Token<?> token); @Override Void cancelDelegationToken(final Token<?> token); @Override void warmUpEncryptedKeys(String... keyNames); @Override void drain(String keyName); @Override void invalidateCache(String keyName); @Override EncryptedKeyVersion generateEncryptedKey(final String encryptionKeyName); @Override KeyVersion decryptEncryptedKey(final EncryptedKeyVersion encryptedKeyVersion); @Override EncryptedKeyVersion reencryptEncryptedKey(
      final EncryptedKeyVersion ekv); @Override void reencryptEncryptedKeys(final List<EncryptedKeyVersion> ekvs); @Override KeyVersion getKeyVersion(final String versionName); @Override List<String> getKeys(); @Override Metadata[] getKeysMetadata(final String... names); @Override List<KeyVersion> getKeyVersions(final String name); @Override KeyVersion getCurrentKey(final String name); @Override Metadata getMetadata(final String name); @Override KeyVersion createKey(final String name, final byte[] material,
      final Options options); @Override KeyVersion createKey(final String name, final Options options); @Override void deleteKey(final String name); @Override KeyVersion rollNewVersion(final String name, final byte[] material); @Override KeyVersion rollNewVersion(final String name); @Override void close(); @Override void flush(); static Logger LOG; }
@Test public void testClientRetriesIdempotentOpWithSocketTimeoutExceptionSucceeds() throws Exception { Configuration conf = new Configuration(); conf.setInt( CommonConfigurationKeysPublic.KMS_CLIENT_FAILOVER_MAX_RETRIES_KEY, 3); final List<String> keys = Arrays.asList("testKey"); KMSClientProvider p1 = mock(KMSClientProvider.class); when(p1.getKeys()) .thenThrow(new SocketTimeoutException("p1")) .thenReturn(keys); KMSClientProvider p2 = mock(KMSClientProvider.class); when(p2.getKeys()).thenThrow(new SocketTimeoutException("p2")); when(p1.getKMSUrl()).thenReturn("p1"); when(p2.getKMSUrl()).thenReturn("p2"); LoadBalancingKMSClientProvider kp = new LoadBalancingKMSClientProvider( new KMSClientProvider[] {p1, p2}, 0, conf); List<String> result = kp.getKeys(); assertEquals(keys, result); verify(p1, Mockito.times(2)).getKeys(); verify(p2, Mockito.times(1)).getKeys(); }