From 288f3c6045d8f6b1e4d9b0b02a99d76f3d3683e1 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 28 Feb 2013 16:06:40 +0100 Subject: RemoveNonStrongRefCache, as it didn't add anything to Map. --- .../persistency/ClusterStorageManager.java | 18 +++++----- .../java/com/c2kernel/utils/NonStrongRefCache.java | 42 ---------------------- src/main/java/com/c2kernel/utils/SoftCache.java | 2 +- src/main/java/com/c2kernel/utils/WeakCache.java | 2 +- 4 files changed, 11 insertions(+), 53 deletions(-) delete mode 100644 src/main/java/com/c2kernel/utils/NonStrongRefCache.java (limited to 'src/main/java/com/c2kernel') diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java index bb5f90f..6c247b2 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.ConcurrentModificationException; import java.util.HashMap; import java.util.Iterator; +import java.util.Map; import java.util.StringTokenizer; import com.c2kernel.common.ObjectNotFoundException; @@ -16,7 +17,6 @@ import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; -import com.c2kernel.utils.NonStrongRefCache; import com.c2kernel.utils.SoftCache; import com.c2kernel.utils.WeakCache; @@ -33,7 +33,7 @@ public class ClusterStorageManager { HashMap> clusterWriters = new HashMap>(); HashMap> clusterReaders = new HashMap>(); // we don't need a soft cache for the top level cache - the proxies and entities clear that when reaped - HashMap> memoryCache = new HashMap>(); + HashMap> memoryCache = new HashMap>(); /** * Initialises all ClusterStorage handlers listed by class name in the property "ClusterStorages" @@ -130,7 +130,7 @@ public class ClusterStorageManager { * Does not look in any currently open transactions. */ public String[] getClusterContents(Integer sysKey, String path) throws ClusterStorageException { - //String[] retArr = new String[0]; + ArrayList contents = new ArrayList(); // get all readers Logger.msg(8, "ClusterStorageManager.getClusterContents() - Finding contents of "+path); @@ -161,7 +161,7 @@ public class ClusterStorageManager { public C2KLocalObject get(Integer sysKeyIntObj, String path) throws ClusterStorageException, ObjectNotFoundException { C2KLocalObject result = null; // check cache first - NonStrongRefCache sysKeyMemCache = null; + Map sysKeyMemCache = null; sysKeyMemCache = memoryCache.get(sysKeyIntObj); if (sysKeyMemCache != null) { synchronized(sysKeyMemCache) { @@ -246,7 +246,7 @@ public class ClusterStorageManager { } } // put in mem cache if that worked - NonStrongRefCache sysKeyMemCache; + Map sysKeyMemCache; if (memoryCache.containsKey(sysKeyIntObj)) sysKeyMemCache = memoryCache.get(sysKeyIntObj); else { @@ -283,7 +283,7 @@ public class ClusterStorageManager { } if (memoryCache.containsKey(sysKeyIntObj)) { - NonStrongRefCache sysKeyMemCache = memoryCache.get(sysKeyIntObj); + Map sysKeyMemCache = memoryCache.get(sysKeyIntObj); synchronized (sysKeyMemCache) { sysKeyMemCache.remove(path); } @@ -298,7 +298,7 @@ public class ClusterStorageManager { Logger.msg(7, "CSM.clearCache() - removing "+sysKeyIntObj+"/"+path); if (memoryCache.containsKey(sysKeyIntObj)) { - NonStrongRefCache sysKeyMemCache = memoryCache.get(sysKeyIntObj); + Map sysKeyMemCache = memoryCache.get(sysKeyIntObj); synchronized(sysKeyMemCache) { for (Iterator iter = sysKeyMemCache.keySet().iterator(); iter.hasNext();) { String thisPath = iter.next(); @@ -318,7 +318,7 @@ public class ClusterStorageManager { if (memoryCache.containsKey(sysKeyIntObj)) { synchronized (memoryCache) { if (Logger.doLog(6)) { - NonStrongRefCache sysKeyMemCache = memoryCache.get(sysKeyIntObj); + Map sysKeyMemCache = memoryCache.get(sysKeyIntObj); int size = sysKeyMemCache.size(); Logger.msg(6, "CSM.clearCache() - "+size+" objects to remove."); } @@ -341,7 +341,7 @@ public class ClusterStorageManager { synchronized(memoryCache) { for (Integer sysKey : memoryCache.keySet()) { Logger.msg(logLevel, "Cached Objects of Entity "+sysKey); - NonStrongRefCache sysKeyMemCache = memoryCache.get(sysKey); + Map sysKeyMemCache = memoryCache.get(sysKey); try { synchronized(sysKeyMemCache) { for (Object name : sysKeyMemCache.keySet()) { diff --git a/src/main/java/com/c2kernel/utils/NonStrongRefCache.java b/src/main/java/com/c2kernel/utils/NonStrongRefCache.java deleted file mode 100644 index bcd576e..0000000 --- a/src/main/java/com/c2kernel/utils/NonStrongRefCache.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * NonStrongRefCache.java - * - * Copyright (c) 2012, The CRISTAL Consortium. All rights reserved. - * - * CRISTAL kernel 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. - * - * This library 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 this library. If not, see: - * http://www.gnu.org/licenses/ - */ - -package com.c2kernel.utils; - -import java.util.Map; -import java.util.Set; - -public interface NonStrongRefCache { - - public abstract V get(Object key); - - public abstract V put(K key, V value); - - public abstract V remove(Object key); - - public abstract void clear(); - - public abstract int size(); - - public abstract Set keySet(); - - public abstract Set> entrySet(); - -} \ No newline at end of file diff --git a/src/main/java/com/c2kernel/utils/SoftCache.java b/src/main/java/com/c2kernel/utils/SoftCache.java index da58c87..2fd79f1 100644 --- a/src/main/java/com/c2kernel/utils/SoftCache.java +++ b/src/main/java/com/c2kernel/utils/SoftCache.java @@ -14,7 +14,7 @@ import java.util.Set; * * $Revision: 1.5 $ $Date: 2004/10/29 13:29:09 $ ******************************************************************************/ -public class SoftCache extends AbstractMap implements NonStrongRefCache { +public class SoftCache extends AbstractMap { private final Map> hash = new HashMap>(); private final int minSize; diff --git a/src/main/java/com/c2kernel/utils/WeakCache.java b/src/main/java/com/c2kernel/utils/WeakCache.java index e7ec105..899852e 100644 --- a/src/main/java/com/c2kernel/utils/WeakCache.java +++ b/src/main/java/com/c2kernel/utils/WeakCache.java @@ -14,7 +14,7 @@ import java.util.Set; * * $Revision: 1.5 $ $Date: 2004/10/29 13:29:09 $ ******************************************************************************/ -public class WeakCache extends AbstractMap implements NonStrongRefCache { +public class WeakCache extends AbstractMap { private final Map> hash = new HashMap>(); private final int minSize; -- cgit v1.2.3