You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2014/12/23 21:36:07 UTC

[24/53] [abbrv] incubator-ignite git commit: GG-9141 - Added @IgniteAsyncSupported annotation.

GG-9141 - Added @IgniteAsyncSupported annotation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8165736f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8165736f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8165736f

Branch: refs/heads/ignite-gg9499
Commit: 8165736fe1937055e8a3e4215d3e5fe5e1d27cca
Parents: a1a5b39
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Fri Dec 19 18:37:22 2014 -0800
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Fri Dec 19 18:37:22 2014 -0800

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCompute.java   | 16 +++++++++++
 .../ignite/lang/IgniteAsyncSupported.java       | 28 ++++++++++++++++++++
 .../apache/ignite/transactions/IgniteTx.java    |  2 ++
 3 files changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8165736f/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
index 16da89f..dc77698 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCompute.java
@@ -119,6 +119,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @see ComputeJobContext#affinityKey()
      * @throws IgniteCheckedException If job failed.
      */
+    @IgniteAsyncSupported
     public void affinityRun(@Nullable String cacheName, Object affKey, Runnable job) throws IgniteCheckedException;
 
     /**
@@ -135,6 +136,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @see ComputeJobContext#cacheName()
      * @see ComputeJobContext#affinityKey()
      */
+    @IgniteAsyncSupported
     public <R> R affinityCall(@Nullable String cacheName, Object affKey, Callable<R> job) throws IgniteCheckedException;
 
     /**
@@ -150,6 +152,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Task result.
      * @throws IgniteCheckedException If task failed.
      */
+    @IgniteAsyncSupported
     public <T, R> R execute(Class<? extends ComputeTask<T, R>> taskCls, @Nullable T arg) throws IgniteCheckedException;
 
     /**
@@ -165,6 +168,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Task result.
      * @throws IgniteCheckedException If task failed.
      */
+    @IgniteAsyncSupported
     public <T, R> R execute(ComputeTask<T, R> task, @Nullable T arg) throws IgniteCheckedException;
 
     /**
@@ -182,6 +186,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @throws IgniteCheckedException If task failed.
      * @see ComputeTask for information about task execution.
      */
+    @IgniteAsyncSupported
     public <T, R> R execute(String taskName, @Nullable T arg) throws IgniteCheckedException;
 
     /**
@@ -192,6 +197,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @param job Job to broadcast to all projection nodes.
      * @throws IgniteCheckedException If job failed.
      */
+    @IgniteAsyncSupported
     public void broadcast(Runnable job) throws IgniteCheckedException;
 
     /**
@@ -204,6 +210,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Collection of results for this execution.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <R> Collection<R> broadcast(Callable<R> job) throws IgniteCheckedException;
 
     /**
@@ -218,6 +225,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Collection of results for this execution.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <R, T> Collection<R> broadcast(IgniteClosure<T, R> job, @Nullable T arg) throws IgniteCheckedException;
 
     /**
@@ -228,6 +236,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @param job Job closure to execute.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public void run(Runnable job) throws IgniteCheckedException;
 
     /**
@@ -238,6 +247,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @param jobs Collection of jobs to execute.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public void run(Collection<? extends Runnable> jobs) throws IgniteCheckedException;
 
     /**
@@ -250,6 +260,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Job result.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <R> R call(Callable<R> job) throws IgniteCheckedException;
 
     /**
@@ -262,6 +273,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Collection of job results for this execution.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <R> Collection<R> call(Collection<? extends Callable<R>> jobs) throws IgniteCheckedException;
 
     /**
@@ -275,6 +287,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Future with reduced job result for this execution.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <R1, R2> R2 call(Collection<? extends Callable<R1>> jobs, IgniteReducer<R1, R2> rdc) throws IgniteCheckedException;
 
     /**
@@ -289,6 +302,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Job result.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <R, T> R apply(IgniteClosure<T, R> job, @Nullable T arg) throws IgniteCheckedException;
 
     /**
@@ -303,6 +317,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Collection of job results.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <T, R> Collection<R> apply(IgniteClosure<T, R> job, Collection<? extends T> args) throws IgniteCheckedException;
 
     /**
@@ -319,6 +334,7 @@ public interface IgniteCompute extends IgniteAsyncSupport {
      * @return Future with reduced job result for this execution.
      * @throws IgniteCheckedException If execution failed.
      */
+    @IgniteAsyncSupported
     public <R1, R2, T> R2 apply(IgniteClosure<T, R1> job, Collection<? extends T> args,
         IgniteReducer<R1, R2> rdc) throws IgniteCheckedException;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8165736f/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java
new file mode 100644
index 0000000..828efdc
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteAsyncSupported.java
@@ -0,0 +1,28 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.apache.ignite.lang;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation to indicate that method can be executed asynchronously if async mode is enabled.
+ * To enable async mode, invoke {@link IgniteAsyncSupport#enableAsync()} method on the API.
+ * The future for the async method can be retrieved via {@link IgniteAsyncSupport#future()} method
+ * right after the execution of an asynchronous method.
+ *
+ * TODO coding example.
+ *
+ * @see IgniteAsyncSupport
+ */
+@Documented
+@Target(ElementType.METHOD)
+public @interface IgniteAsyncSupported {
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8165736f/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
index c3466f7..97a0210 100644
--- a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
+++ b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
@@ -219,6 +219,7 @@ public interface IgniteTx extends GridMetadataAware, AutoCloseable {
      *
      * @throws IgniteCheckedException If commit failed.
      */
+    @IgniteAsyncSupported
     public void commit() throws IgniteCheckedException;
 
     /**
@@ -240,5 +241,6 @@ public interface IgniteTx extends GridMetadataAware, AutoCloseable {
      *
      * @throws IgniteCheckedException If rollback failed.
      */
+    @IgniteAsyncSupported
     public void rollback() throws IgniteCheckedException;
 }