Examples of DeferredReturnFuture


Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @Override
   public NotifyingFuture<V> getAsync(final K key) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();
      final EnumSet<Flag> flags = flagHolder.get() == null ? null : flagHolder.get().flags;

      // Optimization to not start a new thread only when the operation is cheap:
      if (asyncSkipsThread(flags, key)) {
         return wrapInFuture(get(key));
      } else {
         // Make sure the flags are cleared
         final EnumSet<Flag> appliedFlags;
         if (flags == null) {
            appliedFlags = null;
         }
         else {
            appliedFlags = flags.clone();
            flags.clear();
         }
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContext(tx);
               if (appliedFlags != null)
                  ctx.setFlags(appliedFlags);

               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, appliedFlags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @SuppressWarnings("unchecked")
   NotifyingFuture<V> getAsync(final K key, final EnumSet<Flag> explicitFlags, final ClassLoader explicitClassLoader) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();

      // Optimization to not start a new thread only when the operation is cheap:
      if (asyncSkipsThread(explicitFlags, key)) {
         return wrapInFuture(get(key, explicitFlags, explicitClassLoader));
      } else {
         // Make sure the flags are cleared
         final EnumSet<Flag> appliedFlags;
         if (explicitFlags == null) {
            appliedFlags = null;
         } else {
            appliedFlags = explicitFlags.clone();
            explicitFlags.clear();
         }
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContextForRead(tx, appliedFlags, explicitClassLoader, 1);
               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, appliedFlags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @SuppressWarnings("unchecked")
   NotifyingFuture<V> getAsync(final K key, final EnumSet<Flag> explicitFlags, final ClassLoader explicitClassLoader) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();

      // Optimization to not start a new thread only when the operation is cheap:
      if (asyncSkipsThread(explicitFlags, key)) {
         return wrapInFuture(get(key, explicitFlags, explicitClassLoader));
      } else {
         // Make sure the flags are cleared
         final EnumSet<Flag> appliedFlags;
         if (explicitFlags == null) {
            appliedFlags = null;
         } else {
            appliedFlags = explicitFlags.clone();
            explicitFlags.clear();
         }
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContextForRead(tx, appliedFlags, explicitClassLoader, 1);
               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, appliedFlags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @SuppressWarnings("unchecked")
   NotifyingFuture<V> getAsync(final K key, final EnumSet<Flag> explicitFlags, final ClassLoader explicitClassLoader) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();

      // Optimization to not start a new thread only when the operation is cheap:
      if (asyncSkipsThread(explicitFlags, key)) {
         return wrapInFuture(get(key, explicitFlags, explicitClassLoader));
      } else {
         // Make sure the flags are cleared
         final EnumSet<Flag> appliedFlags;
         if (explicitFlags == null) {
            appliedFlags = null;
         } else {
            appliedFlags = explicitFlags.clone();
            explicitFlags.clear();
         }
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContextForRead(tx, appliedFlags, explicitClassLoader, 1);
               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, appliedFlags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @Override
   public NotifyingFuture<V> getAsync(final K key) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();
      final EnumSet<Flag> flags = flagHolder.get() == null ? null : flagHolder.get().flags;

      // Optimisations to not start a new thread:
      // 1. If distribution and no cache loader, and either SKIP_REMOTE_LOOKUP or key is local,
      // 2. If no cache loader config, or config is present and, SKIP_CACHE_STORE or SKIP_CACHE_LOAD flags are passed
      boolean isSkipLoader = isSkipLoader(flags);
      if (isDistributedAndLocal(flags, key, isSkipLoader) || isSkipLoader) {
         return wrapInFuture(get(key));
      } else {
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContext(tx);
               if (flags != null)
                  ctx.setFlags(flags);

               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, flags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @Override
   public NotifyingFuture<V> getAsync(final K key) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();
      final EnumSet<Flag> flags = flagHolder.get() == null ? null : flagHolder.get().flags;

      // Optimisations to not start a new thread:
      // 1. If distribution and no cache loader, and either SKIP_REMOTE_LOOKUP or key is local,
      // 2. If no cache loader config, or config is present and, SKIP_CACHE_STORE or SKIP_CACHE_LOAD flags are passed
      boolean isSkipLoader = isSkipLoader(flags);
      if (isDistributedAndLocal(flags, key, isSkipLoader) || isSkipLoader) {
         return wrapInFuture(get(key));
      } else {
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContext(tx);
               if (flags != null)
                  ctx.setFlags(flags);

               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, flags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @SuppressWarnings("unchecked")
   NotifyingFuture<V> getAsync(final K key, final EnumSet<Flag> explicitFlags, final ClassLoader explicitClassLoader) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();

      // Optimization to not start a new thread only when the operation is cheap:
      if (asyncSkipsThread(explicitFlags, key)) {
         return wrapInFuture(get(key, explicitFlags, explicitClassLoader));
      } else {
         // Make sure the flags are cleared
         final EnumSet<Flag> appliedFlags;
         if (explicitFlags == null) {
            appliedFlags = null;
         } else {
            appliedFlags = explicitFlags.clone();
            explicitFlags.clear();
         }
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContextForRead(tx, appliedFlags, explicitClassLoader);
               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, appliedFlags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @SuppressWarnings("unchecked")
   NotifyingFuture<V> getAsync(final K key, final EnumSet<Flag> explicitFlags, final ClassLoader explicitClassLoader) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();

      // Optimization to not start a new thread only when the operation is cheap:
      if (asyncSkipsThread(explicitFlags, key)) {
         return wrapInFuture(get(key, explicitFlags, explicitClassLoader));
      } else {
         // Make sure the flags are cleared
         final EnumSet<Flag> appliedFlags;
         if (explicitFlags == null) {
            appliedFlags = null;
         } else {
            appliedFlags = explicitFlags.clone();
            explicitFlags.clear();
         }
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContextForRead(tx, appliedFlags, explicitClassLoader, 1);
               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, appliedFlags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @Override
   public NotifyingFuture<V> getAsync(final K key) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();
      final EnumSet<Flag> flags = flagHolder.get() == null ? null : flagHolder.get().flags;

      // Optimisations to not start a new thread:
      // 1. If distribution and no cache loader, and either SKIP_REMOTE_LOOKUP or key is local,
      // 2. If no cache loader config, or config is present and, SKIP_CACHE_STORE or SKIP_CACHE_LOAD flags are passed
      boolean isSkipLoader = isSkipLoader(flags);
      if (isDistributedAndLocal(flags, key, isSkipLoader) || isSkipLoader) {
         return wrapInFuture(get(key));
      } else {
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContext(tx);
               if (flags != null)
                  ctx.setFlags(flags);

               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, flags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here

Examples of org.infinispan.util.concurrent.DeferredReturnFuture

   }

   @Override
   public NotifyingFuture<V> getAsync(final K key) {
      final Transaction tx = getOngoingTransaction();
      final NotifyingNotifiableFuture f = new DeferredReturnFuture();
      final EnumSet<Flag> flags = flagHolder.get() == null ? null : flagHolder.get().flags;

      // Optimisations to not start a new thread:
      // 1. If distribution and no cache loader, and either SKIP_REMOTE_LOOKUP or key is local,
      // 2. If no cache loader config, or config is present and, SKIP_CACHE_STORE or SKIP_CACHE_LOAD flags are passed
      boolean isSkipLoader = isSkipLoader(flags);
      if (isDistributedAndLocal(flags, key, isSkipLoader) || isSkipLoader) {
         return wrapInFuture(get(key));
      } else {
         Callable<V> c = new Callable<V>() {
            @Override
            public V call() throws Exception {
               assertKeyNotNull(key);
               InvocationContext ctx = getInvocationContext(tx);
               if (flags != null)
                  ctx.setFlags(flags);

               GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key, flags);
               Object ret = invoker.invoke(ctx, command);
               f.notifyDone();
               return (V) ret;
            }
         };
         f.setNetworkFuture(asyncExecutor.submit(c));
         return f;
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.