summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2013-02-28 16:06:40 +0100
committerAndrew Branson <andrew.branson@cern.ch>2013-02-28 16:06:40 +0100
commit288f3c6045d8f6b1e4d9b0b02a99d76f3d3683e1 (patch)
treeea29d4eb429eeca7611c1dd0e30e4ab9649bd81e
parentba1d538b588dc57066213a94803584ea9016e1e7 (diff)
RemoveNonStrongRefCache, as it didn't add anything to Map.
-rw-r--r--src/main/java/com/c2kernel/persistency/ClusterStorageManager.java18
-rw-r--r--src/main/java/com/c2kernel/utils/NonStrongRefCache.java42
-rw-r--r--src/main/java/com/c2kernel/utils/SoftCache.java2
-rw-r--r--src/main/java/com/c2kernel/utils/WeakCache.java2
4 files changed, 11 insertions, 53 deletions
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<String, ArrayList<ClusterStorage>> clusterWriters = new HashMap<String, ArrayList<ClusterStorage>>();
HashMap<String, ArrayList<ClusterStorage>> clusterReaders = new HashMap<String, ArrayList<ClusterStorage>>();
// we don't need a soft cache for the top level cache - the proxies and entities clear that when reaped
- HashMap<Integer, NonStrongRefCache<String, C2KLocalObject>> memoryCache = new HashMap<Integer, NonStrongRefCache<String, C2KLocalObject>>();
+ HashMap<Integer, Map<String, C2KLocalObject>> memoryCache = new HashMap<Integer, Map<String, C2KLocalObject>>();
/**
* 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<String> contents = new ArrayList<String>();
// 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<String, C2KLocalObject> sysKeyMemCache = null;
+ Map<String, C2KLocalObject> 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<String, C2KLocalObject> sysKeyMemCache;
+ Map<String, C2KLocalObject> 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<String, C2KLocalObject> 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<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKeyIntObj);
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKeyIntObj);
synchronized(sysKeyMemCache) {
for (Iterator<String> 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<String, C2KLocalObject> 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<String, C2KLocalObject> 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<K, V> {
-
- 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<K> keySet();
-
- public abstract Set<Map.Entry<K, V>> 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<K, V> extends AbstractMap<K, V> implements NonStrongRefCache<K, V> {
+public class SoftCache<K, V> extends AbstractMap<K, V> {
private final Map<K, SoftValue<V>> hash = new HashMap<K, SoftValue<V>>();
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<K, V> extends AbstractMap<K, V> implements NonStrongRefCache<K, V> {
+public class WeakCache<K, V> extends AbstractMap<K, V> {
private final Map<K, WeakValue<V>> hash = new HashMap<K, WeakValue<V>>();
private final int minSize;