Ignite-107 All anonymous to static classes
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2b8bbe9f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2b8bbe9f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2b8bbe9f Branch: refs/heads/ignite-99-2 Commit: 2b8bbe9f5dbf2a6eb4053e3a461e01ee6a61f507 Parents: 714cb9b Author: avinogradov <avinogra...@gridgain.com> Authored: Fri Jan 23 16:03:40 2015 +0300 Committer: avinogradov <avinogra...@gridgain.com> Committed: Fri Jan 23 16:03:40 2015 +0300 ---------------------------------------------------------------------- .../closure/GridClosureProcessor.java | 270 ++++++++++++------- .../MasterLeaveAwareComputeJobAdapter.java | 33 --- 2 files changed, 175 insertions(+), 128 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2b8bbe9f/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/GridClosureProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/GridClosureProcessor.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/GridClosureProcessor.java index a3fd599..2258f99 100644 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/GridClosureProcessor.java +++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/GridClosureProcessor.java @@ -974,13 +974,9 @@ public class GridClosureProcessor extends GridProcessorAdapter { A.notNull(job, "job"); if (job instanceof ComputeJobMasterLeaveAware) - return new C1<>(job, arg); + return new C1MLA<>(job, arg); else { - return new ComputeJobAdapter() { - @Nullable @Override public Object execute() { - return job.apply(arg); - } - }; + return new C1<>(job, arg); } } @@ -995,18 +991,9 @@ public class GridClosureProcessor extends GridProcessorAdapter { A.notNull(c, "job"); if (c instanceof ComputeJobMasterLeaveAware) - return new C2<>(c); + return new C2MLA<>(c); else { - return new ComputeJobAdapter() { - @Override public Object execute() { - try { - return c.call(); - } - catch (Exception e) { - throw new IgniteException(e); - } - } - }; + return new C2<>(c); } } @@ -1023,26 +1010,9 @@ public class GridClosureProcessor extends GridProcessorAdapter { A.notNull(c, "job"); if (c instanceof ComputeJobMasterLeaveAware) - return new C3<>(c, cacheName, affKey); + return new C3MLA<>(c, cacheName, affKey); else { - return new ComputeJobAdapter() { - /** */ - @GridCacheName - private final String cn = cacheName; - - /** */ - @GridCacheAffinityKeyMapped - private final Object ak = affKey; - - @Override public Object execute() { - try { - return c.call(); - } - catch (Exception e) { - throw new IgniteException(e); - } - } - }; + return new C3<>(c, cacheName, affKey); } } @@ -1057,15 +1027,9 @@ public class GridClosureProcessor extends GridProcessorAdapter { A.notNull(r, "job"); if (r instanceof ComputeJobMasterLeaveAware) - return new C4(r); + return new C4MLA(r); else { - return new ComputeJobAdapter() { - @Nullable @Override public Object execute() { - r.run(); - - return null; - } - }; + return new C4(r); } } @@ -1082,23 +1046,9 @@ public class GridClosureProcessor extends GridProcessorAdapter { A.notNull(r, "job"); if (r instanceof ComputeJobMasterLeaveAware) - return new C5(r, cacheName, affKey); + return new C5MLA(r, cacheName, affKey); else { - return new ComputeJobAdapter() { - /** */ - @GridCacheName - private final String cn = cacheName; - - /** */ - @GridCacheAffinityKeyMapped - private final Object ak = affKey; - - @Nullable @Override public Object execute() { - r.run(); - - return null; - } - }; + return new C5(r, cacheName, affKey); } } @@ -1672,12 +1622,17 @@ public class GridClosureProcessor extends GridProcessorAdapter { /** * */ - private static class C1<T, R> extends MasterLeaveAwareComputeJobAdapter { + private static class C1<T, R> implements ComputeJob, Externalizable { /** */ private static final long serialVersionUID = 0L; + /** {@inheritDoc} */ + @Override public void cancel() { + // No-op. + } + /** */ - private IgniteClosure<T, R> job; + protected IgniteClosure<T, R> job; /** */ @GridToStringInclude @@ -1704,11 +1659,6 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** {@inheritDoc} */ - @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { - ((ComputeJobMasterLeaveAware)job).onMasterNodeLeft(ses); - } - - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(job); out.writeObject(arg); @@ -1729,20 +1679,51 @@ public class GridClosureProcessor extends GridProcessorAdapter { /** * */ - private static class C2<R> extends MasterLeaveAwareComputeJobAdapter { + private static class C1MLA<T, R> extends C1<T, R> implements ComputeJobMasterLeaveAware{ + /** + * + */ + public C1MLA() { + super(); + } + + /** + * + */ + public C1MLA(IgniteClosure<T, R> job, T arg) { + super(job, arg); + } + + /** {@inheritDoc} */ + @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { + ((ComputeJobMasterLeaveAware)job).onMasterNodeLeft(ses); + } + } + + /** + * + */ + private static class C2<R> implements ComputeJob, Externalizable { /** */ private static final long serialVersionUID = 0L; + /** {@inheritDoc} */ + @Override public void cancel() { + // No-op. + } + /** */ - private Callable<R> c; + protected Callable<R> c; /** + * */ public C2(){ // No-op. } /** + * */ public C2(Callable<R> c) { this.c = c; @@ -1759,11 +1740,6 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** {@inheritDoc} */ - @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { - ((ComputeJobMasterLeaveAware)c).onMasterNodeLeft(ses); - } - - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(c); } @@ -1775,11 +1751,40 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** + * */ - private static class C3<R> extends MasterLeaveAwareComputeJobAdapter { + private static class C2MLA<R> extends C2<R> implements ComputeJobMasterLeaveAware{ + /** + * + */ + public C2MLA() { + super(); + } + + /** + * + */ + public C2MLA(Callable<R> c) { + super(c); + } + + /** {@inheritDoc} */ + @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { + ((ComputeJobMasterLeaveAware)c).onMasterNodeLeft(ses); + } + } + + /** + */ + private static class C3<R> implements ComputeJob, Externalizable { /** */ private static final long serialVersionUID = 0L; + /** {@inheritDoc} */ + @Override public void cancel() { + // No-op. + } + /** */ @GridCacheName private String cn; @@ -1790,15 +1795,17 @@ public class GridClosureProcessor extends GridProcessorAdapter { /** */ - private Callable<R> c; + protected Callable<R> c; /** + * */ public C3(){ // No-op. } /** + * */ public C3(Callable<R> c, @Nullable String cacheName, Object affKey) { this.cn = cacheName; @@ -1817,11 +1824,6 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** {@inheritDoc} */ - @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { - ((ComputeJobMasterLeaveAware)c).onMasterNodeLeft(ses); - } - - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(cn); out.writeObject(ak); @@ -1837,21 +1839,52 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** + * + */ + private static class C3MLA<R> extends C3<R> implements ComputeJobMasterLeaveAware{ + /** + * + */ + public C3MLA() { + super(); + } + + /** + * + */ + public C3MLA(Callable<R> c, @Nullable String cacheName, Object affKey) { + super(c, cacheName, affKey); + } + + /** {@inheritDoc} */ + @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { + ((ComputeJobMasterLeaveAware)c).onMasterNodeLeft(ses); + } + } + + /** */ - private static class C4 extends MasterLeaveAwareComputeJobAdapter { + private static class C4 implements ComputeJob, Externalizable { /** */ private static final long serialVersionUID = 0L; + /** {@inheritDoc} */ + @Override public void cancel() { + // No-op. + } + /** */ - private Runnable r; + protected Runnable r; /** + * */ public C4(){ // No-op. } /** + * */ public C4(Runnable r) { this.r = r; @@ -1865,11 +1898,6 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** {@inheritDoc} */ - @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { - ((ComputeJobMasterLeaveAware)r).onMasterNodeLeft(ses); - } - - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(r); } @@ -1881,11 +1909,41 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** + * */ - private static class C5 extends MasterLeaveAwareComputeJobAdapter { + private static class C4MLA extends C4 implements ComputeJobMasterLeaveAware{ + /** + * + */ + public C4MLA() { + super(); + } + + /** + * + */ + public C4MLA(Runnable r) { + super(r); + } + + /** {@inheritDoc} */ + @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { + ((ComputeJobMasterLeaveAware)r).onMasterNodeLeft(ses); + } + + } + + /** + */ + private static class C5 implements ComputeJob, Externalizable { /** */ private static final long serialVersionUID = 0L; + /** {@inheritDoc} */ + @Override public void cancel() { + // No-op. + } + /** */ @GridCacheName private String cn; @@ -1895,15 +1953,17 @@ public class GridClosureProcessor extends GridProcessorAdapter { private Object ak; /** */ - private Runnable r; + protected Runnable r; /** + * */ public C5(){ // No-op. } /** + * */ public C5(Runnable r, @Nullable String cacheName, Object affKey) { this.cn = cacheName; @@ -1919,11 +1979,6 @@ public class GridClosureProcessor extends GridProcessorAdapter { } /** {@inheritDoc} */ - @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { - ((ComputeJobMasterLeaveAware)r).onMasterNodeLeft(ses); - } - - /** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(cn); out.writeObject(ak); @@ -1937,4 +1992,29 @@ public class GridClosureProcessor extends GridProcessorAdapter { r = (Runnable) in.readObject(); } } + + /** + * + */ + private static class C5MLA extends C5 implements ComputeJobMasterLeaveAware{ + /** + * + */ + public C5MLA() { + super(); + } + + /** + * + */ + public C5MLA(Runnable r, @Nullable String cacheName, Object affKey) { + super(r, cacheName, affKey); + } + + /** {@inheritDoc} */ + @Override public void onMasterNodeLeft(ComputeTaskSession ses) throws IgniteCheckedException { + ((ComputeJobMasterLeaveAware)r).onMasterNodeLeft(ses); + } + + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2b8bbe9f/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/MasterLeaveAwareComputeJobAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/MasterLeaveAwareComputeJobAdapter.java b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/MasterLeaveAwareComputeJobAdapter.java deleted file mode 100644 index 2374dd6..0000000 --- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/closure/MasterLeaveAwareComputeJobAdapter.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.gridgain.grid.kernal.processors.closure; - -import org.apache.ignite.compute.*; - -import java.io.Externalizable; - -/** - * Job adapter implementing {@link org.apache.ignite.compute.ComputeJobMasterLeaveAware}. - */ -public abstract class MasterLeaveAwareComputeJobAdapter - implements ComputeJob, ComputeJobMasterLeaveAware, Externalizable { - /** {@inheritDoc} */ - @Override public void cancel() { - // No-op. - } -}