@Override public long getTimeoutMillis() { return ehcacheNonStopConfig.getTimeoutMillis(); }
public void initialize(Runnable runnable, NonstopConfiguration nonStopConfiguration) { // Submit the Thread for execution Future<?> future = threadPool.submit(runnable); // wait for initialization to complete (until operations are enabled) waitForInitialization(future, nonStopConfiguration.getTimeoutMillis()); }
@Override public long getTimeoutMillis() { return ehcacheNonStopConfig.getBulkOpsTimeoutMultiplyFactor() * ehcacheNonStopConfig.getTimeoutMillis(); }
private void throwNonStopExceptionWhenClusterNotInit() throws NonStopException { // THIS IS HAND MADE CODE -- DO NOT GENERATED if (delegate == null && ehcacheNonStopConfiguration != null && ehcacheNonStopConfiguration.isEnabled()) { if (ehcacheNonStopConfiguration.isImmediateTimeout()) { if (exceptionDuringInitialization != null) { throw new NonStopToolkitInstantiationException( exceptionDuringInitialization); } throw new NonStopException("Cluster not up OR still in the process of connecting "); } else { long timeout = ehcacheNonStopConfiguration.getTimeoutMillis(); waitForInit(timeout); } } }
/** * Execute call within NonStop executor * * @param callable * @param <V> * @throws CacheException * @throws TimeoutException * @return returns the result of the callable */ protected <V> V executeWithExecutor(final Callable<V> callable) throws CacheException, TimeoutException { return executeWithExecutor(callable, nonstopConfiguration.getTimeoutMillis(), false); }
private <V> V forceExecuteWithExecutor(final Callable<V> callable) throws CacheException, TimeoutException { return forceExecuteWithExecutor(callable, nonstopConfiguration.getTimeoutMillis()); }
private void init() { if (nonstopConfiguration == null) { return; } if (nonstopConfiguration.getTimeoutBehavior() != null && !isDefault(nonstopConfiguration.getTimeoutBehavior())) { addChildElement(new TimeoutBehaviorConfigurationElement(this, nonstopConfiguration.getTimeoutBehavior())); } addAttribute(new SimpleNodeAttribute("enabled", nonstopConfiguration.isEnabled()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_ENABLED)); addAttribute(new SimpleNodeAttribute("immediateTimeout", nonstopConfiguration.isImmediateTimeout()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_IMMEDIATE_TIMEOUT)); addAttribute(new SimpleNodeAttribute("timeoutMillis", nonstopConfiguration.getTimeoutMillis()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_TIMEOUT_MILLIS)); addAttribute(new SimpleNodeAttribute("searchTimeoutMillis", nonstopConfiguration.getSearchTimeoutMillis()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_SEARCH_TIMEOUT_MILLIS)); }
/** * {@inheritDoc} */ public void lock(final LockType type) { boolean acquired = false; try { acquired = tryLock(type, nonstopConfiguration.getTimeoutMillis()); } catch (InterruptedException e) { // NonStop exception would be thrown automatically as acquired would be false } if (!acquired) { throw new LockOperationTimedOutNonstopException("Lock timed out"); } }
@Override public boolean performOperation(ExplicitLockingContext appThreadLockContext, NonstopActiveDelegateHolder nonstopActiveDelegateHolder, Object key, long timeout, LockType type, NonstopConfiguration config) throws Exception { timeout = Math.min(config.getTimeoutMillis(), timeout); boolean success = nonstopActiveDelegateHolder.getUnderlyingCacheLockProvider().getSyncForKey(key).tryLock(type, timeout); if (success) { appThreadLockContext.lockAcquired(NonstopThreadUniqueIdProvider.getCurrentNonstopThreadUniqueId()); } return success; }
/** * {@inheritDoc}. */ public void removeAll(final Collection<?> keys) { try { executeWithExecutor(new Callable<Void>() { public Void call() throws Exception { nonstopActiveDelegateHolder.getUnderlyingTerracottaStore().removeAll(keys); return null; } }, nonstopConfiguration.getTimeoutMillis() * nonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()); } catch (TimeoutException e) { timeoutBehaviorResolver.resolveTimeoutBehaviorStore().removeAll(keys); } }
/** * {@inheritDoc}. */ public void putAll(final Collection<Element> elements) throws CacheException { try { executeWithExecutor(new Callable<Void>() { public Void call() throws Exception { nonstopActiveDelegateHolder.getUnderlyingTerracottaStore().putAll(elements); return null; } }, nonstopConfiguration.getTimeoutMillis() * nonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()); } catch (TimeoutException e) { timeoutBehaviorResolver.resolveTimeoutBehaviorStore().putAll(elements); } }
/** * {@inheritDoc} */ public Map<Object, Element> getAllQuiet(final Collection<?> keys) { Map<Object, Element> rv = null; try { rv = executeWithExecutor(new Callable<Map<Object, Element>>() { public Map<Object, Element> call() throws Exception { return nonstopActiveDelegateHolder.getUnderlyingTerracottaStore().getAllQuiet(keys); }; }, nonstopConfiguration.getTimeoutMillis() * nonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()); } catch (TimeoutException e) { return timeoutBehaviorResolver.resolveTimeoutBehaviorStore().getAllQuiet(keys); } return rv; }
/** * {@inheritDoc} */ public Map<Object, Element> getAll(final Collection<?> keys) { Map<Object, Element> rv = null; try { rv = executeWithExecutor(new Callable<Map<Object, Element>>() { public java.util.Map<Object, Element> call() throws Exception { return nonstopActiveDelegateHolder.getUnderlyingTerracottaStore().getAll(keys); }; }, nonstopConfiguration.getTimeoutMillis() * nonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()); } catch (TimeoutException e) { return timeoutBehaviorResolver.resolveTimeoutBehaviorStore().getAll(keys); } return rv; }
/** * {@inheritDoc}. * The timeout used by this method is {@link NonstopConfiguration#getBulkOpsTimeoutMultiplyFactor()} times the timeout value in the * config. */ public void removeAll() throws CacheException { try { executeWithExecutor(new Callable<Void>() { public Void call() throws Exception { nonstopActiveDelegateHolder.getUnderlyingTerracottaStore().removeAll(); return null; } }, nonstopConfiguration.getTimeoutMillis() * nonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()); } catch (TimeoutException e) { timeoutBehaviorResolver.resolveTimeoutBehaviorStore().removeAll(); } }
/** * {@inheritDoc}. * The timeout used by this method is {@link NonstopConfiguration#getBulkOpsTimeoutMultiplyFactor()} times the timeout value in the * config. */ public void setNodeCoherent(final boolean coherent) throws UnsupportedOperationException { try { // always execute even when cluster offline forceExecuteWithExecutor(new Callable<Void>() { public Void call() throws Exception { nonstopActiveDelegateHolder.getUnderlyingTerracottaStore().setNodeCoherent(coherent); return null; } }, nonstopConfiguration.getTimeoutMillis() * nonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()); } catch (TimeoutException e) { timeoutBehaviorResolver.resolveTimeoutBehaviorStore().setNodeCoherent(coherent); } }
/** * {@inheritDoc}. * The timeout used by this method is {@link net.sf.ehcache.config.NonstopConfiguration#getBulkOpsTimeoutMultiplyFactor()} times the timeout value in the * config. */ @Override public void removeAll() throws CacheException { final Transaction tx = suspendCaller(); try { executeWithExecutor(new Callable<Void>() { public Void call() throws Exception { resumeCallee(tx); try { underlyingTerracottaStore().removeAll(); return null; } finally { suspendCallee(); } } }, nonstopConfiguration.getTimeoutMillis() * nonstopConfiguration.getBulkOpsTimeoutMultiplyFactor()); } catch (TimeoutException e) { resolveTimeoutBehaviorStore().removeAll(); } finally { resumeCaller(tx); } }
private void init() { if (nonstopConfiguration == null) { return; } if (nonstopConfiguration.getTimeoutBehavior() != null && !isDefault(nonstopConfiguration.getTimeoutBehavior())) { addChildElement(new TimeoutBehaviorConfigurationElement(this, nonstopConfiguration.getTimeoutBehavior())); } addAttribute(new SimpleNodeAttribute("enabled", nonstopConfiguration.isEnabled()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_ENABLED)); addAttribute(new SimpleNodeAttribute("immediateTimeout", nonstopConfiguration.isImmediateTimeout()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_IMMEDIATE_TIMEOUT)); addAttribute(new SimpleNodeAttribute("timeoutMillis", nonstopConfiguration.getTimeoutMillis()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_TIMEOUT_MILLIS)); }
final long timeoutMillis = nsCfg.getTimeoutMillis() * nsCfg.getBulkOpsTimeoutMultiplyFactor(); try { getNonstopExecutorService().execute(new Callable<Void>() {
private void init() { if (nonstopConfiguration == null) { return; } if (nonstopConfiguration.getTimeoutBehavior() != null && !isDefault(nonstopConfiguration.getTimeoutBehavior())) { addChildElement(new TimeoutBehaviorConfigurationElement(this, nonstopConfiguration.getTimeoutBehavior())); } addAttribute(new SimpleNodeAttribute("enabled", nonstopConfiguration.isEnabled()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_ENABLED)); addAttribute(new SimpleNodeAttribute("immediateTimeout", nonstopConfiguration.isImmediateTimeout()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_IMMEDIATE_TIMEOUT)); addAttribute(new SimpleNodeAttribute("timeoutMillis", nonstopConfiguration.getTimeoutMillis()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_TIMEOUT_MILLIS)); addAttribute(new SimpleNodeAttribute("searchTimeoutMillis", nonstopConfiguration.getSearchTimeoutMillis()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_SEARCH_TIMEOUT_MILLIS)); }
private void init() { if (nonstopConfiguration == null) { return; } if (nonstopConfiguration.getTimeoutBehavior() != null && !isDefault(nonstopConfiguration.getTimeoutBehavior())) { addChildElement(new TimeoutBehaviorConfigurationElement(this, nonstopConfiguration.getTimeoutBehavior())); } addAttribute(new SimpleNodeAttribute("enabled", nonstopConfiguration.isEnabled()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_ENABLED)); addAttribute(new SimpleNodeAttribute("immediateTimeout", nonstopConfiguration.isImmediateTimeout()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_IMMEDIATE_TIMEOUT)); addAttribute(new SimpleNodeAttribute("timeoutMillis", nonstopConfiguration.getTimeoutMillis()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_TIMEOUT_MILLIS)); addAttribute(new SimpleNodeAttribute("searchTimeoutMillis", nonstopConfiguration.getSearchTimeoutMillis()).optional(true).defaultValue( NonstopConfiguration.DEFAULT_SEARCH_TIMEOUT_MILLIS)); }