ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject incubator-ignite git commit: futures: api cleanup
Date Fri, 06 Mar 2015 06:32:01 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-143 2d45a4700 -> bf01a407f


futures: api cleanup


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

Branch: refs/heads/ignite-143
Commit: bf01a407f368d870c81660e3dc36086d7751eea0
Parents: 2d45a47
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Fri Mar 6 00:08:18 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Fri Mar 6 00:08:18 2015 +0300

----------------------------------------------------------------------
 .../ignite/internal/GridKernalGatewayImpl.java  |  26 ---
 .../managers/communication/GridIoManager.java   |  26 +--
 .../cache/GridCacheDeploymentManager.java       |   2 +-
 .../processors/cache/GridCacheIoManager.java    |   9 +-
 .../processors/cache/GridCacheMessage.java      |   7 -
 .../processors/cache/GridCacheMvccManager.java  |  11 +-
 .../processors/cache/GridCacheUtils.java        |   9 -
 .../distributed/dht/GridDhtTxPrepareFuture.java |   2 +-
 .../cache/transactions/IgniteTxManager.java     |   2 +-
 .../processors/job/GridJobProcessor.java        |   4 +-
 .../ignite/internal/util/GridThreadLocal.java   | 175 ----------------
 .../ignite/internal/util/GridThreadLocalEx.java | 210 -------------------
 .../ignite/internal/util/IgniteUtils.java       |   2 +-
 .../internal/util/future/GridFutureAdapter.java |  17 +-
 .../ignite/internal/util/worker/GridWorker.java |  27 ---
 15 files changed, 35 insertions(+), 494 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/GridKernalGatewayImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalGatewayImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalGatewayImpl.java
index 5982005..c4e2268 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridKernalGatewayImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridKernalGatewayImpl.java
@@ -82,14 +82,10 @@ public class GridKernalGatewayImpl implements GridKernalGateway, Serializable
{
 
             throw illegalState();
         }
-
-        enterThreadLocals();
     }
 
     /** {@inheritDoc} */
     @Override public void readUnlock() {
-        leaveThreadLocals();
-
         rwLock.readUnlock();
     }
 
@@ -99,8 +95,6 @@ public class GridKernalGatewayImpl implements GridKernalGateway, Serializable
{
         if (stackTrace == null)
             stackTrace = stackTrace();
 
-        enterThreadLocals();
-
         boolean interrupted = false;
 
         // Busy wait is intentional.
@@ -129,8 +123,6 @@ public class GridKernalGatewayImpl implements GridKernalGateway, Serializable
{
             if (stackTrace == null)
                 stackTrace = stackTrace();
 
-            enterThreadLocals();
-
             return true;
         }
 
@@ -161,27 +153,9 @@ public class GridKernalGatewayImpl implements GridKernalGateway, Serializable
{
             ", state=" + state + ']');
     }
 
-    /**
-     * Enter thread locals.
-     */
-    private void enterThreadLocals() {
-        GridThreadLocal.enter();
-        GridThreadLocalEx.enter();
-    }
-
-    /**
-     * Leave thread locals.
-     */
-    private void leaveThreadLocals() {
-        GridThreadLocalEx.leave();
-        GridThreadLocal.leave();
-    }
-
     /** {@inheritDoc} */
     @Override public void writeUnlock() {
         rwLock.writeUnlock();
-
-        leaveThreadLocals();
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
index 67ae808..2289c20 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoManager.java
@@ -30,7 +30,6 @@ 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.*;
-import org.apache.ignite.internal.util.worker.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.marshaller.*;
 import org.apache.ignite.plugin.extensions.communication.*;
@@ -112,14 +111,6 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
     /** Lock to sync maps access. */
     private final ReadWriteLock lock = new ReentrantReadWriteLock();
 
-    /** Message cache. */
-    private ThreadLocal<IgniteBiTuple<Object, byte[]>> cacheMsg =
-        new GridThreadLocal<IgniteBiTuple<Object, byte[]>>() {
-            @Nullable @Override protected IgniteBiTuple<Object, byte[]> initialValue()
{
-                return null;
-            }
-        };
-
     /** Fully started flag. When set to true, can send and receive messages. */
     private volatile boolean started;
 
@@ -416,9 +407,6 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
     @Override public void stop(boolean cancel) throws IgniteCheckedException {
         stopSpi();
 
-        // Clear cache.
-        cacheMsg.set(null);
-
         if (log.isDebugEnabled())
             log.debug(stopInfo());
     }
@@ -1332,14 +1320,14 @@ public class GridIoManager extends GridManagerAdapter<CommunicationSpi<Serializa
                     pool(msgSet.policy()).execute(
                         new Runnable() {
                             @Override public void run() {
-                            try {
-                                unwindMessageSet(msgSet, lsnrs0);
-                            }
-                            finally {
-                                workersCnt.decrement();
+                                try {
+                                    unwindMessageSet(msgSet, lsnrs0);
+                                }
+                                finally {
+                                    workersCnt.decrement();
+                                }
                             }
-                        }
-                    });
+                        });
 
                     success = true;
                 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
index c9467eb..5e40bee 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
@@ -71,7 +71,7 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap
     private volatile boolean locDepOwner;
 
     /** */
-    private final GridThreadLocal<Boolean> ignoreOwnership = new GridThreadLocal<Boolean>()
{
+    private final ThreadLocal<Boolean> ignoreOwnership = new ThreadLocal<Boolean>()
{
         @Override protected Boolean initialValue() {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 277c48b..de82f35 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -293,10 +293,6 @@ public class GridCacheIoManager<K, V> extends GridCacheSharedManagerAdapter<K,
V
     private void processMessage(UUID nodeId, GridCacheMessage<K, V> msg,
         IgniteBiInClosure<UUID, GridCacheMessage<K, V>> c) {
         try {
-            // Start clean.
-            if (msg.transactional())
-                CU.resetTxContext(cctx);
-
             // We will not end up with storing a bunch of new UUIDs
             // in each cache entry, since node ID is stored in NIO session
             // on handshake.
@@ -309,8 +305,9 @@ public class GridCacheIoManager<K, V> extends GridCacheSharedManagerAdapter<K,
V
             U.error(log, "Failed processing message [senderId=" + nodeId + ']', e);
         }
         finally {
-            // Clear thread-local tx contexts.
-            CU.resetTxContext(cctx);
+            // Reset thread local context.
+            cctx.tm().txContextReset();
+            cctx.mvcc().contextReset();
 
             // Unwind eviction notifications.
             CU.unwindEvicts(cctx);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index 6b8689c..74994c9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -87,13 +87,6 @@ public abstract class GridCacheMessage<K, V> implements Message {
     }
 
     /**
-     * @return If this is a transactional message.
-     */
-    public boolean transactional() {
-        return false;
-    }
-
-    /**
      * @return {@code True} if class loading errors should be ignored, false otherwise.
      */
     public boolean ignoreClassErrors() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index 9859039..fc586ba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -51,8 +51,8 @@ public class GridCacheMvccManager<K, V> extends GridCacheSharedManagerAdapter<K,
     private static final int MAX_REMOVED_LOCKS = 10240;
 
     /** Pending locks per thread. */
-    private final GridThreadLocal<Queue<GridCacheMvccCandidate<K>>> pending
=
-        new GridThreadLocal<Queue<GridCacheMvccCandidate<K>>>() {
+    private final ThreadLocal<Queue<GridCacheMvccCandidate<K>>> pending
=
+        new ThreadLocal<Queue<GridCacheMvccCandidate<K>>>() {
             @Override protected Queue<GridCacheMvccCandidate<K>> initialValue()
{
                 return new LinkedList<>();
             }
@@ -725,6 +725,13 @@ public class GridCacheMvccManager<K, V> extends GridCacheSharedManagerAdapter<K,
     }
 
     /**
+     * Reset MVCC context.
+     */
+    public void contextReset() {
+        pending.set(new LinkedList<GridCacheMvccCandidate<K>>());
+    }
+
+    /**
      * Adds candidate to the list of near local candidates.
      *
      * @param threadId Thread ID.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index b07c14e..45dfb3f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1240,15 +1240,6 @@ public class GridCacheUtils {
     /**
      * @param ctx Cache context.
      */
-    public static void resetTxContext(GridCacheSharedContext ctx) {
-        assert ctx != null;
-
-        ctx.tm().txContextReset();
-    }
-
-    /**
-     * @param ctx Cache context.
-     */
     public static void unwindEvicts(GridCacheContext ctx) {
         assert ctx != null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index f046554..90df2c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -1096,7 +1096,7 @@ public final class GridDhtTxPrepareFuture<K, V> extends GridCompoundIdentityFutu
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        return S.toString(GridDhtTxPrepareFuture.class, this, "super", super.toString());
+        return S.toString(GridDhtTxPrepareFuture.class, this, "xid", tx.xidVersion(), "super",
super.toString());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 065d545..b1569a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -65,7 +65,7 @@ public class IgniteTxManager<K, V> extends GridCacheSharedManagerAdapter<K,
V> {
     private static final int TX_SALVAGE_TIMEOUT = Integer.getInteger(IGNITE_TX_SALVAGE_TIMEOUT,
100);
 
     /** Committing transactions. */
-    private final ThreadLocal<IgniteInternalTx> threadCtx = new GridThreadLocalEx<>();
+    private final ThreadLocal<IgniteInternalTx> threadCtx = new ThreadLocal<>();
 
     /** Per-thread transaction map. */
     private final ConcurrentMap<Long, IgniteInternalTx<K, V>> threadMap = newMap();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index 6b753b4..49f8998 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -147,14 +147,14 @@ public class GridJobProcessor extends GridProcessorAdapter {
     };
 
     /** Internal task flag. */
-    private final GridThreadLocal<Boolean> internal = new GridThreadLocal<Boolean>()
{
+    private final ThreadLocal<Boolean> internal = new ThreadLocal<Boolean>()
{
         @Override protected Boolean initialValue() {
             return false;
         }
     };
 
     /** Current session. */
-    private final GridThreadLocal<ComputeTaskSession> currentSess = new GridThreadLocal<>();
+    private final ThreadLocal<ComputeTaskSession> currentSess = new ThreadLocal<>();
 
     /**
      * @param ctx Kernal context.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocal.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocal.java
deleted file mode 100644
index 8e94e89..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocal.java
+++ /dev/null
@@ -1,175 +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.apache.ignite.internal.util;
-
-import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.worker.*;
-import org.apache.ignite.lang.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * Thread local that auto resets upon leaving thread context. This thread local is
- * integrated with {@link GridKernalGateway} and
- * with {@link GridWorker} threads.
- */
-public class GridThreadLocal<T> extends ThreadLocal<T> {
-    /** Thread context for non-worker threads. */
-    private static final ThreadLocal<ThreadContext> threadCtx = new ThreadLocal<ThreadContext>()
{
-        @Override protected ThreadContext initialValue() {
-            return new ThreadContext();
-        }
-
-        @Override public String toString() {
-            return "Thread context.";
-        }
-    };
-
-    /** */
-    private final IgniteOutClosure<T> initializer;
-
-    /**
-     *
-     */
-    public GridThreadLocal() {
-        initializer = null;
-    }
-
-    /**
-     * @param initializer Initializer.
-     */
-    public GridThreadLocal(IgniteOutClosure<T> initializer) {
-        this.initializer = initializer;
-    }
-
-    /**
-     * Callback for start of thread context.
-     */
-    public static void enter() {
-        threadCtx.get().enter();
-    }
-
-    /**
-     * Callback for end of thread context.
-     */
-    public static void leave() {
-        threadCtx.get().leave();
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override protected T initialValue() {
-        return initializer == null ? null : initializer.apply();
-    }
-
-    /**
-     * Resets the state of this thread local.
-     */
-    private void reset() {
-        super.set(initialValue());
-    }
-
-    /** {@inheritDoc} */
-    @Override public final T get() {
-        addThreadLocal(this);
-
-        return super.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public final void set(T val) {
-        if (val != null)
-            addThreadLocal(this);
-
-        super.set(val);
-    }
-
-    /**
-     * @param threadLoc Thread local.
-     * @return {@code True} if thread-local was added.
-     */
-    private boolean addThreadLocal(GridThreadLocal<?> threadLoc) {
-        assert threadLoc != null;
-
-        ThreadContext ctx = threadCtx.get();
-
-        return ctx.entered() && ctx.add(threadLoc);
-    }
-
-    /**
-     *
-     */
-    private static class ThreadContext {
-        /** Entered flag. */
-        private int entered;
-
-        /** Thread locals for given thread context. */
-        private Collection<GridThreadLocal<?>> threadLocals = new HashSet<>();
-
-        /**
-         * Enter callback.
-         */
-        void enter() {
-            assert entered >= 0 : "Thread context gateway cannot be negative prior to
enter: " + entered;
-
-            if (entered == 0)
-                reset();
-
-            entered++;
-        }
-
-        /**
-         * Leave callback.
-         */
-        void leave() {
-            assert entered > 0 : "Thread context gateway must be positive prior to leave:
" + entered;
-
-            entered--;
-
-            if (entered == 0)
-                reset();
-        }
-
-        /**
-         * @param threadLoc Thread local to add.
-         * @return {@code True} if thread local was added.
-         */
-        boolean add(GridThreadLocal<?> threadLoc) {
-            return threadLocals.add(threadLoc);
-        }
-
-        /**
-         * @return Entered flag.
-         */
-        boolean entered() {
-            return entered > 0;
-        }
-
-        /**
-         * Resets thread locals.
-         */
-        private void reset() {
-            if (!threadLocals.isEmpty()) {
-                for (GridThreadLocal<?> threadLocal : threadLocals)
-                    threadLocal.reset();
-
-                threadLocals.clear();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocalEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocalEx.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocalEx.java
deleted file mode 100644
index a8f01f3..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridThreadLocalEx.java
+++ /dev/null
@@ -1,210 +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.apache.ignite.internal.util;
-
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.internal.util.worker.*;
-import org.apache.ignite.lang.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * Thread local that auto resets upon leaving thread context. This thread local is different
- * from {@link GridThreadLocal} as it inherits thread local values from the parent
- * {@link GridWorker} thread.
- */
-public class GridThreadLocalEx<T> extends ThreadLocal<T> {
-    /** Thread context for non-worker threads. */
-    private static final ThreadLocal<ThreadContext> threadCtx = new ThreadLocal<ThreadContext>()
{
-        @Override protected ThreadContext initialValue() {
-            return new ThreadContext();
-        }
-    };
-
-    /** */
-    private final IgniteOutClosure<T> initializer;
-
-    /**
-     *
-     */
-    public GridThreadLocalEx() {
-        initializer = null;
-    }
-
-    /**
-     * @param initializer Initializer.
-     */
-    public GridThreadLocalEx(IgniteOutClosure<T> initializer) {
-        this.initializer = initializer;
-    }
-
-    /**
-     * @return Thread locals to inherit.
-     */
-    public static Map<GridThreadLocalEx<?>, ?> inherit() {
-        ThreadContext ctx = threadCtx.get();
-
-        Collection<GridThreadLocalEx<?>> threadLocals = ctx.threadLocals();
-
-        Map<GridThreadLocalEx<?>, Object> ret = F.isEmpty(threadLocals) ?
-            Collections.<GridThreadLocalEx<?>, Object>emptyMap() :
-            U.<GridThreadLocalEx<?>, Object>newHashMap(threadLocals.size());
-
-        for (GridThreadLocalEx<?> t : threadLocals)
-            ret.put(t, t.get());
-
-        return ret;
-    }
-
-    /**
-     * Callback for start of thread context.
-     */
-    public static void enter() {
-        threadCtx.get().enter();
-    }
-
-    /**
-     * Callback for start of thread context.
-     *
-     * @param inherited Inherited map.
-     */
-    @SuppressWarnings({"unchecked"})
-    public static void enter(Map<GridThreadLocalEx<?>, ?> inherited) {
-        threadCtx.get().enter();
-
-        for (Map.Entry<GridThreadLocalEx<?>, ?> e : inherited.entrySet()) {
-            ThreadLocal<Object> t = (ThreadLocal<Object>)e.getKey();
-
-            t.set(e.getValue());
-        }
-    }
-
-    /**
-     * Callback for end of thread context.
-     */
-    public static void leave() {
-        threadCtx.get().leave();
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override protected T initialValue() {
-        return initializer == null ? null : initializer.apply();
-    }
-
-    /** {@inheritDoc} */
-    @Override public final T get() {
-        addThreadLocal(this);
-
-        return super.get();
-    }
-
-    /** {@inheritDoc} */
-    @Override public final void set(T val) {
-        if (val != null)
-            addThreadLocal(this);
-
-        super.set(val);
-    }
-
-    /**
-     * Resets the state of this thread local.
-     */
-    private void reset() {
-        super.set(initialValue());
-    }
-
-    /**
-     * @param threadLoc Thread local.
-     * @return {@code True} if thread-local was added.
-     */
-    private boolean addThreadLocal(GridThreadLocalEx<?> threadLoc) {
-        assert threadLoc != null;
-
-        ThreadContext ctx = threadCtx.get();
-
-        return ctx.entered() && ctx.add(threadLoc);
-    }
-
-    /**
-     *
-     */
-    private static class ThreadContext {
-        /** Entered flag. */
-        private int entered;
-
-        /** Thread locals for given thread context. */
-        private Collection<GridThreadLocalEx<?>> threadLocals = new HashSet<>();
-
-        /**
-         * Enter callback.
-         */
-        void enter() {
-            assert entered >= 0 : "Thread context gateway cannot be negative prior to
enter: " + entered;
-
-            entered++;
-        }
-
-        /**
-         * Leave callback.
-         */
-        void leave() {
-            assert entered > 0 : "Thread context gateway must be positive prior to leave:
" + entered;
-
-            entered--;
-
-            if (entered == 0)
-                reset();
-        }
-
-        /**
-         * @param threadLoc Thread local to add.
-         * @return {@code True} if thread local was added.
-         */
-        boolean add(GridThreadLocalEx<?> threadLoc) {
-            return threadLocals.add(threadLoc);
-        }
-
-        /**
-         * @return Thread locals.
-         */
-        Collection<GridThreadLocalEx<?>> threadLocals() {
-            return threadLocals;
-        }
-
-        /**
-         * @return Entered flag.
-         */
-        boolean entered() {
-            return entered > 0;
-        }
-
-        /**
-         * Resets thread locals.
-         */
-        private void reset() {
-            if (!threadLocals.isEmpty()) {
-                for (GridThreadLocalEx<?> threadLocal : threadLocals)
-                    threadLocal.reset();
-
-                threadLocals.clear();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 89bb6f2..af5b838 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -743,7 +743,7 @@ public abstract class IgniteUtils {
      */
     @Deprecated
     public static void debug(Object msg) {
-        X.println(debugPrefix() + msg);
+        X.error(debugPrefix() + msg);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
index 5246067..5091655 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
@@ -179,12 +179,15 @@ public class GridFutureAdapter<R> extends AbstractQueuedSynchronizer
implements
                         else {
                             lsnr = (IgniteInClosure)new ArrayListener<IgniteInternalFuture>(lsnr,
lsnr0);
                         }
+
+                        return;
                     }
                 }
             }
 
-            if (done)
-                notifyListener(lsnr0);
+            assert done;
+
+            notifyListener(lsnr0);
         }
     }
 
@@ -197,20 +200,20 @@ public class GridFutureAdapter<R> extends AbstractQueuedSynchronizer
implements
      * Notifies all registered listeners.
      */
     private void notifyListeners() {
-        IgniteInClosure<? super IgniteInternalFuture<R>> lsnrs0;
+        IgniteInClosure<? super IgniteInternalFuture<R>> lsnr0;
 
         synchronized (this) {
-            lsnrs0 = lsnr;
+            lsnr0 = lsnr;
 
-            if (lsnrs0 == null)
+            if (lsnr0 == null)
                 return;
 
             lsnr = null;
         }
 
-        assert lsnrs0 != null;
+        assert lsnr0 != null;
 
-        notifyListener(lsnrs0);
+        notifyListener(lsnr0);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bf01a407/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
index 12c5234..4319b61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/worker/GridWorker.java
@@ -19,11 +19,9 @@ package org.apache.ignite.internal.util.worker;
 
 import org.apache.ignite.*;
 import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
-import java.util.*;
 import java.util.concurrent.*;
 
 /**
@@ -55,9 +53,6 @@ public abstract class GridWorker implements Runnable {
     /** Parent thread. */
     private final Thread parent;
 
-    /** Inherited thread locals. */
-    private final Map<GridThreadLocalEx<?>, ?> inherited;
-
     /** */
     private final Object mux = new Object();
 
@@ -87,8 +82,6 @@ public abstract class GridWorker implements Runnable {
                     GridWorker.log = log.getLogger(GridWorker.class);
             }
         }
-
-        inherited = GridThreadLocalEx.inherit();
     }
 
     /**
@@ -104,30 +97,12 @@ public abstract class GridWorker implements Runnable {
         this(gridName, name, log, null);
     }
 
-    /**
-     * Enter thread locals.
-     */
-    private void enterThreadLocals() {
-        GridThreadLocal.enter();
-        GridThreadLocalEx.enter(inherited);
-    }
-
-    /**
-     * Leave thread locals.
-     */
-    private void leaveThreadLocals() {
-        GridThreadLocalEx.leave();
-        GridThreadLocal.leave();
-    }
-
     /** {@inheritDoc} */
     @Override public final void run() {
         // Runner thread must be recorded first as other operations
         // may depend on it being present.
         runner = Thread.currentThread();
 
-        enterThreadLocals();
-
         IgniteLogger log = GridWorker.log;
 
         if (log.isDebugEnabled())
@@ -179,8 +154,6 @@ public abstract class GridWorker implements Runnable {
                 else
                     log.debug("Grid runnable finished normally: " + name);
 
-            leaveThreadLocals();
-
             // Need to set runner to null, to make sure that
             // further operations on this runnable won't
             // affect the thread which could have been recycled


Mime
View raw message