ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [14/14] ignite git commit: IGNITE-3227 - Code review
Date Mon, 04 Jul 2016 03:46:53 GMT
IGNITE-3227 - Code review


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

Branch: refs/heads/ignite-3227
Commit: 2e8b36b18fa7386b5c3537a1f4d1bca7d8aa1756
Parents: dd7943a
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Sun Jul 3 20:46:12 2016 -0700
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Sun Jul 3 20:46:12 2016 -0700

----------------------------------------------------------------------
 examples/config/example-client.xml              |  71 ------
 .../datagrid/CacheClientCacheSizeExample.java   |  79 -------
 .../processors/cache/GridCacheAdapter.java      | 214 +++----------------
 .../processors/cache/GridCacheProxyImpl.java    |  36 ----
 .../processors/cache/IgniteCacheProxy.java      |  33 ++-
 .../processors/cache/IgniteInternalCache.java   |  24 ---
 6 files changed, 64 insertions(+), 393 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2e8b36b1/examples/config/example-client.xml
----------------------------------------------------------------------
diff --git a/examples/config/example-client.xml b/examples/config/example-client.xml
deleted file mode 100644
index 07055ab..0000000
--- a/examples/config/example-client.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-  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.
--->
-
-<!--
-    Ignite getConfiguration with all defaults and enabled p2p deployment and enabled events.
-    Used for testing IgniteSink running Ignite in a client mode.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:util="http://www.springframework.org/schema/util"
-       xsi:schemaLocation="
-        http://www.springframework.org/schema/beans
-        http://www.springframework.org/schema/beans/spring-beans.xsd
-        http://www.springframework.org/schema/util
-        http://www.springframework.org/schema/util/spring-util.xsd">
-    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
-        <!-- Enable client mode. -->
-        <property name="clientMode" value="true"/>
-
-        <!-- Cache accessed from IgniteSink. -->
-        <property name="cacheConfiguration">
-            <list>
-                <!-- Partitioned cache example getConfiguration with configurations adjusted
to server nodes'. -->
-                <bean class="org.apache.ignite.configuration.CacheConfiguration">
-                    <property name="atomicityMode" value="ATOMIC"/>
-
-
-                </bean>
-            </list>
-        </property>
-
-        <!-- Enable cache events. -->
-        <property name="includeEventTypes">
-            <list>
-                <!-- Cache events (only EVT_CACHE_OBJECT_PUT for tests). -->
-                <util:constant static-field="org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT"/>
-            </list>
-        </property>
-
-        <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes.
-->
-        <property name="discoverySpi">
-            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
-                <property name="ipFinder">
-                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
-                        <property name="addresses">
-                            <list>
-                                <value>127.0.0.1:47500</value>
-                            </list>
-                        </property>
-                    </bean>
-                </property>
-            </bean>
-        </property>
-    </bean>
-</beans>

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e8b36b1/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheClientCacheSizeExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheClientCacheSizeExample.java
b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheClientCacheSizeExample.java
deleted file mode 100644
index 041d517..0000000
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheClientCacheSizeExample.java
+++ /dev/null
@@ -1,79 +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.examples.datagrid;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.examples.ExampleNodeStartup;
-
-
-/**
- * This example demonstrates very basic operations on cache, such as size.
- * <p>
- * Remote nodes should always be started with special configuration file which
- * enables P2P class loading: {@code 'ignite.{sh|bat} examples/config/example-ignite.xml'}.
- * <p>
- * Alternatively you can run {@link ExampleNodeStartup} in another JVM which will
- * start node with {@code examples/config/example-ignite.xml} configuration.
- */
-public class CacheClientCacheSizeExample {
-    /** Cache name. */
-    private static final String CACHE_NAME = CacheClientCacheSizeExample.class.getSimpleName();
-
-    /**
-     * Executes example.
-     *
-     * @param args Command line arguments, none required.
-     * @throws IgniteException If example execution failed.
-     */
-    public static void main(String[] args) throws IgniteException {
-        try (Ignite ignite = Ignition.start("examples/config/example-client.xml")) {
-            try (IgniteCache<Integer, String> cache = ignite.getOrCreateCache(CACHE_NAME))
{
-                // Individual puts and gets.
-                putGet(cache);
-                System.out.println(">>> cache size is " +cache.size());
-                System.out.println(">>> cache partition are "+ignite.affinity(CACHE_NAME).partitions());
-                System.out.println(">>> cache size in primary partition "+ 0 +"is
"+cache.size(0, CachePeekMode.PRIMARY));
-            }
-        }
-    }
-
-    /**
-     * Execute individual puts and gets.
-     *
-     * @throws IgniteException If failed.
-     */
-    private static void putGet(IgniteCache<Integer, String> cache) throws IgniteException
{
-        System.out.println();
-        System.out.println(">>> Cache put-get example started.");
-
-        final int keyCnt = 5000;
-
-        // Store keys in cache.
-        for (int i = 0; i < keyCnt; i++)
-            cache.put(i, Integer.toString(i));
-
-        System.out.println(">>> Stored values in cache.");
-
-        for (int i = 0; i < keyCnt; i++)
-            System.out.println("Got [key=" + i + ", val=" + cache.get(i) + ']');
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e8b36b1/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 245009d..f08b27e 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
@@ -3830,14 +3830,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
     }
 
     /** {@inheritDoc} */
-    @Override public int size(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException
{
-        if (isLocal())
-            return localSize(partition, peekModes);
-
-        return sizeAsync(partition, peekModes).get();
-    }
-
-    /** {@inheritDoc} */
     @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException
{
         if (isLocal())
             return localSizeLong(peekModes);
@@ -3875,27 +3867,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Integer> sizeAsync(final int partition, final
CachePeekMode[] peekModes) {
-        assert peekModes != null;
-
-        PeekModes modes = parsePeekModes(peekModes, true);
-
-        IgniteClusterEx cluster = ctx.grid().cluster();
-
-        ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, true, false)
: cluster.forDataNodes(name());
-
-        Collection<ClusterNode> nodes = grp.nodes();
-
-        if (nodes.isEmpty())
-            return new GridFinishedFuture<>(0);
-
-        ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
-
-        return ctx.kernalContext().task().execute(
-                new PartitionSizeTask(ctx.name(), ctx.affinity().affinityTopologyVersion(),
peekModes, partition), null);
-    }
-
-    /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Long> sizeLongAsync(final CachePeekMode[]
peekModes) {
         assert peekModes != null;
 
@@ -3943,11 +3914,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
     }
 
     /** {@inheritDoc} */
-    @Override public int localSize(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException
{
-        return (int)localSizeLong(partition, peekModes);
-    }
-
-    /** {@inheritDoc} */
     @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException
{
         PeekModes modes = parsePeekModes(peekModes, true);
 
@@ -4000,38 +3966,38 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
         PeekModes modes = parsePeekModes(peekModes, true);
 
         long size = 0;
+
         AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
 
-        if (ctx.affinity().localNode(partition, topVer)) {
-            if(ctx.isLocal()){
-                modes.primary = true;
-                modes.backup = true;
+        // Swap and offheap are disabled for near cache.
+        GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap() :
ctx.swap();
 
-                if (modes.heap)
-                    size += size();
-            } else {
-                if (modes.heap) {
-                    GridDhtLocalPartition gridDhtLocalPartition = ctx.topology().localPartition(partition,
topVer, false);
+        if (ctx.isLocal()){
+            modes.primary = true;
+            modes.backup = true;
 
-                    if (!(gridDhtLocalPartition == null)){
-                        if (modes.primary && gridDhtLocalPartition.primary(topVer))
{
-                            size += gridDhtLocalPartition.publicSize();
-                        }
-                        else if (modes.backup && gridDhtLocalPartition.backup(topVer))
{
-                            size += gridDhtLocalPartition.publicSize();
-                        }
-                    }
-                }
-            }
-            // Swap and offheap are disabled for near cache.
-            if (modes.primary || modes.backup) {
-                GridCacheSwapManager swapMgr = ctx.isNear() ? ctx.near().dht().context().swap()
: ctx.swap();
+            if (modes.heap)
+                size += size();
+
+            if (modes.swap)
+                size += swapMgr.swapEntriesCount(0);
+
+            if (modes.offheap)
+                size += swapMgr.offheapEntriesCount(0);
+        }
+        else {
+            GridDhtLocalPartition part = ctx.topology().localPartition(partition, topVer,
false);
+
+            if (part != null) {
+                if (modes.primary && part.primary(topVer) || modes.backup &&
part.backup(topVer)) {
+                    size += part.publicSize();
 
-                if (modes.swap)
-                    size += swapMgr.swapEntriesCount(partition);
+                    if (modes.swap)
+                        size += swapMgr.swapEntriesCount(partition);
 
-                if (modes.offheap)
-                    size += swapMgr.offheapEntriesCount(partition);
+                    if (modes.offheap)
+                        size += swapMgr.offheapEntriesCount(partition);
+                }
             }
         }
 
@@ -5642,52 +5608,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
     }
 
     /**
-     * Internal callable for partition size calculation.
-     */
-    @GridInternal
-    private static class PartitionSizeJob extends TopologyVersionAwareJob {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** Partition. */
-        private final int partition;
-
-        /** Peek modes. */
-        private final CachePeekMode[] peekModes;
-
-        /**
-         * @param cacheName Cache name.
-         * @param topVer Affinity topology version.
-         * @param peekModes Cache peek modes.
-         * @param partition partition.
-         */
-        private PartitionSizeJob(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[]
peekModes, int partition) {
-            super(cacheName, topVer);
-
-            this.peekModes = peekModes;
-            this.partition = partition;
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public Object localExecute(@Nullable IgniteInternalCache cache)
{
-            if (cache == null)
-                return 0;
-
-            try {
-                return cache.localSize(partition, peekModes);
-            }
-            catch (IgniteCheckedException e) {
-                throw U.convertException(e);
-            }
-        }
-
-        /** {@inheritDoc} */
-        public String toString() {
-            return S.toString(PartitionSizeJob.class, this);
-        }
-    }
-
-    /**
      * Internal callable for global size calculation.
      */
     @GridInternal
@@ -6645,76 +6565,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
     }
 
     /**
-     * Partition Size task.
-     */
-    private static class PartitionSizeTask extends ComputeTaskAdapter<Object, Integer>
{
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** Partition. */
-        private final int partition;
-
-        /** Cache name. */
-        private final String cacheName;
-
-        /** Affinity topology version. */
-        private final AffinityTopologyVersion topVer;
-
-        /** Peek modes. */
-        private final CachePeekMode[] peekModes;
-
-        /**
-         * @param cacheName Cache name.
-         * @param topVer Affinity topology version.
-         * @param peekModes Cache peek modes.
-         * @param partition partition.
-         */
-        public PartitionSizeTask(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[]
peekModes, int partition) {
-            this.cacheName = cacheName;
-            this.topVer = topVer;
-            this.peekModes = peekModes;
-            this.partition = partition;
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode>
subgrid,
-                                                                              @Nullable Object
arg) throws IgniteException {
-            Map<ComputeJob, ClusterNode> jobs = new HashMap();
-
-            for (ClusterNode node : subgrid)
-                jobs.put(new PartitionSizeJob(cacheName, topVer, peekModes, partition), node);
-
-            return jobs;
-        }
-
-        /** {@inheritDoc} */
-        @Override public ComputeJobResultPolicy result(ComputeJobResult res, List<ComputeJobResult>
rcvd) {
-            IgniteException e = res.getException();
-
-            if (e != null) {
-                if (e instanceof ClusterTopologyException)
-                    return ComputeJobResultPolicy.WAIT;
-
-                throw new IgniteException("Remote job threw exception.", e);
-            }
-
-            return ComputeJobResultPolicy.WAIT;
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public Integer reduce(List<ComputeJobResult> results) throws
IgniteException {
-            int size = 0;
-
-            for (ComputeJobResult res : results) {
-                if (res.getException() == null && res != null)
-                    size += res.<Integer>getData();
-            }
-
-            return size;
-        }
-    }
-
-    /**
      * Size task.
      */
     private static class SizeLongTask extends ComputeTaskAdapter<Object, Long> {
@@ -6735,7 +6585,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
          * @param topVer Affinity topology version.
          * @param peekModes Cache peek modes.
          */
-        public SizeLongTask(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[]
peekModes) {
+        private SizeLongTask(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[]
peekModes) {
             this.cacheName = cacheName;
             this.topVer = topVer;
             this.peekModes = peekModes;
@@ -6804,7 +6654,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
          * @param peekModes Cache peek modes.
          * @param partition partition.
          */
-        public PartitionSizeLongTask(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[]
peekModes, int partition) {
+        private PartitionSizeLongTask(String cacheName, AffinityTopologyVersion topVer, CachePeekMode[]
peekModes, int partition) {
             this.cacheName = cacheName;
             this.topVer = topVer;
             this.peekModes = peekModes;
@@ -6841,8 +6691,12 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
             long size = 0;
 
             for (ComputeJobResult res : results) {
-                if (res != null && res.getException() == null)
-                    size += res.<Long>getData();
+                if (res != null) {
+                    if (res.getException() == null)
+                        size += res.<Long>getData();
+                    else
+                        throw res.getException();
+                }
             }
 
             return size;

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e8b36b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 01310a2..00898ec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -1460,18 +1460,6 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K,
V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public int size(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException
{
-        CacheOperationContext prev = gate.enter(opCtx);
-
-        try {
-            return delegate.size(partition, peekModes);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException
{
         CacheOperationContext prev = gate.enter(opCtx);
 
@@ -1508,18 +1496,6 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K,
V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Integer> sizeAsync(int partition, CachePeekMode[]
peekModes) {
-        CacheOperationContext prev = gate.enter(opCtx);
-
-        try {
-            return delegate.sizeAsync(partition, peekModes);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Long> sizeLongAsync(CachePeekMode[] peekModes)
{
         CacheOperationContext prev = gate.enter(opCtx);
 
@@ -1556,18 +1532,6 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K,
V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public int localSize(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException
{
-        CacheOperationContext prev = gate.enter(opCtx);
-
-        try {
-            return delegate.localSize(partition, peekModes);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException
{
         CacheOperationContext prev = gate.enter(opCtx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e8b36b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 447da5f..828d629 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -75,6 +75,7 @@ import org.apache.ignite.internal.util.lang.GridClosureException;
 import org.apache.ignite.internal.util.lang.IgniteOutClosureX;
 import org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.C1;
 import org.apache.ignite.internal.util.typedef.CI1;
 import org.apache.ignite.internal.util.typedef.CX1;
 import org.apache.ignite.internal.util.typedef.internal.A;
@@ -864,12 +865,31 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
 
         try {
             if (isAsync()) {
-                setFuture(delegate.sizeAsync(partition, peekModes));
+                IgniteInternalFuture<Long> fut = delegate.sizeLongAsync(partition,
peekModes);
+
+                IgniteInternalFuture<Integer> resFut = fut.chain(new C1<IgniteInternalFuture<Long>,
Integer>() {
+                    @Override public Integer apply(IgniteInternalFuture<Long> res)
{
+                        try {
+                            Long longRes = res.get();
+
+                            if (longRes != null && longRes > Integer.MAX_VALUE)
+                                throw new IgniteCheckedException("Size is too big " +
+                                    "(use sizeLong(...) methods instead): " + longRes);
+
+                            return longRes == null ? 0 : (int)(long)longRes;
+                        }
+                        catch (IgniteCheckedException e) {
+                            throw new GridClosureException(e);
+                        }
+                    }
+                });
+
+                setFuture(resFut);
 
                 return 0;
             }
             else
-                return delegate.size(partition, peekModes);
+                return castSize(delegate.sizeLong(partition, peekModes));
         }
         catch (IgniteCheckedException e) {
             throw cacheException(e);
@@ -926,7 +946,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
         CacheOperationContext prev = onEnter(gate, opCtx);
 
         try {
-            return delegate.localSize(partition, peekModes);
+            return castSize(delegate.localSizeLong(partition, peekModes));
         }
         catch (IgniteCheckedException e) {
             throw cacheException(e);
@@ -2224,6 +2244,13 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
         }
     }
 
+    private int castSize(long size) throws CacheException {
+        if (size > Integer.MAX_VALUE)
+            throw new CacheException("Size is too big (use sizeLong(...) methods instead):
" + size);
+
+        return (int)size;
+    }
+
     /** {@inheritDoc} */
     @Override public String toString() {
         return S.toString(IgniteCacheProxy.class, this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e8b36b1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index c49b93c..0ac98fb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -1447,14 +1447,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K,
V>> {
     public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException;
 
     /**
-     * @param partition partition.
-     * @param peekModes Peek modes.
-     * @return Local cache size.
-     * @throws IgniteCheckedException If failed.
-     */
-    public int localSize(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException;
-
-    /**
      * @param peekModes Peek modes.
      * @return Local cache size as a long value.
      * @throws IgniteCheckedException If failed.
@@ -1469,7 +1461,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K,
V>> {
      */
     public long localSizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException;
 
-
     /**
      * @param peekModes Peek modes.
      * @return Global cache size.
@@ -1478,14 +1469,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K,
V>> {
     public int size(CachePeekMode[] peekModes) throws IgniteCheckedException;
 
     /**
-     * @param partition partition
-     * @param peekModes Peek modes.
-     * @return Global cache size.
-     * @throws IgniteCheckedException If failed.
-     */
-    public int size(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException;
-
-    /**
      * @param peekModes Peek modes.
      * @return Global cache size as a long value.
      * @throws IgniteCheckedException If failed.
@@ -1507,13 +1490,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K,
V>> {
     public IgniteInternalFuture<Integer> sizeAsync(CachePeekMode[] peekModes);
 
     /**
-     * @param partition partition
-     * @param peekModes Peek modes.
-     * @return Future.
-     */
-    public IgniteInternalFuture<Integer> sizeAsync(int partition, CachePeekMode[] peekModes);
-
-    /**
      * @param peekModes Peek modes.
      * @return Future.
      */


Mime
View raw message