ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [1/5] incubator-ignite git commit: ignite-368 review
Date Mon, 16 Mar 2015 14:34:18 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-368 9315a0f39 -> 78bdc2631


ignite-368 review


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

Branch: refs/heads/ignite-368
Commit: dbfa6f6834983eed415562f4c22c759adfa65252
Parents: 78fbe30
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Mon Mar 16 17:12:56 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Mon Mar 16 17:12:56 2015 +0300

----------------------------------------------------------------------
 .../cache/affinity/CacheAffinityKeyMapped.java  |  12 +-
 .../ignite/internal/GridKernalContextImpl.java  |   4 +-
 .../apache/ignite/internal/IgniteKernal.java    |   3 +-
 .../internal/managers/GridManagerAdapter.java   |   6 -
 .../apache/ignite/internal/util/GridTimer.java  |   2 +-
 .../internal/util/IgniteExceptionRegistry.java  | 117 +++++++------------
 .../internal/util/io/GridFilenameUtils.java     |   1 -
 .../org/apache/ignite/spi/IgniteSpiAdapter.java |   7 +-
 .../org/apache/ignite/spi/IgniteSpiContext.java |   8 --
 .../util/IgniteExceptionRegistrySelfTest.java   |   9 +-
 .../testframework/GridSpiTestContext.java       |   5 -
 .../junits/GridTestKernalContext.java           |   2 -
 12 files changed, 49 insertions(+), 127 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityKeyMapped.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityKeyMapped.java
b/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityKeyMapped.java
index 2642ac8..3fff1df 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityKeyMapped.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/CacheAffinityKeyMapped.java
@@ -86,12 +86,11 @@ import java.util.concurrent.*;
  * It is also possible to route computations to the nodes where the data is cached. This
concept
  * is otherwise known as {@code Collocation Of Computations And Data}. In this case,
  * {@code @CacheAffinityKeyMapped} annotation allows to specify a routing affinity key for
a
- * {@link org.apache.ignite.compute.ComputeJob} or any other grid computation, such as {@link
Runnable}, {@link Callable}, or
- * {@link org.apache.ignite.lang.IgniteClosure}. It should be attached to a method or field
that provides affinity key
- * for the computation. Only one annotation per class is allowed. Whenever such annotation
is detected,
- * then {@link org.apache.ignite.spi.loadbalancing.LoadBalancingSpi} will be bypassed, and
computation will be routed to the grid node
- * where the specified affinity key is cached. You can also use optional {@link org.apache.ignite.cache.CacheName
@CacheName}
- * annotation whenever non-default cache name needs to be specified.
+ * {@link org.apache.ignite.compute.ComputeJob} or any other grid computation, such as {@link
Runnable},
+ * {@link Callable}, or {@link org.apache.ignite.lang.IgniteClosure}. It should be attached
to a method or
+ * field that provides affinity key for the computation. Only one annotation per class is
allowed.
+ * Whenever such annotation is detected, then {@link org.apache.ignite.spi.loadbalancing.LoadBalancingSpi}
+ * will be bypassed, and computation will be routed to the grid node where the specified
affinity key is cached.
  * <p>
  * Here is how this annotation can be used to route a job to a node where Person object
  * is cached with ID "1234":
@@ -143,7 +142,6 @@ import java.util.concurrent.*;
  * or not. If cache is not started, affinity function will be fetched from the remote node
  * which does have the cache running.
  *
- * @see org.apache.ignite.cache.CacheName
  * @see CacheAffinityFunction
  * @see CacheAffinityKeyMapper
  * @see CacheAffinityKey

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
index 217e8c8..f67eee8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalContextImpl.java
@@ -321,8 +321,7 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
 
     /**
      * Creates new kernal context.
-     *
-     * @param log Logger.
+     *  @param log Logger.
      * @param grid Grid instance managed by kernal.
      * @param cfg Grid configuration.
      * @param gw Kernal gateway.
@@ -340,7 +339,6 @@ public class GridKernalContextImpl implements GridKernalContext, Externalizable
         IgniteEx grid,
         IgniteConfiguration cfg,
         GridKernalGateway gw,
-        IgniteExceptionRegistry registry,
         ExecutorService utilityCachePool,
         ExecutorService marshCachePool,
         ExecutorService execSvc,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 22b37bd..031c054 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -398,7 +398,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
 
     /** {@inheritDoc} */
     @Override public void printLastErrors() {
-        ctx.exceptionRegistry().printErrors();
+        ctx.exceptionRegistry().printErrors(log);
     }
 
     /** {@inheritDoc} */
@@ -662,7 +662,6 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
                 this,
                 cfg,
                 gw,
-                new IgniteExceptionRegistry(log),
                 utilityCachePool,
                 marshCachePool,
                 execSvc,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
