/** * Requires an invocation against a maxed pool with all instances checked out, must be a strict pool * javax.management.MBeanAttributeInfo[description=, name=AccessTimeouts, type=long, read-only, descriptor={}] * * @throws Exception On error */ public void testAccessTimeouts() throws Exception { final Properties properties = new Properties(); properties.put("MaxSize", "10"); properties.put("AccessTimeout", "0"); properties.put("StrictPooling", "true"); final CounterBean bean = deploy("testAccessTimeouts", properties); assertAttribute("AccessTimeouts", 0l); final Checkout checkout = checkout(bean, 10); for (int i = 0; i < 7; i++) { try { bean.doSomething(); fail("ConcurrentAccessException should have been thrown"); } catch (final ConcurrentAccessException expected) { } } checkout.release(); assertAttribute("AccessTimeouts", 7l); }
@Asynchronous @Override public Future<Integer> runCacheRebuilding() throws ConcurrentAccessException { if (!cacheRebuilding.compareAndSet(false, true)) { log.info("Cache rebuilding still in process -> skipping"); throw new ConcurrentAccessException("Cache rebuilding already in progress..."); } try { return new AsyncResult<>(this.rebuildCache()); } finally { cacheRebuilding.set(false); } }
Future<Integer> runCacheRebuilding() throws ConcurrentAccessException;