it = cache.getKeys().iterator();
+ assertEquals(3, it.next().intValue());
+ assertEquals(12, it.next().intValue());
+ assertEquals(43, it.next().intValue());
+ assertFalse("There should be no more keys.", it.hasNext());
+ }
+
+ @Test
+ public void clearUponSetMaxItems()
+ {
+ cache.put(1, "1");
+ assertTrue(cache.contains(1));
+
+ cache.setMaxItems(10);
+
+ // The item should have gone.
+ assertFalse(cache.contains(1));
+ }
+}
diff --git a/source/java/org/alfresco/repo/cache/EhCacheAdapter.java b/source/java/org/alfresco/repo/cache/EhCacheAdapter.java
deleted file mode 100644
index 5586ed7dad..0000000000
--- a/source/java/org/alfresco/repo/cache/EhCacheAdapter.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cache;
-
-import java.io.Serializable;
-import java.util.Collection;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.Element;
-
-import org.alfresco.error.AlfrescoRuntimeException;
-
-/**
- * A thin adapter for Ehcache support.
- *
- * Thread-safety is taken care of by the underlying Ehcache
- * instance.
- *
- * @see org.springframework.cache.ehcache.EhCacheFactoryBean
- * @see org.springframework.cache.ehcache.EhCacheManagerFactoryBean
- *
- * @author Derek Hulley
- */
-public class EhCacheAdapter
- implements SimpleCache
-{
- private net.sf.ehcache.Cache cache;
-
- public EhCacheAdapter()
- {
- }
-
- /**
- * @param cache the backing Ehcache instance
- */
- public void setCache(Cache cache)
- {
- this.cache = cache;
- }
-
- public boolean contains(K key)
- {
- try
- {
- return (cache.getQuiet(key) != null);
- }
- catch (CacheException e)
- {
- throw new AlfrescoRuntimeException("contains failed", e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public Collection getKeys()
- {
- return cache.getKeys();
- }
-
- @SuppressWarnings("unchecked")
- public V get(K key)
- {
- try
- {
- Element element = cache.get(key);
- if (element != null)
- {
- return (V) element.getObjectValue();
- }
- else
- {
- return null;
- }
- }
- catch (IllegalStateException ie)
- {
- throw new AlfrescoRuntimeException("Failed to get from EhCache as state invalid: \n" +
- " state: " + cache.getStatus() + "\n" +
- " key: " + key,
- ie);
- }
- catch (CacheException e)
- {
- throw new AlfrescoRuntimeException("Failed to get from EhCache: \n" +
- " key: " + key,
- e);
- }
- }
-
- public void put(K key, V value)
- {
- Element element = new Element(key, value);
- cache.put(element);
- }
-
- public void remove(K key)
- {
- cache.remove(key);
- }
-
- public void clear()
- {
- cache.removeAll();
- }
-}
diff --git a/source/java/org/alfresco/repo/cache/EhCacheManagerFactoryBean.java b/source/java/org/alfresco/repo/cache/EhCacheManagerFactoryBean.java
deleted file mode 100644
index c4b2114749..0000000000
--- a/source/java/org/alfresco/repo/cache/EhCacheManagerFactoryBean.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cache;
-
-import java.io.IOException;
-import java.net.URL;
-
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.CacheManager;
-
-import org.alfresco.error.AlfrescoRuntimeException;
-import org.alfresco.util.PropertyCheck;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-/**
- * This is virtually a copy of the Springframework version, with the exception
- * that it uses the newer constructors for the EHCacheManager
- * instances.
- *
- * @author Derek Hulley
- */
-public class EhCacheManagerFactoryBean implements FactoryBean, InitializingBean, DisposableBean
-{
- static
- {
- // https://jira.terracotta.org/jira/browse/EHC-652
- // Force old-style LruMemoryStore
- // System.setProperty("net.sf.ehcache.use.classic.lru", "true");
- }
-
- protected final Log logger = LogFactory.getLog(EhCacheManagerFactoryBean.class);
-
- private Resource configLocation;
- private CacheManager cacheManager;
-
- /**
- *
- * @param configLocation a resource location using the file: or classpath: prefix
- */
- public void setConfigLocation(Resource configLocation)
- {
- this.configLocation = configLocation;
- }
-
- public void afterPropertiesSet() throws IOException, CacheException
- {
- PropertyCheck.mandatory(this, "configLocation", configLocation);
-
- // Double-check the config location or EHCache will throw an NPE
- try
- {
- URL configUrl = this.configLocation.getURL();
- logger.info("Initializing EHCache CacheManager using URL: " + configLocation);
- this.cacheManager = new CacheManager(configUrl);
- }
- catch (IOException e)
- {
- throw new AlfrescoRuntimeException("Unabled to read EHCache configuration file at " + configLocation, e);
- }
- }
-
- public Object getObject()
- {
- return this.cacheManager;
- }
-
- @SuppressWarnings("unchecked")
- public Class getObjectType()
- {
- return (this.cacheManager != null ? this.cacheManager.getClass() : CacheManager.class);
- }
-
- public boolean isSingleton()
- {
- return true;
- }
-
- public void destroy()
- {
- logger.info("Shutting down EHCache CacheManager");
- if(logger.isDebugEnabled()) {
- String[] caches = this.cacheManager.getCacheNames();
- for(String cache : caches) {
- logger.debug("Shutting down EHCache instance " + cache);
- }
- }
- this.cacheManager.shutdown();
- }
-}
diff --git a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java b/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java
deleted file mode 100644
index 6a71c6b163..0000000000
--- a/source/java/org/alfresco/repo/cache/EhCacheTracerJob.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cache;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.List;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-import net.sf.ehcache.Status;
-import net.sf.ehcache.statistics.LiveCacheStatistics;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-
-/**
- * Analyzes the size of EHCache caches used.
- *
- * To activate this class, call the {@link #init()} method.
- *
- * @author Derek Hulley
- */
-public class EhCacheTracerJob implements Job
-{
- private static Log logger = LogFactory.getLog(EhCacheTracerJob.class);
-
- private CacheManager cacheManager;
-
- /**
- * Set the cache manager to analyze. The default cache manager will be analyzed
- * if this property is not set.
- *
- * @param cacheManager optional cache manager to analyze
- */
- public void setCacheManager(CacheManager cacheManager)
- {
- this.cacheManager = cacheManager;
- }
-
- public void execute(JobExecutionContext context) throws JobExecutionException
- {
- try
- {
- execute();
- }
- catch (Throwable e)
- {
- logger.error("Exception during execution of job", e);
- }
- }
-
- private void execute() throws Exception
- {
- if (cacheManager == null)
- {
- cacheManager = InternalEhCacheManagerFactoryBean.getInstance();
- }
-
- long maxHeapSize = Runtime.getRuntime().maxMemory();
- long allCachesTotalSize = 0L;
- double estimatedMaxSize = 0L;
- // get all the caches
- String[] cacheNames = cacheManager.getCacheNames();
- logger.debug("Dumping EHCache info:");
- boolean analyzeAll = true;
- for (String cacheName : cacheNames)
- {
- Cache cache = cacheManager.getCache(cacheName);
- //cache.getCacheEventNotificationService().
-// cache.registerCacheUsageListener(cacheUsageListener)
- if (cache == null) // perhaps a temporary cache
- {
- continue;
- }
- Log cacheLogger = LogFactory.getLog(this.getClass().getName() + "." + cacheName);
- // log each cache to its own logger
- // dump
- if (cacheLogger.isDebugEnabled())
- {
- CacheAnalysis analysis = new CacheAnalysis(cache);
- cacheLogger.debug(analysis);
- // get the size
- allCachesTotalSize += analysis.getSize();
- double cacheEstimatedMaxSize = analysis.getEstimatedMaxSize();
- estimatedMaxSize += (Double.isNaN(cacheEstimatedMaxSize) || Double.isInfinite(cacheEstimatedMaxSize))
- ? 0.0
- : cacheEstimatedMaxSize;
- }
- else
- {
- analyzeAll = false;
- }
- }
- if (analyzeAll)
- {
- // check the size
- double sizePercentage = (double)allCachesTotalSize / (double)maxHeapSize * 100.0;
- double maxSizePercentage = estimatedMaxSize / (double)maxHeapSize * 100.0;
- String msg = String.format(
- "EHCaches currently consume %5.2f MB or %3.2f percent of system VM size. \n" +
- "The estimated maximum size is %5.2f MB or %3.2f percent of system VM size.",
- (double)allCachesTotalSize / 1024.0 / 1024.0,
- sizePercentage,
- estimatedMaxSize / 1024.0 / 1024.0,
- maxSizePercentage);
- logger.debug(msg);
- }
- }
-
- private static class CacheAnalysis
- {
- private Cache cache;
- private long size = 0L;
- double sizeMB;
- long maxSize;
- long currentSize;
- long hitCount;
- long missCount;
- double percentageFull;
- double estMaxSize;
-
- public CacheAnalysis(Cache cache) throws CacheException
- {
- this.cache = cache;
- if (this.cache.getStatus().equals(Status.STATUS_ALIVE))
- {
- try
- {
- calculateSize();
- }
- catch (Throwable e)
- {
- // just ignore
- }
- }
- }
-
- public synchronized long getSize()
- {
- return size;
- }
-
- public synchronized double getEstimatedMaxSize()
- {
- return estMaxSize;
- }
-
- @SuppressWarnings("unchecked")
- private synchronized void calculateSize() throws CacheException
- {
- // calculate the cache deep size - EHCache 1.1 is always returning 0L
- List keys = cache.getKeys();
- // only count a maximum of 1000 entities
- int count = 0;
- for (Serializable key : keys)
- {
- Element element = cache.get(key);
- size += getSize(element);
- count++;
- if (count >= 50)
- {
- break;
- }
- }
-
- // the size must be multiplied by the ratio of the count to actual size
- size = count > 0 ? (long) ((double)size * ((double)keys.size()/(double)count)) : 0L;
-
- sizeMB = (double)size/1024.0/1024.0;
- LiveCacheStatistics statistics = cache.getLiveCacheStatistics();
- maxSize = cache.getCacheConfiguration().getMaxElementsInMemory();
- currentSize = cache.getMemoryStoreSize();
- hitCount = statistics.getCacheHitCount();
- missCount = statistics.getCacheMissCount();
- percentageFull = (double)currentSize / (double)maxSize * 100.0;
- estMaxSize = size / (double) currentSize * (double) maxSize;
- }
-
- private long getSize(Serializable obj)
- {
- ByteArrayOutputStream bout = new ByteArrayOutputStream(1024);
- ObjectOutputStream oos = null;
- try
- {
- oos = new ObjectOutputStream(bout);
- oos.writeObject(obj);
- return bout.size();
- }
- catch (IOException e)
- {
- logger.warn("Deep size calculation failed for cache: \n" + cache);
- return 0L;
- }
- finally
- {
- try { oos.close(); } catch (IOException e) {}
- }
- }
-
- public String toString()
- {
- double sizeMB = (double)getSize()/1024.0/1024.0;
- LiveCacheStatistics statistics = cache.getLiveCacheStatistics();
- long maxSize = cache.getCacheConfiguration().getMaxElementsInMemory();
- long currentSize = cache.getMemoryStoreSize();
- long hitCount = statistics.getCacheHitCount();
- long totalMissCount = statistics.getCacheMissCount() + statistics.getCacheMissCountExpired();
- double hitRatio = (double)hitCount / (double)(totalMissCount + hitCount) * 100.0;
- double percentageFull = (double)currentSize / (double)maxSize * 100.0;
- double estMaxSize = sizeMB / (double) currentSize * (double) maxSize;
-
- StringBuilder sb = new StringBuilder(512);
- sb.append("\n")
- .append("===> EHCache: ").append(cache).append("\n")
- .append(" Hit Ratio: ").append(String.format("%10.2f percent ", hitRatio ))
- .append(" | Hit Count: ").append(String.format("%10d hits ", hitCount ))
- .append(" | Miss Count: ").append(String.format("%10d misses ", totalMissCount )).append("\n")
- .append(" Deep Size: ").append(String.format("%10.2f MB ", sizeMB ))
- .append(" | Current Count: ").append(String.format("%10d entries ", currentSize )).append("\n")
- .append(" Percentage used: ").append(String.format("%10.2f percent", percentageFull))
- .append(" | Max Count: ").append(String.format("%10d entries ", maxSize )).append("\n")
- .append(" Estimated maximum size: ").append(String.format("%10.2f MB ", estMaxSize ));
- return sb.toString();
- }
- }
-}
diff --git a/source/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java b/source/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java
new file mode 100644
index 0000000000..2717b61860
--- /dev/null
+++ b/source/java/org/alfresco/repo/cache/HibernateSimpleCacheAdapter.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2005-2012 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.repo.cache;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.hibernate.cache.Cache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.Timestamper;
+
+/**
+ * Adapts a {@link SimpleCache} instance for use as a Hibernate {@link Cache}.
+ *
+ * @author Matt Ward
+ */
+public class HibernateSimpleCacheAdapter implements Cache
+{
+ private final SimpleCache cache;
+ private final String regionName;
+
+ /**
+ * Adapt a
+ * @param cache
+ * @param regionName
+ */
+ public HibernateSimpleCacheAdapter(SimpleCache cache, String regionName)
+ {
+ this.cache = cache;
+ this.regionName = regionName;
+ }
+
+ @Override
+ public Object read(Object key) throws CacheException
+ {
+ return cache.get(serializable(key));
+ }
+
+ @Override
+ public Object get(Object key) throws CacheException
+ {
+ return cache.get(serializable(key));
+ }
+
+ @Override
+ public void put(Object key, Object value) throws CacheException
+ {
+ cache.put(serializable(key), value);
+ }
+
+ @Override
+ public void update(Object key, Object value) throws CacheException
+ {
+ cache.put(serializable(key), value);
+ }
+
+ @Override
+ public void remove(Object key) throws CacheException
+ {
+ cache.remove(serializable(key));
+ }
+
+ @Override
+ public void clear() throws CacheException
+ {
+ cache.clear();
+ }
+
+ @Override
+ public void destroy() throws CacheException
+ {
+ // NoOp
+ }
+
+ @Override
+ public void lock(Object key) throws CacheException
+ {
+ // NoOp
+ }
+
+ @Override
+ public void unlock(Object key) throws CacheException
+ {
+ // NoOp
+ }
+
+ @Override
+ public long nextTimestamp()
+ {
+ return Timestamper.next();
+ }
+
+ @Override
+ public int getTimeout()
+ {
+ return Timestamper.ONE_MS * 60000; // 1 minute
+ }
+
+ @Override
+ public String getRegionName()
+ {
+ return regionName;
+ }
+
+ @Override
+ public long getSizeInMemory()
+ {
+ return -1;
+ }
+
+ @Override
+ public long getElementCountInMemory()
+ {
+ return -1;
+ }
+
+ @Override
+ public long getElementCountOnDisk()
+ {
+ return 0;
+ }
+
+ @Override
+ public Map toMap()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private Serializable serializable(Object obj)
+ {
+ if (!(obj instanceof Serializable))
+ {
+ throw new IllegalArgumentException("Object is not Serializable, class=" + obj.getClass().getName());
+ }
+ return (Serializable) obj;
+ }
+
+}
diff --git a/source/java/org/alfresco/repo/cache/InternalEhCacheManagerFactoryBean.java b/source/java/org/alfresco/repo/cache/InternalEhCacheManagerFactoryBean.java
deleted file mode 100644
index a2cf2fc0c8..0000000000
--- a/source/java/org/alfresco/repo/cache/InternalEhCacheManagerFactoryBean.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cache;
-
-import java.io.FileNotFoundException;
-import java.net.URL;
-import java.util.Properties;
-
-import net.sf.ehcache.CacheManager;
-
-import org.alfresco.error.AlfrescoRuntimeException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.cache.Cache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.CacheProvider;
-import org.hibernate.cache.EhCache;
-import org.hibernate.cache.EhCacheProvider;
-import org.hibernate.cache.Timestamper;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.util.ResourceUtils;
-
-/**
- * Alfresco-specific cache manager factory.
- *
- * The purpose of this bean is to provide a common point from which the system-wide
- * EHCache CacheManager
singleton is created. Hibernate and Spring
- * will all pick up the same CacheManager
instance. It then becomes
- * possible to initialise this instance in whichever way we require, provided it
- * is done in a well-known (non-configurable) way.
- *
- * For Alfresco purposes, there are two files that are looked for:
- *
- * - classpath:alfresco/extension/ehcache-custom.xml, which will take precedence
- * - classpath:alfresco/ehcache-default.xml, which is the default shipped with Alfresco
- *
- *
- * The EHCache static singleton instance is used but ensuring that all access to the
- * instance goes through the required initialization code first.
- *
- * TODO: Provide mixing of config so that cache definitions in the custom file override
- * those in the default file
- *
- * @see #getInstance()
- *
- * @author Derek Hulley
- */
-public class InternalEhCacheManagerFactoryBean implements FactoryBean, CacheProvider
-{
- static
- {
- // https://jira.terracotta.org/jira/browse/EHC-652
- // Force old-style LruMemoryStore
- // System.setProperty("net.sf.ehcache.use.classic.lru", "true");
- }
-
- public static final String CUSTOM_CONFIGURATION_FILE = "classpath:alfresco/extension/ehcache-custom.xml";
- public static final String DEFAULT_CONFIGURATION_FILE = "classpath:alfresco/ehcache-default.xml";
-
- private static Log logger = LogFactory.getLog(InternalEhCacheManagerFactoryBean.class);
-
- /** keep track of the singleton status to avoid work */
- private static boolean initialized;
- /** the CacheManager
*/
- private static CacheManager cacheManager;
- /** used to ensure that the existing Hibernate logic is maintained */
- private static EhCacheProvider hibernateEhCacheProvider = new EhCacheProvider();
-
- /**
- * Default constructor required by Hibernate. In fact, we anticipate several
- * instances of this class to be created.
- */
- public InternalEhCacheManagerFactoryBean()
- {
- }
-
- /**
- * News up the singleton cache manager according to the rules set out
- * in the class comments.
- */
- private static synchronized void initCacheManager()
- {
- if (initialized)
- {
- return;
- }
- try
- {
- boolean defaultLocation = false;
- try
- {
- URL configUrl = ResourceUtils.getURL(CUSTOM_CONFIGURATION_FILE);
- InternalEhCacheManagerFactoryBean.cacheManager = CacheManager.create(configUrl);
- }
- catch (FileNotFoundException e)
- {
- // try the alfresco default
- URL configUrl = ResourceUtils.getURL(DEFAULT_CONFIGURATION_FILE);
- if (configUrl == null)
- {
- throw new AlfrescoRuntimeException("Missing default cache config: " + DEFAULT_CONFIGURATION_FILE);
- }
- InternalEhCacheManagerFactoryBean.cacheManager = new CacheManager(configUrl);
- defaultLocation = true;
- }
- // done
- if (logger.isDebugEnabled())
- {
- logger.debug("Created EHCache CacheManager instance: \n" +
- " configuration: " + (defaultLocation ? DEFAULT_CONFIGURATION_FILE : CUSTOM_CONFIGURATION_FILE));
- }
- initialized = true;
- }
- catch (Throwable e)
- {
- throw new AlfrescoRuntimeException("EHCache configuration failed", e);
- }
- }
-
- /**
- * @return Returns the properly initialized instance for Alfresco internal use
- *
- * @see #initCacheManager()
- */
- public static CacheManager getInstance()
- {
- if (!InternalEhCacheManagerFactoryBean.initialized)
- {
- InternalEhCacheManagerFactoryBean.initCacheManager();
- }
- return InternalEhCacheManagerFactoryBean.cacheManager;
- }
-
- public Cache buildCache(String regionName, Properties properties) throws CacheException
- {
- CacheManager manager = InternalEhCacheManagerFactoryBean.getInstance();
- try
- {
- net.sf.ehcache.Cache cache = manager.getCache(regionName);
- if (cache == null)
- {
- logger.info("Using default cache configuration: " + regionName);
- manager.addCache(regionName);
- cache = manager.getCache(regionName);
- logger.debug("Started EHCache region: " + regionName);
- }
- return new EhCache(cache);
- }
- catch (net.sf.ehcache.CacheException e)
- {
- throw new CacheException(e);
- }
- }
-
- /**
- * @see #hibernateEhCacheProvider
- */
- public boolean isMinimalPutsEnabledByDefault()
- {
- return false;
- }
-
- /**
- * @see #hibernateEhCacheProvider
- */
- public long nextTimestamp()
- {
- return Timestamper.next();
- }
-
- /**
- * @see #initCacheManager()
- */
- public void start(Properties properties) throws CacheException
- {
- InternalEhCacheManagerFactoryBean.initCacheManager();
- }
-
- /**
- * @see #initCacheManager()
- */
- public void stop()
- {
- // TODO: Does this port over different Locales?
- // Better to override DbPersistenceServiceFactory#close to put a marker on the thread.
- if (Thread.currentThread().getName().contains("Finalizer"))
- {
- // Probably JBPM's finalizer code ... we rely on Spring context calls rather
- return;
- }
-
- synchronized (getClass())
- {
- if(logger.isDebugEnabled()) {
- String[] caches = InternalEhCacheManagerFactoryBean.getInstance().getCacheNames();
- for(String regionName : caches) {
- logger.debug("Stopped EHCache region: " + regionName);
- }
- }
-
- if (initialized) // Avoid re-initialization if it has already been shut down
- {
- InternalEhCacheManagerFactoryBean.getInstance().shutdown();
- initialized = false;
- }
- }
- }
-
- /**
- * @return Returns the singleton cache manager
- *
- * @see #initCacheManager()
- */
- public CacheManager getObject() throws Exception
- {
- return InternalEhCacheManagerFactoryBean.getInstance();
- }
-
- /**
- * @return Returns the singleton cache manager type
- */
- public Class getObjectType()
- {
- return CacheManager.class;
- }
-
- /**
- * @return Returns true always
- */
- public boolean isSingleton()
- {
- return true;
- }
-}
diff --git a/source/java/org/alfresco/repo/cache/TransactionalCache.java b/source/java/org/alfresco/repo/cache/TransactionalCache.java
index 69d4747259..534ca57d57 100644
--- a/source/java/org/alfresco/repo/cache/TransactionalCache.java
+++ b/source/java/org/alfresco/repo/cache/TransactionalCache.java
@@ -25,8 +25,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import net.sf.ehcache.CacheException;
-
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.tenant.TenantUtil;
@@ -734,7 +732,7 @@ public class TransactionalCache
logger.debug("Pre-commit called for " + keys.size() + " values.");
}
}
- catch (CacheException e)
+ catch (Throwable e)
{
throw new AlfrescoRuntimeException("Failed to transfer updates to shared cache", e);
}
@@ -795,7 +793,7 @@ public class TransactionalCache
logger.debug("Post-commit called for " + keys.size() + " values.");
}
}
- catch (CacheException e)
+ catch (Throwable e)
{
throw new AlfrescoRuntimeException("Failed to transfer updates to shared cache", e);
}
@@ -837,7 +835,7 @@ public class TransactionalCache
}
}
}
- catch (CacheException e)
+ catch (Throwable e)
{
throw new AlfrescoRuntimeException("Failed to transfer updates to shared cache", e);
}
diff --git a/source/java/org/alfresco/repo/cluster/BuildSafeTestSuite.java b/source/java/org/alfresco/repo/cluster/BuildSafeTestSuite.java
deleted file mode 100644
index b922fa0974..0000000000
--- a/source/java/org/alfresco/repo/cluster/BuildSafeTestSuite.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test suite for org.alfresco.repo.cluster tests, but excluding
- * tests which are known to fail in the CI environment (Bamboo).
- *
- * These tests are still useful in the desktop development environment however,
- * so are kept for this reason. {@link ClusterTestSuite} runs all the tests in this
- * suite, plus the offending tests.
- *
- * @author Matt Ward
- */
-@RunWith(Suite.class)
-@SuiteClasses({
- org.alfresco.repo.cluster.HazelcastConfigFactoryBeanTest.class,
- org.alfresco.repo.cluster.HazelcastMessengerFactoryTest.class,
- org.alfresco.repo.cluster.HazelcastMessengerTest.class
-})
-public class BuildSafeTestSuite
-{
- // Annotations specify the suite.
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterCheckEvent.java b/source/java/org/alfresco/repo/cluster/ClusterCheckEvent.java
deleted file mode 100644
index 7d75bc7c6a..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterCheckEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-/**
- *
- * @since Odin
- *
- */
-public class ClusterCheckEvent extends ClusterMessageEvent
-{
- private static final long serialVersionUID = -4633842466757526069L;
-
- public ClusterCheckEvent(ClusterChecker clusterChecker, String sourceId, String targetId)
- {
- super(clusterChecker, sourceId, targetId);
- }
-
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterChecker.java b/source/java/org/alfresco/repo/cluster/ClusterChecker.java
deleted file mode 100644
index 7bbe410402..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterChecker.java
+++ /dev/null
@@ -1,759 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.alfresco.repo.lock.JobLockService;
-import org.alfresco.repo.lock.LockAcquisitionException;
-import org.alfresco.repo.security.authentication.AuthenticationException;
-import org.alfresco.repo.security.authentication.AuthenticationUtil;
-import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
-import org.alfresco.service.cmr.security.AuthenticationService;
-import org.alfresco.service.namespace.NamespaceService;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.util.EqualsHelper;
-import org.alfresco.util.GUID;
-import org.alfresco.util.TempFileProvider;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ApplicationEvent;
-
-/**
- * Checks that the cluster is working.
- *
- * @since Odin
- *
- */
-public class ClusterChecker implements MessageReceiver, ApplicationContextAware
-{
- private static final Log logger = LogFactory.getLog(ClusterChecker.class);
- private static final String TmpFile = ".clusterChecker";
- private static final QName LOCK = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "ClusterChecker");
-
- /*
- * WORKING: is synced with other nodes in the cluster
- * NOTWORKING: is alive but not synced with other nodes in the cluster
- * UNKNOWN: status is unknown (could be in the middle of checking)
- * CHECKING: still waiting for cluster check response
- */
- public static enum NodeStatus
- {
- WORKING, NOTWORKING, TIMEOUT, UNKNOWN;
- };
-
- // time to wait for a cluster node to respond
- private int timeout = 4000; // ms
-
- private ApplicationContext applicationContext;
- private AuthenticationService authenticationService;
- private TransactionService transactionService;
- private MessengerFactory messengerFactory;
- private JobLockService jobLockService;
-
- private Messenger messenger;
-
- private Timer timer = new Timer();
-
- // cluster nodes that this node knows about
- private Map nodeInfo = new ConcurrentHashMap();
-
- // unique id for this cluster node
- private String id = null;
-
- public ClusterChecker() throws FileNotFoundException, IOException, ClassNotFoundException
- {
- this.id = buildId();
- }
-
- private String buildId() throws FileNotFoundException, IOException, ClassNotFoundException
- {
- // we need an immutable unique id for the cluster node
- String guid = null;
-
- File systemTmpDir = TempFileProvider.getSystemTempDir();
- File tmpFile = new File(systemTmpDir, TmpFile);
-
- // persist the id locally
- if(!tmpFile.exists())
- {
- guid = GUID.generate();
- tmpFile.createNewFile();
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(tmpFile));
- out.writeObject(guid);
- out.close();
- }
- else
- {
- ObjectInputStream in = new ObjectInputStream(new FileInputStream(tmpFile));
- guid = (String)in.readObject();
- in.close();
- }
-
- return guid;
- }
-
- /**
- * Attempts to get the lock. If the lock couldn't be taken, then null is returned.
- *
- * @return Returns the lock token or null
- */
- private String getLock(long time)
- {
- try
- {
- return jobLockService.getLock(LOCK, time);
- }
- catch (LockAcquisitionException e)
- {
- return null;
- }
- }
-
- public void init()
- {
- this.messenger = messengerFactory.createMessenger(getClass().getName(), true);
- messenger.setReceiver(this);
- }
-
- public void shutdown()
- {
- cancelTimer();
- }
-
- public void setTimeout(int timeout)
- {
- this.timeout = timeout;
- }
-
- public void setJobLockService(JobLockService jobLockService)
- {
- this.jobLockService = jobLockService;
- }
-
- public void setTransactionService(TransactionService transactionService)
- {
- this.transactionService = transactionService;
- }
-
- public void setAuthenticationService(AuthenticationService authenticationService)
- {
- this.authenticationService = authenticationService;
- }
-
- public void setMessengerFactory(MessengerFactory messengerFactory)
- {
- this.messengerFactory = messengerFactory;
- }
-
- private void cancelTimer()
- {
- timer.cancel();
- }
-
- private NodeInfo registerNode(String id)
- {
- NodeInfo info = new NodeInfo(id);
- nodeInfo.put(id, info);
- return info;
- }
-
- private void checkCluster()
- {
- // set the status of any currently tracked to 'checking'
- for(NodeInfo info : nodeInfo.values())
- {
- info.setChecking(true);
- }
-
- // Authenticate and get a ticket. This will be used to validate that the other nodes in the cluster are
- // 'working' i.e. their caches are updating in the cluster.
- try
- {
- AuthenticationUtil.pushAuthentication();
- AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
- String ticket = authenticationService.getCurrentTicket();
- messenger.send(new ClusterValidateEvent(this, ticket, id, null));
- }
- catch(AuthenticationException e)
- {
- logger.warn("Unable to check cluster, authentication failed", e);
- return;
- }
- finally
- {
- AuthenticationUtil.popAuthentication();
- }
-
- // A timer to mark nodes still in the checking state as not alive after a timeout.
- timer.schedule(new TimerTask()
- {
- @Override
- public void run()
- {
- for(NodeInfo info : nodeInfo.values())
- {
- List timedOut = info.timeoutNodes();
- for(String nodeId : timedOut)
- {
- nodePairStatusChange(info.getId(), nodeId, NodeStatus.TIMEOUT);
- }
- }
- }
- }, timeout);
- }
-
- private void nodePairStatusChange(String sourceNodeId, String targetNodeId, NodeStatus status)
- {
- publishEvent(new ClusterNodePairStatusEvent(this, sourceNodeId, targetNodeId, status));
- }
-
- private void nodeFound(String nodeId)
- {
- publishEvent(new ClusterNodeExistsEvent(this, nodeId));
- }
-
- private String getAddress()
- {
- try
- {
- return InetAddress.getLocalHost().getHostName();
- }
- catch(UnknownHostException e)
- {
- return "Unknown";
- }
- }
-
- private void publishEvent(ApplicationEvent event)
- {
- applicationContext.publishEvent(event);
- }
-
- private void handleValidationEvent(ClusterValidateEvent validateEvent)
- {
- String sourceId = validateEvent.getSourceId();
- String ticket = validateEvent.getTicket();
-
- // try to validate the ticket generated by the source node
- boolean ticketValid = true;
- try
- {
- AuthenticationUtil.pushAuthentication();
- authenticationService.validate(ticket);
- if(!authenticationService.getCurrentUserName().equals(AuthenticationUtil.getAdminUserName()))
- {
- ticketValid = false;
- }
- }
- catch(AuthenticationException e)
- {
- ticketValid = false;
- }
- finally
- {
- AuthenticationUtil.popAuthentication();
- }
-
- messenger.send(new ClusterValidateResponseEvent(this, getAddress(), sourceId, id, ticketValid));
- }
-
- private void handleValidationResponse(ClusterValidateResponseEvent validateResponseEvent)
- {
- String sourceId = validateResponseEvent.getSourceId();
- String targetId = validateResponseEvent.getTargetId();
- String address = validateResponseEvent.getAddress(); // target address
-
- NodeInfo source = getNodeInfo(sourceId);
- boolean newSourceNode = false;
- if(source == null)
- {
- source = registerNode(sourceId);
- newSourceNode = true;
- }
-
- // update the target's address, if it isn't known already
- boolean newTargetNode = false;
- NodeInfo remote = getNodeInfo(targetId);
- if(remote == null)
- {
- remote = registerNode(targetId);
- newTargetNode = true;
- }
- remote.setAddress(address);
-
- // update source node's view of the target's status
- boolean ticketValid = validateResponseEvent.isTicketValid();
- NodeStatus newTargetStatus = ticketValid ? NodeStatus.WORKING : NodeStatus.NOTWORKING;
- source.setStatus(targetId, newTargetStatus);
-
- if(newSourceNode)
- {
- nodeFound(sourceId);
- }
-
- if(newTargetNode)
- {
- nodeFound(targetId);
- }
-
- if(!sourceId.equals(targetId) && newTargetStatus != NodeStatus.UNKNOWN)
- {
- nodePairStatusChange(sourceId, targetId, newTargetStatus);
- }
- }
-
- public boolean isConnected()
- {
- return messenger.isConnected();
- }
-
- public boolean isClusterActive()
- {
- return messengerFactory.isClusterActive();
- }
-
- public Map getNodeInfo()
- {
- return Collections.unmodifiableMap(nodeInfo);
- }
-
- public NodeInfo getNodeInfo(String nodeId)
- {
- return nodeInfo.get(nodeId);
- }
-
- public String getId()
- {
- return id;
- }
-
- public void check()
- {
- // Take out a lock to prevent more than one check at a time
- RetryingTransactionCallback txnWork = new RetryingTransactionCallback()
- {
- public String execute() throws Exception
- {
- String lockToken = getLock(timeout + 1000);
- return lockToken;
- }
- };
-
- final String lockToken = transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false, true);
- if(lockToken == null)
- {
- logger.warn("Can't get lock. Assume multiple cluster checkers ...");
- return;
- }
-
- // Kick off the check by broadcasting the initiating event to each node in the cluster
- if (messenger.isConnected())
- {
- messenger.send(new ClusterCheckEvent(this, id, null));
- }
-
- // A timer to release the lock after a timeout
- timer.schedule(new TimerTask()
- {
- @Override
- public void run()
- {
- jobLockService.releaseLock(lockToken, LOCK);
- }
- }, timeout);
- }
-
- public List getPeers(String nodeId)
- {
- NodeInfo nodeInfo = getNodeInfo(nodeId);
- Map peersInfo = nodeInfo.getPeersInfo();
-
- List ret = new ArrayList();
- for(String peerId : peersInfo.keySet())
- {
- if(peerId.equals(nodeId))
- {
- continue;
- }
- NodeInfo peerInfo = getNodeInfo(peerId);
- NodeStatus peerStatus = peersInfo.get(peerId).getNodeStatus();
- String peerAddress = peerInfo.getAddress();
- ret.add(new PeerNodeInfo(peerId, peerAddress, peerStatus));
- }
-
- return ret;
- }
-
- public void stopChecking(String nodeId)
- {
- if(nodeInfo.containsKey(nodeId))
- {
- nodeInfo.remove(nodeId);
- }
- for(NodeInfo node : nodeInfo.values())
- {
- node.stopChecking(nodeId);
- }
- publishEvent(new ClusterNodeStopTrackingEvent(this, nodeId));
- }
-
- @Override
- public void onReceive(ClusterMessageEvent event)
- {
- if (event == null)
- {
- return;
- }
-
- if(event instanceof ClusterCheckEvent)
- {
- checkCluster();
- }
- else if(event instanceof ClusterValidateEvent)
- {
- // handle validation request from another node
- handleValidationEvent((ClusterValidateEvent)event);
- }
- else if(event instanceof ClusterValidateResponseEvent)
- {
- // handle response to a validation request
- handleValidationResponse((ClusterValidateResponseEvent)event);
- }
- }
-
- public Set> getNonWorkingNodePairs()
- {
- Set> nonWorkingPairs = new HashSet>();
-
- for(NodeInfo node : nodeInfo.values())
- {
- // a cluster node is regarded as working only if every other node agrees
- // notes that for a 2 node cluster with one node down, the other node will still be regarded
- // as not working because there are no other nodes to counter the non-working node.
- nonWorkingPairs.addAll(node.getNonWorkingPeers());
- }
-
- return nonWorkingPairs;
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
- {
- this.applicationContext = applicationContext;
- }
-
- // Records information on a peer i.e. whether it is being checked and its status
- private static class PeerStatus
- {
- private boolean checking;
- private NodeStatus nodeStatus;
-
- public PeerStatus()
- {
- this.checking = false;
- this.nodeStatus = NodeStatus.UNKNOWN;
- }
-
- public boolean isChecking()
- {
- return checking;
- }
-
- void setChecking(boolean checking)
- {
- this.checking = checking;
- }
-
- public NodeStatus getNodeStatus()
- {
- return nodeStatus;
- }
-
- void setNodeStatus(NodeStatus nodeStatus)
- {
- this.nodeStatus = nodeStatus;
- }
- }
-
- public static class PeerNodeInfo
- {
- private String peerId;
- private String peerAddress;
- private NodeStatus peerStatus;
-
- public PeerNodeInfo(String peerId, String peerAddress, NodeStatus peerStatus) {
- super();
- this.peerId = peerId;
- this.peerAddress = peerAddress;
- this.peerStatus = peerStatus;
- }
-
- public String getPeerId()
- {
- return peerId;
- }
-
- public String getPeerAddress()
- {
- return peerAddress;
- }
-
- public NodeStatus getPeerStatus()
- {
- return peerStatus;
- }
- }
-
- // Information pertaining to a cluster node and its peers
- public static class NodeInfo
- {
- private String id;
- private String address;
- private Map nodeInfos = new ConcurrentHashMap(5);
-
- public NodeInfo(String id)
- {
- super();
- this.id = id;
- }
-
- public String getId()
- {
- return id;
- }
-
- public String getAddress()
- {
- return address;
- }
-
- void setAddress(String address)
- {
- this.address = address;
- }
-
- void setStatus(String targetId, NodeStatus status)
- {
- PeerStatus peerStatus = getStatus(targetId, true);
- peerStatus.setChecking(false);
- peerStatus.setNodeStatus(status);
- }
-
- void stopChecking(String nodeId)
- {
- nodeInfos.remove(nodeId);
- }
-
- public Map getPeersInfo()
- {
- return Collections.unmodifiableMap(nodeInfos);
- }
-
- public PeerStatus getStatus(String nodeId)
- {
- return getStatus(nodeId, false);
- }
-
- public PeerStatus getStatus(String nodeId, boolean create)
- {
- PeerStatus peerStatus = nodeInfos.get(nodeId);
- if(peerStatus == null)
- {
- peerStatus = new PeerStatus();
- nodeInfos.put(nodeId, peerStatus);
- }
- return peerStatus;
- }
-
- void setChecking(boolean checking)
- {
- for(String nodeId : nodeInfos.keySet())
- {
- setChecking(nodeId, checking);
- }
- }
-
- void setChecking(String nodeId, boolean checking)
- {
- PeerStatus status = getStatus(nodeId, true);
- status.setChecking(checking);
- }
-
- void setStatuses(NodeStatus status)
- {
- for(String nodeId : nodeInfos.keySet())
- {
- setStatus(nodeId, status);
- }
- }
-
- List timeoutNodes()
- {
- List timedOut = new ArrayList();
-
- for(String nodeId : nodeInfos.keySet())
- {
- if(getStatus(nodeId).isChecking())
- {
- setStatus(nodeId, NodeStatus.TIMEOUT);
- timedOut.add(nodeId);
- }
- }
-
- return timedOut;
- }
-
- public Set> getNonWorkingPeers()
- {
- Set> nonWorkingPeers = new HashSet>();
- for(String nodeId : nodeInfos.keySet())
- {
- if(!getId().equals(nodeId) && getStatus(nodeId).getNodeStatus() != NodeStatus.WORKING)
- {
- nonWorkingPeers.add(new UnorderedPair(getId(), nodeId));
- }
- }
-
- return nonWorkingPeers;
- }
-
- public boolean equals(Object other)
- {
- if (this == other)
- {
- return true;
- }
-
- if(!(other instanceof NodeInfo))
- {
- return false;
- }
-
- NodeInfo nodeInfo = (NodeInfo)other;
- return EqualsHelper.nullSafeEquals(getId(), nodeInfo.getId());
- }
- }
-
- public static class UnorderedPair implements Serializable
- {
- private static final long serialVersionUID = -8947346745086237616L;
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public static final UnorderedPair NULL_PAIR = new UnorderedPair(null, null);
-
- @SuppressWarnings("unchecked")
- public static final UnorderedPair nullPair()
- {
- return NULL_PAIR;
- }
-
- /**
- * The first member of the pair.
- */
- private T first;
-
- /**
- * The second member of the pair.
- */
- private T second;
-
- /**
- * Make a new one.
- *
- * @param first The first member.
- * @param second The second member.
- */
- public UnorderedPair(T first, T second)
- {
- this.first = first;
- this.second = second;
- }
-
- /**
- * Get the first member of the tuple.
- * @return The first member.
- */
- public final T getFirst()
- {
- return first;
- }
-
- /**
- * Get the second member of the tuple.
- * @return The second member.
- */
- public final T getSecond()
- {
- return second;
- }
-
- @Override
- public boolean equals(Object other)
- {
- if (this == other)
- {
- return true;
- }
- if (other == null || !(other instanceof UnorderedPair>))
- {
- return false;
- }
- UnorderedPair> o = (UnorderedPair>)other;
- return EqualsHelper.nullSafeEquals(this.first, o.first) &&
- EqualsHelper.nullSafeEquals(this.second, o.second) ||
- EqualsHelper.nullSafeEquals(this.first, o.second) &&
- EqualsHelper.nullSafeEquals(this.second, o.first);
- }
-
- @Override
- public int hashCode()
- {
- return (first == null ? 0 : first.hashCode()) + (second == null ? 0 : second.hashCode());
- }
-
- @Override
- public String toString()
- {
- return "(" + first + ", " + second + ")";
- }
- }
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cluster/ClusterEvent.java b/source/java/org/alfresco/repo/cluster/ClusterEvent.java
deleted file mode 100644
index f33448228e..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterEvent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import org.springframework.context.ApplicationEvent;
-
-/**
- *
- * @since Odin
- *
- */
-public class ClusterEvent extends ApplicationEvent
-{
- private static final long serialVersionUID = 7481373845772903712L;
-
- public ClusterEvent(ClusterChecker clusterChecker)
- {
- super(clusterChecker);
- }
-
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterMessageEvent.java b/source/java/org/alfresco/repo/cluster/ClusterMessageEvent.java
deleted file mode 100644
index 0c15bcf48d..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterMessageEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-/**
- *
- * @since Odin
- *
- */
-public class ClusterMessageEvent extends ClusterEvent
-{
- private static final long serialVersionUID = -8677530378696271077L;
-
- private String sourceId;
- private String targetId;
-
- public ClusterMessageEvent(ClusterChecker clusterChecker, String sourceId, String targetId)
- {
- super(clusterChecker);
- this.sourceId = sourceId;
- this.targetId = targetId;
- }
-
- public String getSourceId()
- {
- return sourceId;
- }
-
- public String getTargetId()
- {
- return targetId;
- }
-
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterNodeExistsEvent.java b/source/java/org/alfresco/repo/cluster/ClusterNodeExistsEvent.java
deleted file mode 100644
index db2bd59850..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterNodeExistsEvent.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-/**
- *
- * @since Odin
- *
- */
-public class ClusterNodeExistsEvent extends ClusterEvent
-{
- private static final long serialVersionUID = -9060051914186153663L;
- public static final String NOTIFICATION_TYPE = "Cluster Node Found";
-
- private String nodeId;
-
- public ClusterNodeExistsEvent(ClusterChecker clusterChecker, String nodeId)
- {
- super(clusterChecker);
- this.nodeId = nodeId;
- }
-
- public String getNodeId()
- {
- return nodeId;
- }
-
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterNodePairStatusEvent.java b/source/java/org/alfresco/repo/cluster/ClusterNodePairStatusEvent.java
deleted file mode 100644
index 9541796ec5..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterNodePairStatusEvent.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import org.alfresco.repo.cluster.ClusterChecker.NodeStatus;
-
-/**
- *
- * @Odin
- *
- */
-public class ClusterNodePairStatusEvent extends ClusterEvent
-{
- private static final long serialVersionUID = -4045195741687097066L;
- public static final String NOTIFICATION_TYPE = "Cluster Node Pair Status";
-
- private String sourceNodeId;
- private String targetNodeId;
- private NodeStatus status;
-
- public ClusterNodePairStatusEvent(ClusterChecker clusterChecker, String sourceNodeId, String targetNodeId, NodeStatus status)
- {
- super(clusterChecker);
- this.sourceNodeId = sourceNodeId;
- this.targetNodeId = targetNodeId;
- this.status = status;
-
- }
-
- public String getSourceNodeId()
- {
- return sourceNodeId;
- }
-
- public String getTargetNodeId()
- {
- return targetNodeId;
- }
-
- public NodeStatus getStatus()
- {
- return status;
- }
-
-}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/cluster/ClusterNodeStopTrackingEvent.java b/source/java/org/alfresco/repo/cluster/ClusterNodeStopTrackingEvent.java
deleted file mode 100644
index f6415e0452..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterNodeStopTrackingEvent.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-/**
- *
- * @since Odin
- *
- */
-public class ClusterNodeStopTrackingEvent extends ClusterEvent
-{
- private static final long serialVersionUID = -116885933025872510L;
-
- public static final String NOTIFICATION_TYPE = "Cluster Node Stop Tracking";
-
- private String nodeId;
-
- public ClusterNodeStopTrackingEvent(ClusterChecker clusterChecker, String nodeId)
- {
- super(clusterChecker);
- this.nodeId = nodeId;
-
- }
-
- public String getNodeId()
- {
- return nodeId;
- }
-
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterTestSuite.java b/source/java/org/alfresco/repo/cluster/ClusterTestSuite.java
deleted file mode 100644
index 502fba17a9..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterTestSuite.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test suite for the org.alfresco.repo.cluster package.
- *
- * This includes tests which will fail on the build servers -
- * do not include this suite in the CI build targets.
- *
- * @author Matt Ward
- */
-@RunWith(Suite.class)
-@SuiteClasses({
- // Run the standard tests
- org.alfresco.repo.cluster.BuildSafeTestSuite.class,
-
- // Additionally run these tests that cannot be run on the build servers.
- org.alfresco.repo.cluster.HazelcastTest.class
-})
-public class ClusterTestSuite
-{
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterValidateEvent.java b/source/java/org/alfresco/repo/cluster/ClusterValidateEvent.java
deleted file mode 100644
index 7899bf4d4c..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterValidateEvent.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-/**
- *
- * @since Odin
- *
- */
-public class ClusterValidateEvent extends ClusterMessageEvent
-{
- private static final long serialVersionUID = -8091460189522981871L;
-
- private String ticket;
-
- public ClusterValidateEvent(ClusterChecker clusterChecker, String ticket, String sourceId, String targetId)
- {
- super(clusterChecker, sourceId, targetId);
- this.ticket = ticket;
- }
-
- public String getTicket()
- {
- return ticket;
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterValidateResponseEvent.java b/source/java/org/alfresco/repo/cluster/ClusterValidateResponseEvent.java
deleted file mode 100644
index 577032c648..0000000000
--- a/source/java/org/alfresco/repo/cluster/ClusterValidateResponseEvent.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-/**
- *
- * @since Odin
- *
- */
-public class ClusterValidateResponseEvent extends ClusterMessageEvent
-{
- private static final long serialVersionUID = -813956714769487998L;
-
- private String address;
- private boolean ticketValid;
-
- public ClusterValidateResponseEvent(ClusterChecker clusterChecker, String address, String sourceId, String targetId, boolean ticketValid)
- {
- super(clusterChecker, sourceId, targetId);
- this.address = address;
- this.ticketValid = ticketValid;
- }
-
- public String getAddress()
- {
- return address;
- }
-
- public boolean isTicketValid()
- {
- return ticketValid;
- }
-
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBean.java b/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBean.java
deleted file mode 100644
index 405535583c..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBean.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.util.Properties;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.IOUtils;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.core.io.Resource;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.config.InMemoryXmlConfig;
-
-/**
- * FactoryBean used to create Hazelcast {@link Config} objects. A configuration file is supplied
- * in the form of a Spring {@link Resource} and a set of {@link Properties} can also be provided. The
- * XML file is processed so that property placeholders of the form ${property.name} are substitued for
- * the corresponding property value before the XML is parsed into the Hazelcast configuration object.
- *
- * @author Matt Ward
- */
-public class HazelcastConfigFactoryBean implements InitializingBean, FactoryBean
-{
- private static final String PLACEHOLDER_END = "}";
- private static final String PLACEHOLDER_START = "${";
- private Resource configFile;
- private Config config;
- private Properties properties;
-
-
- /**
- * Set the Hazelcast XML configuration file to use. This will be merged with the supplied
- * Properties and parsed to produce a final {@link Config} object.
- * @param configFile the configFile to set
- */
- public void setConfigFile(Resource configFile)
- {
- this.configFile = configFile;
- }
-
- /**
- * Used to supply the set of Properties that the configuration file can reference.
- *
- * @param properties the properties to set
- */
- public void setProperties(Properties properties)
- {
- this.properties = properties;
- }
-
- /**
- * Spring {@link InitializingBean} lifecycle method. Substitutes property placeholders for their
- * corresponding values and creates a {@link Config Hazelcast configuration} with the post-processed
- * XML file - ready for the {@link #getObject()} factory method to be used to retrieve it.
- */
- @Override
- public void afterPropertiesSet() throws Exception
- {
- if (configFile == null)
- {
- throw new IllegalArgumentException("No configuration file specified.");
- }
- if (properties == null)
- {
- properties = new Properties();
- }
-
- // These configXML strings will be large and are therefore intended
- // to be thrown away. We only want to keep the final Config object.
- String rawConfigXML = getConfigFileContents();
- String configXML = substituteProperties(rawConfigXML);
- config = new InMemoryXmlConfig(configXML);
- }
-
- /**
- * For the method parameter text
, replaces all occurrences of placeholders having
- * the form ${property.name} with the value of the property having the key "property.name". The
- * properties are supplied using {@link #setProperties(Properties)}.
- *
- * @param text The String to apply property substitutions to.
- * @return String after substitutions have been applied.
- */
- private String substituteProperties(String text)
- {
- for (String propName : properties.stringPropertyNames())
- {
- String propValue = properties.getProperty(propName);
- String quotedPropName = Pattern.quote(PLACEHOLDER_START + propName + PLACEHOLDER_END);
- text = text.replaceAll(quotedPropName, propValue);
- }
-
- return text;
- }
-
- /**
- * Opens the configFile {@link Resource} and reads the contents into a String.
- *
- * @return the contents of the configFile resource.
- */
- private String getConfigFileContents()
- {
- StringWriter writer = new StringWriter();
- InputStream inputStream = null;
- try
- {
- inputStream = configFile.getInputStream();
- IOUtils.copy(inputStream, writer, "UTF-8");
- return writer.toString();
- }
- catch (IOException e)
- {
- throw new RuntimeException("Couldn't read configuration: " + configFile, e);
- }
- finally
- {
- try
- {
- if (inputStream != null)
- {
- inputStream.close();
- }
- }
- catch (IOException e)
- {
- throw new RuntimeException("Couldn't close stream", e);
- }
- }
- }
-
- /**
- * FactoryBean's factory method. Returns the config with the property key/value
- * substitutions in place.
- */
- @Override
- public Config getObject() throws Exception
- {
- return config;
- }
-
- @Override
- public Class> getObjectType()
- {
- return Config.class;
- }
-
- @Override
- public boolean isSingleton()
- {
- return true;
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBeanTest.java b/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBeanTest.java
deleted file mode 100644
index 5a897852cf..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastConfigFactoryBeanTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Properties;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-
-import com.hazelcast.config.Config;
-
-/**
- * Tests for the HazelcastConfigFactoryBean class.
- *
- * @author Matt Ward
- */
-public class HazelcastConfigFactoryBeanTest
-{
- private HazelcastConfigFactoryBean configFactory;
- private Resource resource;
- private Properties properties;
-
- @Before
- public void setUp() throws Exception
- {
- configFactory = new HazelcastConfigFactoryBean();
- resource = new ClassPathResource("cluster-test/placeholder-test.xml");
- configFactory.setConfigFile(resource);
-
- properties = new Properties();
- properties.setProperty("alfresco.hazelcast.password", "let-me-in");
- properties.setProperty("alfresco.cluster.name", "cluster-name");
- configFactory.setProperties(properties);
-
- // Trigger the spring post-bean creation lifecycle method
- configFactory.afterPropertiesSet();
- }
-
-
- @Test
- public void testConfigHasNewPropertyValues() throws Exception
- {
- // Invoke the factory method.
- Config config = configFactory.getObject();
-
- assertEquals("let-me-in", config.getGroupConfig().getPassword());
- assertEquals("cluster-name", config.getGroupConfig().getName());
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastInstanceFactory.java b/source/java/org/alfresco/repo/cluster/HazelcastInstanceFactory.java
deleted file mode 100644
index feb88886aa..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastInstanceFactory.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.alfresco.util.PropertyCheck;
-
-import com.hazelcast.config.Config;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-
-/**
- * Provides a way of lazily creating HazelcastInstances for a given configuration.
- * The HazelcastInstance will not be created until {@link #getInstance()} is called.
- *
- * An intermediary class such as this is required in order to avoid starting
- * Hazelcast instances when clustering is not configured/required. Otherwise
- * simply by defining a HazelcastInstance bean clustering would spring into life.
- *
- * Please note this class provides non-static access deliberately, and should be
- * injected into any clients that require its services.
- *
- * @author Matt Ward
- */
-public class HazelcastInstanceFactory
-{
- private Config config;
- private HazelcastInstance hazelcastInstance;
- /** Guards {@link #config} and {@link #hazelcastInstance} */
- private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
-
- public HazelcastInstance getInstance()
- {
- rwLock.readLock().lock();
- try
- {
- if (hazelcastInstance != null)
- {
- return hazelcastInstance;
- }
- }
- finally
- {
- rwLock.readLock().unlock();
- }
-
- // hazelcastInstance is null, so create it.
- rwLock.writeLock().lock();
- try
- {
- // Double check condition hasn't changed in between locks.
- if (hazelcastInstance == null)
- {
- hazelcastInstance = Hazelcast.newHazelcastInstance(config);
- }
- return hazelcastInstance;
- }
- finally
- {
- rwLock.writeLock().unlock();
- }
- }
-
- /**
- * Checks whether hazelcast has been given a valid cluster name. If so,
- * then clustering is considered enabled. This condition should be checked
- * before calling {@link #getInstance()}.
- *
- * @return true if clustering is enabled, false otherwise.
- */
- public boolean isClusteringEnabled()
- {
- rwLock.readLock().lock();
- try
- {
- String clusterName = config.getGroupConfig().getName();
- return (PropertyCheck.isValidPropertyString(clusterName));
- }
- finally
- {
- rwLock.readLock().unlock();
- }
- }
-
- /**
- * Retrieve the name of the cluster for the configuration used by this factory.
- *
- * @return String - the cluster name.
- */
- public String getClusterName()
- {
- rwLock.readLock().lock();
- try
- {
- String clusterName = config.getGroupConfig().getName();
- return clusterName;
- }
- finally
- {
- rwLock.readLock().unlock();
- }
- }
-
- /**
- * Sets the Hazelcast configuration that will be used by this factory when
- * creating the HazelcastInstance.
- *
- * @param config Hazelcast configuration
- */
- public void setConfig(Config config)
- {
- rwLock.writeLock().lock();
- try
- {
- this.config = config;
- }
- finally
- {
- rwLock.writeLock().unlock();
- }
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessenger.java b/source/java/org/alfresco/repo/cluster/HazelcastMessenger.java
deleted file mode 100644
index 0a3d540304..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastMessenger.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import java.io.Serializable;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.hazelcast.core.ITopic;
-import com.hazelcast.core.MessageListener;
-
-/**
- * Hazelcast-based implementation of the {@link Messenger} interface.
- *
- * @see HazelcastMessengerFactory
- * @author Matt Ward
- */
-public class HazelcastMessenger implements Messenger, MessageListener
-{
- private ITopic topic;
- private MessageReceiver receiverDelegate;
- private String address;
- private final static Log logger = LogFactory.getLog(HazelcastMessenger.class);
-
- /**
- * @param topic
- */
- public HazelcastMessenger(ITopic topic, String address)
- {
- this.topic = topic;
- this.address = address;
- }
-
-
- @Override
- public void send(T message)
- {
- if (logger.isTraceEnabled())
- {
- String digest = StringUtils.abbreviate(message.toString(), 50);
- logger.trace("Sending [source: " + address + "]: " + digest);
- }
- topic.publish(message);
- }
-
- @Override
- public void setReceiver(MessageReceiver receiver)
- {
- // Install a delegate to ready to handle incoming messages.
- receiverDelegate = receiver;
- // Start receiving messages.
- topic.addMessageListener(this);
- }
-
- @Override
- public void onMessage(T message)
- {
- if (logger.isTraceEnabled())
- {
- String digest = StringUtils.abbreviate(message.toString(), 50);
- logger.trace("Received [destination: " + address + "] (delegating to receiver): " + digest);
- }
- receiverDelegate.onReceive(message);
- }
-
- @Override
- public boolean isConnected()
- {
- return true;
- }
-
- protected ITopic getTopic()
- {
- return topic;
- }
-
-
- @Override
- public String getAddress()
- {
- return address;
- }
-
-
- @Override
- public String toString()
- {
- return "HazelcastMessenger[connected=" + isConnected() +
- ", topic=" + getTopic() +
- ", address=" + getAddress() + "]";
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactory.java b/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactory.java
deleted file mode 100644
index 9ba93ac6dd..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactory.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import java.io.Serializable;
-import java.util.Set;
-
-import com.hazelcast.core.HazelcastInstance;
-import com.hazelcast.core.ITopic;
-import com.hazelcast.core.Member;
-import com.hazelcast.core.MembershipEvent;
-import com.hazelcast.core.MembershipListener;
-
-/**
- * Hazelcast-based implementation of the {@link MessengerFactory} interface.
- * The factory must be configured with a {@link HazelcastInstance} - which
- * is the underlying factory for {@link ITopic} creation.
- *
- * @author Matt Ward
- */
-public class HazelcastMessengerFactory implements MessengerFactory
-{
- private HazelcastInstanceFactory hazelcastInstanceFactory;
-
- @Override
- public Messenger createMessenger(String appRegion)
- {
- return createMessenger(appRegion, false);
- }
-
- @Override
- public Messenger createMessenger(String appRegion, boolean acceptLocalMessages)
- {
- if (!isClusterActive())
- {
- return new NullMessenger();
- }
- // Clustering is enabled, create a messenger.
- HazelcastInstance hazelcast = hazelcastInstanceFactory.getInstance();
- ITopic topic = hazelcast.getTopic(appRegion);
- String address = hazelcast.getCluster().getLocalMember().getInetSocketAddress().toString();
- return new HazelcastMessenger(topic, address);
- }
-
- /**
- * Provide the messenger factory with a means to obtain a HazelcastInstance.
- *
- * @param hazelcastInstanceFactory
- */
- public void setHazelcastInstanceFactory(HazelcastInstanceFactory hazelcastInstanceFactory)
- {
- this.hazelcastInstanceFactory = hazelcastInstanceFactory;
- }
-
- @Override
- public boolean isClusterActive()
- {
- return hazelcastInstanceFactory.isClusteringEnabled();
- }
-
- @Override
- public void addMembershipListener(final ClusterMembershipListener listener)
- {
- if (isClusterActive())
- {
- HazelcastInstance hazelcast = hazelcastInstanceFactory.getInstance();
- hazelcast.getCluster().addMembershipListener(new MembershipListener()
- {
- @Override
- public void memberRemoved(MembershipEvent e)
- {
- listener.memberLeft(member(e), cluster(e));
- }
-
- @Override
- public void memberAdded(MembershipEvent e)
- {
- listener.memberJoined(member(e), cluster(e));
- }
-
- private String member(MembershipEvent e)
- {
- return e.getMember().getInetSocketAddress().toString();
- }
-
- private String[] cluster(MembershipEvent e)
- {
- Set members = e.getCluster().getMembers();
- String[] cluster = new String[members.size()];
- int i = 0;
- for (Member m : members)
- {
- cluster[i++] = m.getInetSocketAddress().toString();
- }
- return cluster;
- }
- });
- }
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactoryTest.java b/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactoryTest.java
deleted file mode 100644
index 84e5d02e80..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastMessengerFactoryTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.mockito.Mockito.when;
-
-import java.net.InetSocketAddress;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import com.hazelcast.core.Cluster;
-import com.hazelcast.core.HazelcastInstance;
-import com.hazelcast.core.ITopic;
-import com.hazelcast.core.Member;
-
-
-/**
- * Tests for the HazelcastMessengerFactory class.
- *
- * @author Matt Ward
- */
-@RunWith(MockitoJUnitRunner.class)
-public class HazelcastMessengerFactoryTest
-{
- private HazelcastMessengerFactory factory;
- private @Mock HazelcastInstance hazelcast;
- private @Mock Member member;
- private @Mock Cluster cluster;
- private @Mock ITopic topic;
- private @Mock HazelcastInstanceFactory hazelcastInstanceFactory;
-
- @Before
- public void setUp()
- {
- factory = new HazelcastMessengerFactory();
- factory.setHazelcastInstanceFactory(hazelcastInstanceFactory);
-
- when(hazelcastInstanceFactory.isClusteringEnabled()).thenReturn(true);
- when(hazelcastInstanceFactory.getInstance()).thenReturn(hazelcast);
- }
-
- @Test
- public void topicWrappedInMessenger()
- {
- when(hazelcast.getTopic("app-region")).thenReturn(topic);
- when(hazelcast.getCluster()).thenReturn(cluster);
- when(cluster.getLocalMember()).thenReturn(member);
- when(member.getInetSocketAddress()).thenReturn(InetSocketAddress.createUnresolved("a-host-name", 1234));
-
- Messenger messenger = factory.createMessenger("app-region");
-
- assertSame(topic, ((HazelcastMessenger) messenger).getTopic());
- assertEquals("a-host-name:1234", messenger.getAddress());
- }
-
- @Test
- public void canCheckClusterIsActive()
- {
- assertEquals(true, factory.isClusterActive());
-
- when(hazelcastInstanceFactory.isClusteringEnabled()).thenReturn(false);
- assertEquals(false, factory.isClusterActive());
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastMessengerTest.java b/source/java/org/alfresco/repo/cluster/HazelcastMessengerTest.java
deleted file mode 100644
index 5ef3fd1ca3..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastMessengerTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.verify;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import com.hazelcast.core.ITopic;
-
-/**
- * Tests for the HazelcastMessenger class.
- *
- * @author Matt Ward
- */
-@RunWith(MockitoJUnitRunner.class)
-public class HazelcastMessengerTest
-{
- private @Mock ITopic topic;
- private HazelcastMessenger messenger;
- private String receivedMsg;
-
- @Before
- public void setUp()
- {
- messenger = new HazelcastMessenger(topic, "address");
- receivedMsg = null;
- }
-
- @Test
- public void canSendMessage()
- {
- messenger.send("Test string");
- verify(topic).publish("Test string");
- }
-
- @Test
- public void canReceiveMessage()
- {
- messenger.setReceiver(new MessageReceiver()
- {
- @Override
- public void onReceive(String message)
- {
- receivedMsg = new String(message);
- }
- });
-
- // Hazelcast will call the onMessage method...
- messenger.onMessage("Hazelcast is sending a message.");
-
- // setReceiver() should have resulted in a listener being registered with the topic.
- verify(topic).addMessageListener(messenger);
-
- assertEquals("Hazelcast is sending a message.", receivedMsg);
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/HazelcastTest.java b/source/java/org/alfresco/repo/cluster/HazelcastTest.java
deleted file mode 100644
index d161152711..0000000000
--- a/source/java/org/alfresco/repo/cluster/HazelcastTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-
-import org.alfresco.repo.cluster.MessengerTestHelper.TestMessageReceiver;
-import org.alfresco.util.ApplicationContextHelper;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.context.ApplicationContext;
-
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import com.hazelcast.core.ITopic;
-import com.hazelcast.core.MessageListener;
-
-/**
- * Tests for Hazelcast implementations of {@link Messenger} and related classes.
- * These are integration tests and configured through a Spring test context file.
- *
- * @author Matt Ward
- */
-public class HazelcastTest implements MessageListener
-{
- private static ApplicationContext ctx;
- private MessengerTestHelper helper;
- private HazelcastInstanceFactory hiFactory;
- private HazelcastInstance hi;
-
- @BeforeClass
- public static void setUpClass()
- {
- ctx = ApplicationContextHelper.
- getApplicationContext(new String[] { "cluster-test/hazelcast-messenger-test.xml" });
- }
-
- @AfterClass
- public static void tearDownClass()
- {
- ApplicationContextHelper.closeApplicationContext();
- Hazelcast.shutdownAll();
- }
-
- @Before
- public void setUp()
- {
- helper = new MessengerTestHelper();
- hiFactory = ctx.getBean(HazelcastInstanceFactory.class);
- hi = hiFactory.getInstance();
- }
-
-
- @Test
- public void canSendWithHazelcastMessengerFactory() throws InterruptedException
- {
- ITopic topic = hi.getTopic("testregion");
-
- topic.addMessageListener(this);
-
- MessengerFactory messengerFactory = (MessengerFactory) ctx.getBean("messengerFactory");
- Messenger messenger = messengerFactory.createMessenger("testregion");
- messenger.send("Full test including spring.");
-
- helper.checkMessageReceivedWas("Full test including spring.");
- }
-
- @Ignore("Behaviour not yet implemented.")
- @Test
- public void messengerWillNotReceiveMessagesFromSelf() throws InterruptedException
- {
- MessengerFactory messengerFactory = (MessengerFactory) ctx.getBean("messengerFactory");
- Messenger m1 = messengerFactory.createMessenger("testregion");
- TestMessageReceiver r1 = new TestMessageReceiver();
- m1.setReceiver(r1);
-
- ITopic topic2 = hi.getTopic("testregion");
- String address2 = hi.getCluster().getLocalMember().getInetSocketAddress().toString();
- Messenger m2 = new HazelcastMessenger(topic2, address2);
- TestMessageReceiver r2 = new TestMessageReceiver();
- m2.setReceiver(r2);
-
- m1.send("This should be received by r2 but not r1");
-
- r2.helper.checkMessageReceivedWas("This should be received by r2 but not r1");
- r1.helper.checkNoMessageReceived();
- }
-
- @Override
- public void onMessage(String message)
- {
- helper.setReceivedMsg(message);
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/MessageReceiver.java b/source/java/org/alfresco/repo/cluster/MessageReceiver.java
deleted file mode 100644
index 474c4adac6..0000000000
--- a/source/java/org/alfresco/repo/cluster/MessageReceiver.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import java.io.Serializable;
-
-/**
- * Implement this interface and supply to a {@link Messenger} using
- * {@link Messenger#setReceiver(MessageReceiver)} in order to receive
- * messages from other {@link Messenger}s.
- *
- * @author Matt Ward
- */
-public interface MessageReceiver
-{
- void onReceive(T message);
-}
diff --git a/source/java/org/alfresco/repo/cluster/Messenger.java b/source/java/org/alfresco/repo/cluster/Messenger.java
deleted file mode 100644
index 465e112278..0000000000
--- a/source/java/org/alfresco/repo/cluster/Messenger.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import java.io.Serializable;
-
-/**
- * Provides facilities for peer-to-peer messaging within a cluster. This interface
- * is intended to act as a facade, allowing the actual implementation (e.g. Hazelcast)
- * to be decoupled as much as possible from the Alfresco code base.
- *
- * Instances of this class are parameterised with the type of message payload
- * to send and receive.
- *
- * @author Matt Ward
- */
-public interface Messenger
-{
- void send(T message);
-
- void setReceiver(MessageReceiver receiver);
-
- boolean isConnected();
-
- String getAddress();
-}
diff --git a/source/java/org/alfresco/repo/cluster/MessengerFactory.java b/source/java/org/alfresco/repo/cluster/MessengerFactory.java
deleted file mode 100644
index fc39ddfa7d..0000000000
--- a/source/java/org/alfresco/repo/cluster/MessengerFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import java.io.Serializable;
-
-/**
- * Factory class responsible for creating instances of {@link Messenger} class.
- *
- * @author Matt Ward
- */
-public interface MessengerFactory
-{
- /** A catch-all for unknown application regions. */
- public static final String APP_REGION_DEFAULT = "DEFAULT";
-
- /** The application region used by the EHCache heartbeat implementation. */
- public static final String APP_REGION_EHCACHE_HEARTBEAT = "EHCACHE_HEARTBEAT";
-
- Messenger createMessenger(String appRegion);
-
- Messenger createMessenger(String appRegion, boolean acceptLocalMessages);
-
- boolean isClusterActive();
-
- void addMembershipListener(ClusterMembershipListener membershipListener);
-}
diff --git a/source/java/org/alfresco/repo/cluster/MessengerFactoryProvider.java b/source/java/org/alfresco/repo/cluster/MessengerFactoryProvider.java
deleted file mode 100644
index 3bc3630757..0000000000
--- a/source/java/org/alfresco/repo/cluster/MessengerFactoryProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-/**
- * Static container for MessengerFactory. This allows code to obtain the correct
- * {@link MessengerFactory} implementation where dependency injection is not available.
- *
- * @author Matt Ward
- */
-public class MessengerFactoryProvider
-{
- private static MessengerFactory instance;
-
- public void setInstance(MessengerFactory messengerFactory)
- {
- instance = messengerFactory;
- }
-
- public static MessengerFactory getInstance()
- {
- if (instance == null)
- {
- throw new IllegalStateException("MessengerFactory instance not configured yet.");
- }
- return instance;
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/MessengerTestHelper.java b/source/java/org/alfresco/repo/cluster/MessengerTestHelper.java
deleted file mode 100644
index cdab15a0d4..0000000000
--- a/source/java/org/alfresco/repo/cluster/MessengerTestHelper.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.cluster;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-/**
- * Helper class for testing Messenger related code.
- *
- * @author Matt Ward
- */
-public class MessengerTestHelper
-{
- private String receivedMsg;
- private final static int SLEEP_MILLIS = 50;
- private static final int MAX_TRIES = 30;
-
-
- public MessengerTestHelper()
- {
- setReceivedMsg(null);
- }
-
- /**
- * Try to avoid intermitten test failures by trying multiple times. Hopefully the messge
- * will have been received after the very first sleep, but in a slow environment it may take longer.
- * This also allows the sleep time to be lower - rather than waiting for say 50 ms, we can try 10 times
- * at 5 ms - with a chance that we can return after the initial 5 ms.
- *
- * @param expectedMsg
- * @throws InterruptedException
- */
- public void checkMessageReceivedWas(String expectedMsg)
- {
- int tries = 0;
-
- while (tries < MAX_TRIES)
- {
- try
- {
- Thread.sleep(SLEEP_MILLIS);
- }
- catch (InterruptedException e)
- {
- // Carry on
- e.printStackTrace();
- }
- if (getReceivedMsg() != null)
- {
- assertEquals(expectedMsg, getReceivedMsg());
- return;
- }
- tries++;
- }
- fail("No message received, tried " + tries +
- " times, sleeping " + SLEEP_MILLIS + "ms each time.");
- }
-
- /**
- * Assert that no message was received in the given period.
- */
- public void checkNoMessageReceived()
- {
- int tries = 0;
-
- while (tries < MAX_TRIES)
- {
- try
- {
- Thread.sleep(SLEEP_MILLIS);
- }
- catch (InterruptedException e)
- {
- // Carry on
- e.printStackTrace();
- }
- if (getReceivedMsg() != null)
- {
- fail("Message received but should NOT have been. Message was: " + getReceivedMsg());
- }
- tries++;
- }
- }
-
- /**
- * @return the receivedMsg
- */
- public String getReceivedMsg()
- {
- return this.receivedMsg;
- }
-
- /**
- * @param receivedMsg the receivedMsg to set
- */
- public void setReceivedMsg(String receivedMsg)
- {
- this.receivedMsg = receivedMsg;
- }
-
-
- public static class TestMessageReceiver implements MessageReceiver
- {
- MessengerTestHelper helper = new MessengerTestHelper();
-
- @Override
- public void onReceive(String message)
- {
- helper.setReceivedMsg(message);
- }
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/NullMessenger.java b/source/java/org/alfresco/repo/cluster/NullMessenger.java
deleted file mode 100644
index 55b63587aa..0000000000
--- a/source/java/org/alfresco/repo/cluster/NullMessenger.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.cluster;
-
-import java.io.Serializable;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * A do-nothing implementation of the {@link Messenger} interface.
- *
- * @author Matt Ward
- */
-public class NullMessenger implements Messenger
-{
- private static final Log logger = LogFactory.getLog(NullMessenger.class);
-
- @Override
- public void send(T message)
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("Throwing away message: " + message);
- }
- }
-
- @Override
- public void setReceiver(MessageReceiver receiver)
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("Throwing away receiver: " + receiver);
- }
- }
-
- @Override
- public boolean isConnected()
- {
- return false;
- }
-
- @Override
- public String getAddress()
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("getAddress() always returns loopback address: 127.0.0.1");
- }
- return "127.0.0.1";
- }
-}
diff --git a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java
index 2f9a66b6c6..4bf5444845 100644
--- a/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java
+++ b/source/java/org/alfresco/repo/content/RoutingContentStoreTest.java
@@ -24,10 +24,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-
-import org.alfresco.repo.cache.EhCacheAdapter;
+import org.alfresco.repo.cache.DefaultSimpleCache;
+import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.content.filestore.FileContentStore;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
@@ -158,11 +156,7 @@ public class RoutingContentStoreTest extends AbstractWritableContentStoreTest
{
this.stores.add(store);
}
- Cache ehCache = new Cache("RandomRoutingContentStore", 50, false, true, 0L, 0L);
- CacheManager cacheManager = new CacheManager();
- cacheManager.addCache(ehCache);
- EhCacheAdapter, ContentStore> cache = new EhCacheAdapter, ContentStore>();
- cache.setCache(ehCache);
+ SimpleCache, ContentStore> cache = new DefaultSimpleCache, ContentStore>();
super.setStoresCache(cache);
}
diff --git a/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java b/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java
index fe8a5158aa..54dfb157c7 100644
--- a/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java
+++ b/source/java/org/alfresco/repo/content/caching/CachingContentStoreSpringTest.java
@@ -20,9 +20,8 @@ package org.alfresco.repo.content.caching;
import java.io.File;
-import net.sf.ehcache.CacheManager;
-
-import org.alfresco.repo.cache.EhCacheAdapter;
+import org.alfresco.repo.cache.DefaultSimpleCache;
+import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.content.AbstractWritableContentStoreTest;
import org.alfresco.repo.content.ContentContext;
import org.alfresco.repo.content.ContentStore;
@@ -42,8 +41,6 @@ import org.junit.runner.RunWith;
@RunWith(JUnit38ClassRunner.class)
public class CachingContentStoreSpringTest extends AbstractWritableContentStoreTest
{
- private static final String EHCACHE_NAME = "cache.test.cachingContentStoreCache";
- private static final int T24_HOURS = 86400;
private CachingContentStore store;
private FileContentStore backingStore;
private ContentCacheImpl cache;
@@ -67,22 +64,9 @@ public class CachingContentStoreSpringTest extends AbstractWritableContentStoreT
store = new CachingContentStore(backingStore, cache, false);
}
- private EhCacheAdapter createMemoryStore()
+ private SimpleCache createMemoryStore()
{
- CacheManager manager = CacheManager.getInstance();
-
- // Create the cache if it hasn't already been created.
- if (!manager.cacheExists(EHCACHE_NAME))
- {
- net.sf.ehcache.Cache memoryOnlyCache =
- new net.sf.ehcache.Cache(EHCACHE_NAME, 50, false, false, T24_HOURS, T24_HOURS);
-
- manager.addCache(memoryOnlyCache);
- }
-
- EhCacheAdapter memoryStore = new EhCacheAdapter();
- memoryStore.setCache(manager.getCache(EHCACHE_NAME));
-
+ SimpleCache memoryStore = new DefaultSimpleCache();
return memoryStore;
}
diff --git a/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java b/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java
index acfe5d9a1b..c8590c58d8 100644
--- a/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java
+++ b/source/java/org/alfresco/repo/dictionary/RepoDictionaryDAOTest.java
@@ -28,11 +28,11 @@ import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
import org.alfresco.model.ContentModel;
-import org.alfresco.repo.cache.EhCacheAdapter;
+import org.alfresco.repo.cache.DefaultSimpleCache;
+import org.alfresco.repo.cache.NullCache;
+import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.dictionary.DictionaryDAOImpl.DictionaryRegistry;
import org.alfresco.repo.dictionary.NamespaceDAOImpl.NamespaceRegistry;
import org.alfresco.repo.dictionary.constraint.AbstractConstraint;
@@ -116,25 +116,13 @@ public class RepoDictionaryDAOTest extends TestCase
private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO)
{
- CacheManager cacheManager = new CacheManager();
-
- Cache dictionaryEhCache = new Cache("dictionaryCache", 50, false, true, 0L, 0L);
- cacheManager.addCache(dictionaryEhCache);
- EhCacheAdapter dictionaryCache = new EhCacheAdapter();
- dictionaryCache.setCache(dictionaryEhCache);
-
+ SimpleCache dictionaryCache = new DefaultSimpleCache();
dictionaryDAO.setDictionaryRegistryCache(dictionaryCache);
}
private void initNamespaceCaches(NamespaceDAOImpl namespaceDAO)
{
- CacheManager cacheManager = new CacheManager();
-
- Cache namespaceEhCache = new Cache("namespaceCache", 50, false, true, 0L, 0L);
- cacheManager.addCache(namespaceEhCache);
- EhCacheAdapter namespaceCache = new EhCacheAdapter();
- namespaceCache.setCache(namespaceEhCache);
-
+ SimpleCache namespaceCache = new NullCache();
namespaceDAO.setNamespaceRegistryCache(namespaceCache);
}
diff --git a/source/java/org/alfresco/repo/dictionary/TestModel.java b/source/java/org/alfresco/repo/dictionary/TestModel.java
index 5eeab22062..f8c7211dc5 100644
--- a/source/java/org/alfresco/repo/dictionary/TestModel.java
+++ b/source/java/org/alfresco/repo/dictionary/TestModel.java
@@ -21,10 +21,8 @@ package org.alfresco.repo.dictionary;
import java.util.ArrayList;
import java.util.List;
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-
-import org.alfresco.repo.cache.EhCacheAdapter;
+import org.alfresco.repo.cache.DefaultSimpleCache;
+import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.dictionary.DictionaryDAOImpl.DictionaryRegistry;
import org.alfresco.repo.dictionary.NamespaceDAOImpl.NamespaceRegistry;
import org.alfresco.repo.tenant.SingleTServiceImpl;
@@ -120,25 +118,13 @@ public class TestModel
private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO)
{
- CacheManager cacheManager = new CacheManager();
-
- Cache dictionaryEhCache = new Cache("dictionaryCache", 50, false, true, 0L, 0L);
- cacheManager.addCache(dictionaryEhCache);
- EhCacheAdapter dictionaryCache = new EhCacheAdapter();
- dictionaryCache.setCache(dictionaryEhCache);
-
+ SimpleCache dictionaryCache = new DefaultSimpleCache();
dictionaryDAO.setDictionaryRegistryCache(dictionaryCache);
}
private static void initNamespaceCaches(NamespaceDAOImpl namespaceDAO)
{
- CacheManager cacheManager = new CacheManager();
-
- Cache namespaceEhCache = new Cache("namespaceCache", 50, false, true, 0L, 0L);
- cacheManager.addCache(namespaceEhCache);
- EhCacheAdapter namespaceCache = new EhCacheAdapter();
- namespaceCache.setCache(namespaceEhCache);
-
+ SimpleCache namespaceCache = new DefaultSimpleCache();
namespaceDAO.setNamespaceRegistryCache(namespaceCache);
}
}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java b/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java
index 836b336e68..14fc9064e0 100644
--- a/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java
+++ b/source/java/org/alfresco/repo/remoteticket/RemoteAlfrescoTicketServiceImpl.java
@@ -23,7 +23,7 @@ import java.util.HashMap;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
-import org.alfresco.repo.cache.EhCacheAdapter;
+import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.remotecredentials.PasswordCredentialsInfoImpl;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
@@ -67,7 +67,7 @@ public class RemoteAlfrescoTicketServiceImpl implements RemoteAlfrescoTicketServ
private RetryingTransactionHelper retryingTransactionHelper;
private RemoteCredentialsService remoteCredentialsService;
private RemoteConnectorService remoteConnectorService;
- private EhCacheAdapter ticketsCache;
+ private SimpleCache ticketsCache;
private Map remoteSystemsUrls = new HashMap();
private Map> remoteSystemsReqHeaders = new HashMap>();
@@ -89,9 +89,9 @@ public class RemoteAlfrescoTicketServiceImpl implements RemoteAlfrescoTicketServ
}
/**
- * Sets the EhCache to be used to cache remote tickets in
+ * Sets the SimpleCache to be used to cache remote tickets in
*/
- public void setTicketsCache(EhCacheAdapter ticketsCache)
+ public void setTicketsCache(SimpleCache ticketsCache)
{
this.ticketsCache = ticketsCache;
}
diff --git a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java
index 49197b2bbf..c1f0b1714a 100644
--- a/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java
+++ b/source/java/org/alfresco/repo/transaction/RetryingTransactionHelper.java
@@ -21,6 +21,9 @@ package org.alfresco.repo.transaction;
import java.lang.reflect.Method;
import java.sql.BatchUpdateException;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
@@ -31,8 +34,6 @@ import javax.transaction.RollbackException;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
-import net.sf.ehcache.distribution.RemoteCacheException;
-
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.error.ExceptionStackUtil;
import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -89,24 +90,68 @@ public class RetryingTransactionHelper
public static final Class[] RETRY_EXCEPTIONS;
static
{
- RETRY_EXCEPTIONS = new Class[] {
- ConcurrencyFailureException.class,
- DeadlockLoserDataAccessException.class,
- StaleObjectStateException.class,
- JdbcUpdateAffectedIncorrectNumberOfRowsException.class, // Similar to StaleObjectState
- LockAcquisitionException.class,
- ConstraintViolationException.class,
- UncategorizedSQLException.class,
- SQLException.class,
- BatchUpdateException.class,
- DataIntegrityViolationException.class,
- StaleStateException.class,
- TooManyResultsException.class, // Expected one result but found multiple (bad key alert)
- ObjectNotFoundException.class,
- CacheException.class, // Usually a cache replication issue
- RemoteCacheException.class, // A cache replication issue
- SQLGrammarException.class // Actually specific to MS SQL Server 2005 - we check for this
- };
+ Class>[] coreClasses = new Class[] {
+ ConcurrencyFailureException.class,
+ DeadlockLoserDataAccessException.class,
+ StaleObjectStateException.class,
+ JdbcUpdateAffectedIncorrectNumberOfRowsException.class, // Similar to StaleObjectState
+ LockAcquisitionException.class,
+ ConstraintViolationException.class,
+ UncategorizedSQLException.class,
+ SQLException.class,
+ BatchUpdateException.class,
+ DataIntegrityViolationException.class,
+ StaleStateException.class,
+ TooManyResultsException.class, // Expected one result but found multiple (bad key alert)
+ ObjectNotFoundException.class,
+ CacheException.class, // Usually a cache replication issue
+ SQLGrammarException.class // Actually specific to MS SQL Server 2005 - we check for this
+ };
+
+ List> retryExceptions = new ArrayList>();
+ // Add core classes to the list.
+ retryExceptions.addAll(Arrays.asList(coreClasses));
+ // Add enterprise-specific classes to the list
+ retryExceptions.addAll(enterpriseRetryExceptions());
+
+ RETRY_EXCEPTIONS = retryExceptions.toArray(new Class[] {});
+ }
+
+ /**
+ * Use reflection to load a list of enterprise-specific exception classes to add to the
+ * core list specified in this class.
+ *
+ * This is used to decouple this class from enterprise-specific libraries.
+ *
+ * @return List of enterprise exception classes or empty list if not available.
+ */
+ private static List> enterpriseRetryExceptions()
+ {
+ List> retryExceptions = null;
+ try
+ {
+ Class> c = Class.forName("org.alfresco.enterprise.repo.transaction.RetryExceptions");
+ retryExceptions = (List>) c.newInstance();
+ }
+ catch (ClassNotFoundException error)
+ {
+ // It's ok not to have the enterprise class available.
+ }
+ catch (InstantiationException error)
+ {
+ throw new AlfrescoRuntimeException("Unable to instantiate enterprise RetryExceptions.");
+ }
+ catch (IllegalAccessException error)
+ {
+ throw new AlfrescoRuntimeException("Unable to instantiate enterprise RetryExceptions.");
+ }
+
+ // If no enterprise class found then create an empty list.
+ if (retryExceptions == null)
+ {
+ retryExceptions = Collections.emptyList();
+ }
+ return retryExceptions;
}
/**
diff --git a/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java b/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java
deleted file mode 100644
index ea15b79aa1..0000000000
--- a/source/java/org/alfresco/repo/webdav/LockStoreFactoryImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2005-2012 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.repo.webdav;
-
-import java.util.concurrent.ConcurrentMap;
-
-import org.alfresco.repo.cluster.HazelcastInstanceFactory;
-import org.alfresco.service.cmr.repository.NodeRef;
-
-import com.hazelcast.core.HazelcastInstance;
-
-
-/**
- * Default implementation of the {@link LockStoreFactory} interface. Creates {@link LockStore}s
- * backed by a Hazelcast distributed Map if clustering is enabled,
- * otherwise it creates a non-clustered {@link SimpleLockStore}.
- *
- * @see LockStoreFactory
- * @see LockStoreImpl
- * @author Matt Ward
- */
-public class LockStoreFactoryImpl implements LockStoreFactory
-{
- private static final String HAZELCAST_MAP_NAME = "webdav-locks";
- private HazelcastInstanceFactory hazelcastInstanceFactory;
-
- /**
- * This method should be used sparingly and the created {@link LockStore}s should be
- * retained (this factory does not cache instances of them).
- */
- @Override
- public synchronized LockStore createLockStore()
- {
- if (!hazelcastInstanceFactory.isClusteringEnabled())
- {
- return new SimpleLockStore();
- }
- else
- {
- HazelcastInstance instance = hazelcastInstanceFactory.getInstance();
- ConcurrentMap map = instance.getMap(HAZELCAST_MAP_NAME);
- return new LockStoreImpl(map);
- }
- }
-
- /**
- * @param hazelcastInstanceFactory the factory that will create a HazelcastInstance if required.
- */
- public synchronized void setHazelcastInstanceFactory(HazelcastInstanceFactory hazelcastInstanceFactory)
- {
- this.hazelcastInstanceFactory = hazelcastInstanceFactory;
- }
-}
diff --git a/source/java/org/alfresco/repo/cluster/ClusterMembershipListener.java b/source/java/org/alfresco/repo/webdav/SimpleLockStoreFactory.java
similarity index 71%
rename from source/java/org/alfresco/repo/cluster/ClusterMembershipListener.java
rename to source/java/org/alfresco/repo/webdav/SimpleLockStoreFactory.java
index 2341986774..c38c42337e 100644
--- a/source/java/org/alfresco/repo/cluster/ClusterMembershipListener.java
+++ b/source/java/org/alfresco/repo/webdav/SimpleLockStoreFactory.java
@@ -16,15 +16,18 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see .
*/
-package org.alfresco.repo.cluster;
+package org.alfresco.repo.webdav;
/**
- * Implementing classes can react to members joining or leaving the cluster.
+ * LockStoreFactory that always returns a new {@link SimpleLockStore} instance.
*
* @author Matt Ward
*/
-public interface ClusterMembershipListener
+public class SimpleLockStoreFactory implements LockStoreFactory
{
- void memberJoined(String member, String[] cluster);
- void memberLeft(String member, String[] cluster);
+ @Override
+ public LockStore createLockStore()
+ {
+ return new SimpleLockStore();
+ }
}
diff --git a/source/test-resources/cache-test/cache-test-config.xml b/source/test-resources/cache-test/cache-test-config.xml
deleted file mode 100644
index a8a1a4192b..0000000000
--- a/source/test-resources/cache-test/cache-test-config.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/test-resources/cache-test/cache-test-context.xml b/source/test-resources/cache-test/cache-test-context.xml
deleted file mode 100644
index 6744de122c..0000000000
--- a/source/test-resources/cache-test/cache-test-context.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
- classpath:cache-test/cache-test-config.xml
-
-
-
-
-
-
-
-
-
-
- cache1
-
-
-
-
-
-
-
-
-
-
-
-
- backingCache
-
-
-
-
-
-
-
- transactionalCache
- 200000
-
-
-
-
-
-
-
-
-
- objectCache
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/test-resources/cachingstore/test-context.xml b/source/test-resources/cachingstore/test-context.xml
index 6e06be347f..017f14f380 100644
--- a/source/test-resources/cachingstore/test-context.xml
+++ b/source/test-resources/cachingstore/test-context.xml
@@ -5,19 +5,7 @@
-
-
-
-
-
-
-
- org.alfresco.cache.cachingContentStoreCache
-
-
-
-
-
+
diff --git a/source/test-resources/cachingstore/test-std-quota-context.xml b/source/test-resources/cachingstore/test-std-quota-context.xml
index 07580f16fd..9111463219 100644
--- a/source/test-resources/cachingstore/test-std-quota-context.xml
+++ b/source/test-resources/cachingstore/test-std-quota-context.xml
@@ -35,24 +35,8 @@
-
-
-
-
-
-
-
- org.alfresco.cache.cachingContentStoreCache
-
-
-
-
-
-
-
-
-
-
+
+
diff --git a/source/test-resources/cluster-test/hazelcast-messenger-test.xml b/source/test-resources/cluster-test/hazelcast-messenger-test.xml
deleted file mode 100644
index b7c391e185..0000000000
--- a/source/test-resources/cluster-test/hazelcast-messenger-test.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- test_hazelcast_cluster
- test_hazelcast_cluster_password
-
-
-
-
-
-
-
-
diff --git a/source/test-resources/cluster-test/placeholder-test.xml b/source/test-resources/cluster-test/placeholder-test.xml
deleted file mode 100644
index 9bbcaab1a7..0000000000
--- a/source/test-resources/cluster-test/placeholder-test.xml
+++ /dev/null
@@ -1,166 +0,0 @@
-
-
-
-
- ${alfresco.cluster.name}
- ${alfresco.hazelcast.password}
-
-
- 5701
-
-
- 224.2.2.3
- 54327
-
-
- 127.0.0.1
-
-
- my-access-key
- my-secret-key
-
- us-west-1
-
- hazelcast-sg
- type
- hz-nodes
-
-
-
- 10.10.1.*
-
-
-
- PBEWithMD5AndDES
-
- thesalt
-
- thepass
-
- 19
-
-
-
- RSA/NONE/PKCS1PADDING
-
- thekeypass
-
- local
-
- JKS
-
- thestorepass
-
- keystore
-
-
-
- 16
- 64
- 60
-
-
-
- 0
-
- default
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/test-resources/jbpm-test/test-hibernate-cfg.properties b/source/test-resources/jbpm-test/test-hibernate-cfg.properties
index 5a45d7dc0d..795d8d0dad 100644
--- a/source/test-resources/jbpm-test/test-hibernate-cfg.properties
+++ b/source/test-resources/jbpm-test/test-hibernate-cfg.properties
@@ -11,7 +11,7 @@ hibernate.jdbc.use_streams_for_binary=true
hibernate.show_sql=false
hibernate.cache.use_query_cache=false
hibernate.max_fetch_depth=10
-hibernate.cache.provider_class=org.alfresco.repo.cache.InternalEhCacheManagerFactoryBean
+hibernate.cache.provider_class=org.alfresco.repo.cache.DefaultCacheProvider
hibernate.cache.use_second_level_cache=true
hibernate.default_batch_fetch_size=1
hibernate.jdbc.batch_size=32
diff --git a/source/test-resources/jbpmresources/ehcache.xml b/source/test-resources/jbpmresources/ehcache.xml
deleted file mode 100644
index 663cdef302..0000000000
--- a/source/test-resources/jbpmresources/ehcache.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file