From 9a0094b40dd2e8c837883442886ec42ef0c16a1e Mon Sep 17 00:00:00 2001 From: Vladimir Dzhuvinov Date: Thu, 10 Nov 2016 10:41:52 +0200 Subject: [PATCH 1/2] Fixes parsing of top-level inherited XML attributes (iss #4) --- .../RedisStoreConfigurationParser80.java | 5 +++++ .../configuration/XmlFileParsingTest.java | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/main/java/org/infinispan/persistence/redis/configuration/RedisStoreConfigurationParser80.java b/src/main/java/org/infinispan/persistence/redis/configuration/RedisStoreConfigurationParser80.java index 4a1056a..79f0715 100644 --- a/src/main/java/org/infinispan/persistence/redis/configuration/RedisStoreConfigurationParser80.java +++ b/src/main/java/org/infinispan/persistence/redis/configuration/RedisStoreConfigurationParser80.java @@ -225,6 +225,11 @@ private void parseRedisStoreAttributes(XMLExtendedStreamReader reader, RedisStor builder.maxRedirections(Integer.parseInt(value)); break; } + + default: { + Parser80.parseStoreAttribute(reader, i, builder); + break; + } } } } diff --git a/src/test/java/org/infinispan/persistence/redis/configuration/XmlFileParsingTest.java b/src/test/java/org/infinispan/persistence/redis/configuration/XmlFileParsingTest.java index 114bef7..31e6a6f 100644 --- a/src/test/java/org/infinispan/persistence/redis/configuration/XmlFileParsingTest.java +++ b/src/test/java/org/infinispan/persistence/redis/configuration/XmlFileParsingTest.java @@ -36,6 +36,27 @@ public void testRedisCacheStore() throws Exception assert store.servers().size() == 2; } + public void testInheritedCacheStoreAttributes() throws Exception + { + String config = InfinispanStartTag.LATEST + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + TestingUtil.INFINISPAN_END_TAG; + + RedisStoreConfiguration store = (RedisStoreConfiguration) buildCacheManagerWithCacheStore(config); + assert store.shared(); + assert store.preload(); + assert store.servers().size() == 1; + } + private StoreConfiguration buildCacheManagerWithCacheStore(final String config) throws IOException { From 52f6de028ed3df33396a0f0523d42a050d94bc45 Mon Sep 17 00:00:00 2001 From: Vladimir Dzhuvinov Date: Thu, 10 Nov 2016 11:13:51 +0200 Subject: [PATCH 2/2] Includes cache name in Redis store log statements (iss #6) --- .../persistence/redis/RedisStore.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/infinispan/persistence/redis/RedisStore.java b/src/main/java/org/infinispan/persistence/redis/RedisStore.java index d4ec292..f6f6552 100644 --- a/src/main/java/org/infinispan/persistence/redis/RedisStore.java +++ b/src/main/java/org/infinispan/persistence/redis/RedisStore.java @@ -37,7 +37,7 @@ final public class RedisStore implements AdvancedLoadWriteStore @Override public void init(InitializationContext ctx) { - RedisStore.log.info("Redis cache store initialising"); + RedisStore.log.info("Initialising Redis store for cache " + ctx.getCache().getName()); this.ctx = ctx; } @@ -47,13 +47,13 @@ public void init(InitializationContext ctx) @Override public void start() { - RedisStore.log.info("Redis cache store starting"); + RedisStore.log.info("Starting Redis store for cache " + ctx.getCache().getName()); try { this.connectionPool = RedisConnectionPoolFactory.factory(this.ctx.getConfiguration(), this.ctx.getMarshaller()); } catch(Exception ex) { - RedisStore.log.error("Failed to initialise the redis store", ex); + RedisStore.log.error("Failed to initialise the Redis store for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } } @@ -64,7 +64,7 @@ public void start() @Override public void stop() { - RedisStore.log.info("Redis cache store stopping"); + RedisStore.log.info("Stopping Redis store for cache " + ctx.getCache().getName()); if (null != this.connectionPool) { this.connectionPool.shutdown(); @@ -101,7 +101,7 @@ public void process( boolean fetchMetadata ) { - RedisStore.log.debug("Iterating Redis store entries"); + RedisStore.log.debug("Iterating Redis store entries for cache " + ctx.getCache().getName()); final InitializationContext ctx = this.ctx; final TaskContext taskContext = new TaskContextImpl(); @@ -137,7 +137,7 @@ public void run() { } } catch (Exception ex) { - RedisStore.log.error("Failed to process the redis store key", ex); + RedisStore.log.error("Failed to process a Redis store key for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } } @@ -145,7 +145,7 @@ public void run() { } } catch(Exception ex) { - RedisStore.log.error("Failed to process the redis store keys", ex); + RedisStore.log.error("Failed to process the Redis store keys for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } finally { @@ -175,7 +175,7 @@ public void purge(Executor executor, final PurgeListener purgeListener) @Override public int size() { - RedisStore.log.debug("Calculating Redis store size"); + RedisStore.log.debug("Fetching the Redis store size for cache " + ctx.getCache().getName()); RedisConnection connection = null; try { @@ -187,9 +187,9 @@ public int size() // log the anomaly and return the int max size if (dbSize > Integer.MAX_VALUE) { RedisStore.log.info( - String.format("Redis store is holding more elements than we can count! " + - "Total number of elements found %d. Limited to returning count as %d", - dbSize, Integer.MAX_VALUE + String.format("The Redis store for cache %s is holding more entries than we can count! " + + "Total number of entries found %d. Limited to returning count as %d", + ctx.getCache().getName(), dbSize, Integer.MAX_VALUE ) ); @@ -200,7 +200,7 @@ public int size() } } catch(Exception ex) { - RedisStore.log.error("Failed to fetch element count from the redis store", ex); + RedisStore.log.error("Failed to fetch the entry count for the Redis store for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } finally { @@ -218,7 +218,7 @@ public int size() @Override public void clear() { - RedisStore.log.debug("Clearing Redis store"); + RedisStore.log.debug("Clearing the Redis store for cache " + ctx.getCache().getName()); RedisConnection connection = null; try { @@ -226,7 +226,7 @@ public void clear() connection.flushDb(); } catch(Exception ex) { - RedisStore.log.error("Failed to clear all elements in the redis store", ex); + RedisStore.log.error("Failed to clear the Redis store for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } finally { @@ -247,7 +247,7 @@ public void clear() @Override public MarshalledEntry load(Object key) { - RedisStore.log.debug("Loading entry from Redis store"); + RedisStore.log.debug("Loading entry from the Redis store for cache " + ctx.getCache().getName()); RedisConnection connection = null; try { @@ -270,7 +270,7 @@ public MarshalledEntry load(Object key) return this.ctx.getMarshalledEntryFactory().newMarshalledEntry(key, valueBuf, metadataBuf); } catch(Exception ex) { - RedisStore.log.error("Failed to load element from the redis store", ex); + RedisStore.log.error("Failed to load entry from the Redis store for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } finally { @@ -289,7 +289,7 @@ public MarshalledEntry load(Object key) @Override public void write(MarshalledEntry marshalledEntry) { - RedisStore.log.debug("Writing entry to Redis store"); + RedisStore.log.debug("Writing entry to the Redis store for cache " + ctx.getCache().getName()); RedisConnection connection = null; try { @@ -317,7 +317,7 @@ public void write(MarshalledEntry marshalledEntry) } } catch(Exception ex) { - RedisStore.log.error("Failed to write element to the redis store", ex); + RedisStore.log.error("Failed to write entry to the Redis store for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } finally { @@ -336,7 +336,7 @@ public void write(MarshalledEntry marshalledEntry) @Override public boolean delete(Object key) { - RedisStore.log.debug("Deleting entry from Redis store"); + RedisStore.log.debug("Deleting entry from Redis store for cache " + ctx.getCache().getName()); RedisConnection connection = null; try { @@ -344,7 +344,7 @@ public boolean delete(Object key) return connection.delete(key); } catch(Exception ex) { - RedisStore.log.error("Failed to delete element from the redis store", ex); + RedisStore.log.error("Failed to delete entry from the Redis store for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } finally { @@ -363,7 +363,7 @@ public boolean delete(Object key) @Override public boolean contains(Object key) { - RedisStore.log.debug("Checking store for Redis entry"); + RedisStore.log.debug("Checking key in Redis store for cache " + ctx.getCache().getName()); RedisConnection connection = null; try { @@ -371,7 +371,7 @@ public boolean contains(Object key) return connection.exists(key); } catch(Exception ex) { - RedisStore.log.error("Failed to discover if element is in the redis store", ex); + RedisStore.log.error("Failed to check key in Redis store for cache " + ctx.getCache().getName(), ex); throw new PersistenceException(ex); } finally {