@Test public void testCryptoJobExecutorServiceDiffThreadCount() throws GeneralSecurityException, InterruptedException { int totalDataCount = 10; for (int j = 0; j < 5; j++) { cryptoJobHandler.close(); cryptoJobHandler = new CryptoJobHandler(j + 1); CountDownLatch encryptCallBackCount = new CountDownLatch(totalDataCount); CountDownLatch decryptCallBackCount = new CountDownLatch(totalDataCount); SecretKeySpec perBlobKey = kms.getRandomKey(); for (int i = 0; i < totalDataCount; i++) { testEncryptDecryptFlow(perBlobKey, encryptCallBackCount, decryptCallBackCount, Mode.Both); } awaitCountDownLatch(encryptCallBackCount, ENCRYPT_JOB_TYPE); awaitCountDownLatch(decryptCallBackCount, DECRYPT_JOB_TYPE); } }
public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } CryptoJobHandler(int threadCount); }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } CryptoJobHandler(int threadCount); void close(); }
CryptoJobHandler implements Closeable { public void close() { if (enabled.compareAndSet(true, false)) { List<Runnable> pendingTasks = scheduler.shutdownNow(); for (Runnable task : pendingTasks) { if (task instanceof CryptoJob) { ((CryptoJob) task).closeJob(CLOSED_EXCEPTION); } else { logger.error("Unknown type of job seen : {}", task.getClass()); } } try { scheduler.awaitTermination(1000, TimeUnit.MILLISECONDS); } catch (Exception e) { logger.error("Unexpected exception while waiting for crypto jobs to terminate", e); } } } CryptoJobHandler(int threadCount); void close();  }