index 83841e2..68c5d41 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java
@@ -18,14 +18,12 @@
 package org.apache.ignite.internal.managers;
 
 import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.managers.communication.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
 import org.apache.ignite.internal.processors.cache.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -524,10 +522,6 @@ public abstract class GridManagerAdapter<T extends IgniteSpi> implements
GridMan
                         return ctx.io().messageFactory();
                     }
 
-                    @Override public IgniteExceptionRegistry exceptionRegistry() {
-                        return ctx.exceptionRegistry();
-                    }
-
                     /**
                      * @param e Exception to handle.
                      * @return GridSpiException Converted exception.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/internal/util/GridTimer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridTimer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridTimer.java
index 4306d9a..05e52f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridTimer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridTimer.java
@@ -112,7 +112,7 @@ public class GridTimer {
     }
 
     /**
-     * @return End time ({@code -1 if not stopped).
+     * @return End time ({@code -1} if not stopped).
      */
     public long endTime() {
         return end;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteExceptionRegistry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteExceptionRegistry.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteExceptionRegistry.java
index 08a7aa0..ab113d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteExceptionRegistry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteExceptionRegistry.java
@@ -33,40 +33,32 @@ import static org.apache.ignite.IgniteSystemProperties.*;
  */
 public class IgniteExceptionRegistry {
     /** */
-    public static final IgniteExceptionRegistry DUMMY_REGISTRY = new DummyRegistry();
-    
-    /** */
     public static final int DEFAULT_QUEUE_SIZE = 1000;
 
     /** */
-    private int maxSize = IgniteSystemProperties.getInteger(IGNITE_EXCEPTION_REGISTRY_MAX_SIZE,
DEFAULT_QUEUE_SIZE);
+    private static final IgniteExceptionRegistry instance = new IgniteExceptionRegistry();
 
     /** */
-    private AtomicLong errorCnt = new AtomicLong();
+    private int maxSize = IgniteSystemProperties.getInteger(IGNITE_EXCEPTION_REGISTRY_MAX_SIZE,
DEFAULT_QUEUE_SIZE);
 
     /** */
-    private final ConcurrentLinkedDeque<ExceptionInfo> queue;
+    private AtomicLong errCnt = new AtomicLong();
 
     /** */
-    private final IgniteLogger log;
+    private final ConcurrentLinkedDeque<ExceptionInfo> q = new ConcurrentLinkedDeque<>();
 
     /**
-     * Constructor.
-     *
-     * @param log Ignite logger.
+     * @return Registry instance.
      */
-    public IgniteExceptionRegistry(IgniteLogger log) {
-        this.log = log;
-
-        queue = new ConcurrentLinkedDeque<>();
+    public static IgniteExceptionRegistry get() {
+        return instance;
     }
 
     /**
-     * Default constructor.
+     *
      */
-    protected IgniteExceptionRegistry() {
-        log = null;
-        queue = null;
+    private IgniteExceptionRegistry() {
+        // No-op.
     }
 
     /**
@@ -77,14 +69,20 @@ public class IgniteExceptionRegistry {
      * @param e Exception.
      */
     public void onException(String msg, Throwable e) {
-        long order = errorCnt.incrementAndGet();
-
-        // Remove extra entity.
-        while (queue.size() >= maxSize)
-            queue.pollLast();
-
-        queue.offerFirst(new ExceptionInfo(order, e, msg, Thread.currentThread().getId(),
-            Thread.currentThread().getName(), U.currentTimeMillis()));
+        q.offerFirst(
+            new ExceptionInfo(
+                errCnt.incrementAndGet(),
+                e,
+                msg,
+                Thread.currentThread().getId(),
+                Thread.currentThread().getName(),
+                U.currentTimeMillis()));
+
+        // Remove extra entries.
+        int delta = q.size() - maxSize;
+
+        for (int i = 0; i < delta && q.size() > maxSize; i++)
+            q.pollLast();
     }
 
     /**
@@ -96,7 +94,7 @@ public class IgniteExceptionRegistry {
     public List<ExceptionInfo> getErrors(long order) {
         List<ExceptionInfo> errors = new ArrayList<>();
 
-        for (ExceptionInfo error : queue) {
+        for (ExceptionInfo error : q) {
             if (error.order > order)
                 errors.add(error);
         }
@@ -117,26 +115,26 @@ public class IgniteExceptionRegistry {
 
     /**
      * Prints errors.
+     *
+     * @param log Logger.
      */
-    public void printErrors() {
-        int size = queue.size();
+    public void printErrors(IgniteLogger log) {
+        int size = q.size();
 
-        int cnt = 0;
+        Iterator<ExceptionInfo> descIter = q.descendingIterator();
 
-        Iterator<ExceptionInfo> descIter = queue.descendingIterator();
-
-        while (descIter.hasNext() && cnt < size){
+        for (int i = 0; i < size && descIter.hasNext(); i++) {
             ExceptionInfo error = descIter.next();
 
-            log.error(
-                "Time of occurrence: " + new Date(error.time()) + "\n" +
-                "Error message: " + error.message() + "\n" +
-                "Thread id: " + error.threadId() + "\n" +
-                "Thread name: " + error.threadName(),
+            U.error(
+                log,
+                "Error: " + (i + 1) + U.nl() +
+                "    Time: " + new Date(error.time()) + U.nl() +
+                "    Error: " + error.message() + U.nl() +
+                "    Thread ID: " + error.threadId() + U.nl() +
+                "    Thread name: " + error.threadName(),
                 error.error()
             );
-
-            ++cnt;
         }
     }
 
@@ -146,7 +144,7 @@ public class IgniteExceptionRegistry {
      * @return Errors count.
      */
     public long errorCount() {
-        return errorCnt.get();
+        return errCnt.get();
     }
 
     /**
@@ -242,41 +240,4 @@ public class IgniteExceptionRegistry {
             return S.toString(ExceptionInfo.class, this);
         }
     }
-
-    /**
-     * Dummy registry.
-     */
-    private static final class DummyRegistry extends IgniteExceptionRegistry {
-        /**
-         * Constructor.
-         */
-        private DummyRegistry() {
-            super(null);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void onException(String msg, Throwable e) {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public List<ExceptionInfo> getErrors(long order) {
-            return Collections.emptyList();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void setMaxSize(int maxSize) {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public void printErrors() {
-            // No-op.
-        }
-
-        /** {@inheritDoc} */
-        @Override public long errorCount() {
-            return -1L;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridFilenameUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridFilenameUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridFilenameUtils.java
index ba793ac..36d76f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridFilenameUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridFilenameUtils.java
@@ -506,7 +506,6 @@ public class GridFilenameUtils {
      * @throws IOException
      *             if an IO error occurs while checking the files.
      * @since 2.2
-     * @see FileUtils#directoryContains(File, File)
      */
     public static boolean directoryContains(final String canonicalParent, final String canonicalChild)
             throws IOException {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
index 23572ac..2235895 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
@@ -221,7 +221,7 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement
      * @return Exception registry.
      */
     public IgniteExceptionRegistry getExceptionRegistry() {
-        return spiCtx.exceptionRegistry();
+        return IgniteExceptionRegistry.get();
     }
 
     /** {@inheritDoc} */
@@ -688,10 +688,5 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement
         @Override public MessageFactory messageFactory() {
             return null;
         }
-
-        /** {@inheritDoc} */
-        @Override public IgniteExceptionRegistry exceptionRegistry() {
-            return IgniteExceptionRegistry.DUMMY_REGISTRY;
-        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
index 8ebbbaf..cdc5492 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
@@ -22,7 +22,6 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.managers.communication.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.plugin.extensions.communication.*;
 import org.apache.ignite.plugin.security.*;
 import org.apache.ignite.spi.swapspace.*;
@@ -347,11 +346,4 @@ public interface IgniteSpiContext {
      * @return Message factory.
      */
     public MessageFactory messageFactory();
-
-    /**
-     * Gets exception registry.
-     *
-     * @return Exception registry.
-     */
-    public IgniteExceptionRegistry exceptionRegistry();
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java
index 34320b2..a9b6778 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteExceptionRegistrySelfTest.java
@@ -29,14 +29,7 @@ import java.util.concurrent.*;
 @GridCommonTest(group = "Utils")
 public class IgniteExceptionRegistrySelfTest extends GridCommonAbstractTest {
     /** */
-    private IgniteExceptionRegistry registry;
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        super.beforeTest();
-
-        registry = new IgniteExceptionRegistry(new GridStringLogger());
-    }
+    private IgniteExceptionRegistry registry = IgniteExceptionRegistry.get();
 
     /**
      * @throws Exception if failed.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
index 203dbc2..80e5c42 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridSpiTestContext.java
@@ -512,11 +512,6 @@ public class GridSpiTestContext implements IgniteSpiContext {
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteExceptionRegistry exceptionRegistry() {
-        return IgniteExceptionRegistry.DUMMY_REGISTRY;
-    }
-
-    /** {@inheritDoc} */
     @Override public MessageFactory messageFactory() {
         if (factory == null)
             factory = new GridIoMessageFactory(null);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dbfa6f68/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
index 4911f1b..b871a4a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestKernalContext.java
@@ -20,7 +20,6 @@ package org.apache.ignite.testframework.junits;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.testframework.*;
 
@@ -39,7 +38,6 @@ public class GridTestKernalContext extends GridKernalContextImpl {
             new IgniteKernal(null),
             new IgniteConfiguration(),
             new GridKernalGatewayImpl(null),
-            IgniteExceptionRegistry.DUMMY_REGISTRY,
             null,
             null,
             null,


Mime
View raw message