Refine search
@SuppressWarnings("unchecked") @Override @Nullable public T process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException { Callable<T> valueLoader = (Callable<T>) arguments[0]; if (entry.exists()) { return (T) fromStoreValue(entry.getValue()); } else { T value; try { value = valueLoader.call(); } catch (Exception ex) { throw new EntryProcessorException("Value loader '" + valueLoader + "' failed " + "to compute value for key '" + entry.getKey() + "'", ex); } entry.setValue(toStoreValue(value)); return value; } } }
@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()); } }
/** {@inheritDoc} */ @Override public T get() throws EntryProcessorException { if (err != null) { if (err instanceof UnregisteredClassException || err instanceof UnregisteredBinaryTypeException) throw (IgniteException) err; if (err instanceof EntryProcessorException) throw (EntryProcessorException)err; throw new EntryProcessorException(err); } return res; }
/** {@inheritDoc} */ @Override public Integer process(MutableEntry<Integer, Integer> e, Object... arguments) throws EntryProcessorException { assertTrue(e.exists()); if (expVal != null) assertEquals(expVal, e.getValue()); throw new EntryProcessorException("Test processor exception."); }
@Override public Object process(MutableEntry<Integer, Integer> entry, Object... arguments) throws EntryProcessorException { entry.setValue(1); try { Thread.sleep(100); } catch (InterruptedException e) { throw new EntryProcessorException(e); } return null; } });
entry.setValue(reader.readObjectDetached()); entry.remove(); throw new EntryProcessorException("Failed to execute native cache entry processor.", ctx.createNativeException(nativeErr)); throw new EntryProcessorException("Failed to execute native cache entry processor: " + errMsg);
@Override public User process(MutableEntry<Integer, User> entry, Object... arguments) throws EntryProcessorException { // test arguments length if (arguments.length < 1) { throw new EntryProcessorException("One argument needed: username"); } // get first argument and test for String type Object argument = arguments[0]; if (!(argument instanceof String)) { throw new EntryProcessorException("First argument has wrong type, required java.lang.String"); } // retrieve the value from the MutableEntry User user = entry.getValue(); // retrieve the new username from the first argument String newUsername = (String) arguments[0]; // set the new username user.setUsername(newUsername); // set the changed user to mark the entry as dirty entry.setValue(user); // return the changed user to return it to the caller return user; } }
Ignite ignite = entry.unwrap(Ignite.class); IntegerKey key = entry.getKey(); throw new EntryProcessorException(msg);
/** {@inheritDoc} */ @Override public Object process(MutableEntry entry, Object... args) throws EntryProcessorException { try { Ignite ignite = (Ignite)entry.unwrap(Ignite.class); PlatformProcessor interopProc; try { interopProc = PlatformUtils.platformProcessor(ignite); } catch (IllegalStateException ex){ throw new EntryProcessorException(ex); } interopProc.awaitStart(); return execute0(interopProc.context(), entry); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long getAndIncrement() { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, GetAndIncrementProcessor.INSTANCE); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
private static <T> EntryProcessorResult<T> newErrorThrowingEntryProcessorResult(final Exception e) { return () -> { if (e instanceof EntryProcessorException) { throw (EntryProcessorException) e; } throw new EntryProcessorException(e); }; }
@Override public Object process(MutableEntry<Integer, Integer> entry, Object... arguments) throws EntryProcessorException { entry.setValue(1); try { Thread.sleep(200); } catch (InterruptedException e) { throw new EntryProcessorException(e); } return null; } });
entry.setValue(reader.readObjectDetached()); entry.remove(); throw new EntryProcessorException("Failed to execute native cache entry processor.", ctx.createNativeException(nativeErr)); throw new EntryProcessorException("Failed to execute native cache entry processor: " + errMsg);
/** {@inheritDoc} */ @Override public Object process(MutableEntry entry, Object... args) throws EntryProcessorException { try { Ignite ignite = (Ignite)entry.unwrap(Ignite.class); PlatformProcessor interopProc; try { interopProc = PlatformUtils.platformProcessor(ignite); } catch (IllegalStateException ex){ throw new EntryProcessorException(ex); } interopProc.awaitStart(); return execute0(interopProc.context(), entry); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
/** {@inheritDoc} */ @Override public long getAndDecrement() { checkRemoved(); try { EntryProcessorResult<Long> res = cacheView.invoke(key, GetAndDecrementProcessor.INSTANCE); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }
@SuppressWarnings("unchecked") @Override @Nullable public T process(MutableEntry<Object, Object> entry, Object... arguments) throws EntryProcessorException { Callable<T> valueLoader = (Callable<T>) arguments[0]; if (entry.exists()) { return (T) fromStoreValue(entry.getValue()); } else { T value; try { value = valueLoader.call(); } catch (Exception ex) { throw new EntryProcessorException("Value loader '" + valueLoader + "' failed " + "to compute value for key '" + entry.getKey() + "'", ex); } entry.setValue(toStoreValue(value)); return value; } } }
/** {@inheritDoc} */ @Override public Integer process(MutableEntry<String, Integer> e, Object... args) { throw new EntryProcessorException("Test entry processor exception."); } }
/** {@inheritDoc} */ @Override public Object process(MutableEntry entry, Object... arguments) { assert processorStartLatch != null; assert hangLatch != null; try { processorStartLatch.countDown(); if (!hangLatch.await(60, TimeUnit.SECONDS)) throw new RuntimeException("Failed to wait for latch"); } catch (Exception e) { System.out.println("Unexpected error: " + e); throw new EntryProcessorException(e); } entry.setValue(U.currentTimeMillis()); return null; } }
@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()); } }
/** {@inheritDoc} */ @Override public long incrementAndGet() { checkRemoved(); try{ EntryProcessorResult<Long> res = cacheView.invoke(key, IncrementAndGetProcessor.INSTANCE); assert res != null && res.get() != null : res; return res.get(); } catch (EntryProcessorException e) { throw new IgniteException(e.getMessage(), e); } catch (IgniteCheckedException e) { throw U.convertException(e); } }