Skip to content

Commit

Permalink
Add "evict on read access" as configurable mode.
Browse files Browse the repository at this point in the history
Update find and iterator to "evict on read access" processing including
the update of the last-access time.
Setup the usage of the LR to explicit define the "evict on read access"
mode.
Fix issue #707.

Signed-off-by: Achim Kraus <achim.kraus@bosch-si.com>
  • Loading branch information
Achim Kraus committed Jul 31, 2018
1 parent 11f641e commit e42c9a6
Show file tree
Hide file tree
Showing 7 changed files with 271 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public InMemoryMessageIdProvider(final NetworkConfig config) {
// 10 minutes
trackers = new LeastRecentlyUsedCache<>(config.getInt(NetworkConfig.Keys.MAX_ACTIVE_PEERS, 150000),
config.getLong(NetworkConfig.Keys.MAX_PEER_INACTIVITY_PERIOD, 10 * 60));
trackers.setEvictingOnReadAccess(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public final class AnonymizedOriginTracer extends MessageInterceptorAdapter {
} catch (NoSuchAlgorithmException e) {
}
HMAC = mac;
CLIENT_CACHE.setEvictingOnReadAccess(true);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ public BlockwiseLayer(final NetworkConfig config) {
NetworkConfigDefaults.DEFAULT_MAX_RESOURCE_BODY_SIZE);
int maxActivePeers = config.getInt(NetworkConfig.Keys.MAX_ACTIVE_PEERS,
NetworkConfigDefaults.DEFAULT_MAX_ACTIVE_PEERS);
block1Transfers = new LeastRecentlyUsedCache<>(maxActivePeers, blockTimeout / 1000);
block2Transfers = new LeastRecentlyUsedCache<>(maxActivePeers, blockTimeout / 1000);
block1Transfers = new LeastRecentlyUsedCache<>(maxActivePeers, TimeUnit.MILLISECONDS.toSeconds(blockTimeout));
block1Transfers.setEvictingOnReadAccess(false);
block2Transfers = new LeastRecentlyUsedCache<>(maxActivePeers, TimeUnit.MILLISECONDS.toSeconds(blockTimeout));
block2Transfers.setEvictingOnReadAccess(false);

LOGGER.info(
"BlockwiseLayer uses MAX_MESSAGE_SIZE={}, PREFERRED_BLOCK_SIZE={}, BLOCKWISE_STATUS_LIFETIME={} and MAX_RESOURCE_BODY_SIZE={}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ public class RequestStatistic extends CoapResource {
private static final long START_TIME = System.currentTimeMillis();
private static final int MAX_HISTORY = 8;

private LeastRecentlyUsedCache<String, List<RequestInformation>> requests = new LeastRecentlyUsedCache<String, List<RequestInformation>>(
private final LeastRecentlyUsedCache<String, List<RequestInformation>> requests = new LeastRecentlyUsedCache<String, List<RequestInformation>>(
1024 * 16, 0);

public RequestStatistic() {
super(RESOURCE_NAME);
getAttributes().setTitle("Resource that collects requests for client staistics");
getAttributes().addContentType(TEXT_PLAIN);
getAttributes().addContentType(APPLICATION_JSON);
requests.setEvictingOnReadAccess(false);
}

@Override
Expand Down

0 comments on commit e42c9a6

Please sign in to comment.