Skip to content

Commit

Permalink
Rainfall-Ehcache 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aurbroszniowski committed Oct 19, 2015
1 parent bc8c3ff commit db4a227
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<groupId>io.rainfall</groupId>
<artifactId>rainfall-ehcache</artifactId>
<name>Rainfall-ehcache</name>
<version>1.1.1-SNAPSHOT</version>
<version>1.1.1</version>
<packaging>jar</packaging>

<properties>
<rainfall.core.version>1.1.2-SNAPSHOT</rainfall.core.version>
<rainfall.core.version>1.1.1</rainfall.core.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
final long next = sequenceGenerator.next();
List<Cache<K, V>> caches = cacheConfig.getCaches();
for (final Cache<K, V> cache : caches) {
K k = keyGenerator.generate(next);
V value;

long start = getTimeInNs();
try {
value = cache.get(keyGenerator.generate(next));
value = cache.get(k);
long end = getTimeInNs();
if (value == null) {
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), MISS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
List<Cache<K, V>> caches = cacheConfig.getCaches();
for (final Cache<K, V> cache : caches) {
V v;
K k = keyGenerator.generate(next);
V v1 = valueGenerator.generate(next);

long start = getTimeInNs();
try {
v = cache.putIfAbsent(keyGenerator.generate(next), valueGenerator.generate(next));
v = cache.putIfAbsent(k, v1);
long end = getTimeInNs();
if (v != null) {
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), MISS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
long end = getTimeInNs();
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), EXCEPTION);
}

V v1 = cache.get(k);
if (v!=null && !v.equals(v1)) {
log.error("incorrect value found in cache for the key {} : {}", k, v);
statisticsHolder.increaseAssertionsErrorsCount(cacheConfig.getCacheName(cache));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
List<Cache<K, V>> caches = cacheConfig.getCaches();
for (final Cache<K, V> cache : caches) {
boolean removed;
K k = keyGenerator.generate(next);
V v = valueGenerator.generate(next);

long start = getTimeInNs();
try {
removed = cache.remove(keyGenerator.generate(next), valueGenerator.generate(next));
removed = cache.remove(k, v);
long end = getTimeInNs();
if (!removed) {
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), MISS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
List<Cache<K, V>> caches = cacheConfig.getCaches();
for (final Cache<K, V> cache : caches) {
boolean removed;
K k = keyGenerator.generate(next);

long start = getTimeInNs();
try {
cache.remove(keyGenerator.generate(next));
cache.remove(k);
long end = getTimeInNs();
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), REMOVE);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
List<Cache<K, V>> caches = cacheConfig.getCaches();
for (final Cache<K, V> cache : caches) {
boolean replaced;
K k = keyGenerator.generate(next);
V v = valueGenerator.generate(next + 1);

long start = getTimeInNs();
try {
replaced = cache.replace(keyGenerator.generate(next), valueGenerator.generate(next), valueGenerator.generate(next));
replaced = cache.replace(k, v, v);
long end = getTimeInNs();
if (!replaced) {
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), MISS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
List<Cache<K, V>> caches = cacheConfig.getCaches();
for (final Cache<K, V> cache : caches) {
V v;
K k = keyGenerator.generate(next);
V v1 = valueGenerator.generate(next);

long start = getTimeInNs();
try {
v = cache.replace(keyGenerator.generate(next), valueGenerator.generate(next));
v = cache.replace(k, v1);
long end = getTimeInNs();
if (v == null) {
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), MISS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
long currentTps = statisticsHolder.getCurrentTps(EhcacheResult.GET);
if (currentTps < this.tpsLimit) {
for (final Cache<K, V> cache : caches) {
K k = keyGenerator.generate(next);
V value;

long start = getTimeInNs();
try {
value = cache.get(keyGenerator.generate(next));
value = cache.get(k);
long end = getTimeInNs();
if (value == null) {
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), MISS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ public void exec(final StatisticsHolder statisticsHolder, final Map<Class<? exte
long currentTps = statisticsHolder.getCurrentTps(EhcacheResult.PUT);
if (currentTps < this.tpsLimit) {
for (final Cache<K, V> cache : caches) {
K k = keyGenerator.generate(next);
V v = valueGenerator.generate(next);

long start = getTimeInNs();
try {
cache.put(keyGenerator.generate(next), valueGenerator.generate(next));
cache.put(k, v);
long end = getTimeInNs();
statisticsHolder.record(cacheConfig.getCacheName(cache), (end - start), PUT);
} catch (Exception e) {
Expand Down

0 comments on commit db4a227

Please sign in to comment.