use of org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl in project ignite by apache.
the class GridCommonAbstractTest method calcAffinity.
/**
* @param cache Cache.
* @param nodes Nodes.
*/
private List<List<ClusterNode>> calcAffinity(IgniteCache<?, ?> cache, List<ClusterNode> nodes) {
IgniteCacheProxyImpl proxy = cache.unwrap(IgniteCacheProxyImpl.class);
GridCacheContext<?, ?> cctx = proxy.context();
AffinityFunction func = cctx.config().getAffinity();
AffinityFunctionContext ctx = new GridAffinityFunctionContextImpl(nodes, null, null, AffinityTopologyVersion.NONE, cctx.config().getBackups());
return func.assignPartitions(ctx);
}
use of org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl in project ignite by apache.
the class IgniteSqlSinglePartitionMultiParallelismTest method segmenKey.
/**
* @param segment Target index segment.
* @return Cache key for target segment.
*/
protected Integer segmenKey(int segment) {
IgniteCache<Object, Object> cache = ignite(0).cache(CACHE_NAME);
IgniteCacheProxyImpl proxy = cache.unwrap(IgniteCacheProxyImpl.class);
GridCacheContext<?, ?> cctx = proxy.context();
for (int k = 1; k <= KEY_CNT; k++) {
int keySegment = InlineIndexImpl.calculateSegment(CACHE_PARALLELISM, cctx.affinity().partition(k));
if (keySegment == segment)
return k;
}
throw new IgniteException("Key is not found. Please, check range of keys and segmentsCnt. " + "Requested segmentId is " + segment);
}
use of org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl in project ignite by apache.
the class GridCommonAbstractTest method partitionKeysIterator.
/**
* @param cache Cache.
* @param part Partition.
* @return Unbounded iterator for partition keys.
*/
protected Iterator<Integer> partitionKeysIterator(IgniteCache<?, ?> cache, int part) {
IgniteCacheProxyImpl proxy = cache.unwrap(IgniteCacheProxyImpl.class);
GridCacheContext<?, ?> cctx = proxy.context();
return new Iterator<Integer>() {
int cur, next = 0;
{
advance();
}
private void advance() {
while (cctx.affinity().partition(cur = next++) != part) ;
}
@Override
public boolean hasNext() {
return true;
}
@Override
public Integer next() {
int tmp = cur;
advance();
return tmp;
}
};
}
use of org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl in project ignite by apache.
the class GridCommonAbstractTest method partitionKeys.
/**
* @param cache Cache.
* @param part Partition.
* @param cnt Count.
* @param skipCnt Skip keys from start.
* @return List of keys for partition.
*/
protected List<Integer> partitionKeys(IgniteCache<?, ?> cache, int part, int cnt, int skipCnt) {
IgniteCacheProxyImpl proxy = cache.unwrap(IgniteCacheProxyImpl.class);
GridCacheContext<?, ?> cctx = proxy.context();
int k = 0, c = 0, skip0 = 0;
List<Integer> keys = new ArrayList<>(cnt);
while (c < cnt) {
if (cctx.affinity().partition(k) == part) {
if (skip0 < skipCnt) {
k++;
skip0++;
continue;
}
c++;
keys.add(k);
}
k++;
}
return keys;
}
Aggregations