@Override @Nullable public <T> T get(Object key, Callable<T> valueLoader) { try { return this.cache.invoke(key, new ValueLoaderEntryProcessor<T>(), valueLoader); } catch (EntryProcessorException ex) { throw new ValueRetrievalException(key, valueLoader, ex.getCause()); } }
@Override @Nullable public <T> T get(Object key, Callable<T> valueLoader) { try { return this.cache.invoke(key, new ValueLoaderEntryProcessor<T>(), valueLoader); } catch (EntryProcessorException ex) { throw new ValueRetrievalException(key, valueLoader, ex.getCause()); } }
@Override public Object call() throws Exception { EntryProcessorResult<Boolean> res = c.invoke(key, new EntryProcessor<Object, Object, Boolean>() { @Override public Boolean process(MutableEntry<Object, Object> entry, Object... objects) throws EntryProcessorException { GridCacheEntryEx ex = ((CacheInvokeEntry)entry).entry(); if (entry.getValue() == null) return false; try { ex.updateTtl(ex.version(), ttl); } catch (GridCacheEntryRemovedException e) { throw new EntryProcessorException(e.getCause()); } return true; } }); try { return res.get(); } catch (EntryProcessorException e) { throw new IgniteCheckedException(e.getCause()); } } }, false);
@Override public Object call() throws Exception { EntryProcessorResult<Boolean> res = cache.invoke(key, new EntryProcessor<Object, Object, Boolean>() { @Override public Boolean process(MutableEntry<Object, Object> entry, Object... objects) throws EntryProcessorException { try { Object curVal = entry.getValue(); if (curVal == null) return false; // Modify current value with appendix one. Object newVal = appendOrPrepend(curVal, val, !prepend); // Put new value asynchronously. entry.setValue(newVal); return true; } catch (IgniteCheckedException e) { throw new EntryProcessorException(e); } } }); try { return res.get(); } catch (EntryProcessorException e) { throw new IgniteCheckedException(e.getCause()); } } }, false);
@Override public <T> T get(Object key, Callable<T> valueLoader) { try { return this.cache.invoke(key, new ValueLoaderEntryProcessor<T>(), valueLoader); } catch (EntryProcessorException ex) { throw new ValueRetrievalException(key, valueLoader, ex.getCause()); } }
@Override public Object call() throws Exception { EntryProcessorResult<Boolean> res = c.invoke(key, new EntryProcessor<Object, Object, Boolean>() { @Override public Boolean process(MutableEntry<Object, Object> entry, Object... objects) throws EntryProcessorException { GridCacheEntryEx ex = ((CacheInvokeEntry)entry).entry(); if (entry.getValue() == null) return false; try { ex.updateTtl(ex.version(), ttl); } catch (GridCacheEntryRemovedException e) { throw new EntryProcessorException(e.getCause()); } return true; } }); try { return res.get(); } catch (EntryProcessorException e) { throw new IgniteCheckedException(e.getCause()); } } }, false);
@Override public Object call() throws Exception { EntryProcessorResult<Boolean> res = cache.invoke(key, new EntryProcessor<Object, Object, Boolean>() { @Override public Boolean process(MutableEntry<Object, Object> entry, Object... objects) throws EntryProcessorException { try { Object curVal = entry.getValue(); if (curVal == null) return false; // Modify current value with appendix one. Object newVal = appendOrPrepend(curVal, val, !prepend); // Put new value asynchronously. entry.setValue(newVal); return true; } catch (IgniteCheckedException e) { throw new EntryProcessorException(e); } } }); try { return res.get(); } catch (EntryProcessorException e) { throw new IgniteCheckedException(e.getCause()); } } }, false);
@Test public void testProcessorEmptyExceptionIsWrapped() { try { cache.invoke(123, new ThrowExceptionEntryProcessor<Integer, String, Void>(UnsupportedOperationException.class)); fail(); } catch (EntryProcessorException e) { assertTrue(e.getCause() instanceof RuntimeException); //expected } }
@Test public void testProcessorExceptionIsWrapped() { try { cache.invoke(123, new ThrowExceptionEntryProcessor<Integer, String, Void>(UnsupportedOperationException.class)); fail(); } catch (EntryProcessorException e) { assertTrue(e.getCause() instanceof RuntimeException); //expected } }