JBoss Cache SVN: r6852 - in core/branches/flat/src/main/java/org/jboss: starobrno and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-07 11:11:47 -0400 (Tue, 07 Oct 2008)
New Revision: 6852
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/
core/branches/flat/src/main/java/org/jboss/starobrno/AtomicGroup.java
core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/
core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
core/branches/flat/src/main/java/org/jboss/starobrno/test/
core/branches/flat/src/main/java/org/jboss/starobrno/test/SimpleTest.java
Log:
_____ ____ ____
\/__/\ \ \ \L\ \\ \ \/\_\
_\ \ \ \ _ <'\ \ \/_/_
/\ \_\ \ \ \L\ \\ \ \L\ \
\ \____/\ \____/ \ \____/
\/___/ \/___/ \/___/
Added: core/branches/flat/src/main/java/org/jboss/starobrno/AtomicGroup.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/AtomicGroup.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/AtomicGroup.java 2008-10-07 15:11:47 UTC (rev 6852)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import java.util.concurrent.ConcurrentMap;
+import java.util.HashMap;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class AtomicGroup extends HashMap
+{
+
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-10-07 15:11:47 UTC (rev 6852)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import org.jboss.util.NotImplementedException;
+import org.jboss.starobrno.config.CacheConfig;
+
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class Cache implements ConcurrentMap
+{
+ private ConcurrentHashMap data = new ConcurrentHashMap();
+ private Map<String, AtomicGroup> atomicGroups = new ConcurrentHashMap<String, AtomicGroup>();
+ private CacheConfig cacheConfig;
+
+
+ public Cache(CacheConfig cacheConfig)
+ {
+ this.cacheConfig = cacheConfig;
+ }
+
+ public Object putIfAbsent(Object key, Object value)
+ {
+ return data.putIfAbsent(key, value);
+ }
+
+ public boolean remove(Object key, Object value)
+ {
+ return data.remove(key, value);
+ }
+
+ public boolean replace(Object key, Object oldValue, Object newValue)
+ {
+ return data.replace(key, oldValue, newValue);
+ }
+
+ public Object replace(Object key, Object value)
+ {
+ return data.replace(key, value);
+ }
+
+ public int size()
+ {
+ throw new NotImplementedException("not impl!");
+ }
+
+ public boolean isEmpty()
+ {
+ throw new NotImplementedException("not impl!");
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return false;
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return data.contains(value);
+ }
+
+ public Object get(Object key)
+ {
+ return data.get(key);
+ }
+
+ public Object put(Object key, Object value)
+ {
+ return data.put(key, value);
+ }
+
+ public Object remove(Object key)
+ {
+ return data.remove(key);
+ }
+
+ public void putAll(Map t)
+ {
+ data.putAll(t);
+ }
+
+ public void clear()
+ {
+ data.clear();
+ }
+
+ public Set keySet()
+ {
+ throw new NotImplementedException("not impl!");
+ }
+
+ public Collection values()
+ {
+ throw new NotImplementedException("not impl!");
+ }
+
+ public Set entrySet()
+ {
+ throw new NotImplementedException("not impl!");
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Cache cache = (Cache) o;
+
+ if (data != null ? !data.equals(cache.data) : cache.data != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (data != null ? data.hashCode() : 0);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java 2008-10-07 15:11:47 UTC (rev 6852)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno;
+
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.CacheConfig;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class CacheManager
+{
+ private Configuration config;
+ private Map<String, Cache> caches = new HashMap<String, Cache>();
+
+ public CacheManager(Configuration config)
+ {
+ this.config = config;
+ }
+
+ public Cache getCache(String confName)
+ {
+ if (caches.containsKey(confName)) return caches.get(confName);
+ CacheConfig config = this.config.getCacheConfig(confName);
+ if (config == null) throw new IllegalArgumentException("No such cache config: " + confName);
+ Cache result = new Cache(config);
+ caches.put(confName, result);
+ return result;
+ }
+}
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java (from rev 6850, core/branches/flat/src/main/java/org/jboss/cache/config/Configuration.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java 2008-10-07 15:11:47 UTC (rev 6852)
@@ -0,0 +1,1074 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.config;
+
+import org.jboss.cache.Version;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.config.parsing.JGroupsStackParser;
+import org.jboss.cache.config.*;
+import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.marshall.Marshaller;
+import org.w3c.dom.Element;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Encapsulates the configuration of a Cache.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@NonVolatile
+public class CacheConfig extends ConfigurationComponent
+{
+ private static final long serialVersionUID = 5553791890144997466L;
+
+ private Marshaller marshaller;
+
+ private transient JGroupsStackParser jGroupsStackParser = new JGroupsStackParser();
+ private boolean invocationBatchingEnabled;
+
+ /**
+ * Behavior of the JVM shutdown hook registered by the cache
+ */
+ public static enum ShutdownHookBehavior
+ {
+ /**
+ * By default a shutdown hook is registered if no MBean server (apart from the JDK default) is detected.
+ */
+ DEFAULT,
+ /**
+ * Forces the cache to register a shutdown hook even if an MBean server is detected.
+ */
+ REGISTER,
+ /**
+ * Forces the cache NOT to register a shutdown hook, even if no MBean server is detected.
+ */
+ DONT_REGISTER
+ }
+
+ /**
+ * Cache replication mode.
+ */
+ public static enum CacheMode
+ {
+ /**
+ * Data is not replicated.
+ */
+ LOCAL,
+
+ /**
+ * Data replicated synchronously.
+ */
+ REPL_SYNC,
+
+ /**
+ * Data replicated asynchronously.
+ */
+ REPL_ASYNC,
+
+ /**
+ * Data invalidated synchronously.
+ */
+ INVALIDATION_SYNC,
+
+ /**
+ * Data invalidated asynchronously.
+ */
+ INVALIDATION_ASYNC;
+
+ /**
+ * Returns true if the mode is invalidation, either sync or async.
+ */
+ public boolean isInvalidation()
+ {
+ return this == INVALIDATION_SYNC || this == INVALIDATION_ASYNC;
+ }
+
+ public boolean isSynchronous()
+ {
+ return this == REPL_SYNC || this == INVALIDATION_SYNC || this == LOCAL;
+ }
+
+ }
+
+ public static CacheMode legacyModeToCacheMode(int legacyMode)
+ {
+ switch (legacyMode)
+ {
+ case 1:
+ return CacheMode.LOCAL;
+ case 2:
+ return CacheMode.REPL_ASYNC;
+ case 3:
+ return CacheMode.REPL_SYNC;
+ case 4:
+ return CacheMode.INVALIDATION_ASYNC;
+ case 5:
+ return CacheMode.INVALIDATION_SYNC;
+ default:
+ throw new IllegalArgumentException("Unknown legacy cache mode " +
+ legacyMode);
+ }
+ }
+
+ /**
+ * Cache node locking scheme.
+ */
+ public static enum NodeLockingScheme
+ {
+ /**
+ * Data is locked using the MVCC locking scheme. This is the default locking scheme in JBoss Cache 3.0.0.
+ *
+ * @see <a href="http://wiki.jboss.org/wiki/JBossCacheMVCC">http://wiki.jboss.org/wiki/JBossCacheMVCC</a>
+ */
+ MVCC,
+ /**
+ * Data is exclusively locked during modification.
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/Concurrency_control">http://en.wikipedia.org/wiki/Concurrency_control (pessimistic)</a>
+ */
+ PESSIMISTIC,
+ /**
+ * Data is unlocked during modification, modifications merged at commit.
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/Optimistic_concurrency_control">http://en.wikipedia.org/wiki/Optimistic_concurrency_control</a>
+ */
+ OPTIMISTIC;
+
+ /**
+ * @return true if the node locking scheme uses versioning.
+ */
+ public boolean isVersionedScheme()
+ {
+ return this == OPTIMISTIC;
+ }
+ }
+
+ /**
+ * Default replication version, from {@link org.jboss.cache.Version#getVersionShort}.
+ */
+ public static final short DEFAULT_REPLICATION_VERSION = Version.getVersionShort();
+
+ // ------------------------------------------------------------------------------------------------------------
+ // CONFIGURATION OPTIONS
+ // ------------------------------------------------------------------------------------------------------------
+
+ private String clusterName = "JBossCache-Cluster";
+ private String clusterConfig = null;
+ private boolean useReplQueue = false;
+ @Dynamic
+ private int replQueueMaxElements = 1000;
+ @Dynamic
+ private long replQueueInterval = 5000;
+ private boolean exposeManagementStatistics = true;
+ @Dynamic
+ private boolean fetchInMemoryState = true;
+ private short replicationVersion = DEFAULT_REPLICATION_VERSION;
+ @Dynamic
+ private long lockAcquisitionTimeout = 10000;
+ @Dynamic
+ private long syncReplTimeout = 15000;
+ private CacheMode cacheMode = CacheMode.LOCAL;
+ private boolean inactiveOnStartup = false;
+ @Dynamic
+ private long stateRetrievalTimeout = 10000;
+ private IsolationLevel isolationLevel = IsolationLevel.REPEATABLE_READ;
+ @Dynamic
+ private boolean lockParentForChildInsertRemove = false;
+ @Dynamic
+ private EvictionConfig evictionConfig = null;
+ private boolean useRegionBasedMarshalling = false;
+ private String transactionManagerLookupClass = null;
+ private CacheLoaderConfig cacheLoaderConfig = null;
+ @Dynamic
+ private boolean syncCommitPhase = false;
+ @Dynamic
+ private boolean syncRollbackPhase = false;
+ private BuddyReplicationConfig buddyReplicationConfig;
+
+ private NodeLockingScheme nodeLockingScheme = NodeLockingScheme.MVCC;
+ private String muxStackName = null;
+ private boolean usingMultiplexer = false;
+ private transient RuntimeConfig runtimeConfig;
+ private String marshallerClass;
+ private ShutdownHookBehavior shutdownHookBehavior = ShutdownHookBehavior.DEFAULT;
+ private boolean useLazyDeserialization = false;
+ private int objectInputStreamPoolSize = 50;
+ private int objectOutputStreamPoolSize = 50;
+ private List<CustomInterceptorConfig> customInterceptors = Collections.emptyList();
+ private boolean writeSkewCheck = false;
+ private int concurrencyLevel = 500;
+ private int listenerAsyncPoolSize = 1;
+ private int serializationExecutorPoolSize = 25;
+
+ @Start(priority = 1)
+ private void correctIsolationLevels()
+ {
+ // ensure the correct isolation level upgrades and/or downgrades are performed.
+ if (nodeLockingScheme == NodeLockingScheme.MVCC)
+ {
+ switch (isolationLevel)
+ {
+ case NONE:
+ case READ_UNCOMMITTED:
+ isolationLevel = IsolationLevel.READ_COMMITTED;
+ break;
+ case SERIALIZABLE:
+ isolationLevel = IsolationLevel.REPEATABLE_READ;
+ break;
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------------------------------------------
+ // SETTERS - MAKE SURE ALL SETTERS PERFORM testImmutability()!!!
+ // ------------------------------------------------------------------------------------------------------------
+
+ public void setCacheMarshaller(Marshaller instance)
+ {
+ marshaller = instance;
+ }
+
+ public Marshaller getMarshaller()
+ {
+ return marshaller;
+ }
+
+ public boolean isWriteSkewCheck()
+ {
+ return writeSkewCheck;
+ }
+
+ public void setWriteSkewCheck(boolean writeSkewCheck)
+ {
+ testImmutability("writeSkewCheck");
+ this.writeSkewCheck = writeSkewCheck;
+ }
+
+ public int getConcurrencyLevel()
+ {
+ return concurrencyLevel;
+ }
+
+ public void setConcurrencyLevel(int concurrencyLevel)
+ {
+ testImmutability("concurrencyLevel");
+ this.concurrencyLevel = concurrencyLevel;
+ }
+
+ /**
+ * Converts a list of elements to a Java Groups property string.
+ */
+ public void setClusterConfig(Element config)
+ {
+ setClusterConfig(jGroupsStackParser.parseClusterConfigXml(config));
+ }
+
+ public void setClusterName(String clusterName)
+ {
+ testImmutability("clusterName");
+ this.clusterName = clusterName;
+ }
+
+ public void setClusterConfig(String clusterConfig)
+ {
+ testImmutability("clusterConfig");
+ this.clusterConfig = clusterConfig;
+ }
+
+ public void setReplQueueMaxElements(int replQueueMaxElements)
+ {
+ testImmutability("replQueueMaxElements");
+ this.replQueueMaxElements = replQueueMaxElements;
+ }
+
+ public void setReplQueueInterval(long replQueueInterval)
+ {
+ testImmutability("replQueueInterval");
+ this.replQueueInterval = replQueueInterval;
+ }
+
+ public void setExposeManagementStatistics(boolean useMbean)
+ {
+ testImmutability("exposeManagementStatistics");
+ this.exposeManagementStatistics = useMbean;
+ }
+
+ /**
+ * Enables invocation batching if set to <tt>true</tt>. You still need to use {@link org.jboss.cache.Cache#startBatch()}
+ * and {@link org.jboss.cache.Cache#endBatch(boolean)} to demarcate the start and end of batches.
+ *
+ * @param enabled if true, batching is enabled.
+ * @since 3.0
+ */
+ public void setInvocationBatchingEnabled(boolean enabled)
+ {
+ testImmutability("invocationBatchingEnabled");
+ this.invocationBatchingEnabled = enabled;
+ }
+
+ public void setFetchInMemoryState(boolean fetchInMemoryState)
+ {
+ testImmutability("fetchInMemoryState");
+ this.fetchInMemoryState = fetchInMemoryState;
+ }
+
+ public void setReplicationVersion(short replicationVersion)
+ {
+ testImmutability("replicationVersion");
+ this.replicationVersion = replicationVersion;
+ }
+
+ public void setReplVersionString(String replVersionString)
+ {
+ setReplicationVersion(replVersionString == null ? 0 : Version.getVersionShort(replVersionString));
+ }
+
+ public void setLockAcquisitionTimeout(long lockAcquisitionTimeout)
+ {
+ testImmutability("lockAcquisitionTimeout");
+ this.lockAcquisitionTimeout = lockAcquisitionTimeout;
+ }
+
+ public void setSyncReplTimeout(long syncReplTimeout)
+ {
+ testImmutability("syncReplTimeout");
+ this.syncReplTimeout = syncReplTimeout;
+ }
+
+ public void setCacheMode(CacheMode cacheModeInt)
+ {
+ testImmutability("cacheMode");
+ this.cacheMode = cacheModeInt;
+ }
+
+ public void setCacheMode(String cacheMode)
+ {
+ testImmutability("cacheMode");
+ if (cacheMode == null) throw new ConfigurationException("Cache mode cannot be null", "CacheMode");
+ this.cacheMode = CacheMode.valueOf(uc(cacheMode));
+ if (this.cacheMode == null)
+ {
+ log.warn("Unknown cache mode '" + cacheMode + "', using defaults.");
+ this.cacheMode = CacheMode.LOCAL;
+ }
+ }
+
+ public String getCacheModeString()
+ {
+ return cacheMode == null ? null : cacheMode.toString();
+ }
+
+ public void setCacheModeString(String cacheMode)
+ {
+ setCacheMode(cacheMode);
+ }
+
+ public void setInactiveOnStartup(boolean inactiveOnStartup)
+ {
+ testImmutability("inactiveOnStartup");
+ this.inactiveOnStartup = inactiveOnStartup;
+ }
+
+ public EvictionConfig getEvictionConfig()
+ {
+ return evictionConfig;
+ }
+
+ public void setEvictionConfig(EvictionConfig config)
+ {
+ testImmutability("evictionConfig");
+ this.evictionConfig = config;
+ }
+
+ /**
+ * This is a deprecated configuration option. While it will be supported for the 2.x series for backward compatibility,
+ * expect to see it disappear in 3.x.
+ * <p/>
+ * With {@link #isUseLazyDeserialization()}, which is enabled by default, custom class loaders are handled implicitly.
+ * See the user guide for details on how this is handled.
+ * <p/>
+ */
+ public void setUseRegionBasedMarshalling(boolean useRegionBasedMarshalling)
+ {
+ testImmutability("useRegionBasedMarshalling");
+ this.useRegionBasedMarshalling = useRegionBasedMarshalling;
+ }
+
+ public void setTransactionManagerLookupClass(String transactionManagerLookupClass)
+ {
+ testImmutability("transactionManagerLookupClass");
+ this.transactionManagerLookupClass = transactionManagerLookupClass;
+ }
+
+ public void setCacheLoaderConfig(CacheLoaderConfig config)
+ {
+ testImmutability("cacheLoaderConfig");
+ replaceChildConfig(this.cacheLoaderConfig, config);
+ this.cacheLoaderConfig = config;
+ }
+
+ public void setSyncCommitPhase(boolean syncCommitPhase)
+ {
+ testImmutability("syncCommitPhase");
+ this.syncCommitPhase = syncCommitPhase;
+ }
+
+ public void setSyncRollbackPhase(boolean syncRollbackPhase)
+ {
+ testImmutability("syncRollbackPhase");
+ this.syncRollbackPhase = syncRollbackPhase;
+ }
+
+ /**
+ * Sets the size of the asynchronous listener notification thread pool size. Defaults to 1, and if set to below 1,
+ * all async listeners (specified with {@link org.jboss.cache.notifications.annotation.CacheListener#sync()} are notified
+ * synchronously.
+ *
+ * @param listenerAsyncPoolSize number of threads in pool
+ * @since 3.0
+ */
+ public void setListenerAsyncPoolSize(int listenerAsyncPoolSize)
+ {
+ testImmutability("asyncListenerPoolSize");
+ this.listenerAsyncPoolSize = listenerAsyncPoolSize;
+ }
+
+ public void setBuddyReplicationConfig(BuddyReplicationConfig config)
+ {
+ testImmutability("buddyReplicationConfig");
+ replaceChildConfig(this.buddyReplicationConfig, config);
+ this.buddyReplicationConfig = config;
+ }
+
+ public void setNodeLockingScheme(NodeLockingScheme nodeLockingScheme)
+ {
+ testImmutability("nodeLockingScheme");
+ testImmutability("nodeLockingOptimistic");
+ this.nodeLockingScheme = nodeLockingScheme;
+ }
+
+ public void setUseReplQueue(boolean useReplQueue)
+ {
+ testImmutability("useReplQueue");
+ this.useReplQueue = useReplQueue;
+ }
+
+ public void setIsolationLevel(IsolationLevel isolationLevel)
+ {
+ testImmutability("isolationLevel");
+ this.isolationLevel = isolationLevel;
+ }
+
+ /**
+ * Starting with 3.x there are 3 locking schemes, so if true is passed in then state is not defined.
+ * It is here for backward compatibility reasons only and should not be used by new code.
+ */
+ @Deprecated
+ public void setNodeLockingOptimistic(boolean nodeLockingOptimistic)
+ {
+ testImmutability("nodeLockingOptimistic");
+ if (nodeLockingOptimistic) setNodeLockingScheme(NodeLockingScheme.OPTIMISTIC);
+ else setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
+ }
+
+ public void setStateRetrievalTimeout(long stateRetrievalTimeout)
+ {
+ testImmutability("stateRetrievalTimeout");
+ this.stateRetrievalTimeout = stateRetrievalTimeout;
+ }
+
+ public void setNodeLockingScheme(String nodeLockingScheme)
+ {
+ testImmutability("nodeLockingScheme");
+ if (nodeLockingScheme == null)
+ {
+ throw new ConfigurationException("Node locking scheme cannot be null", "NodeLockingScheme");
+ }
+ this.nodeLockingScheme = NodeLockingScheme.valueOf(uc(nodeLockingScheme));
+ if (this.nodeLockingScheme == null)
+ {
+ log.warn("Unknown node locking scheme '" + nodeLockingScheme + "', using defaults.");
+ this.nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
+ }
+ }
+
+ public String getNodeLockingSchemeString()
+ {
+ return nodeLockingScheme == null ? null : nodeLockingScheme.toString();
+ }
+
+ public void setNodeLockingSchemeString(String nodeLockingScheme)
+ {
+ setNodeLockingScheme(nodeLockingScheme);
+ }
+
+ private static String uc(String s)
+ {
+ return s.toUpperCase(Locale.ENGLISH);
+ }
+
+ public void setIsolationLevel(String isolationLevel)
+ {
+ testImmutability("isolationLevel");
+ if (isolationLevel == null) throw new ConfigurationException("Isolation level cannot be null", "IsolationLevel");
+ this.isolationLevel = IsolationLevel.valueOf(uc(isolationLevel));
+ if (this.isolationLevel == null)
+ {
+ log.warn("Unknown isolation level '" + isolationLevel + "', using defaults.");
+ this.isolationLevel = IsolationLevel.REPEATABLE_READ;
+ }
+ }
+
+ public String getIsolationLevelString()
+ {
+ return isolationLevel == null ? null : isolationLevel.toString();
+ }
+
+ public void setIsolationLevelString(String isolationLevel)
+ {
+ setIsolationLevel(isolationLevel);
+ }
+
+ /**
+ * Sets whether inserting or removing a node requires a write lock
+ * on the node's parent (when pessimistic locking is used.)
+ * <p/>
+ * The default value is <code>false</code>
+ */
+ public void setLockParentForChildInsertRemove(boolean lockParentForChildInsertRemove)
+ {
+ testImmutability("lockParentForChildInsertRemove");
+ this.lockParentForChildInsertRemove = lockParentForChildInsertRemove;
+ }
+
+ public void setMultiplexerStack(String stackName)
+ {
+ testImmutability("muxStackName");
+ this.muxStackName = stackName;
+ }
+
+ public boolean isUsingMultiplexer()
+ {
+ return usingMultiplexer;
+ }
+
+ public void setUsingMultiplexer(boolean usingMultiplexer)
+ {
+ testImmutability("usingMultiplexer");
+ this.usingMultiplexer = usingMultiplexer;
+ }
+
+ public void setShutdownHookBehavior(ShutdownHookBehavior shutdownHookBehavior)
+ {
+ testImmutability("shutdownHookBehavior");
+ this.shutdownHookBehavior = shutdownHookBehavior;
+ }
+
+ public void setShutdownHookBehavior(String shutdownHookBehavior)
+ {
+ testImmutability("shutdownHookBehavior");
+ if (shutdownHookBehavior == null)
+ throw new ConfigurationException("Shutdown hook behavior cannot be null", "ShutdownHookBehavior");
+ this.shutdownHookBehavior = ShutdownHookBehavior.valueOf(uc(shutdownHookBehavior));
+ if (this.shutdownHookBehavior == null)
+ {
+ log.warn("Unknown shutdown hook behavior '" + shutdownHookBehavior + "', using defaults.");
+ this.shutdownHookBehavior = ShutdownHookBehavior.DEFAULT;
+ }
+ }
+
+ public void setUseLazyDeserialization(boolean useLazyDeserialization)
+ {
+ testImmutability("useLazyDeserialization");
+ this.useLazyDeserialization = useLazyDeserialization;
+ }
+
+ /**
+ * Initialises the size of the object input stream pool size, which defaults to 50.
+ *
+ * @param objectInputStreamPoolSize
+ * @since 2.1.0
+ */
+ public void setObjectInputStreamPoolSize(int objectInputStreamPoolSize)
+ {
+ testImmutability("objectInputStreamPoolSize");
+ this.objectInputStreamPoolSize = objectInputStreamPoolSize;
+ }
+
+ /**
+ * Initialises the size of the object output stream pool size, which defaults to 50.
+ *
+ * @param objectOutputStreamPoolSize
+ * @since 2.1.0
+ */
+ public void setObjectOutputStreamPoolSize(int objectOutputStreamPoolSize)
+ {
+ testImmutability("objectOutputStreamPoolSize");
+ this.objectOutputStreamPoolSize = objectOutputStreamPoolSize;
+ }
+
+ /**
+ * Sets the async replication serialization executor pool size for async replication. Has no effect if the
+ * replication queue is used.
+ *
+ * @param serializationExecutorPoolSize number of threads to use
+ */
+ public void setSerializationExecutorPoolSize(int serializationExecutorPoolSize)
+ {
+ testImmutability("serializationExecutorPoolSize");
+ this.serializationExecutorPoolSize = serializationExecutorPoolSize;
+ }
+
+ // ------------------------------------------------------------------------------------------------------------
+ // GETTERS
+ // ------------------------------------------------------------------------------------------------------------
+
+
+ public ShutdownHookBehavior getShutdownHookBehavior()
+ {
+ return this.shutdownHookBehavior;
+ }
+
+ /**
+ * This helper method is deprecated and will be removed when optimistic and pessimistic locking support is dropped.
+ *
+ * @return true if node locking scheme is optimistic.
+ * @deprecated use {@link #getNodeLockingScheme()} to determine node locking scheme used.
+ */
+ @Deprecated
+ public boolean isNodeLockingOptimistic()
+ {
+ return nodeLockingScheme == NodeLockingScheme.OPTIMISTIC;
+ }
+
+ public boolean isUseReplQueue()
+ {
+ return useReplQueue;
+ }
+
+ public String getClusterName()
+ {
+ return clusterName;
+ }
+
+ public String getClusterConfig()
+ {
+ return clusterConfig;
+ }
+
+ public int getReplQueueMaxElements()
+ {
+ return replQueueMaxElements;
+ }
+
+ public long getReplQueueInterval()
+ {
+ return replQueueInterval;
+ }
+
+ /**
+ * @deprecated use isExposeManagementStatistics()
+ */
+ @Deprecated
+ public boolean getExposeManagementStatistics()
+ {
+ return exposeManagementStatistics;
+ }
+
+ public boolean isExposeManagementStatistics()
+ {
+ return exposeManagementStatistics;
+ }
+
+ /**
+ * @return true if invocation batching is enabled.
+ * @since 3.0
+ */
+ public boolean isInvocationBatchingEnabled()
+ {
+ return invocationBatchingEnabled;
+ }
+
+ public boolean isFetchInMemoryState()
+ {
+ return fetchInMemoryState;
+ }
+
+ public short getReplicationVersion()
+ {
+ return replicationVersion;
+ }
+
+ public String getReplVersionString()
+ {
+ return Version.getVersionString(replicationVersion);
+ }
+
+ public long getLockAcquisitionTimeout()
+ {
+ return lockAcquisitionTimeout;
+ }
+
+ public long getSyncReplTimeout()
+ {
+ return syncReplTimeout;
+ }
+
+ public CacheMode getCacheMode()
+ {
+ return cacheMode;
+ }
+
+ public boolean isInactiveOnStartup()
+ {
+ return inactiveOnStartup;
+ }
+
+ public IsolationLevel getIsolationLevel()
+ {
+ return isolationLevel;
+ }
+
+ /**
+ * Gets whether inserting or removing a node requires a write lock
+ * on the node's parent (when pessimistic locking is used.)
+ * <p/>
+ * The default value is <code>false</code>
+ */
+ public boolean isLockParentForChildInsertRemove()
+ {
+ return lockParentForChildInsertRemove;
+ }
+
+ public boolean isUseRegionBasedMarshalling()
+ {
+ return useRegionBasedMarshalling;
+ }
+
+ public String getTransactionManagerLookupClass()
+ {
+ return transactionManagerLookupClass;
+ }
+
+ public CacheLoaderConfig getCacheLoaderConfig()
+ {
+ return cacheLoaderConfig;
+ }
+
+ public boolean isSyncCommitPhase()
+ {
+ return syncCommitPhase;
+ }
+
+ public boolean isSyncRollbackPhase()
+ {
+ return syncRollbackPhase;
+ }
+
+ /**
+ * Gets the size of the asynchronous listener notification thread pool size. Defaults to 1, and if set to below 1,
+ * all async listeners (specified with {@link org.jboss.cache.notifications.annotation.CacheListener#sync()} are notified
+ * synchronously.
+ *
+ * @return thread pool size
+ * @since 3.0
+ */
+ public int getListenerAsyncPoolSize()
+ {
+ return listenerAsyncPoolSize;
+ }
+
+ public BuddyReplicationConfig getBuddyReplicationConfig()
+ {
+ return buddyReplicationConfig;
+ }
+
+ public NodeLockingScheme getNodeLockingScheme()
+ {
+ return nodeLockingScheme;
+ }
+
+ public long getStateRetrievalTimeout()
+ {
+ return stateRetrievalTimeout;
+ }
+
+ public String getMultiplexerStack()
+ {
+ return muxStackName;
+ }
+
+ public boolean isUseLazyDeserialization()
+ {
+ return useLazyDeserialization;
+ }
+
+ public synchronized RuntimeConfig getRuntimeConfig()
+ {
+ if (runtimeConfig == null)
+ {
+ setRuntimeConfig(new RuntimeConfig(), false);
+ }
+ return runtimeConfig;
+ }
+
+ public void setRuntimeConfig(RuntimeConfig runtimeConfig)
+ {
+ setRuntimeConfig(runtimeConfig, true);
+ }
+
+ private void setRuntimeConfig(RuntimeConfig runtimeConfig, boolean testImmutability)
+ {
+ if (testImmutability)
+ {
+ testImmutability("runtimeConfig");
+ }
+ this.runtimeConfig = runtimeConfig;
+ }
+
+ public String getMarshallerClass()
+ {
+ return marshallerClass;
+ }
+
+ public void setMarshallerClass(String marshallerClass)
+ {
+ this.marshallerClass = marshallerClass;
+ }
+
+ /**
+ * @return the size of he object input stream pool
+ * @since 2.1.0
+ */
+ public int getObjectInputStreamPoolSize()
+ {
+ return objectInputStreamPoolSize;
+ }
+
+ /**
+ * @return the size of he object output stream pool
+ * @since 2.1.0
+ */
+ public int getObjectOutputStreamPoolSize()
+ {
+ return objectOutputStreamPoolSize;
+ }
+
+
+ /**
+ * Returns a {@link java.net.URL} to a default JGroups configuration file.
+ *
+ * @return a default JGroups config file
+ */
+ public URL getDefaultClusterConfig()
+ {
+ URL url = getClass().getClassLoader().getResource("flush-udp.xml");
+ if (log.isTraceEnabled()) log.trace("Using default JGroups configuration file " + url);
+ return url;
+ }
+
+ /**
+ * @return the serialization executor pool size.
+ */
+ public int getSerializationExecutorPoolSize()
+ {
+ return serializationExecutorPoolSize;
+ }
+
+ // ------------------------------------------------------------------------------------------------------------
+ // HELPERS
+ // ------------------------------------------------------------------------------------------------------------
+
+ // ------------------------------------------------------------------------------------------------------------
+ // OVERRIDDEN METHODS
+ // ------------------------------------------------------------------------------------------------------------
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ CacheConfig that = (CacheConfig) o;
+
+ if (exposeManagementStatistics != that.exposeManagementStatistics) return false;
+ if (fetchInMemoryState != that.fetchInMemoryState) return false;
+ if (inactiveOnStartup != that.inactiveOnStartup) return false;
+ if (lockAcquisitionTimeout != that.lockAcquisitionTimeout) return false;
+ if (lockParentForChildInsertRemove != that.lockParentForChildInsertRemove) return false;
+ if (objectInputStreamPoolSize != that.objectInputStreamPoolSize) return false;
+ if (objectOutputStreamPoolSize != that.objectOutputStreamPoolSize) return false;
+ if (replQueueInterval != that.replQueueInterval) return false;
+ if (replQueueMaxElements != that.replQueueMaxElements) return false;
+ if (replicationVersion != that.replicationVersion) return false;
+ if (stateRetrievalTimeout != that.stateRetrievalTimeout) return false;
+ if (syncCommitPhase != that.syncCommitPhase) return false;
+ if (syncReplTimeout != that.syncReplTimeout) return false;
+ if (syncRollbackPhase != that.syncRollbackPhase) return false;
+ if (useLazyDeserialization != that.useLazyDeserialization) return false;
+ if (useRegionBasedMarshalling != that.useRegionBasedMarshalling) return false;
+ if (useReplQueue != that.useReplQueue) return false;
+ if (usingMultiplexer != that.usingMultiplexer) return false;
+ if (buddyReplicationConfig != null ? !buddyReplicationConfig.equals(that.buddyReplicationConfig) : that.buddyReplicationConfig != null)
+ return false;
+ if (cacheLoaderConfig != null ? !cacheLoaderConfig.equals(that.cacheLoaderConfig) : that.cacheLoaderConfig != null)
+ return false;
+ if (cacheMode != that.cacheMode) return false;
+ if (clusterConfig != null ? !clusterConfig.equals(that.clusterConfig) : that.clusterConfig != null) return false;
+ if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false;
+ if (evictionConfig != null ? !evictionConfig.equals(that.evictionConfig) : that.evictionConfig != null)
+ return false;
+ if (isolationLevel != that.isolationLevel) return false;
+ if (marshaller != null ? !marshaller.equals(that.marshaller) : that.marshaller != null) return false;
+ if (marshallerClass != null ? !marshallerClass.equals(that.marshallerClass) : that.marshallerClass != null)
+ return false;
+ if (muxStackName != null ? !muxStackName.equals(that.muxStackName) : that.muxStackName != null) return false;
+ if (nodeLockingScheme != that.nodeLockingScheme) return false;
+ if (runtimeConfig != null ? !runtimeConfig.equals(that.runtimeConfig) : that.runtimeConfig != null) return false;
+ if (shutdownHookBehavior != that.shutdownHookBehavior) return false;
+ if (transactionManagerLookupClass != null ? !transactionManagerLookupClass.equals(that.transactionManagerLookupClass) : that.transactionManagerLookupClass != null)
+ return false;
+ if (listenerAsyncPoolSize != that.listenerAsyncPoolSize) return false;
+ if (serializationExecutorPoolSize != that.serializationExecutorPoolSize) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (marshaller != null ? marshaller.hashCode() : 0);
+ result = 31 * result + (clusterName != null ? clusterName.hashCode() : 0);
+ result = 31 * result + (clusterConfig != null ? clusterConfig.hashCode() : 0);
+ result = 31 * result + (useReplQueue ? 1 : 0);
+ result = 31 * result + replQueueMaxElements;
+ result = 31 * result + (int) (replQueueInterval ^ (replQueueInterval >>> 32));
+ result = 31 * result + (exposeManagementStatistics ? 1 : 0);
+ result = 31 * result + (fetchInMemoryState ? 1 : 0);
+ result = 31 * result + (int) replicationVersion;
+ result = 31 * result + (int) (lockAcquisitionTimeout ^ (lockAcquisitionTimeout >>> 32));
+ result = 31 * result + (int) (syncReplTimeout ^ (syncReplTimeout >>> 32));
+ result = 31 * result + (cacheMode != null ? cacheMode.hashCode() : 0);
+ result = 31 * result + (inactiveOnStartup ? 1 : 0);
+ result = 31 * result + (int) (stateRetrievalTimeout ^ (stateRetrievalTimeout >>> 32));
+ result = 31 * result + (isolationLevel != null ? isolationLevel.hashCode() : 0);
+ result = 31 * result + (lockParentForChildInsertRemove ? 1 : 0);
+ result = 31 * result + (evictionConfig != null ? evictionConfig.hashCode() : 0);
+ result = 31 * result + (useRegionBasedMarshalling ? 1 : 0);
+ result = 31 * result + (transactionManagerLookupClass != null ? transactionManagerLookupClass.hashCode() : 0);
+ result = 31 * result + (cacheLoaderConfig != null ? cacheLoaderConfig.hashCode() : 0);
+ result = 31 * result + (syncCommitPhase ? 1 : 0);
+ result = 31 * result + (syncRollbackPhase ? 1 : 0);
+ result = 31 * result + (buddyReplicationConfig != null ? buddyReplicationConfig.hashCode() : 0);
+ result = 31 * result + (nodeLockingScheme != null ? nodeLockingScheme.hashCode() : 0);
+ result = 31 * result + (muxStackName != null ? muxStackName.hashCode() : 0);
+ result = 31 * result + (usingMultiplexer ? 1 : 0);
+ result = 31 * result + (runtimeConfig != null ? runtimeConfig.hashCode() : 0);
+ result = 31 * result + (marshallerClass != null ? marshallerClass.hashCode() : 0);
+ result = 31 * result + (shutdownHookBehavior != null ? shutdownHookBehavior.hashCode() : 0);
+ result = 31 * result + (useLazyDeserialization ? 1 : 0);
+ result = 31 * result + objectInputStreamPoolSize;
+ result = 31 * result + objectOutputStreamPoolSize;
+ result = 31 * result + serializationExecutorPoolSize;
+ return result;
+ }
+
+ @Override
+ public org.jboss.cache.config.Configuration clone() throws CloneNotSupportedException
+ {
+ org.jboss.cache.config.Configuration c = (org.jboss.cache.config.Configuration) super.clone();
+ if (buddyReplicationConfig != null)
+ {
+ c.setBuddyReplicationConfig(buddyReplicationConfig.clone());
+ }
+ if (evictionConfig != null)
+ {
+ c.setEvictionConfig(evictionConfig.clone());
+ }
+ if (cacheLoaderConfig != null)
+ {
+ c.setCacheLoaderConfig(cacheLoaderConfig.clone());
+ }
+ if (runtimeConfig != null)
+ {
+ c.setRuntimeConfig(runtimeConfig.clone());
+ // always make sure we reset the runtime when cloning.
+ c.getRuntimeConfig().reset();
+ }
+ return c;
+ }
+
+ public boolean isUsingCacheLoaders()
+ {
+ return getCacheLoaderConfig() != null && !getCacheLoaderConfig().getIndividualCacheLoaderConfigs().isEmpty();
+ }
+
+ public boolean isUsingBuddyReplication()
+ {
+ return getBuddyReplicationConfig() != null && getBuddyReplicationConfig().isEnabled() &&
+ getCacheMode() != CacheConfig.CacheMode.LOCAL;
+ }
+
+ public String getMuxStackName()
+ {
+ return muxStackName;
+ }
+
+ public void setMuxStackName(String muxStackName)
+ {
+ this.muxStackName = muxStackName;
+ }
+
+ /**
+ * Returns the {@link org.jboss.cache.config.CustomInterceptorConfig}, if any, associated with this configuration
+ * object. The custom interceptors will be added to the cache at startup in the sequence defined by this list.
+ *
+ * @return List of cutom interceptors, never null
+ */
+ @SuppressWarnings("unchecked")
+ public List<CustomInterceptorConfig> getCustomInterceptors()
+ {
+ return customInterceptors == null ? Collections.EMPTY_LIST : customInterceptors;
+ }
+
+ /**
+ * @see #getCustomInterceptors()
+ */
+ public void setCustomInterceptors(List<CustomInterceptorConfig> customInterceptors)
+ {
+ testImmutability("customInterceptors");
+ this.customInterceptors = customInterceptors;
+ }
+
+ public BuddyManager getConsistentHashing()
+ {
+ return null;
+ }
+
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-07 15:11:47 UTC (rev 6852)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.config;
+
+import org.jboss.util.NotImplementedException;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class Configuration
+{
+ public Map<String, CacheConfig> cacheConfigs = new HashMap<String, CacheConfig>();
+
+ //todo - to be implemented, do the parsing here
+ public Configuration(String configFile)
+ {
+ throw new NotImplementedException("not impl!");
+ }
+
+ public Configuration()
+ {
+ }
+
+ public CacheConfig getCacheConfig(String name)
+ {
+ return cacheConfigs.get(name);
+ }
+
+ public void addCacheConfig(String name, CacheConfig config)
+ {
+ cacheConfigs.put(name, config);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/test/SimpleTest.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/test/SimpleTest.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/test/SimpleTest.java 2008-10-07 15:11:47 UTC (rev 6852)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.starobrno.test;
+
+import org.testng.annotations.Test;
+import org.jboss.starobrno.config.CacheConfig;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.CacheManager;
+import org.jboss.starobrno.Cache;
+
+/**
+ * @author Mircea.Markus(a)jboss.com
+ */
+@Test
+public class SimpleTest
+{
+
+ public void testLocalCache()
+ {
+ CacheConfig cc = new CacheConfig();
+ cc.setCacheMode(CacheConfig.CacheMode.LOCAL);
+ Configuration configuration = new Configuration();
+ configuration.addCacheConfig("local", cc);
+
+ CacheManager cm = new CacheManager(configuration);
+ Cache cache = cm.getCache("local");
+ cache.put("key","value");
+
+ assert cache.get("key").equals("value");
+ }
+}
16 years, 2 months
JBoss Cache SVN: r6851 - core/trunk/src/test/java/org/jboss/cache/optimistic.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-07 09:55:33 -0400 (Tue, 07 Oct 2008)
New Revision: 6851
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java
Log:
?
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java 2008-10-07 07:50:50 UTC (rev 6850)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncCacheTest.java 2008-10-07 13:55:33 UTC (rev 6851)
@@ -80,7 +80,7 @@
assertEquals(pojo, cache.get(Fqn.fromString("/one/two"), "key1"));
// allow changes to replicate since this is async
- TestingUtil.sleepThread((long) 1000);
+ TestingUtil.sleepThread((long) 5000);
assertEquals(0, cache2.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
@@ -122,7 +122,7 @@
assertEquals(pojo, cache.get(Fqn.fromString("/one/two"), "key1"));
// let the async calls complete
- TestingUtil.sleepThread((long) 1000);
+ TestingUtil.sleepThread((long) 5000);
assertEquals(0, cache2.getTransactionTable().getNumGlobalTransactions());
assertEquals(0, cache2.getTransactionTable().getNumLocalTransactions());
16 years, 2 months
JBoss Cache SVN: r6850 - benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-07 03:50:50 -0400 (Tue, 07 Oct 2008)
New Revision: 6850
Modified:
benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
Log:
Modified: benchmarks/benchmark-fwk/trunk/cache-products/jbosscache-3.0.0/lib/jbosscache-core.jar
===================================================================
(Binary files differ)
16 years, 2 months
JBoss Cache SVN: r6849 - core/trunk/src/main/resources/config-samples.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-06 16:15:31 -0400 (Mon, 06 Oct 2008)
New Revision: 6849
Modified:
core/trunk/src/main/resources/config-samples/invalidation-async.xml
core/trunk/src/main/resources/config-samples/total-replication.xml
Log:
Updated streaming state transfer cfgs
Modified: core/trunk/src/main/resources/config-samples/invalidation-async.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-10-06 20:09:23 UTC (rev 6848)
+++ core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-10-06 20:15:31 UTC (rev 6849)
@@ -36,7 +36,8 @@
oob_thread_pool.min_threads="8" oob_thread_pool.queue_enabled="false" oob_thread_pool.queue_max_size="10"
oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
thread_pool.keep_alive_time="10000" thread_pool.max_threads="15" thread_pool.min_threads="8"
- thread_pool.queue_enabled="true" thread_pool.queue_max_size="100000" thread_pool.rejection_policy="Discard"
+ thread_pool.queue_enabled="true" thread_pool.queue_max_size="100000"
+ thread_pool.rejection_policy="Discard"
tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
use_incoming_packet_handler="true"/>
<PING num_initial_members="3" timeout="2000"/>
@@ -52,7 +53,7 @@
view_bundling="true"/>
<FC max_credits="500000" min_threshold="0.2"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
Modified: core/trunk/src/main/resources/config-samples/total-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/total-replication.xml 2008-10-06 20:09:23 UTC (rev 6848)
+++ core/trunk/src/main/resources/config-samples/total-replication.xml 2008-10-06 20:15:31 UTC (rev 6849)
@@ -50,9 +50,9 @@
<pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
view_bundling="true"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
<pbcast.FLUSH timeout="0"/>
-
+
</jgroupsConfig>
</transport>
16 years, 2 months
JBoss Cache SVN: r6848 - core/trunk/src/main/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-06 16:09:23 -0400 (Mon, 06 Oct 2008)
New Revision: 6848
Modified:
core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java
Log:
Removed system out
Modified: core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java 2008-10-06 14:53:33 UTC (rev 6847)
+++ core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java 2008-10-06 20:09:23 UTC (rev 6848)
@@ -75,9 +75,6 @@
lockSegmentShift = 32 - tempLockSegShift;
lockSegmentMask = numLocks - 1;
- System.out.println("Lock Seg Shift = " + lockSegmentShift);
- System.out.println("Lock Seg Mask = " + lockSegmentMask);
-
sharedLocks = new ReentrantReadWriteLock[numLocks];
for (int i = 0; i < numLocks; i++) sharedLocks[i] = new ReentrantReadWriteLock();
16 years, 2 months
JBoss Cache SVN: r6847 - in core/trunk/src/main/java/org/jboss/cache: util/concurrent/locks and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-06 10:53:33 -0400 (Mon, 06 Oct 2008)
New Revision: 6847
Modified:
core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java
core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/LockContainer.java
Log:
Better hashcode
Modified: core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java 2008-10-06 14:28:08 UTC (rev 6846)
+++ core/trunk/src/main/java/org/jboss/cache/lock/StripedLock.java 2008-10-06 14:53:33 UTC (rev 6847)
@@ -75,6 +75,9 @@
lockSegmentShift = 32 - tempLockSegShift;
lockSegmentMask = numLocks - 1;
+ System.out.println("Lock Seg Shift = " + lockSegmentShift);
+ System.out.println("Lock Seg Mask = " + lockSegmentMask);
+
sharedLocks = new ReentrantReadWriteLock[numLocks];
for (int i = 0; i < numLocks; i++) sharedLocks[i] = new ReentrantReadWriteLock();
@@ -130,17 +133,22 @@
/**
* Returns a hash code for non-null Object x.
- * Uses the same hash code spreader as most other java.util hash tables, except that this uses the string representation
- * of the object passed in.
*
* @param x the object serving as a key
* @return the hash code
*/
final int hash(Object x)
{
+ // Spread bits to regularize both segment and index locations,
+ // using variant of single-word Wang/Jenkins hash.
int h = x.hashCode();
- h ^= (h >>> 20) ^ (h >>> 12);
- return h ^ (h >>> 7) ^ (h >>> 4);
+ h += (h << 15) ^ 0xffffcd7d;
+ h ^= (h >>> 10);
+ h += (h << 3);
+ h ^= (h >>> 6);
+ h += (h << 2) + (h << 14);
+ h = h ^ (h >>> 16);
+ return h;
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/LockContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/LockContainer.java 2008-10-06 14:28:08 UTC (rev 6846)
+++ core/trunk/src/main/java/org/jboss/cache/util/concurrent/locks/LockContainer.java 2008-10-06 14:53:33 UTC (rev 6847)
@@ -67,9 +67,16 @@
*/
final int hash(E object)
{
+ // Spread bits to regularize both segment and index locations,
+ // using variant of single-word Wang/Jenkins hash.
int h = object.hashCode();
- h ^= (h >>> 20) ^ (h >>> 12);
- return h ^ (h >>> 7) ^ (h >>> 4);
+ h += (h << 15) ^ 0xffffcd7d;
+ h ^= (h >>> 10);
+ h += (h << 3);
+ h ^= (h >>> 6);
+ h += (h << 2) + (h << 14);
+ h = h ^ (h >>> 16);
+ return h;
}
protected abstract void initLocks(int numLocks);
16 years, 2 months
JBoss Cache SVN: r6846 - core/branches.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-06 10:28:08 -0400 (Mon, 06 Oct 2008)
New Revision: 6846
Added:
core/branches/flat/
Log:
Copied: core/branches/flat (from rev 6845, core/trunk)
16 years, 2 months
JBoss Cache SVN: r6845 - core/tags/1.4.1.SP10/src/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-06 10:08:47 -0400 (Mon, 06 Oct 2008)
New Revision: 6845
Modified:
core/tags/1.4.1.SP10/src/org/jboss/cache/Version.java
Log:
Modified: core/tags/1.4.1.SP10/src/org/jboss/cache/Version.java
===================================================================
--- core/tags/1.4.1.SP10/src/org/jboss/cache/Version.java 2008-10-06 13:29:06 UTC (rev 6844)
+++ core/tags/1.4.1.SP10/src/org/jboss/cache/Version.java 2008-10-06 14:08:47 UTC (rev 6845)
@@ -37,7 +37,7 @@
* Returns version information as a string.
*/
public static String printVersion() {
- return "JBossCache '" + codename + "' " + version + "[ " + cvs + "]";
+ return "JBossCache '" + codename + "' " + version;
}
public static String printVersionId(byte[] v, int len)
16 years, 2 months
JBoss Cache SVN: r6844 - benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-06 09:29:06 -0400 (Mon, 06 Oct 2008)
New Revision: 6844
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
Log:
enhanced session simulator
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2008-10-06 13:14:38 UTC (rev 6843)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2008-10-06 13:29:06 UTC (rev 6844)
@@ -146,7 +146,6 @@
log.info("Gathering replication delay");
String key = "registerReplicationDelay";
List<String> path = Arrays.asList(key);
- Set received = new HashSet();
int clusterSize = configuration.getClusterConfig().getClusterSize();
while (notAllAck(path, cacheWrapper))
{
@@ -157,16 +156,11 @@
if (log.isTraceEnabled()) log.trace("replication delay value from node " + i + " is " + replicatedValue);
if (replicatedValue != null)
{
- received.add(replicatedValue);
cacheWrapper.put(path, buildAckKey(Integer.parseInt(String.valueOf(replicatedValue)), getNodeIndex()), "recieved");
}
}
- if (received.size() < clusterSize)
- {
- //todo mmarkus this brings a delay of 1 sec to the async replication config
- log.info("Recieved " + received.size() + " replication messages. Sleeping 1 sec before moving on");
- Thread.sleep(1000);
- }
+ //todo mmarkus this brings a delay of 1 sec to the async replication config
+ Thread.sleep(1000);
}
replicationDelay = System.currentTimeMillis() - replicationDelay;
log.info("Replication delay is " + replicationDelay + " millis.");
@@ -174,7 +168,7 @@
return replicationDelay;
}
- private String buildAckKey(int sender, int receiver )
+ private String buildAckKey(int sender, int receiver)
{
return sender + "->" + receiver;
}
@@ -185,18 +179,21 @@
{
for (int j = 0; j < configuration.getClusterConfig().getClusterSize(); j++)
{
- if (cacheWrapper.get(path, buildAckKey(i,j)) == null) return false;
-
+ if (cacheWrapper.get(path, buildAckKey(i, j)) == null)
+ {
+ if (log.isTraceEnabled()) log.trace("Missing replication message: " + buildAckKey(i,j));
+ return true;
+ }
}
}
- return true;
+ return false;
}
private void logRunCount(int i)
{
if (((i + 1) % LOG_AFTER_OPERATION_COUNT == 0) || (i == 0))
{
- log.info("SessionSimulatorTest performed " + (i == 0 ? 0 : (i+1)) + " operations");
+ log.info("SessionSimulatorTest performed " + (i == 0 ? 0 : (i + 1)) + " operations");
}
}
16 years, 2 months
JBoss Cache SVN: r6843 - benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-06 09:14:38 -0400 (Mon, 06 Oct 2008)
New Revision: 6843
Modified:
benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
Log:
enhanced session simulator
Modified: benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java
===================================================================
--- benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2008-10-06 11:21:05 UTC (rev 6842)
+++ benchmarks/benchmark-fwk/trunk/src/org/cachebench/tests/SessionSimulatorTest.java 2008-10-06 13:14:38 UTC (rev 6843)
@@ -148,9 +148,9 @@
List<String> path = Arrays.asList(key);
Set received = new HashSet();
int clusterSize = configuration.getClusterConfig().getClusterSize();
- while (received.size() < clusterSize)
+ while (notAllAck(path, cacheWrapper))
{
- cacheWrapper.put(path, key + getNodeIndex(), "value" + getNodeIndex());
+ cacheWrapper.put(path, key + getNodeIndex(), getNodeIndex());
for (int i = 0; i < clusterSize; i++)
{
Object replicatedValue = cacheWrapper.get(path, key + i);
@@ -158,6 +158,7 @@
if (replicatedValue != null)
{
received.add(replicatedValue);
+ cacheWrapper.put(path, buildAckKey(Integer.parseInt(String.valueOf(replicatedValue)), getNodeIndex()), "recieved");
}
}
if (received.size() < clusterSize)
@@ -173,6 +174,24 @@
return replicationDelay;
}
+ private String buildAckKey(int sender, int receiver )
+ {
+ return sender + "->" + receiver;
+ }
+
+ private boolean notAllAck(List path, CacheWrapper cacheWrapper) throws Exception
+ {
+ for (int i = 0; i < configuration.getClusterConfig().getClusterSize(); i++)
+ {
+ for (int j = 0; j < configuration.getClusterConfig().getClusterSize(); j++)
+ {
+ if (cacheWrapper.get(path, buildAckKey(i,j)) == null) return false;
+
+ }
+ }
+ return true;
+ }
+
private void logRunCount(int i)
{
if (((i + 1) % LOG_AFTER_OPERATION_COUNT == 0) || (i == 0))
@@ -221,9 +240,9 @@
+ numberOfAttributes + ", writePercentage=" + writePercentage + ", sizeOfAnAttribute=" + sizeOfAnAttribute + " ]");
}
- public String getNodeIndex()
+ public int getNodeIndex()
{
- return configuration.isLocalOnly() ? "0" : configuration.getClusterConfig().getCurrentNodeIndex() + "";
+ return configuration.isLocalOnly() ? 0 : configuration.getClusterConfig().getCurrentNodeIndex();
}
}
16 years, 2 months