Moti Asayag has uploaded a new change for review. Change subject: engine: Replace CacheWrapper with plan Map ......................................................................
engine: Replace CacheWrapper with plan Map The CacheWrapper provides only a sub-set of the Map interface. Change-Id: I5fc00faa1e71a43b544cadd8f825c06799ec1154 Signed-off-by: Moti Asayag <masa...@redhat.com> --- D backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheProviderFactory.java D backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheWrapper.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandContextsCacheImpl.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java D backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/MapWrapperImpl.java 5 files changed, 9 insertions(+), 70 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/98/38698/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheProviderFactory.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheProviderFactory.java deleted file mode 100644 index d8898f3..0000000 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheProviderFactory.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.ovirt.engine.core.bll.tasks; - -public class CacheProviderFactory { - public static <K, V> CacheWrapper<K, V> getCacheWrapper() { - return new MapWrapperImpl<K, V>(); - } -} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheWrapper.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheWrapper.java deleted file mode 100644 index 180ea63..0000000 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CacheWrapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.ovirt.engine.core.bll.tasks; - -import java.util.Set; - -public interface CacheWrapper<K, V> { - - Set<K> keySet(); - - void put(K key, V value); - - V get(K key); - - void remove(final K key); - - boolean containsKey(K key); - -} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandContextsCacheImpl.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandContextsCacheImpl.java index b09cbb3..53e5935 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandContextsCacheImpl.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandContextsCacheImpl.java @@ -1,5 +1,8 @@ package org.ovirt.engine.core.bll.tasks; +import java.util.HashMap; +import java.util.Map; + import org.ovirt.engine.core.bll.context.CommandContext; import org.ovirt.engine.core.bll.context.EngineContext; import org.ovirt.engine.core.bll.job.ExecutionContext; @@ -11,13 +14,13 @@ public class CommandContextsCacheImpl implements CommandContextsCache { private final CommandsCache commandsCache; - private CacheWrapper<Guid, CommandContext> contextsMap; + private Map<Guid, CommandContext> contextsMap; private volatile boolean cacheInitialized; private Object LOCK = new Object(); public CommandContextsCacheImpl(final CommandsCache commandsCache) { this.commandsCache = commandsCache; - contextsMap = CacheProviderFactory.<Guid, CommandContext> getCacheWrapper(); + contextsMap = new HashMap<>(); } private void initializeCache() { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java index 409f20f..4b11bba 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/CommandsCacheImpl.java @@ -1,6 +1,8 @@ package org.ovirt.engine.core.bll.tasks; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Set; import javax.transaction.Transaction; @@ -14,12 +16,12 @@ public class CommandsCacheImpl implements CommandsCache { - private CacheWrapper<Guid, CommandEntity> commandMap; + private Map<Guid, CommandEntity> commandMap; private volatile boolean cacheInitialized; private Object LOCK = new Object(); public CommandsCacheImpl() { - commandMap = CacheProviderFactory.<Guid, CommandEntity> getCacheWrapper(); + commandMap = new HashMap<>(); } private void initializeCache() { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/MapWrapperImpl.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/MapWrapperImpl.java deleted file mode 100644 index 2b672a7..0000000 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/MapWrapperImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.ovirt.engine.core.bll.tasks; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -public class MapWrapperImpl<K, V> implements CacheWrapper<K, V> { - - private final Map<K, V> cache = new HashMap<>(); - - public MapWrapperImpl() { - } - - @Override - public Set<K> keySet() { - return getCache().keySet(); - } - - @Override - public void put(final K key, final V value) { - getCache().put(key, value); - } - - @Override - public V get(final K key) { - return getCache().get(key); - } - - @Override - public void remove(final K key) { - getCache().remove(key); - } - - public Map<K, V> getCache() { - return cache; - } - - @Override - public boolean containsKey(final K key) { - return getCache().containsKey(key); - } -} -- To view, visit https://gerrit.ovirt.org/38698 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5fc00faa1e71a43b544cadd8f825c06799ec1154 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Moti Asayag <masa...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches