ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [10/25] incubator-ignite git commit: #IGNITE-53: Move classes from package org.gridgain.grid.kernal.processors.cache to org.apache.ignite.internal.processors.cache
Date Tue, 27 Jan 2015 07:01:02 GMT
#IGNITE-53: Move classes from package org.gridgain.grid.kernal.processors.cache to org.apache.ignite.internal.processors.cache


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

Branch: refs/heads/ignite-59
Commit: 9fd191a22f39716ff2f9d8b30bc3a371f6582a0f
Parents: 7faa36f
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Mon Jan 26 12:12:54 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Mon Jan 26 12:12:54 2015 +0300

----------------------------------------------------------------------
 .../cache/CacheIteratorConverter.java           |  39 ++++
 .../cache/CacheWeakQueryIteratorsHolder.java    | 228 +++++++++++++++++++
 .../processors/cache/GridCacheAdapter.java      |   1 -
 .../processors/cache/GridCacheContext.java      |   1 -
 .../cache/datastructures/GridCacheSetImpl.java  |   3 -
 .../cache/CacheIteratorConverter.java           |  39 ----
 .../cache/CacheWeakQueryIteratorsHolder.java    | 228 -------------------
 7 files changed, 267 insertions(+), 272 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fd191a2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIteratorConverter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIteratorConverter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIteratorConverter.java
new file mode 100644
index 0000000..9df9849
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheIteratorConverter.java
@@ -0,0 +1,39 @@
+/*
+ * 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.processors.cache;
+
+/**
+ * @param <T> Type for iterator.
+ * @param <V> Type for cache query future.
+ */
+public abstract class CacheIteratorConverter <T, V> {
+    /**
+     * Converts class V to class T.
+     *
+     * @param v Item to convert.
+     * @return Converted item.
+     */
+    protected abstract T convert(V v);
+
+    /**
+     * Removes item.
+     *
+     * @param item Item to remove.
+     */
+    protected abstract void remove(T item);
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fd191a2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
new file mode 100644
index 0000000..902cf12
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheWeakQueryIteratorsHolder.java
@@ -0,0 +1,228 @@
+/*
+ * 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.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.query.*;
+import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.jdk8.backport.*;
+
+import java.lang.ref.*;
+import java.util.*;
+
+/**
+ * @param <V> Type for cache query future.
+ */
+public class CacheWeakQueryIteratorsHolder<V> {
+    /** Iterators weak references queue. */
+    private final ReferenceQueue<WeakQueryFutureIterator> refQueue = new ReferenceQueue<>();
+
+    /** Iterators futures. */
+    private final Map<WeakReference<WeakQueryFutureIterator>, CacheQueryFuture<V>>
futs =
+        new ConcurrentHashMap8<>();
+
+    /** Logger. */
+    private final IgniteLogger log;
+
+    /**
+     * @param log Logger.
+     */
+    public CacheWeakQueryIteratorsHolder(IgniteLogger log) {
+        this.log = log;
+    }
+
+    /**
+     * @param fut Query to iterate.
+     * @param convert Cache iterator converter.
+     * @param <T> Type for the iterator.
+     * @return Iterator over the cache.
+     */
+    public <T> WeakQueryFutureIterator iterator(CacheQueryFuture<V> fut, CacheIteratorConverter<T,
V> convert) {
+        WeakQueryFutureIterator it = new WeakQueryFutureIterator(fut, convert);
+
+        CacheQueryFuture<V> old = futs.put(it.weakReference(), fut);
+
+        assert old == null;
+
+        return it;
+    }
+
+    /**
+     * @param it Iterator.
+     *
+     * @throws IgniteCheckedException If failed.
+     */
+    public void removeIterator(WeakQueryFutureIterator it) throws IgniteCheckedException
{
+        futs.remove(it.weakReference());
+
+        it.close();
+    }
+
+    /**
+     * Closes unreachable iterators.
+     */
+    public void checkWeakQueue() {
+        for (Reference<? extends WeakQueryFutureIterator> itRef = refQueue.poll();
itRef != null;
+            itRef = refQueue.poll()) {
+            try {
+                WeakReference<WeakQueryFutureIterator> weakRef = (WeakReference<WeakQueryFutureIterator>)itRef;
+
+                CacheQueryFuture<?> fut = futs.remove(weakRef);
+
+                if (fut != null)
+                    fut.cancel();
+            }
+            catch (IgniteCheckedException e) {
+                U.error(log, "Failed to close iterator.", e);
+            }
+        }
+    }
+
+    /**
+     * Cancel all cache queries.
+     */
+    public void clearQueries(){
+        for (CacheQueryFuture<?> fut : futs.values()) {
+            try {
+                fut.cancel();
+            }
+            catch (IgniteCheckedException e) {
+                U.error(log, "Failed to close iterator.", e);
+            }
+        }
+
+        futs.clear();
+    }
+
+
+    /**
+     * Iterator based of {@link CacheQueryFuture}.
+     *
+     * @param <T> Type for iterator.
+     */
+    public class WeakQueryFutureIterator<T> extends GridCloseableIteratorAdapter<T>
{
+        /** Query future. */
+        private final CacheQueryFuture<V> fut;
+
+        /** Weak reference. */
+        private final WeakReference<WeakQueryFutureIterator<T>> weakRef;
+
+        CacheIteratorConverter<T, V> convert;
+
+        /** Init flag. */
+        private boolean init;
+
+        /** Next item. */
+        private T next;
+
+        /** Current item. */
+        private T cur;
+
+        /**
+         * @param fut GridCacheQueryFuture to iterate.
+         */
+        WeakQueryFutureIterator(CacheQueryFuture<V> fut, CacheIteratorConverter<T,
V> convert) {
+            this.fut = fut;
+
+            this.weakRef = new WeakReference<>(this, refQueue);
+
+            this.convert = convert;
+        }
+
+        /** {@inheritDoc} */
+        @Override public T onNext() throws IgniteCheckedException {
+            init();
+
+            if (next == null) {
+                clearWeakReference();
+
+                throw new NoSuchElementException();
+            }
+
+            cur = next;
+
+            V futNext = fut.next();
+
+            if (futNext == null)
+                clearWeakReference();
+
+            next = futNext != null ? convert.convert(futNext) : null;
+
+            return cur;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean onHasNext() throws IgniteCheckedException {
+            init();
+
+            boolean hasNext = next != null;
+
+            if (!hasNext)
+                clearWeakReference();
+
+            return hasNext;
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void onClose() throws IgniteCheckedException {
+            fut.cancel();
+
+            clearWeakReference();
+        }
+
+        /** {@inheritDoc} */
+        @Override protected void onRemove() throws IgniteCheckedException {
+            if (cur == null)
+                throw new IllegalStateException();
+
+            convert.remove(cur);
+
+            cur = null;
+        }
+
+        /**
+         * @return Iterator weak reference.
+         */
+        private WeakReference<WeakQueryFutureIterator<T>> weakReference() {
+            return weakRef;
+        }
+
+        /**
+         * Clears weak reference.
+         */
+        private void clearWeakReference() {
+            weakRef.clear();
+
+            futs.remove(weakRef);
+        }
+
+        /**
+         * @throws IgniteCheckedException If failed.
+         */
+        private void init() throws IgniteCheckedException {
+            if (!init) {
+                V futNext = fut.next();
+
+                next = futNext != null ? convert.convert(futNext) : null;
+
+                init = true;
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fd191a2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 3c0ed75..4ec52bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -46,7 +46,6 @@ import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
-import org.gridgain.grid.kernal.processors.cache.*;
 import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fd191a2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index d1dcaa3..1e8e090 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -52,7 +52,6 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.offheap.unsafe.*;
 import org.apache.ignite.internal.util.tostring.*;
-import org.gridgain.grid.kernal.processors.cache.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.configuration.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fd191a2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetImpl.java
index b84d957..2bb679b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheSetImpl.java
@@ -30,12 +30,9 @@ import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
-import org.gridgain.grid.kernal.processors.cache.*;
-import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
-import java.lang.ref.*;
 import java.util.*;
 import java.util.concurrent.*;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fd191a2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheIteratorConverter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheIteratorConverter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheIteratorConverter.java
deleted file mode 100644
index 466460d..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheIteratorConverter.java
+++ /dev/null
@@ -1,39 +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.cache;
-
-/**
- * @param <T> Type for iterator.
- * @param <V> Type for cache query future.
- */
-public abstract class CacheIteratorConverter <T, V> {
-    /**
-     * Converts class V to class T.
-     *
-     * @param v Item to convert.
-     * @return Converted item.
-     */
-    protected abstract T convert(V v);
-
-    /**
-     * Removes item.
-     *
-     * @param item Item to remove.
-     */
-    protected abstract void remove(T item);
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9fd191a2/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheWeakQueryIteratorsHolder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheWeakQueryIteratorsHolder.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheWeakQueryIteratorsHolder.java
deleted file mode 100644
index eea72fe..0000000
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/CacheWeakQueryIteratorsHolder.java
+++ /dev/null
@@ -1,228 +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.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.query.*;
-import org.apache.ignite.internal.util.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.jdk8.backport.*;
-
-import java.lang.ref.*;
-import java.util.*;
-
-/**
- * @param <V> Type for cache query future.
- */
-public class CacheWeakQueryIteratorsHolder<V> {
-    /** Iterators weak references queue. */
-    private final ReferenceQueue<WeakQueryFutureIterator> refQueue = new ReferenceQueue<>();
-
-    /** Iterators futures. */
-    private final Map<WeakReference<WeakQueryFutureIterator>, CacheQueryFuture<V>>
futs =
-        new ConcurrentHashMap8<>();
-
-    /** Logger. */
-    private final IgniteLogger log;
-
-    /**
-     * @param log Logger.
-     */
-    public CacheWeakQueryIteratorsHolder(IgniteLogger log) {
-        this.log = log;
-    }
-
-    /**
-     * @param fut Query to iterate.
-     * @param convert Cache iterator converter.
-     * @param <T> Type for the iterator.
-     * @return Iterator over the cache.
-     */
-    public <T> WeakQueryFutureIterator iterator(CacheQueryFuture<V> fut, CacheIteratorConverter<T,
V> convert) {
-        WeakQueryFutureIterator it = new WeakQueryFutureIterator(fut, convert);
-
-        CacheQueryFuture<V> old = futs.put(it.weakReference(), fut);
-
-        assert old == null;
-
-        return it;
-    }
-
-    /**
-     * @param it Iterator.
-     *
-     * @throws IgniteCheckedException If failed.
-     */
-    public void removeIterator(WeakQueryFutureIterator it) throws IgniteCheckedException
{
-        futs.remove(it.weakReference());
-
-        it.close();
-    }
-
-    /**
-     * Closes unreachable iterators.
-     */
-    public void checkWeakQueue() {
-        for (Reference<? extends WeakQueryFutureIterator> itRef = refQueue.poll();
itRef != null;
-            itRef = refQueue.poll()) {
-            try {
-                WeakReference<WeakQueryFutureIterator> weakRef = (WeakReference<WeakQueryFutureIterator>)itRef;
-
-                CacheQueryFuture<?> fut = futs.remove(weakRef);
-
-                if (fut != null)
-                    fut.cancel();
-            }
-            catch (IgniteCheckedException e) {
-                U.error(log, "Failed to close iterator.", e);
-            }
-        }
-    }
-
-    /**
-     * Cancel all cache queries.
-     */
-    public void clearQueries(){
-        for (CacheQueryFuture<?> fut : futs.values()) {
-            try {
-                fut.cancel();
-            }
-            catch (IgniteCheckedException e) {
-                U.error(log, "Failed to close iterator.", e);
-            }
-        }
-
-        futs.clear();
-    }
-
-
-    /**
-     * Iterator based of {@link CacheQueryFuture}.
-     *
-     * @param <T> Type for iterator.
-     */
-    public class WeakQueryFutureIterator<T> extends GridCloseableIteratorAdapter<T>
{
-        /** Query future. */
-        private final CacheQueryFuture<V> fut;
-
-        /** Weak reference. */
-        private final WeakReference<WeakQueryFutureIterator<T>> weakRef;
-
-        CacheIteratorConverter<T, V> convert;
-
-        /** Init flag. */
-        private boolean init;
-
-        /** Next item. */
-        private T next;
-
-        /** Current item. */
-        private T cur;
-
-        /**
-         * @param fut GridCacheQueryFuture to iterate.
-         */
-        WeakQueryFutureIterator(CacheQueryFuture<V> fut, CacheIteratorConverter<T,
V> convert) {
-            this.fut = fut;
-
-            this.weakRef = new WeakReference<>(this, refQueue);
-
-            this.convert = convert;
-        }
-
-        /** {@inheritDoc} */
-        @Override public T onNext() throws IgniteCheckedException {
-            init();
-
-            if (next == null) {
-                clearWeakReference();
-
-                throw new NoSuchElementException();
-            }
-
-            cur = next;
-
-            V futNext = fut.next();
-
-            if (futNext == null)
-                clearWeakReference();
-
-            next = futNext != null ? convert.convert(futNext) : null;
-
-            return cur;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean onHasNext() throws IgniteCheckedException {
-            init();
-
-            boolean hasNext = next != null;
-
-            if (!hasNext)
-                clearWeakReference();
-
-            return hasNext;
-        }
-
-        /** {@inheritDoc} */
-        @Override protected void onClose() throws IgniteCheckedException {
-            fut.cancel();
-
-            clearWeakReference();
-        }
-
-        /** {@inheritDoc} */
-        @Override protected void onRemove() throws IgniteCheckedException {
-            if (cur == null)
-                throw new IllegalStateException();
-
-            convert.remove(cur);
-
-            cur = null;
-        }
-
-        /**
-         * @return Iterator weak reference.
-         */
-        private WeakReference<WeakQueryFutureIterator<T>> weakReference() {
-            return weakRef;
-        }
-
-        /**
-         * Clears weak reference.
-         */
-        private void clearWeakReference() {
-            weakRef.clear();
-
-            futs.remove(weakRef);
-        }
-
-        /**
-         * @throws IgniteCheckedException If failed.
-         */
-        private void init() throws IgniteCheckedException {
-            if (!init) {
-                V futNext = fut.next();
-
-                next = futNext != null ? convert.convert(futNext) : null;
-
-                init = true;
-            }
-        }
-    }
-}


Mime
View raw message