Skip to content

Commit

Permalink
ignite-320 Fix CacheExpiryTest.iteratorNextShouldCallGetExpiryForAcce…
Browse files Browse the repository at this point in the history
…ssedEntry
  • Loading branch information
sevdokimov authored and sevdokimov-gg committed Mar 11, 2015
1 parent efed98d commit 2bd7421
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
@@ -0,0 +1,28 @@
/*
* 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.cache.*;

/**
*
*/
public class CachePeekModes {
/** */
public static final CachePeekMode[] ONHEAP_ONLY = {CachePeekMode.ONHEAP};
}
Expand Up @@ -4120,10 +4120,45 @@ IgniteInternalFuture<?> globalLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p
return entrySet().iterator();
}

/**
*
*/
private Iterator<Cache.Entry<K, V>> localIteratorHonorExpirePolicy() {
return F.iterator(
iterator(),

new IgniteClosure<Cache.Entry<K, V>, Cache.Entry<K, V>>() {
private IgniteCacheExpiryPolicy expiryPlc = ctx.cache().expiryPolicy(ctx.expiry());

@Override public Cache.Entry<K, V> apply(Cache.Entry<K, V> lazyEntry) {
try {
V val = localPeek(lazyEntry.getKey(), CachePeekModes.ONHEAP_ONLY, expiryPlc);

return new CacheEntryImpl<>(lazyEntry.getKey(), val);
}
catch (IgniteCheckedException e) {
throw CU.convertToCacheException(e);
}
}
},

false,

new IgnitePredicate<Cache.Entry<K, V>>() {
@Override public boolean apply(Cache.Entry<K, V> lazyEntry) {
return !lazyEntry.unwrap(GridCacheEntryEx.class).obsoleteOrDeleted();
}
}
);
}

/**
* @return Distributed ignite cache iterator.
*/
public Iterator<Cache.Entry<K, V>> igniteIterator() {
if (!ctx.isSwapOrOffheapEnabled() && ctx.kernalContext().discovery().size() == 1)
return localIteratorHonorExpirePolicy();

CacheQueryFuture<Map.Entry<K, V>> fut = queries().createScanQuery(null)
.keepAll(false)
.execute();
Expand Down
Expand Up @@ -745,8 +745,6 @@ private GridCloseableIterator<IgniteBiTuple<K, V>> scanIterator(final GridCacheQ

injectResources(keyValFilter);

final CachePeekMode[] peekModes = {CachePeekMode.ONHEAP};

final GridDhtCacheAdapter dht = cctx.isLocal() ? null : (cctx.isNear() ? cctx.near().dht() : cctx.dht());

final ExpiryPolicy plc = cctx.expiry();
Expand Down Expand Up @@ -789,7 +787,7 @@ private void advance() {
V val;

try {
val = prj.localPeek(key, peekModes, expiryPlc);
val = prj.localPeek(key, CachePeekModes.ONHEAP_ONLY, expiryPlc);
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
Expand Down

0 comments on commit 2bd7421

Please sign in to comment.