/** {@inheritDoc} */ @Override public long getWalTotalSize() { if (!metricsEnabled) return 0; IgniteOutClosure<Long> walSize = this.walSizeProvider; return walSize != null ? walSize.apply() : 0; }
/** * @param cls State item type. * @param factory Item factory. */ public DirectMessageState(Class<T> cls, IgniteOutClosure<T> factory) { this.factory = factory; stack = (T[])Array.newInstance(cls, INIT_SIZE); stack[0] = factory.apply(); }
/** * Go forward. */ public void forward() { pos++; if (pos == stack.length) { T[] stack0 = stack; stack = (T[])Array.newInstance(stack.getClass().getComponentType(), stack.length << 1); System.arraycopy(stack0, 0, stack, 0, stack0.length); } if (stack[pos] == null) stack[pos] = factory.apply(); }
/** * Sets thread context class loader to the given loader, executes the closure, and then * resets thread context class loader to its initial value. * * @param ldr Class loader to run the closure under. * @param c Closure to run. * @param <R> Return type. * @return Return value. */ @Nullable public static <R> R wrapThreadLoader(ClassLoader ldr, IgniteOutClosure<R> c) { Thread curThread = Thread.currentThread(); // Get original context class loader. ClassLoader ctxLdr = curThread.getContextClassLoader(); try { curThread.setContextClassLoader(ldr); return c.apply(); } finally { // Set the original class loader back. curThread.setContextClassLoader(ctxLdr); } }
/** * Executes given callable in the given user context. * The main contract of this method is that {@link #currentUser()} method invoked * inside closure always returns 'user' this callable executed with. * @param user the user name to invoke closure on behalf of. * @param c the closure to execute * @param <T> The type of closure result. * @return the result of closure execution. * @throws IllegalArgumentException if user name is null or empty String or if the closure is null. */ public static <T> T doAs(String user, final IgniteOutClosure<T> c) { if (F.isEmpty(user)) throw new IllegalArgumentException("Failed to use null or empty user name."); final String ctxUser = userStackThreadLocal.get(); if (F.eq(ctxUser, user)) return c.apply(); // correct context is already there userStackThreadLocal.set(user); try { return c.apply(); } finally { userStackThreadLocal.set(ctxUser); } }
/** {@inheritDoc} */ @Override public float getPagesFillFactor() { if (!metricsEnabled || freeSpaceProvider == null) return 0; long freeSpace = freeSpaceProvider.apply(); long totalAllocated = getPageSize() * totalAllocatedPages.longValue(); return totalAllocated != 0 ? (float) (totalAllocated - freeSpace) / totalAllocated : 0f; }
@Override public void applyx(IgniteInternalFuture<B> embedded) { try { IgniteInternalFuture<A> next = c.apply();
@Override public void run() { c1.apply(msg); c2.apply(msg); c3.apply(); c4.reduce(); System.out.println("Test message: " + msg); } });
writer.apply(obj); TestObject newObj = reader.apply();
rndCache.apply().put(key, key);
cache.apply().put(key, key);
final CacheContinuousQueryHandler hnd = clsr.apply();
/** {@inheritDoc} */ @Override public long getWalTotalSize() { if (!metricsEnabled) return 0; IgniteOutClosure<Long> walSize = this.walSizeProvider; return walSize != null ? walSize.apply() : 0; }
/** * @param cls State item type. * @param factory Item factory. */ @SuppressWarnings("unchecked") public DirectMessageState(Class<T> cls, IgniteOutClosure<T> factory) { this.factory = factory; stack = (T[])Array.newInstance(cls, INIT_SIZE); stack[0] = factory.apply(); }
/** * Go forward. */ @SuppressWarnings("unchecked") public void forward() { pos++; if (pos == stack.length) { T[] stack0 = stack; stack = (T[])Array.newInstance(stack.getClass().getComponentType(), stack.length << 1); System.arraycopy(stack0, 0, stack, 0, stack0.length); } if (stack[pos] == null) stack[pos] = factory.apply(); }
/** * Sets thread context class loader to the given loader, executes the closure, and then * resets thread context class loader to its initial value. * * @param ldr Class loader to run the closure under. * @param c Closure to run. * @param <R> Return type. * @return Return value. */ @Nullable public static <R> R wrapThreadLoader(ClassLoader ldr, IgniteOutClosure<R> c) { Thread curThread = Thread.currentThread(); // Get original context class loader. ClassLoader ctxLdr = curThread.getContextClassLoader(); try { curThread.setContextClassLoader(ldr); return c.apply(); } finally { // Set the original class loader back. curThread.setContextClassLoader(ctxLdr); } }
/** * Executes given callable in the given user context. * The main contract of this method is that {@link #currentUser()} method invoked * inside closure always returns 'user' this callable executed with. * @param user the user name to invoke closure on behalf of. * @param c the closure to execute * @param <T> The type of closure result. * @return the result of closure execution. * @throws IllegalArgumentException if user name is null or empty String or if the closure is null. */ public static <T> T doAs(String user, final IgniteOutClosure<T> c) { if (F.isEmpty(user)) throw new IllegalArgumentException("Failed to use null or empty user name."); final String ctxUser = userStackThreadLocal.get(); if (F.eq(ctxUser, user)) return c.apply(); // correct context is already there userStackThreadLocal.set(user); try { return c.apply(); } finally { userStackThreadLocal.set(ctxUser); } }
msg = c.apply();
/** {@inheritDoc} */ @Override public float getPagesFillFactor() { if (!metricsEnabled || freeSpaceProvider == null) return 0; long freeSpace = freeSpaceProvider.apply(); long totalAllocated = getPageSize() * totalAllocatedPages.longValue(); return totalAllocated != 0 ? (float) (totalAllocated - freeSpace) / totalAllocated : 0f; }