JBoss Cache SVN: r6892 - in core/branches/flat/src/main/java/org/jboss: cache/util/concurrent/locks and 14 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-09 04:56:47 -0400 (Thu, 09 Oct 2008)
New Revision: 6892
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/container/
core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java
core/branches/flat/src/main/java/org/jboss/starobrno/container/UnsortedDataContainer.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/DataContainerFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/LockManagerFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ReplicationException.java
core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java
Removed:
core/branches/flat/src/main/java/org/jboss/cache/Cache.java
core/branches/flat/src/main/java/org/jboss/cache/CacheSPI.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifier/
Modified:
core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java
core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockContainer.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java
core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/NullMarkerEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/ReadCommittedEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/Notifier.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/NodeModifiedEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
Log:
Several pints of Starobrno
Deleted: core/branches/flat/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Cache.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/cache/Cache.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -1,539 +0,0 @@
-/*
- * 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.cache;
-
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.starobrno.CacheException;
-import org.jboss.starobrno.config.Configuration;
-import org.jgroups.Address;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Interface for a Cache where data mappings are grouped and stored in a tree data
- * structure consisting of {@link Node}s.
- * <p/>
- * This is the central construct and basic client API of JBoss Cache and is used for
- * cache-wide operations.
- * <p/>
- * The cache is constructed using a {@link CacheFactory} and is started
- * using {@link #start}, if not already started by the CacheFactory.
- * <p/>
- * Once constructed, the Cache interface can be used to create or access {@link Node}s, which contain data. Once references
- * to {@link Node}s are obtained, data can be stored in them,
- * <p/>
- * As a convenience (and mainly to provide a familiar API to the older JBoss Cache 1.x.x releases) methods are provided that
- * operate directly on nodes.
- * <ul>
- * <li>{@link #put(Fqn,Object,Object)} </li>
- * <li>{@link #put(Fqn,java.util.Map)} </li>
- * <li>{@link #get(Fqn,Object)} </li>
- * <li>{@link #remove(Fqn,Object)} </li>
- * <li>{@link #removeNode(Fqn)} </li>
- * </ul>
- * <p/>
- * A simple example of usage:
- * <pre>
- * // creates with default settings and starts the cache
- * Cache cache = DefaultCacheFactory.getInstance().createCache();
- * Fqn personRecords = Fqn.fromString("/org/mycompany/personRecords");
- * <p/>
- * Node rootNode = cache.getRoot();
- * Node personRecordsNode = rootNode.addChild(personRecords);
- * <p/>
- * // now add some person records.
- * Fqn peterGriffin = Fqn.fromString("/peterGriffin");
- * Fqn stewieGriffin = Fqn.fromString("/stewieGriffin");
- * <p/>
- * // the addChild() API uses relative Fqns
- * Node peter = personRecordsNode.addChild(peterGriffin);
- * Node stewie = personRecordsNode.addChild(stewieGriffin);
- * <p/>
- * peter.put("name", "Peter Griffin");
- * peter.put("ageGroup", "MidLifeCrisis");
- * peter.put("homicidal", Boolean.FALSE);
- * <p/>
- * stewie.put("name", "Stewie Griffin");
- * stewie.put("ageGroup", "Infant");
- * stewie.put("homicidal", Boolean.TRUE);
- * <p/>
- * peter.getFqn().toString(); // will print out /org/mycompany/personRecords/peterGriffin
- * stewie.getFqn().toString(); // will print out /org/mycompany/personRecords/stewieGriffin
- * <p/>
- * peter.getFqn().getParent().equals(stewie.getFqn().getParent()); // will return true
- * <p/>
- * </pre>
- * <p/>
- * For more information, please read the JBoss Cache user guide and tutorial, available on <a href="http://labs.jboss.com/portal/jbosscache/docs/index.html" target="_BLANK">the JBoss Cache documentation site</a>,
- * and look through the examples <a href="http://labs.jboss.com/portal/jbosscache/download/index.html" target="_BLANK">shipped with the JBoss Cache distribution</a>.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @see Node
- * @see CacheFactory
- * @since 2.0.0
- */
-@ThreadSafe
-public interface Cache<K, V>
-{
- /**
- * Retrieves the configuration of this cache.
- *
- * @return the configuration.
- */
- Configuration getConfiguration();
-
- /**
- * Returns the root node of this cache.
- *
- * @return the root node
- */
- Node<K, V> getRoot();
-
- /**
- * Adds a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object to the entire cache. The object passed in needs to be properly annotated with the
- * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
- *
- * @param listener listener to add
- */
- void addCacheListener(Object listener);
-
- /**
- * Removes a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object from the cache. The object passed in needs to be properly annotated with the
- * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
- *
- * @param listener listener to remove
- */
- void removeCacheListener(Object listener);
-
- /**
- * Retrieves an immutable {@link List} of objects annotated as {@link org.jboss.cache.notifications.annotation.CacheListener}s attached to the cache.
- *
- * @return an immutable {@link List} of objects annotated as {@link org.jboss.cache.notifications.annotation.CacheListener}s attached to the cache.
- */
- Set<Object> getCacheListeners();
-
- /**
- * Associates the specified value with the specified key for a {@link Node} in this cache.
- * If the {@link Node} previously contained a mapping for this key, the old value is replaced by the specified value.
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
- * A <code>null</code> return can also indicate that the Node previously associated <code>null</code> with the specified key, if the implementation supports null values.
- * @throws IllegalStateException if the cache is not in a started state.
- */
- V put(Fqn fqn, K key, V value);
-
- /**
- * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #put(Fqn, Object, Object)}
- *
- * @param fqn String representation of the Fqn
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
- * A <code>null</code> return can also indicate that the Node previously associated <code>null</code> with the specified key, if the implementation supports null values.
- * @throws IllegalStateException if the cache is not in a started state
- */
-
- V put(String fqn, K key, V value);
-
- /**
- * Under special operating behavior, associates the value with the specified key for a node identified by the Fqn passed in.
- * <ul>
- * <li> Only goes through if the node specified does not exist; no-op otherwise.</i>
- * <li> Force asynchronous mode for replication to prevent any blocking.</li>
- * <li> invalidation does not take place. </li>
- * <li> 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a no-op, and swallows the timeout exception.</li>
- * <li> Ongoing transactions are suspended before this call, so failures here will not affect any ongoing transactions.</li>
- * <li> Errors and exceptions are 'silent' - logged at a much lower level than normal, and this method does not throw exceptions</li>
- * </ul>
- * This method is for caching data that has an external representation in storage, where, concurrent modification and
- * transactions are not a consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome'
- * rather than a 'failing outcome'.
- * <p/>
- * An example of when this method is useful is when data is read from, for example, a legacy datastore, and is cached before
- * returning the data to the caller. Subsequent calls would prefer to get the data from the cache and if the data doesn't exist
- * in the cache, fetch again from the legacy datastore.
- * <p/>
- * See <a href="http://jira.jboss.com/jira/browse/JBCACHE-848">JBCACHE-848</a> for details around this feature.
- * <p/>
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.jboss.cache.CacheStatus#STARTED}.
- */
- void putForExternalRead(Fqn fqn, K key, V value);
-
- /**
- * Copies all of the mappings from the specified map to a {@link Node}.
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to copy the data to
- * @param data mappings to copy
- * @throws IllegalStateException if the cache is not in a started state
- */
- void put(Fqn fqn, Map<? extends K, ? extends V> data);
-
- /**
- * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #put(Fqn, java.util.Map)}
- *
- * @param fqn String representation of the Fqn
- * @param data data map to insert
- * @throws IllegalStateException if the cache is not in a started state
- */
- void put(String fqn, Map<? extends K, ? extends V> data);
-
- /**
- * Removes the mapping for this key from a Node.
- * Returns the value to which the Node previously associated the key, or
- * <code>null</code> if the Node contained no mapping for this key.
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
- * @param key key whose mapping is to be removed from the Node
- * @return previous value associated with specified Node's key
- * @throws IllegalStateException if the cache is not in a started state
- */
- V remove(Fqn fqn, K key);
-
- /**
- * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #remove(Fqn, Object)}
- *
- * @param fqn string representation of the Fqn to retrieve
- * @param key key to remove
- * @return old value removed, or null if the fqn does not exist
- * @throws IllegalStateException if the cache is not in a started state
- */
- V remove(String fqn, K key);
-
- /**
- * Removes a {@link Node} indicated by absolute {@link Fqn}.
- *
- * @param fqn {@link Node} to remove
- * @return true if the node was removed, false if the node was not found
- * @throws IllegalStateException if the cache is not in a started state
- */
- boolean removeNode(Fqn fqn);
-
- /**
- * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #removeNode(Fqn)}
- *
- * @param fqn string representation of the Fqn to retrieve
- * @return true if the node was found and removed, false otherwise
- * @throws IllegalStateException if the cache is not in a started state
- */
- boolean removeNode(String fqn);
-
- /**
- * A convenience method to retrieve a node directly from the cache. Equivalent to calling cache.getRoot().getChild(fqn).
- *
- * @param fqn fqn of the node to retrieve
- * @return a Node object, or a null if the node does not exist.
- * @throws IllegalStateException if the cache is not in a started state
- */
- Node<K, V> getNode(Fqn fqn);
-
- /**
- * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #getNode(Fqn)}
- *
- * @param fqn string representation of the Fqn to retrieve
- * @return node, or null if the node does not exist
- * @throws IllegalStateException if the cache is not in a started state
- */
- Node<K, V> getNode(String fqn);
-
-
- /**
- * Convenience method that allows for direct access to the data in a {@link Node}.
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
- * @param key key under which value is to be retrieved.
- * @return returns data held under specified key in {@link Node} denoted by specified Fqn.
- * @throws IllegalStateException if the cache is not in a started state
- */
- V get(Fqn fqn, K key);
-
- /**
- * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #get(Fqn, Object)}
- *
- * @param fqn string representation of the Fqn to retrieve
- * @param key key to fetch
- * @return value, or null if the fqn does not exist.
- * @throws IllegalStateException if the cache is not in a started state
- */
- V get(String fqn, K key);
-
- /**
- * Eviction call that evicts the specified {@link Node} from memory.
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be evicted.
- * @param recursive evicts children as well
- * @throws IllegalStateException if the cache is not in a started state
- */
- void evict(Fqn fqn, boolean recursive);
-
- /**
- * Eviction call that evicts the specified {@link Node} from memory. Not recursive.
- *
- * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be evicted.
- * @throws IllegalStateException if the cache is not in a started state
- */
- void evict(Fqn fqn);
-
- /**
- * Retrieves a {@link Region} for a given {@link Fqn}. If the region does not exist,
- * and <li>createIfAbsent</li> is true, then one is created.
- * <p/>
- * If not, parent Fqns will be consulted in turn for registered regions, gradually working up to
- * Fqn.ROOT. If no regions are defined in any of the parents either, a null is returned.
- *
- * @param fqn Fqn that is contained in a region.
- * @param createIfAbsent If true, will create a new associated region if not found.
- * @return a MarshRegion. Null if none is found.
- * @see Region
- */
- Region getRegion(Fqn fqn, boolean createIfAbsent);
-
- /**
- * Removes a region denoted by the Fqn passed in.
- *
- * @param fqn of the region to remove
- * @return true if a region did exist and was removed; false otherwise.
- */
- boolean removeRegion(Fqn fqn);
-
- /**
- * Lifecycle method that initializes configuration state, the root node, etc.
- *
- * @throws CacheException if there are creation problems
- */
- void create() throws CacheException;
-
- /**
- * Lifecycle method that starts the cache loader,
- * starts cache replication, starts the region manager, etc., and (if configured) warms the cache using a
- * state transfer or cache loader preload.
- *
- * @throws CacheException if there are startup problems
- */
- void start() throws CacheException;
-
- /**
- * Lifecycle method that stops the cache, including replication,
- * clustering, cache loading, notifications, etc., and clears all cache in-memory state.
- * <p/>
- * State can be reconstituted by using either a cache loader or state transfer when the cache starts again.
- */
- void stop();
-
- /**
- * Lifecycle method that destroys the cache and removes any interceptors/configuration elements.
- * Cache can then be restarted (potentially after reconfiguring) using {@link #create()} and {@link #start()}.
- */
- void destroy();
-
- /**
- * Gets where the cache currently is its lifecycle transitions.
- *
- * @return the CacheStatus. Will not return <code>null</code>.
- */
- CacheStatus getCacheStatus();
-
- /**
- * @return the current invocation context for the current invocation and cache instance.
- * @throws IllegalStateException if the cache has been destroyed.
- */
- InvocationContext getInvocationContext();
-
- /**
- * Sets the passed in {@link org.jboss.cache.InvocationContext} as current.
- *
- * @param ctx invocation context to use
- * @throws IllegalStateException if the cache has been destroyed.
- */
- void setInvocationContext(InvocationContext ctx);
-
- /**
- * Returns the local address of this cache in a cluster, or <code>null</code>
- * if running in local mode.
- *
- * @return the local address of this cache in a cluster, or <code>null</code>
- * if running in local mode.
- */
- Address getLocalAddress();
-
- /**
- * Returns a list of members in the cluster, or <code>null</code>
- * if running in local mode.
- *
- * @return a {@link List} of members in the cluster, or <code>null</code>
- * if running in local mode.
- */
- List<Address> getMembers();
-
- /**
- * Moves a part of the cache to a different subtree.
- * <p/>
- * E.g.:
- * <p/>
- * assume a cache structure such as:
- * <p/>
- * <pre>
- * /a/b/c
- * /a/b/d
- * /a/b/e
- * <p/>
- * <p/>
- * Fqn f1 = Fqn.fromString("/a/b/c");
- * Fqn f2 = Fqn.fromString("/a/b/d");
- * <p/>
- * cache.move(f1, f2);
- * </pre>
- * <p/>
- * Will result in:
- * <pre>
- * <p/>
- * /a/b/d/c
- * /a/b/e
- * <p/>
- * </pre>
- * <p/>
- * and now
- * <p/>
- * <pre>
- * Fqn f3 = Fqn.fromString("/a/b/e");
- * Fqn f4 = Fqn.fromString("/a");
- * cache.move(f3, f4);
- * </pre>
- * <p/>
- * will result in:
- * <pre>
- * /a/b/d/c
- * /a/e
- * </pre>
- * No-op if the node to be moved is the root node.
- * <p/>
- * <b>Note</b>: As of 3.0.0 and when using MVCC locking, more specific behaviour is defined as follows:
- * <ul>
- * <li>A no-op if the node is moved unto itself. E.g., <tt>move(fqn, fqn.getParent())</tt> will not do anything.</li>
- * <li>If a target node does not exist it will be created silently, to be more consistent with other APIs such as <tt>put()</tt> on a nonexistent node.</li>
- * <li>If the source node does not exist this is a no-op, to be more consistent with other APIs such as <tt>get()</tt> on a nonexistent node.</li>
- * </ul>
- *
- * @param nodeToMove the Fqn of the node to move.
- * @param newParent new location under which to attach the node being moved.
- * @throws NodeNotExistsException may throw one of these if the target node does not exist or if a different thread has moved this node elsewhere already.
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
- */
- void move(Fqn nodeToMove, Fqn newParent) throws NodeNotExistsException;
-
- /**
- * Convenience method that takes in string representations of Fqns. Otherwise identical to {@link #move(Fqn, Fqn)}
- *
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
- */
- void move(String nodeToMove, String newParent) throws NodeNotExistsException;
-
- /**
- * Returns the version of the cache as a string.
- *
- * @return the version string of the cache.
- * @see Version#printVersion
- */
- String getVersion();
-
- /**
- * Retrieves a defensively copied data map of the underlying node. A convenience method to retrieving a node and
- * getting data from the node directly.
- *
- * @param fqn
- * @return map of data, or an empty map
- * @throws CacheException
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
- */
- Map<K, V> getData(Fqn fqn);
-
- /**
- * Convenience method that takes in a String represenation of the Fqn. Otherwise identical to {@link #getKeys(Fqn)}.
- */
- Set<K> getKeys(String fqn);
-
- /**
- * Returns a set of attribute keys for the Fqn.
- * Returns null if the node is not found, otherwise a Set.
- * The set is a copy of the actual keys for this node.
- * <p/>
- * A convenience method to retrieving a node and
- * getting keys from the node directly.
- *
- * @param fqn name of the node
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
- */
- Set<K> getKeys(Fqn fqn);
-
- /**
- * Convenience method that takes in a String represenation of the Fqn. Otherwise identical to {@link #clearData(Fqn)}.
- *
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
- */
- void clearData(String fqn);
-
- /**
- * Removes the keys and properties from a named node.
- * <p/>
- * A convenience method to retrieving a node and
- * getting keys from the node directly.
- *
- * @param fqn name of the node
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
- */
- void clearData(Fqn fqn);
-
- /**
- * Starts a batch. This is a lightweight batching mechanism that groups cache writes together and finally performs the
- * write, persistence and/or replication when {@link #endBatch(boolean)} is called rather than for each invocation on the
- * cache.
- * <p/>
- * Note that if there is an existing transaction in scope and the cache has been configured to use a JTA compliant
- * transaction manager, calls to {@link #startBatch()} and {@link #endBatch(boolean)} are ignored and treated as no-ops.
- * <p/>
- *
- * @see #endBatch(boolean)
- * @since 3.0
- */
- void startBatch();
-
- /**
- * Ends an existing ongoing batch. A no-op if a batch has not been started yet.
- * <p/>
- * Note that if there is an existing transaction in scope and the cache has been configured to use a JTA compliant
- * transaction manager, calls to {@link #startBatch()} and {@link #endBatch(boolean)} are ignored and treated as no-ops.
- * <p/>
- *
- * @param successful if <tt>true</tt>, changes made in the batch are committed. If <tt>false</tt>, they are discarded.
- * @see #startBatch()
- * @since 3.0
- */
- void endBatch(boolean successful);
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/CacheSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheSPI.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheSPI.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -1,354 +0,0 @@
-/*
- * 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.cache;
-
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.statetransfer.StateTransferManager;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.List;
-import java.util.Set;
-
-/**
- * A more detailed interface to {@link Cache}, which is used when writing plugins for or extending JBoss Cache. A reference
- * to this interface should only be obtained when it is passed in to your code, for example when you write an
- * {@link org.jboss.cache.interceptors.base.CommandInterceptor} or {@link CacheLoader}.
- * <p/>
- * <B><I>You should NEVER attempt to directly cast a {@link Cache} instance to this interface. In future, the implementation may not allow it.</I></B>
- * <p/>
- * This interface contains overridden method signatures of some methods from {@link Cache}, overridden to ensure return
- * types of {@link Node} are replaced with {@link NodeSPI}.
- * <p/>
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @see NodeSPI
- * @see Cache
- * @see org.jboss.cache.loader.CacheLoader
- * @since 2.0.0
- */
-@ThreadSafe
-public interface CacheSPI<K, V> extends Cache<K, V>
-{
- /**
- * Overrides {@link org.jboss.cache.Cache#getRoot()} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
- */
- NodeSPI<K, V> getRoot();
-
- /**
- * Overrides {@link Cache#getNode(String)} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
- *
- * @param s string representation of an Fqn
- * @return a NodeSPI
- */
- NodeSPI<K, V> getNode(String s);
-
- /**
- * Overrides {@link Cache#getNode(Fqn)} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
- *
- * @param f an Fqn
- * @return a NodeSPI
- */
- NodeSPI<K, V> getNode(Fqn f);
-
-
- /**
- * Retrieves a reference to a running {@link javax.transaction.TransactionManager}, if one is configured.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return a TransactionManager
- */
- TransactionManager getTransactionManager();
-
- /**
- * Retrieves the current Interceptor chain.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return an immutable {@link List} of {@link org.jboss.cache.interceptors.base.CommandInterceptor}s configured for this cache, or
- * <code>null</code> if {@link Cache#create() create()} has not been invoked
- * and the interceptors thus do not exist.
- */
- List<CommandInterceptor> getInterceptorChain();
-
- /**
- * Retrieves an instance of a {@link Marshaller}, which is capable of
- * converting Java objects to bytestreams and back in an efficient manner, which is
- * also interoperable with bytestreams produced/consumed by other versions of JBoss
- * Cache.
- * <p/>
- * The use of this marshaller is the <b>recommended</b> way of creating efficient,
- * compatible, byte streams from objects.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return an instance of {@link Marshaller}
- */
- Marshaller getMarshaller();
-
- /**
- * Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain
- * is at position 0 and the last one at getInterceptorChain().size() - 1.
- *
- * @param i the interceptor to add
- * @param position the position to add the interceptor
- */
- void addInterceptor(CommandInterceptor i, int position);
-
- /**
- * Adds a custom interceptor to the interceptor chain, after an instance of the specified interceptor type. Throws a
- * cache exception if it cannot find an interceptor of the specified type.
- *
- * @param i interceptor to add
- * @param afterInterceptor interceptor type after which to place custom interceptor
- */
- void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor);
-
- /**
- * Removes the interceptor at a specified position, where the first interceptor in the chain
- * is at position 0 and the last one at getInterceptorChain().size() - 1.
- *
- * @param position the position at which to remove an interceptor
- */
- void removeInterceptor(int position);
-
- /**
- * Removes the interceptor of specified type.
- *
- * @param interceptorType type of interceptor to remove
- */
- void removeInterceptor(Class<? extends CommandInterceptor> interceptorType);
-
- /**
- * Retrieves the current CacheCacheLoaderManager instance associated with the current Cache instance.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return Retrieves a reference to the currently configured {@link org.jboss.cache.loader.CacheLoaderManager} if one or more cache loaders are configured, null otherwise.
- */
- CacheLoaderManager getCacheLoaderManager();
-
- /**
- * Retrieves the current BuddyManager instance associated with the current Cache instance.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return an instance of {@link BuddyManager} if buddy replication is enabled, null otherwise.
- */
- BuddyManager getBuddyManager();
-
- /**
- * Retrieves the current TransactionTable instance associated with the current Cache instance.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return the current {@link TransactionTable}
- */
- TransactionTable getTransactionTable();
-
- /**
- * Gets a handle of the RPC manager.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return the {@link org.jboss.cache.RPCManager} configured.
- */
- RPCManager getRPCManager();
-
- /**
- * Retrieves the current StateTransferManager instance associated with the current Cache instance.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return the current {@link org.jboss.cache.statetransfer.StateTransferManager}
- */
- StateTransferManager getStateTransferManager();
-
- /**
- * Retrieves the current RegionManager instance associated with the current Cache instance.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return the {@link RegionManager}
- */
- RegionManager getRegionManager();
-
-
- /**
- * Retrieves the current Notifier instance associated with the current Cache instance.
- * <p/>
- * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
- * {@link org.jboss.cache.factories.annotations.Inject} annotation.
- *
- * @return the notifier attached with this instance of the cache. See {@link org.jboss.cache.notifications.Notifier}, a class
- * that is responsible for emitting notifications to registered CacheListeners.
- */
- Notifier getNotifier();
-
- /**
- * @return the name of the cluster. Null if running in local mode.
- */
- String getClusterName();
-
- /**
- * @return the number of attributes in the cache.
- */
- int getNumberOfAttributes();
-
- /**
- * @return the number of nodes in the cache.
- */
- int getNumberOfNodes();
-
- /**
- * Returns the global transaction for this local transaction.
- * Optionally creates a new global transaction if it does not exist.
- *
- * @param tx the current transaction
- * @param createIfNotExists if true creates a new transaction if none exists
- * @return a GlobalTransaction
- */
- GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists);
-
- /**
- * Returns the transaction associated with the current thread.
- * If a local transaction exists, but doesn't yet have a mapping to a
- * GlobalTransaction, a new GlobalTransaction will be created and mapped to
- * the local transaction. Note that if a local transaction exists, but is
- * not ACTIVE or PREPARING, null is returned.
- *
- * @return A GlobalTransaction, or null if no (local) transaction was associated with the current thread
- */
- GlobalTransaction getCurrentTransaction();
-
- /**
- * Returns a node without accessing the interceptor chain. Does not return any nodes marked as invalid. Note that this call works
- * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
- * loading or activation does not take place, and so the results of this call should not be treated as definitive. Concurrent node
- * removal, passivation, etc. may affect the results of this call.
- *
- * @param fqn the Fqn to look up.
- * @param includeDeletedNodes if you intend to see nodes marked as deleted within the current tx, set this to true
- * @return a node if one exists or null
- */
- NodeSPI<K, V> peek(Fqn fqn, boolean includeDeletedNodes);
-
- /**
- * Returns a node without accessing the interceptor chain, optionally returning nodes that are marked as invalid ({@link org.jboss.cache.Node#isValid()} == false).
- * Note that this call works
- * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
- * loading or activation does not take place, and so the results of this call should not be treated as definitive. Concurrent node
- * removal, passivation, etc. may affect the results of this call.
- *
- * @param fqn the Fqn to look up.
- * @param includeDeletedNodes if you intend to see nodes marked as deleted within the current tx, set this to true
- * @param includeInvalidNodes if true, nodes marked as being invalid are also returned.
- * @return a node if one exists or null
- */
- NodeSPI<K, V> peek(Fqn fqn, boolean includeDeletedNodes, boolean includeInvalidNodes);
-
- /**
- * Used with buddy replication's data gravitation interceptor. If marshalling is necessary, ensure that the cache is
- * configured to use {@link org.jboss.cache.config.Configuration#useRegionBasedMarshalling} and the {@link org.jboss.cache.Region}
- * pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.
- *
- * @param fqn the fqn to gravitate
- * @param searchBuddyBackupSubtrees if true, buddy backup subtrees are searched and if false, they are not.
- * @param ctx
- * @return a GravitateResult which contains the data for the gravitation
- */
- GravitateResult gravitateData(Fqn fqn, boolean searchBuddyBackupSubtrees, InvocationContext ctx);
-
- /**
- * Returns a Set<Fqn> of Fqns of the topmost node of internal regions that
- * should not included in standard state transfers. Will include
- * {@link BuddyManager#BUDDY_BACKUP_SUBTREE} if buddy replication is
- * enabled.
- *
- * @return an unmodifiable Set<Fqn>. Will not return <code>null</code>.
- */
- Set<Fqn> getInternalFqns();
-
- int getNumberOfLocksHeld();
-
- /**
- * Helper method that does a peek and ensures that the result of the peek is not null. Note that this call works
- * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
- * loading or activation does not take place, and so the results of this call should not be treated as definitive.
- *
- * @param fqn Fqn to peek
- * @return true if the peek returns a non-null value.
- */
- boolean exists(Fqn fqn);
-
- /**
- * A convenience method that takes a String representation of an Fqn. Otherwise identical to {@link #exists(Fqn)}.
- * Note that this call works
- * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
- * loading or activation does not take place, and so the results of this call should not be treated as definitive.
- */
- boolean exists(String fqn);
-
- /**
- * Returns all children of a given node. Returns an empty set if there are no children.
- * The set is unmodifiable.
- *
- * @param fqn The fully qualified name of the node
- * @return Set an unmodifiable set of children names, Object.
- */
- Set<Object> getChildrenNames(Fqn fqn);
-
- /**
- * Convenience method that takes a String representation of an Fqn. Otherwise identical to {@link #getChildrenNames(Fqn)}
- *
- * @param fqn as a string
- * @return Set an unmodifiable set of children names, Object.
- */
- Set<String> getChildrenNames(String fqn);
-
- /**
- * Returns the component registry associated with this cache instance.
- *
- * @see org.jboss.cache.factories.ComponentRegistry
- */
- ComponentRegistry getComponentRegistry();
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -46,7 +46,7 @@
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.factories.annotations.Stop;
-import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.transaction.TransactionTable;
import org.jgroups.Address;
import org.jgroups.Channel;
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLock.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -22,8 +22,8 @@
package org.jboss.cache.util.concurrent.locks;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.transaction.GlobalTransaction;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.AbstractQueuedSynchronizer;
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockContainer.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockContainer.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -22,7 +22,7 @@
package org.jboss.cache.util.concurrent.locks;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.invocation.InvocationContextContainer;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
import java.util.Arrays;
@@ -40,6 +40,11 @@
OwnableReentrantLock[] sharedLocks;
InvocationContextContainer icc;
+ public OwnableReentrantLockContainer(int concurrencyLevel, Object dummy)
+ {
+ throw new UnsupportedOperationException("Barf"); // todo remove this
+ }
+
/**
* Creates a new LockContainer which uses a certain number of shared locks across all elements that need to be locked.
*
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -44,7 +44,7 @@
import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.invocation.InvocationContextContainer;
-import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -21,19 +21,25 @@
*/
package org.jboss.starobrno.commands;
-import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
import org.jboss.starobrno.commands.read.SizeCommand;
-import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
import org.jboss.starobrno.commands.tx.RollbackCommand;
-import org.jboss.starobrno.commands.tx.CommitCommand;
-import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.commands.write.ClearCommand;
+import org.jboss.starobrno.commands.write.EvictCommand;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.PutMapCommand;
+import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.commands.write.ReplaceCommand;
+import org.jboss.starobrno.container.DataContainer;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.transaction.GlobalTransaction;
-import org.jboss.starobrno.notifier.Notifier;
import org.jgroups.Address;
+import java.util.List;
import java.util.Map;
-import java.util.List;
/**
* @author Mircea.Markus(a)jboss.com
@@ -43,6 +49,13 @@
private DataContainer dataContainer;
private Notifier notifier;
+ @Inject
+ private void setupDependencies(DataContainer container, Notifier notifier)
+ {
+ this.dataContainer = container;
+ this.notifier = notifier;
+ }
+
public PutKeyValueCommand buildPutKeyValueCommand(Object key, Object value)
{
return new PutKeyValueCommand(key, value, false);
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GetKeyValueCommand.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -26,7 +26,7 @@
import org.jboss.starobrno.commands.Visitor;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.mvcc.MVCCEntry;
-import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.starobrno.notifications.Notifier;
/**
* // TODO: MANIK: Document this
@@ -70,7 +70,7 @@
Object result = entry.getValue();
if (trace) log.trace("Found value " + result);
// if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
- return result;
+ return result;
}
public int getCommandId()
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -25,8 +25,8 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.starobrno.CacheSPI;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
import org.jgroups.Address;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/SizeCommand.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -21,9 +21,9 @@
*/
package org.jboss.starobrno.commands.read;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.Visitor;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
/**
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/ClusteredGetCommand.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -23,9 +23,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.commands.DataCommand;
import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.interceptors.InterceptorChain;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/remote/DataGravitationCleanupCommand.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -27,8 +27,8 @@
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.transaction.GlobalTransaction;
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java (from rev 6891, core/branches/flat/src/main/java/org/jboss/starobrno/DataContainer.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/container/DataContainer.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,48 @@
+/*
+ * 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.container;
+
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface DataContainer<K, V>
+{
+ Set<Entry<K, V>> getEntries();
+
+ Entry<K, V> getEntry(K k);
+
+ void putEntry(Entry<K, V> entry);
+
+ boolean exists(Entry<K, V> entry);
+
+ int size();
+
+ void clear();
+
+ void removeEntry(K key);
+}
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/container/UnsortedDataContainer.java (from rev 6891, core/branches/flat/src/main/java/org/jboss/starobrno/UnsortedDataContainer.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/container/UnsortedDataContainer.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/container/UnsortedDataContainer.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,78 @@
+/*
+ * 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.container;
+
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * // TODO: crappy and inefficient - but just a placeholder for now.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class UnsortedDataContainer<K, V> implements DataContainer<K, V>
+{
+ private final ConcurrentMap<K, V> data = new ConcurrentHashMap<K, V>();
+
+ public Set<Entry<K, V>> getEntries()
+ {
+ return data.entrySet();
+ }
+
+ public Entry<K, V> getEntry(K k)
+ {
+ if (k == null) throw new NullPointerException("I don't like nulls!");
+ for (Entry<K, V> e : data.entrySet())
+ {
+ if (k.equals(e.getKey())) return e;
+ }
+ return null;
+ }
+
+ public void putEntry(Entry<K, V> kvEntry)
+ {
+ data.put(kvEntry.getKey(), kvEntry.getValue());
+ }
+
+ public boolean exists(Entry<K, V> kvEntry)
+ {
+ return data.containsKey(kvEntry.getKey());
+ }
+
+ public int size()
+ {
+ return data.size();
+ }
+
+ public void clear()
+ {
+ data.clear();
+ }
+
+ public void removeEntry(K key)
+ {
+ data.remove(key);
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -21,9 +21,9 @@
*/
package org.jboss.starobrno.context;
-import org.jboss.starobrno.OrderedSynchronizationHandler;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.transaction.OrderedSynchronizationHandler;
import javax.transaction.Transaction;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -25,7 +25,7 @@
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.mvcc.MVCCEntry;
-import org.jboss.starobrno.OrderedSynchronizationHandler;
+import org.jboss.starobrno.transaction.OrderedSynchronizationHandler;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -196,6 +196,8 @@
s.add(StateTransferManagerFactory.class);
s.add(StateTransferFactory.class);
s.add(NullComponentFactory.class);
+ s.add(LockManagerFactory.class);
+ s.add(DataContainerFactory.class);
return s;
}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/DataContainerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/DataContainerFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/DataContainerFactory.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,41 @@
+/*
+ * 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.factories;
+
+import org.jboss.starobrno.container.DataContainer;
+import org.jboss.starobrno.container.UnsortedDataContainer;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@DefaultFactoryFor(classes = DataContainer.class)
+public class DataContainerFactory extends ComponentFactory
+{
+ protected <T> T construct(Class<T> componentType)
+ {
+ return (T) new UnsortedDataContainer();
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -30,15 +30,14 @@
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.VersionAwareMarshaller;
-import org.jboss.cache.mvcc.MVCCNodeHelper;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
import org.jboss.starobrno.factories.context.ContextFactory;
import org.jboss.starobrno.invocation.InvocationContextContainer;
-import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.starobrno.mvcc.MVCCEntryWrapper;
+import org.jboss.starobrno.notifications.Notifier;
import org.jboss.starobrno.transaction.TransactionTable;
/**
@@ -47,9 +46,9 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.1.0
*/
-@DefaultFactoryFor(classes = {Notifier.class, MVCCNodeHelper.class, RegionRegistry.class,
+@DefaultFactoryFor(classes = {Notifier.class, RegionRegistry.class,
ChannelMessageListener.class, CacheLoaderManager.class, Marshaller.class, InvocationContextContainer.class,
- CacheInvocationDelegate.class, TransactionTable.class, DataContainer.class,
+ CacheInvocationDelegate.class, TransactionTable.class, MVCCEntryWrapper.class,
LockStrategyFactory.class, BuddyFqnTransformer.class, BatchContainer.class,
ContextFactory.class, EntryFactory.class, CommandsFactory.class})
public class EmptyConstructorFactory extends ComponentFactory
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -22,8 +22,8 @@
package org.jboss.starobrno.factories;
import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.mvcc.EntryImpl;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -22,7 +22,6 @@
package org.jboss.starobrno.factories;
-import org.jboss.starobrno.TxInterceptor;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.CustomInterceptorConfig;
@@ -31,6 +30,7 @@
import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.interceptors.InvocationContextInterceptor;
import org.jboss.starobrno.interceptors.LockingInterceptor;
+import org.jboss.starobrno.interceptors.TxInterceptor;
import org.jboss.starobrno.interceptors.base.CommandInterceptor;
import java.util.List;
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/LockManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/LockManagerFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/LockManagerFactory.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,41 @@
+/*
+ * 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.factories;
+
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.lock.LockManager;
+import org.jboss.starobrno.lock.StripedLockManager;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@DefaultFactoryFor(classes = LockManager.class)
+public class LockManagerFactory extends ComponentFactory
+{
+ protected <T> T construct(Class<T> componentType)
+ {
+ return (T) new StripedLockManager();
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -21,11 +21,11 @@
*/
package org.jboss.starobrno.factories;
-import org.jboss.cache.RPCManager;
import org.jboss.cache.util.BeanUtils;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.RuntimeConfig;
import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.remoting.RPCManager;
import java.lang.reflect.Method;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -22,8 +22,6 @@
package org.jboss.starobrno.interceptors;
-import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
@@ -35,7 +33,9 @@
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.transaction.TransactionTable;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/LockingInterceptor.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno.interceptors;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.read.GetKeyValueCommand;
import org.jboss.starobrno.commands.read.GravitateDataCommand;
@@ -35,6 +34,7 @@
import org.jboss.starobrno.commands.write.PutMapCommand;
import org.jboss.starobrno.commands.write.RemoveCommand;
import org.jboss.starobrno.commands.write.ReplaceCommand;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.interceptors.base.PrePostProcessingCommandInterceptor;
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java (from rev 6891, core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,1051 @@
+/*
+ * 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.interceptors;
+
+import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.commands.CommandsFactory;
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
+import org.jboss.starobrno.commands.tx.PrepareCommand;
+import org.jboss.starobrno.commands.tx.RollbackCommand;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.context.TransactionContext;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.context.ContextFactory;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.jmx.annotations.ManagedAttribute;
+import org.jboss.starobrno.jmx.annotations.ManagedOperation;
+import org.jboss.starobrno.lock.LockManager;
+import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.remoting.RPCManager;
+import org.jboss.starobrno.remoting.ReplicationException;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.transaction.OrderedSynchronizationHandler;
+import org.jboss.starobrno.transaction.TransactionTable;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * This interceptor is the new default at the head of all interceptor chains,
+ * and makes transactional attributes available to all interceptors in the chain.
+ * This interceptor is also responsible for registering for synchronisation on
+ * transaction completion.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
+ */
+public class TxInterceptor extends BaseTransactionalContextInterceptor
+{
+ protected CommandsFactory commandsFactory;
+ protected RPCManager rpcManager;
+ private Notifier notifier;
+ private InvocationContextContainer invocationContextContainer;
+ private ComponentRegistry componentRegistry;
+ private ContextFactory contextFactory;
+
+ /**
+ * List <Transaction>that we have registered for
+ */
+ private final Set<Transaction> transactions = new ConcurrentHashSet<Transaction>();
+ private final Map<Transaction, GlobalTransaction> rollbackTransactions = new ConcurrentHashMap<Transaction, GlobalTransaction>(16);
+ private long prepares = 0;
+ private long commits = 0;
+ private long rollbacks = 0;
+ protected boolean optimistic = false;
+ private LockManager lockManager;
+ private boolean statsEnabled;
+
+ @Inject
+ public void intialize(RPCManager rpcManager, ContextFactory contextFactory,
+ Notifier notifier, InvocationContextContainer icc,
+ CommandsFactory factory, ComponentRegistry componentRegistry, LockManager lockManager)
+ {
+ this.contextFactory = contextFactory;
+ this.commandsFactory = factory;
+ this.rpcManager = rpcManager;
+ this.notifier = notifier;
+ this.invocationContextContainer = icc;
+ this.componentRegistry = componentRegistry;
+ this.lockManager = lockManager;
+ setStatisticsEnabled(configuration.isExposeManagementStatistics());
+ }
+
+ @Override
+ public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ Object result = null;
+
+ // this is a prepare, commit, or rollback.
+ if (log.isDebugEnabled()) log.debug("Got gtx from invocation context " + ctx.getGlobalTransaction());
+ try
+ {
+ if (ctx.getGlobalTransaction().isRemote())
+ {
+ result = handleRemotePrepare(ctx, command);
+ if (getStatisticsEnabled()) prepares++;
+ }
+ else
+ {
+ if (trace) log.trace("received my own message (discarding it)");
+ result = null;
+ }
+ }
+ catch (Throwable e)
+ {
+ ctx.throwIfNeeded(e);
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ if (!ctx.getGlobalTransaction().isRemote())
+ {
+ if (trace) log.trace("received my own message (discarding it)");
+ return null;
+ }
+ try
+ {
+ if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") call on command [" + command + "]");
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ Transaction ltx = txTable.getLocalTransaction(gtx, true);
+ // disconnect if we have a current tx associated
+ Transaction currentTx = txManager.getTransaction();
+ boolean resumeCurrentTxOnCompletion = false;
+ try
+ {
+ if (!ltx.equals(currentTx))
+ {
+ currentTx = txManager.suspend();
+ resumeCurrentTxOnCompletion = true;
+ txManager.resume(ltx);
+ // make sure we set this in the ctx
+ ctx.setTransaction(ltx);
+ }
+ if (log.isDebugEnabled()) log.debug(" executing commit() with local TX " + ltx + " under global tx " + gtx);
+ txManager.commit();
+ if (getStatisticsEnabled()) commits++;
+ }
+ finally
+ {
+ //resume the old transaction if we suspended it
+ if (resumeCurrentTxOnCompletion)
+ {
+ resumeTransactionOnCompletion(ctx, currentTx);
+ }
+ // remove from local lists.
+ transactions.remove(ltx);
+ // this tx has completed. Clean up in the tx table.
+ txTable.remove(gtx, ltx);
+ }
+ if (log.isDebugEnabled()) log.debug("Finished remote rollback method for " + gtx);
+ }
+ catch (Throwable throwable)
+ {
+ ctx.throwIfNeeded(throwable);
+ }
+ return null;
+ }
+
+ @Override
+ public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ if (!ctx.getGlobalTransaction().isRemote())
+ {
+ if (trace) log.trace("received my own message (discarding it)");
+ return null;
+ }
+ try
+ {
+ if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") call on command [" + command + "]");
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ Transaction ltx = txTable.getLocalTransaction(gtx);
+ if (ltx == null)
+ {
+ log.warn("No local transaction for this remotely originating rollback. Possibly rolling back before a prepare call was broadcast?");
+ txTable.remove(gtx);
+ return null;
+ }
+ // disconnect if we have a current tx associated
+ Transaction currentTx = txManager.getTransaction();
+ boolean resumeCurrentTxOnCompletion = false;
+ try
+ {
+ if (!ltx.equals(currentTx))
+ {
+ currentTx = txManager.suspend();
+ resumeCurrentTxOnCompletion = true;
+ txManager.resume(ltx);
+ // make sure we set this in the ctx
+ ctx.setTransaction(ltx);
+ }
+ if (log.isDebugEnabled()) log.debug("executing with local TX " + ltx + " under global tx " + gtx);
+ txManager.rollback();
+ if (getStatisticsEnabled()) rollbacks++;
+ }
+ finally
+ {
+ //resume the old transaction if we suspended it
+ if (resumeCurrentTxOnCompletion)
+ {
+ resumeTransactionOnCompletion(ctx, currentTx);
+ }
+
+ // remove from local lists.
+ transactions.remove(ltx);
+
+ // this tx has completed. Clean up in the tx table.
+ txTable.remove(gtx, ltx);
+ }
+ if (log.isDebugEnabled()) log.debug("Finished remote commit/rollback method for " + gtx);
+ }
+ catch (Throwable throwable)
+ {
+ ctx.throwIfNeeded(throwable);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ try
+ {
+ return attachGtxAndPassUpChain(ctx, command);
+ }
+ catch (Throwable throwable)
+ {
+ ctx.throwIfNeeded(throwable);
+ return null;
+ }
+ }
+
+ protected Object attachGtxAndPassUpChain(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ Transaction tx = ctx.getTransaction();
+ if (tx != null) attachGlobalTransaction(ctx, tx, command);
+ return invokeNextInterceptor(ctx, command);
+ }
+
+ // ------------------------------------------------------------------------
+ // JMX statistics
+ // ------------------------------------------------------------------------
+
+ // --------------------------------------------------------------
+
+ /**
+ * Handles a remotely originating prepare call, by creating a local transaction for the remote global transaction
+ * and replaying modifications in this new local transaction.
+ *
+ * @param ctx invocation context
+ * @param command prepare command
+ * @return result of the prepare, typically a null.
+ * @throws Throwable in the event of problems.
+ */
+ private Object handleRemotePrepare(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ // the InvocationContextInterceptor would have set this for us
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+
+ // Is there a local transaction associated with GTX? (not the current tx associated with the thread, which may be
+ // in the invocation context
+ Transaction ltx = txTable.getLocalTransaction(gtx);
+ Transaction currentTx = txManager.getTransaction();
+
+ Object retval = null;
+ boolean success = false;
+ try
+ {
+ if (ltx == null)
+ {
+ if (currentTx != null) txManager.suspend();
+ // create a new local transaction
+ ltx = createLocalTx();
+ // associate this with a global tx
+ txTable.put(ltx, gtx);
+ if (trace) log.trace("Created new tx for gtx " + gtx);
+
+ if (log.isDebugEnabled())
+ log.debug("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
+ }
+ else
+ {
+ //this should be valid
+ if (!TransactionTable.isValid(ltx))
+ throw new CacheException("Transaction " + ltx + " not in correct state to be prepared");
+
+ //associate this thread with the local transaction associated with the global transaction, IF the localTx is NOT the current tx.
+ if (currentTx == null || !ltx.equals(currentTx))
+ {
+ if (trace) log.trace("Suspending current tx " + currentTx);
+ txManager.suspend();
+ txManager.resume(ltx);
+ }
+ }
+ if (trace) log.trace("Resuming existing tx " + ltx + ", global tx=" + gtx);
+
+ // at this point we have a non-null ltx
+
+ // Asssociate the local TX with the global TX. Create new
+ // transactionContext for TX in txTable, the modifications
+ // below will need this transactionContext to add their modifications
+ // under the GlobalTx key
+ TransactionContext transactionContext = txTable.get(gtx);
+ if (transactionContext == null)
+ {
+ // create a new transaction transactionContext
+ if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
+ transactionContext = contextFactory.createTransactionContext(ltx);
+ txTable.put(gtx, transactionContext);
+ }
+
+ setTransactionalContext(ltx, gtx, transactionContext, ctx);
+
+ // register a sync handler for this tx.
+ registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, transactionContext), ctx);
+
+ success = false;
+
+ // replay modifications
+ replayModifications(ctx, ltx, command);
+
+ success = true; // no exceptions were thrown above!!
+
+ // now pass the prepare command up the chain as well.
+ if (command.isOnePhaseCommit())
+ {
+ if (trace)
+ log.trace("Using one-phase prepare. Not propagating the prepare call up the stack until called to do so by the sync handler.");
+ }
+ else
+ {
+ // now pass up the prepare method itself.
+ invokeNextInterceptor(ctx, command);
+ }
+ // JBCACHE-361 Confirm that the transaction is ACTIVE
+ assertTxIsStillValid(ltx);
+ }
+ finally
+ {
+ // if we are running a one-phase commit, perform a commit or rollback now.
+ if (trace) log.trace("Are we running a 1-phase commit? " + command.isOnePhaseCommit());
+
+ if (command.isOnePhaseCommit())
+ {
+ try
+ {
+ if (success)
+ {
+ ltx.commit();
+ }
+ else
+ {
+ ltx.rollback();
+ }
+ }
+ catch (Throwable t)
+ {
+ log.error("Commit/rollback failed.", t);
+ if (success)
+ {
+ // try another rollback...
+ try
+ {
+ log.info("Attempting anotehr rollback");
+ //invokeOnePhaseCommitMethod(globalTransaction, modifications.size() > 0, false);
+ ltx.rollback();
+ }
+ catch (Throwable t2)
+ {
+ log.error("Unable to rollback", t2);
+ }
+ }
+ }
+ finally
+ {
+ transactions.remove(ltx);// JBAS-298
+ }
+ }
+
+ txManager.suspend();// suspends ltx - could be null
+ // resume whatever else we had going.
+ if (currentTx != null) txManager.resume(currentTx);
+ if (log.isDebugEnabled()) log.debug("Finished remote prepare " + gtx);
+ }
+
+ return retval;
+ }
+
+ private ReplicableCommand attachGlobalTransaction(InvocationContext ctx, Transaction tx, VisitableCommand command) throws Throwable
+ {
+ if (trace)
+ {
+ log.trace(" local transaction exists - registering global tx if not present for " + Thread.currentThread());
+ }
+ if (trace)
+ {
+ GlobalTransaction tempGtx = txTable.get(tx);
+ log.trace("Associated gtx in txTable is " + tempGtx);
+ }
+
+ // register a sync handler for this tx - only if the globalTransaction is not remotely initiated.
+ GlobalTransaction gtx = registerTransaction(tx, ctx);
+ if (gtx == null)
+ {
+ // get the current globalTransaction from the txTable.
+ gtx = txTable.get(tx);
+ }
+
+ // make sure we attach this globalTransaction to the invocation context.
+ ctx.setGlobalTransaction(gtx);
+
+ return command;
+ }
+
+ /**
+ * Replays modifications
+ */
+ protected void replayModifications(InvocationContext ctx, Transaction ltx, PrepareCommand command) throws Throwable
+ {
+ try
+ {
+ // replay modifications
+ for (VisitableCommand modification : command.getModifications())
+ {
+ invokeNextInterceptor(ctx, modification);
+ assertTxIsStillValid(ltx);
+ }
+ }
+ catch (Throwable th)
+ {
+ log.error("prepare failed!", th);
+ throw th;
+ }
+ }
+
+ private void resumeTransactionOnCompletion(InvocationContext ctx, Transaction currentTx)
+ throws SystemException, InvalidTransactionException
+ {
+ if (trace) log.trace("Resuming suspended transaction " + currentTx);
+ txManager.suspend();
+ if (currentTx != null)
+ {
+ txManager.resume(currentTx);
+ ctx.setTransaction(currentTx);
+ }
+ }
+
+ /**
+ * Handles a commit or a rollback. Called by the synch handler. Simply tests that we are in the correct tx and
+ * passes the meth call up the interceptor chain.
+ *
+ * @throws Throwable
+ */
+ @SuppressWarnings("deprecation")
+ private Object handleCommitRollback(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ Object result;
+ VisitableCommand originalCommand = ctx.getCommand();
+ ctx.setCommand(command);
+ try
+ {
+ result = invokeNextInterceptor(ctx, command);
+ }
+ finally
+ {
+ ctx.setCommand(originalCommand);
+ }
+ if (log.isDebugEnabled()) log.debug("Finished local commit/rollback method for " + gtx);
+ return result;
+ }
+
+ // --------------------------------------------------------------
+ // Transaction phase runners
+ // --------------------------------------------------------------
+
+ protected PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, boolean onePhaseCommit)
+ {
+ return commandsFactory.buildPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(), onePhaseCommit);
+ }
+
+ /**
+ * creates a commit()
+ */
+ protected void runCommitPhase(InvocationContext ctx, GlobalTransaction gtx, List modifications, boolean onePhaseCommit)
+ {
+ try
+ {
+ VisitableCommand commitCommand = onePhaseCommit ? buildPrepareCommand(gtx, modifications, true) : commandsFactory.buildCommitCommand(gtx);
+
+ if (trace) log.trace("Running commit for " + gtx);
+
+ handleCommitRollback(ctx, commitCommand);
+ }
+ catch (Throwable e)
+ {
+ log.warn("Commit failed. Clearing stale locks.");
+ try
+ {
+ cleanupStaleLocks(ctx);
+ }
+ catch (RuntimeException re)
+ {
+ log.error("Unable to clear stale locks", re);
+ throw re;
+ }
+ catch (Throwable e2)
+ {
+ log.error("Unable to clear stale locks", e2);
+ throw new RuntimeException(e2);
+ }
+ if (e instanceof RuntimeException)
+ throw (RuntimeException) e;
+ else
+ throw new RuntimeException("Commit failed.", e);
+ }
+ }
+
+ protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
+ {
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null) lockManager.unlock(ctx);
+ }
+
+ /**
+ * creates a rollback()
+ */
+ protected void runRollbackPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx)
+ {
+ try
+ {
+ // JBCACHE-457
+ VisitableCommand rollbackCommand = commandsFactory.buildRollbackCommand(gtx);
+ if (trace) log.trace(" running rollback for " + gtx);
+
+ //JBCACHE-359 Store a lookup for the globalTransaction so a listener
+ // callback can find it
+ rollbackTransactions.put(tx, gtx);
+
+ handleCommitRollback(ctx, rollbackCommand);
+ }
+ catch (Throwable e)
+ {
+ log.warn("Rollback had a problem", e);
+ }
+ finally
+ {
+ rollbackTransactions.remove(tx);
+ }
+ }
+
+ private boolean isOnePhaseCommit()
+ {
+ if (!configuration.getCacheMode().isSynchronous())
+ {
+ // this is a REPL_ASYNC call - do 1-phase commit. break!
+ if (trace) log.trace("This is a REPL_ASYNC call (1 phase commit) - do nothing for beforeCompletion()");
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Handles a local prepare - invoked by the sync handler. Tests if the current tx matches the gtx passed in to the
+ * method call and passes the prepare() call up the chain.
+ */
+ @SuppressWarnings("deprecation")
+ public Object runPreparePhase(InvocationContext ctx, GlobalTransaction gtx, List<VisitableCommand> modifications) throws Throwable
+ {
+ // running a 2-phase commit.
+ VisitableCommand prepareCommand = buildPrepareCommand(gtx, modifications, false);
+
+ Object result;
+
+ // Is there a local transaction associated with GTX ?
+ Transaction ltx = ctx.getTransaction();
+
+ //if ltx is not null and it is already running
+ Transaction currentTransaction = txManager.getTransaction();
+ if (currentTransaction != null && ltx != null && currentTransaction.equals(ltx))
+ {
+ VisitableCommand originalCommand = ctx.getCommand();
+ ctx.setCommand(prepareCommand);
+ try
+ {
+ result = invokeNextInterceptor(ctx, prepareCommand);
+ }
+ finally
+ {
+ ctx.setCommand(originalCommand);
+ }
+ }
+ else
+ {
+ log.warn("Local transaction does not exist or does not match expected transaction " + gtx);
+ throw new CacheException(" local transaction " + ltx + " does not exist or does not match expected transaction " + gtx);
+ }
+ return result;
+ }
+
+ // --------------------------------------------------------------
+ // Private helper methods
+ // --------------------------------------------------------------
+
+ protected void assertTxIsStillValid(Transaction tx)
+ {
+ if (!TransactionTable.isActive(tx))
+ {
+ try
+ {
+ throw new ReplicationException("prepare() failed -- local transaction status is not STATUS_ACTIVE; is " + tx.getStatus());
+ }
+ catch (SystemException e)
+ {
+ throw new ReplicationException("prepare() failed -- local transaction status is not STATUS_ACTIVE; Unable to retrieve transaction status.");
+ }
+ }
+ }
+
+ /**
+ * Creates a gtx (if one doesnt exist), a sync handler, and registers the tx.
+ */
+ private GlobalTransaction registerTransaction(Transaction tx, InvocationContext ctx) throws Exception
+ {
+ GlobalTransaction gtx;
+
+ if (TransactionTable.isValid(tx) && transactions.add(tx))
+ {
+ gtx = txTable.getCurrentTransaction(tx, true);
+ TransactionContext transactionContext;
+ if (ctx.getGlobalTransaction() == null)
+ {
+ ctx.setGlobalTransaction(gtx);
+ transactionContext = txTable.get(gtx);
+ ctx.setTransactionContext(transactionContext);
+ }
+ else
+ {
+ transactionContext = ctx.getTransactionContext();
+ }
+ if (gtx.isRemote())
+ {
+ // should be no need to register a handler since this a remotely initiated globalTransaction
+ if (trace) log.trace("is a remotely initiated gtx so no need to register a tx for it");
+ }
+ else
+ {
+ if (trace) log.trace("Registering sync handler for tx " + tx + ", gtx " + gtx);
+
+ // see the comment in the LocalSyncHandler for the last isOriginLocal param.
+ LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, transactionContext, !ctx.isOriginLocal());
+ registerHandler(tx, myHandler, ctx);
+ }
+ }
+ else if ((gtx = rollbackTransactions.get(tx)) != null)
+ {
+ if (trace) log.trace("Transaction " + tx + " is already registered and is rolling back.");
+ }
+ else
+ {
+ if (trace) log.trace("Transaction " + tx + " is already registered.");
+ }
+ return gtx;
+ }
+
+ /**
+ * Registers a sync hander against a tx.
+ */
+ private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx) throws Exception
+ {
+ OrderedSynchronizationHandler orderedHandler = ctx.getTransactionContext().getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
+
+ if (trace) log.trace("registering for TX completion: SynchronizationHandler(" + handler + ")");
+
+ orderedHandler.registerAtHead(handler);// needs to be invoked first on TX commit
+
+ notifier.notifyTransactionRegistered(tx, ctx);
+ }
+
+ /**
+ * Creates and starts a local tx
+ *
+ * @throws Exception
+ */
+ protected Transaction createLocalTx() throws Exception
+ {
+ if (trace)
+ {
+ log.trace("Creating transaction for thread " + Thread.currentThread());
+ }
+ Transaction localTx;
+ if (txManager == null) throw new Exception("Failed to create local transaction; TransactionManager is null");
+ txManager.begin();
+ localTx = txManager.getTransaction();
+ return localTx;
+ }
+
+ // ------------------------------------------------------------------------
+ // Synchronization classes
+ // ------------------------------------------------------------------------
+
+ // this controls the whole transaction
+
+ private class RemoteSynchronizationHandler implements Synchronization
+ {
+ Transaction tx = null;
+ GlobalTransaction gtx = null;
+ List<VisitableCommand> modifications = null;
+ TransactionContext transactionContext = null;
+ protected InvocationContext ctx; // the context for this call.
+
+ RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionContext entry)
+ {
+ this.gtx = gtx;
+ this.tx = tx;
+ this.transactionContext = entry;
+ }
+
+ public void beforeCompletion()
+ {
+ if (trace) log.trace("Running beforeCompletion on gtx " + gtx);
+
+ if (transactionContext == null)
+ {
+ log.error("Transaction has a null transaction entry - beforeCompletion() will fail.");
+ throw new IllegalStateException("cannot find transaction entry for " + gtx);
+ }
+
+ modifications = transactionContext.getModifications();
+ ctx = invocationContextContainer.get();
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+
+ if (ctx.isOptionsUninitialised() && transactionContext.getOption() != null)
+ ctx.setOptionOverrides(transactionContext.getOption());
+
+ assertCanContinue();
+
+ ctx.setOriginLocal(false);
+ }
+
+ // this should really not be done here -
+ // it is supposed to be post commit not actually run the commit
+ public void afterCompletion(int status)
+ {
+ // could happen if a rollback is called and beforeCompletion() doesn't get called.
+ if (ctx == null)
+ {
+ ctx = invocationContextContainer.get();
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+
+ if (ctx.isOptionsUninitialised() && transactionContext != null && transactionContext.getOption() != null)
+ {
+ // use the options from the transaction entry instead
+ ctx.setOptionOverrides(transactionContext.getOption());
+ }
+ }
+
+ try
+ {
+ assertCanContinue();
+
+ try
+ {
+ if (txManager.getTransaction() != null && !txManager.getTransaction().equals(tx)) txManager.resume(tx);
+ }
+ catch (Exception e)
+ {
+ log.error("afterCompletion error: " + status, e);
+ }
+
+ if (trace) log.trace("calling aftercompletion for " + gtx);
+
+ // set any transaction wide options as current for this thread.
+ if (transactionContext != null)
+ {
+ // this should ideally be set in beforeCompletion(), after compacting the list.
+ if (modifications == null) modifications = transactionContext.getModifications();
+ ctx.setOptionOverrides(transactionContext.getOption());
+ }
+ if (tx != null) transactions.remove(tx);
+
+ switch (status)
+ {
+ case Status.STATUS_COMMITTED:
+ boolean onePhaseCommit = isOnePhaseCommit();
+ if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
+ runCommitPhase(ctx, gtx, modifications, onePhaseCommit);
+ log.debug("Finished commit phase");
+ break;
+ case Status.STATUS_UNKNOWN:
+ log.warn("Received JTA STATUS_UNKNOWN in afterCompletion()! XA resources may not be in sync. The app should manually clean up resources at this point.");
+ case Status.STATUS_MARKED_ROLLBACK:
+ case Status.STATUS_ROLLEDBACK:
+ log.debug("Running rollback phase");
+ runRollbackPhase(ctx, gtx, tx);
+ log.debug("Finished rollback phase");
+ break;
+
+ default:
+ throw new IllegalStateException("illegal status: " + status);
+ }
+ }
+ catch (Exception th)
+ {
+ log.trace("Caught exception ", th);
+
+ }
+ finally
+ {
+ // clean up the tx table
+ txTable.remove(gtx);
+ txTable.remove(tx);
+ setTransactionalContext(null, null, null, ctx);
+ cleanupInternalState();
+ }
+ }
+
+ private void assertCanContinue()
+ {
+ if (!componentRegistry.invocationsAllowed(true) && (ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isSkipCacheStatusCheck()))
+ throw new IllegalStateException("Cache not in STARTED state!");
+ }
+
+ /**
+ * Cleans out (nullifies) member variables held by the sync object for easier gc. Could be (falsely) seen as a mem
+ * leak if the TM implementation hangs on to the synchronizations for an unnecessarily long time even after the tx
+ * completes. See JBCACHE-1007.
+ */
+ private void cleanupInternalState()
+ {
+ tx = null;
+ gtx = null;
+ modifications = null;
+ if (transactionContext != null) transactionContext.reset();
+ transactionContext = null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TxInterceptor.RemoteSynchronizationHandler(gtx=" + gtx + ", tx=" + getTxAsString() + ")";
+ }
+
+ protected String getTxAsString()
+ {
+ // JBCACHE-1114 -- don't call toString() on tx or it can lead to stack overflow
+ if (tx == null)
+ return null;
+
+ return tx.getClass().getName() + "@" + System.identityHashCode(tx);
+ }
+ }
+
+ private class LocalSynchronizationHandler extends RemoteSynchronizationHandler
+ {
+ private boolean localRollbackOnly = true;
+ // a VERY strange situation where a tx has remote origins, but since certain buddy group org methods perform local
+ // cleanups even when remotely triggered, and optimistic locking is used, you end up with an implicit local tx.
+ // This is STILL remotely originating though and this needs to be made explicit here.
+ // this can be checked by inspecting the InvocationContext.isOriginLocal() at the time of registering the sync.
+ private boolean remoteLocal = false;
+ private Option originalOptions, transactionalOptions;
+
+ /**
+ * A Synchronization for locally originating txs.
+ * <p/>
+ * a VERY strange situation where a tx has remote origins, but since certain buddy group org methods perform local
+ * cleanups even when remotely triggered, and optimistic locking is used, you end up with an implicit local tx.
+ * This is STILL remotely originating though and this needs to be made explicit here.
+ * this can be checked by inspecting the InvocationContext.isOriginLocal() at the time of registering the sync.
+ *
+ * @param gtx
+ * @param tx
+ * @param remoteLocal
+ */
+ LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionContext transactionContext, boolean remoteLocal)
+ {
+ super(gtx, tx, transactionContext);
+ this.remoteLocal = remoteLocal;
+ }
+
+ @Override
+ public void beforeCompletion()
+ {
+ super.beforeCompletion();
+ ctx.setOriginLocal(!remoteLocal); // this is the LOCAL sync handler after all!
+ // fetch the modifications before the transaction is committed
+ // (and thus removed from the txTable)
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+ if (!transactionContext.hasModifications())
+ {
+ if (trace) log.trace("No modifications in this tx. Skipping beforeCompletion()");
+ modifications = Collections.emptyList();
+ return;
+ }
+ else
+ {
+ modifications = transactionContext.getModifications();
+ }
+
+ // set any transaction wide options as current for this thread, caching original options that would then be reset
+ originalOptions = ctx.getOptionOverrides();
+ transactionalOptions = transactionContext.getOption();
+ ctx.setOptionOverrides(transactionalOptions);
+
+ try
+ {
+ switch (tx.getStatus())
+ {
+ // if we are active or preparing then we can go ahead
+ case Status.STATUS_ACTIVE:
+ case Status.STATUS_PREPARING:
+ // run a prepare call.
+
+ Object result = isOnePhaseCommit() ? null : runPreparePhase(ctx, gtx, modifications);
+
+ if (result instanceof Throwable)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Transaction needs to be rolled back - the cache returned an instance of Throwable for this prepare call (tx=" + tx + " and gtx=" + gtx + ")", (Throwable) result);
+ tx.setRollbackOnly();
+ throw (Throwable) result;
+ }
+ break;
+ default:
+ throw new CacheException("transaction " + tx + " in status " + tx.getStatus() + " unable to start transaction");
+ }
+ }
+ catch (Throwable t)
+ {
+ if (log.isWarnEnabled()) log.warn("Caught exception, will now set transaction to roll back", t);
+ try
+ {
+ tx.setRollbackOnly();
+ }
+ catch (SystemException se)
+ {
+ throw new RuntimeException("setting tx rollback failed ", se);
+ }
+ if (t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ else
+ throw new RuntimeException("", t);
+ }
+ finally
+ {
+ localRollbackOnly = false;
+ setTransactionalContext(null, null, null, ctx);
+ ctx.setOptionOverrides(originalOptions);
+ }
+ }
+
+ @Override
+ public void afterCompletion(int status)
+ {
+ // could happen if a rollback is called and beforeCompletion() doesn't get called.
+ if (ctx == null) ctx = invocationContextContainer.get();
+ ctx.setLocalRollbackOnly(localRollbackOnly);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+ if (transactionalOptions != null) ctx.setOptionOverrides(transactionalOptions);
+ try
+ {
+ super.afterCompletion(status);
+ }
+ finally
+ {
+ ctx.setOptionOverrides(originalOptions);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TxInterceptor.LocalSynchronizationHandler(gtx=" + gtx + ", tx=" + getTxAsString() + ")";
+ }
+ }
+
+ @ManagedOperation
+ public void resetStatistics()
+ {
+ prepares = 0;
+ commits = 0;
+ rollbacks = 0;
+ }
+
+ @ManagedOperation
+ public Map<String, Object> dumpStatistics()
+ {
+ Map<String, Object> retval = new HashMap<String, Object>(3);
+ retval.put("Prepares", prepares);
+ retval.put("Commits", commits);
+ retval.put("Rollbacks", rollbacks);
+ return retval;
+ }
+
+ @ManagedAttribute
+ public boolean getStatisticsEnabled()
+ {
+ return this.statsEnabled;
+ }
+
+ @ManagedAttribute
+ public void setStatisticsEnabled(boolean enabled)
+ {
+ this.statsEnabled = enabled;
+ }
+
+ @ManagedAttribute(description = "number of transaction prepares")
+ public long getPrepares()
+ {
+ return prepares;
+ }
+
+ @ManagedAttribute(description = "number of transaction commits")
+ public long getCommits()
+ {
+ return commits;
+ }
+
+ @ManagedAttribute(description = "number of transaction rollbacks")
+ public long getRollbacks()
+ {
+ return rollbacks;
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/TxInterceptor.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -23,8 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.invocation.InvocationContextContainer;
-import org.jboss.cache.lock.MVCCLockManager;
import org.jboss.cache.util.concurrent.locks.LockContainer;
import org.jboss.cache.util.concurrent.locks.OwnableReentrantLock;
import org.jboss.cache.util.concurrent.locks.OwnableReentrantLockContainer;
@@ -33,6 +31,7 @@
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
import javax.transaction.TransactionManager;
import java.util.List;
@@ -53,7 +52,7 @@
LockContainer<Object> lockContainer;
private TransactionManager transactionManager;
private InvocationContextContainer invocationContextContainer;
- private static final Log log = LogFactory.getLog(MVCCLockManager.class);
+ private static final Log log = LogFactory.getLog(StripedLockManager.class);
private static final boolean trace = log.isTraceEnabled();
@Inject
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntry.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntry.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.mvcc;
-import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
import java.util.Map.Entry;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -24,8 +24,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.lock.TimeoutException;
-import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.EntryFactory;
import org.jboss.starobrno.factories.annotations.Inject;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/NullMarkerEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/NullMarkerEntry.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/NullMarkerEntry.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.mvcc;
-import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.container.DataContainer;
/**
* A marker node to represent a null node for repeatable read, so that a read that returns a null can continue to return
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/ReadCommittedEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/ReadCommittedEntry.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/ReadCommittedEntry.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.container.DataContainer;
import org.jboss.starobrno.context.InvocationContext;
import static org.jboss.starobrno.mvcc.ReadCommittedEntry.Flags.*;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -25,7 +25,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.mvcc.RepeatableReadNode;
import org.jboss.starobrno.CacheException;
-import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.container.DataContainer;
import static org.jboss.starobrno.mvcc.ReadCommittedEntry.Flags.CHANGED;
import java.util.Map.Entry;
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/notifications (from rev 6891, core/branches/flat/src/main/java/org/jboss/starobrno/notifier)
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/Notifier.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/Notifier.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -19,11 +19,11 @@
* 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.notifier;
+package org.jboss.starobrno.notifications;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.notifier.event.NodeModifiedEvent;
+import org.jboss.starobrno.notifications.event.NodeModifiedEvent;
import org.jgroups.View;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifier/NotifierImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/NotifierImpl.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -19,7 +19,7 @@
* 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.notifier;
+package org.jboss.starobrno.notifications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -43,7 +43,7 @@
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.factories.annotations.Stop;
import org.jboss.starobrno.mvcc.MVCCEntry;
-import org.jboss.starobrno.notifier.event.NodeModifiedEvent;
+import org.jboss.starobrno.notifications.event.NodeModifiedEvent;
import org.jgroups.View;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/NodeModifiedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifier/event/NodeModifiedEvent.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifications/event/NodeModifiedEvent.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -19,7 +19,7 @@
* 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.notifier.event;
+package org.jboss.starobrno.notifications.event;
import org.jboss.cache.notifications.event.NodeEvent;
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java (from rev 6891, core/branches/flat/src/main/java/org/jboss/starobrno/RPCManager.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,154 @@
+/*
+ * 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.remoting;
+
+import org.jboss.cache.Fqn;
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.blocks.RspFilter;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * Provides a mechanism for communicating with other caches in the cluster. For now this is based on JGroups as an underlying
+ * transport, and in future more transport options may become available.
+ * <p/>
+ * Implementations have a simple lifecycle:
+ * <ul>
+ * <li>start() - starts the underlying channel based on configuration options injected, and connects the channel</li>
+ * <li>disconnect() - disconnects the channel</li>
+ * <li>stop() - stops the dispatcher and releases resources</li>
+ * </ul>
+ *
+ * @author Manik Surtani
+ * @since 2.1.0
+ */
+public interface RPCManager
+{
+ /**
+ * Disconnects and closes the underlying JGroups channel.
+ */
+ void disconnect();
+
+ /**
+ * Stops the RPCDispatcher and frees resources. Closes and disconnects the underlying JGroups channel if this is
+ * still open/connected.
+ */
+ void stop();
+
+ /**
+ * Starts the RPCManager by connecting the underlying JGroups channel (if configured for replication). Connecting
+ * the channel may also involve state transfer (if configured) so the interceptor chain should be started and
+ * available before this method is called.
+ */
+ void start();
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param responseFilter a response filter with which to filter out failed/unwanted/invalid responses.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param mode the group request mode to use. See {@link org.jgroups.blocks.GroupRequest}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, int mode, long timeout, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * Invokes an RPC call on other caches in the cluster.
+ *
+ * @param recipients a list of Addresses to invoke the call on. If this is null, the call is broadcast to the entire cluster.
+ * @param cacheCommand the cache command to invoke
+ * @param synchronous if true, sets group request mode to {@link org.jgroups.blocks.GroupRequest#GET_ALL}, and if false sets it to {@link org.jgroups.blocks.GroupRequest#GET_NONE}.
+ * @param timeout a timeout after which to throw a replication exception.
+ * @param useOutOfBandMessage if true, the message is put on JGroups' OOB queue. See JGroups docs for more info.
+ * @return a list of responses from each member contacted.
+ * @throws Exception in the event of problems.
+ */
+ List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand cacheCommand, boolean synchronous, long timeout, boolean useOutOfBandMessage) throws Exception;
+
+ /**
+ * @return true if the current Channel is the coordinator of the cluster.
+ */
+ boolean isCoordinator();
+
+ /**
+ * @return the Address of the current coordinator.
+ */
+ Address getCoordinator();
+
+ /**
+ * Retrieves the local JGroups channel's address
+ *
+ * @return an Address
+ */
+ Address getLocalAddress();
+
+ /**
+ * Returns a defensively copied list of members in the current cluster view.
+ */
+ List<Address> getMembers();
+
+ /**
+ * Retrieves partial state from remote instances.
+ *
+ * @param sources sources to consider for a state transfer
+ * @param sourceTarget Fqn on source to retrieve state for
+ * @param integrationTarget integration point on local cache to apply state
+ * @throws Exception in the event of problems
+ */
+ void fetchPartialState(List<Address> sources, Fqn sourceTarget, Fqn integrationTarget) throws Exception;
+
+ /**
+ * Retrieves partial state from remote instances.
+ *
+ * @param sources sources to consider for a state transfer
+ * @param subtree Fqn subtree to retrieve. Will be integrated at the same point.
+ * @throws Exception in the event of problems
+ */
+ void fetchPartialState(List<Address> sources, Fqn subtree) throws Exception;
+
+ /**
+ * Retrieves the Channel
+ *
+ * @return a channel
+ */
+ Channel getChannel();
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManager.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/RPCManagerImpl.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,831 @@
+/*
+ * 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.remoting;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.SuspectException;
+import org.jboss.cache.jmx.annotations.MBean;
+import org.jboss.cache.jmx.annotations.ManagedAttribute;
+import org.jboss.cache.jmx.annotations.ManagedOperation;
+import org.jboss.cache.lock.TimeoutException;
+import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
+import org.jboss.cache.marshall.Marshaller;
+import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
+import org.jboss.cache.statetransfer.DefaultStateTransferManager;
+import org.jboss.cache.util.concurrent.ReclosableLatch;
+import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.interceptors.InterceptorChain;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.lock.LockManager;
+import org.jboss.starobrno.notifications.Notifier;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.transaction.TransactionTable;
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.ChannelException;
+import org.jgroups.ChannelFactory;
+import org.jgroups.ExtendedMembershipListener;
+import org.jgroups.JChannel;
+import org.jgroups.StateTransferException;
+import org.jgroups.View;
+import org.jgroups.blocks.GroupRequest;
+import org.jgroups.blocks.RspFilter;
+import org.jgroups.protocols.TP;
+import org.jgroups.stack.ProtocolStack;
+import org.jgroups.util.Rsp;
+import org.jgroups.util.RspList;
+
+import javax.transaction.TransactionManager;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Manager that handles all RPC calls between JBoss Cache instances
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@MBean(objectName = "RPCManager")
+public class RPCManagerImpl implements RPCManager
+{
+ private Channel channel;
+ private final Log log = LogFactory.getLog(RPCManagerImpl.class);
+ private List<Address> members;
+ private long replicationCount;
+ private long replicationFailures;
+ private boolean statisticsEnabled = false;
+
+ private final Object coordinatorLock = new Object();
+ /**
+ * True if this Cache is the coordinator.
+ */
+ private volatile boolean coordinator = false;
+ /**
+ * Thread gate used to block Dispatcher during JGroups FLUSH protocol
+ */
+ private final ReclosableLatch flushBlockGate = new ReclosableLatch();
+ /**
+ * JGroups RpcDispatcher in use.
+ */
+ private CommandAwareRpcDispatcher rpcDispatcher = null;
+
+ /**
+ * JGroups message listener.
+ */
+ private ChannelMessageListener messageListener;
+ private Configuration configuration;
+ private Notifier notifier;
+ private CacheSPI spi;
+ private InvocationContextContainer invocationContextContainer;
+ private final boolean trace = log.isTraceEnabled();
+ private Marshaller marshaller;
+ private TransactionManager txManager;
+ private TransactionTable txTable;
+ private InterceptorChain interceptorChain;
+
+ private boolean isUsingBuddyReplication;
+ private boolean isInLocalMode;
+ private ComponentRegistry componentRegistry;
+ private LockManager lockManager;
+
+ @Inject
+ public void setupDependencies(ChannelMessageListener messageListener, Configuration configuration, Notifier notifier,
+ Marshaller marshaller, TransactionTable txTable,
+ TransactionManager txManager, InvocationContextContainer container, InterceptorChain interceptorChain,
+ ComponentRegistry componentRegistry, LockManager lockManager)
+ {
+ this.messageListener = messageListener;
+ this.configuration = configuration;
+ this.notifier = notifier;
+ // TODO: Inject cacheSPI when we are ready
+// this.spi = spi;
+ this.marshaller = marshaller;
+ this.txManager = txManager;
+ this.txTable = txTable;
+ this.invocationContextContainer = container;
+ this.interceptorChain = interceptorChain;
+ this.componentRegistry = componentRegistry;
+ this.lockManager = lockManager;
+ }
+
+ // ------------ START: Lifecycle methods ------------
+
+ @Start(priority = 15)
+ public void start()
+ {
+ switch (configuration.getCacheMode())
+ {
+ case LOCAL:
+ log.debug("cache mode is local, will not create the channel");
+ isInLocalMode = true;
+ isUsingBuddyReplication = false;
+ break;
+ case REPL_SYNC:
+ case REPL_ASYNC:
+ case INVALIDATION_ASYNC:
+ case INVALIDATION_SYNC:
+ isInLocalMode = false;
+ isUsingBuddyReplication = configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled();
+ if (log.isDebugEnabled()) log.debug("Cache mode is " + configuration.getCacheMode());
+
+ boolean fetchState = shouldFetchStateOnStartup();
+ initialiseChannelAndRpcDispatcher(fetchState);
+
+ if (fetchState)
+ {
+ try
+ {
+ long start = System.currentTimeMillis();
+ // connect and state transfer
+ channel.connect(configuration.getClusterName(), null, null, configuration.getStateRetrievalTimeout());
+ //if I am not the only and the first member than wait for a state to arrive
+ if (getMembers().size() > 1) messageListener.waitForState();
+
+ if (log.isDebugEnabled())
+ log.debug("connected, state was retrieved successfully (in " + (System.currentTimeMillis() - start) + " milliseconds)");
+ }
+ catch (StateTransferException ste)
+ {
+ // make sure we disconnect from the channel before we throw this exception!
+ // JBCACHE-761
+ disconnect();
+ throw new CacheException("Unable to fetch state on startup", ste);
+ }
+ catch (ChannelException e)
+ {
+ throw new CacheException("Unable to connect to JGroups channel", e);
+ }
+ catch (Exception ex)
+ {
+ throw new CacheException("Unable to fetch state on startup", ex);
+ }
+ }
+ else
+ {
+ //otherwise just connect
+ try
+ {
+ channel.connect(configuration.getClusterName());
+ }
+ catch (ChannelException e)
+ {
+ throw new CacheException("Unable to connect to JGroups channel", e);
+ }
+ }
+ if (log.isInfoEnabled()) log.info("Cache local address is " + getLocalAddress());
+ }
+ }
+
+ public void disconnect()
+ {
+ if (channel != null && channel.isOpen())
+ {
+ log.info("Disconnecting and closing the Channel");
+ channel.disconnect();
+ channel.close();
+ }
+ }
+
+ @Stop(priority = 8)
+ public void stop()
+ {
+ try
+ {
+ disconnect();
+ }
+ catch (Exception toLog)
+ {
+ log.error("Problem closing channel; setting it to null", toLog);
+ }
+
+ channel = null;
+ configuration.getRuntimeConfig().setChannel(null);
+ if (rpcDispatcher != null)
+ {
+ log.info("Stopping the RpcDispatcher");
+ rpcDispatcher.stop();
+ }
+
+ if (members != null) members = null;
+
+ coordinator = false;
+
+ rpcDispatcher = null;
+ }
+
+ /**
+ * @return true if we need to fetch state on startup. I.e., initiate a state transfer.
+ */
+ private boolean shouldFetchStateOnStartup()
+ {
+ boolean loaderFetch = configuration.getCacheLoaderConfig() != null && configuration.getCacheLoaderConfig().isFetchPersistentState();
+ return !configuration.isInactiveOnStartup() && !isUsingBuddyReplication && (configuration.isFetchInMemoryState() || loaderFetch);
+ }
+
+ @SuppressWarnings("deprecation")
+ private void initialiseChannelAndRpcDispatcher(boolean fetchState) throws CacheException
+ {
+ channel = configuration.getRuntimeConfig().getChannel();
+ if (channel == null)
+ {
+ // Try to create a multiplexer channel
+ channel = getMultiplexerChannel();
+
+ if (channel != null)
+ {
+ ReflectionUtil.setValue(configuration, "accessible", true);
+ configuration.setUsingMultiplexer(true);
+ if (log.isDebugEnabled())
+ log.debug("Created Multiplexer Channel for cache cluster " + configuration.getClusterName() + " using stack " + configuration.getMultiplexerStack());
+ }
+ else
+ {
+ try
+ {
+ if (configuration.getClusterConfig() == null)
+ {
+ log.debug("setting cluster properties to default value");
+ channel = new JChannel(configuration.getDefaultClusterConfig());
+ }
+ else
+ {
+ if (trace)
+ {
+ log.trace("Cache cluster properties: " + configuration.getClusterConfig());
+ }
+ channel = new JChannel(configuration.getClusterConfig());
+ }
+ }
+ catch (ChannelException e)
+ {
+ throw new CacheException(e);
+ }
+ }
+
+ configuration.getRuntimeConfig().setChannel(channel);
+ }
+
+ // Channel.LOCAL *must* be set to false so we don't see our own messages - otherwise invalidations targeted at
+ // remote instances will be received by self.
+ channel.setOpt(Channel.LOCAL, false);
+ channel.setOpt(Channel.AUTO_RECONNECT, true);
+ channel.setOpt(Channel.AUTO_GETSTATE, fetchState);
+ channel.setOpt(Channel.BLOCK, true);
+ // todo fix me
+ /*
+ if (configuration.isUseRegionBasedMarshalling())
+ {
+ rpcDispatcher = new InactiveRegionAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(),
+ spi, invocationContextContainer, interceptorChain, componentRegistry);
+ }
+ else
+ {
+ rpcDispatcher = new CommandAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(),
+ invocationContextContainer, invocationContextContainer, interceptorChain, componentRegistry);
+ }
+ */
+ checkAppropriateConfig();
+ rpcDispatcher.setRequestMarshaller(marshaller);
+ rpcDispatcher.setResponseMarshaller(marshaller);
+ }
+
+ public Channel getChannel()
+ {
+ return channel;
+ }
+
+
+ private JChannel getMultiplexerChannel() throws CacheException
+ {
+ String stackName = configuration.getMultiplexerStack();
+
+ RuntimeConfig rtc = configuration.getRuntimeConfig();
+ ChannelFactory channelFactory = rtc.getMuxChannelFactory();
+ JChannel muxchannel = null;
+
+ if (channelFactory != null)
+ {
+ try
+ {
+ muxchannel = (JChannel) channelFactory.createMultiplexerChannel(stackName, configuration.getClusterName());
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Failed to create multiplexed channel using stack " + stackName, e);
+ }
+ }
+
+ return muxchannel;
+ }
+
+
+ @Deprecated
+ private void removeLocksForDeadMembers(NodeSPI node, List deadMembers)
+ {
+ Set<GlobalTransaction> deadOwners = new HashSet<GlobalTransaction>();
+ Object owner = lockManager.getOwner(node);
+
+ // todo fix me
+ /*
+ if (isLockOwnerDead(owner, deadMembers)) deadOwners.add((GlobalTransaction) owner);
+
+
+ for (Object readOwner : lockManager.getReadOwners(node))
+ {
+ if (isLockOwnerDead(readOwner, deadMembers)) deadOwners.add((GlobalTransaction) readOwner);
+ }
+ */
+
+ for (GlobalTransaction deadOwner : deadOwners)
+ {
+ boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
+ // TODO: Fix me!!!
+// boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+ boolean broken = true;
+
+ if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);
+ }
+
+ // Recursively unlock children
+ for (Object child : node.getChildrenDirect())
+ {
+ removeLocksForDeadMembers((NodeSPI) child, deadMembers);
+ }
+ }
+
+
+ /**
+ * Only used with MVCC.
+ */
+ // TODO: Fix me
+ /*
+ private void removeLocksForDeadMembers(InternalNode<?, ?> node, List deadMembers)
+ {
+ Set<GlobalTransaction> deadOwners = new HashSet<GlobalTransaction>();
+ Object owner = lockManager.getWriteOwner(node.getFqn());
+
+ if (isLockOwnerDead(owner, deadMembers)) deadOwners.add((GlobalTransaction) owner);
+
+ // MVCC won't have any read locks.
+
+ for (GlobalTransaction deadOwner : deadOwners)
+ {
+ boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
+// boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+ boolean broken = true; // TODO fix me!!
+
+ if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);
+ }
+
+ // Recursively unlock children
+ for (InternalNode child : node.getChildren()) removeLocksForDeadMembers(child, deadMembers);
+ }
+
+ private boolean isLockOwnerDead(Object owner, List deadMembers)
+ {
+ boolean result = false;
+ if (owner != null && owner instanceof GlobalTransaction)
+ {
+ Object addr = ((GlobalTransaction) owner).getAddress();
+ result = deadMembers.contains(addr);
+ }
+ return result;
+ }
+ */
+
+ // ------------ END: Lifecycle methods ------------
+
+ // ------------ START: RPC call methods ------------
+ public List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand command, int mode, long timeout, boolean useOutOfBandMessage) throws Exception
+ {
+ return callRemoteMethods(recipients, command, mode, timeout, null, useOutOfBandMessage);
+ }
+
+ public List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand command, boolean synchronous, long timeout, boolean useOutOfBandMessage) throws Exception
+ {
+ return callRemoteMethods(recipients, command, synchronous ? GroupRequest.GET_ALL : GroupRequest.GET_NONE, timeout, useOutOfBandMessage);
+ }
+
+ public List<Object> callRemoteMethods(Vector<Address> recipients, ReplicableCommand command, int mode, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
+ {
+ boolean success = true;
+ try
+ {
+ // short circuit if we don't have an RpcDispatcher!
+ if (rpcDispatcher == null) return null;
+ int modeToUse = mode;
+ int preferredMode;
+ if ((preferredMode = spi.getInvocationContext().getOptionOverrides().getGroupRequestMode()) > -1)
+ modeToUse = preferredMode;
+ if (trace)
+ log.trace("callRemoteMethods(): valid members are " + recipients + " methods: " + command + " Using OOB? " + useOutOfBandMessage);
+ if (channel.flushSupported())
+ {
+ if (!flushBlockGate.await(configuration.getStateRetrievalTimeout(), TimeUnit.MILLISECONDS))
+ throw new TimeoutException("State retrieval timed out waiting for flush unblock.");
+ }
+ useOutOfBandMessage = false;
+ // todo fix me!!
+ RspList rsps = null;//rpcDispatcher.invokeRemoteCommands(recipients, command, modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage, responseFilter);
+ if (mode == GroupRequest.GET_NONE) return Collections.emptyList();// async case
+ if (trace)
+ log.trace("(" + getLocalAddress() + "): responses for method " + command.getClass().getSimpleName() + ":\n" + rsps);
+ // short-circuit no-return-value calls.
+ if (rsps == null) return Collections.emptyList();
+ List<Object> retval = new ArrayList<Object>(rsps.size());
+ for (Rsp rsp : rsps.values())
+ {
+ if (rsp.wasSuspected() || !rsp.wasReceived())
+ {
+ CacheException ex;
+ if (rsp.wasSuspected())
+ {
+ ex = new SuspectException("Suspected member: " + rsp.getSender());
+ }
+ else
+ {
+ ex = new TimeoutException("Replication timeout for " + rsp.getSender());
+ }
+ retval.add(new ReplicationException("rsp=" + rsp, ex));
+ success = false;
+ }
+ else
+ {
+ Object value = rsp.getValue();
+ if (value instanceof Exception && !(value instanceof ReplicationException))
+ {
+ // if we have any application-level exceptions make sure we throw them!!
+ if (trace) log.trace("Recieved exception'" + value + "' from " + rsp.getSender());
+ throw (Exception) value;
+ }
+ retval.add(value);
+ success = true;
+ }
+ }
+ return retval;
+ }
+ catch (Exception e)
+ {
+ success = false;
+ throw e;
+ }
+ finally
+ {
+ computeStats(success);
+ }
+ }
+
+ // ------------ START: Partial state transfer methods ------------
+
+ public void fetchPartialState(List<Address> sources, Fqn sourceTarget, Fqn integrationTarget) throws Exception
+ {
+ String encodedStateId = sourceTarget + DefaultStateTransferManager.PARTIAL_STATE_DELIMITER + integrationTarget;
+ fetchPartialState(sources, encodedStateId);
+ }
+
+ public void fetchPartialState(List<Address> sources, Fqn subtree) throws Exception
+ {
+ if (subtree == null)
+ {
+ throw new IllegalArgumentException("Cannot fetch partial state. Null subtree.");
+ }
+ fetchPartialState(sources, subtree.toString());
+ }
+
+ private void fetchPartialState(List<Address> sources, String stateId) throws Exception
+ {
+ if (sources == null || sources.isEmpty() || stateId == null)
+ {
+ // should this really be throwing an exception? Are there valid use cases where partial state may not be available? - Manik
+ // Yes -- cache is configured LOCAL but app doesn't know it -- Brian
+ //throw new IllegalArgumentException("Cannot fetch partial state, targets are " + sources + " and stateId is " + stateId);
+ if (log.isWarnEnabled())
+ log.warn("Cannot fetch partial state, targets are " + sources + " and stateId is " + stateId);
+ return;
+ }
+
+ List<Address> targets = new LinkedList<Address>(sources);
+
+ //skip *this* node as a target
+ targets.remove(getLocalAddress());
+
+ if (targets.isEmpty())
+ {
+ // Definitely no exception here -- this happens every time the 1st node in the
+ // cluster activates a region!! -- Brian
+ if (log.isDebugEnabled()) log.debug("Cannot fetch partial state. There are no target members specified");
+ return;
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from members " + targets);
+ boolean successfulTransfer = false;
+ for (Address target : targets)
+ {
+ try
+ {
+ if (log.isDebugEnabled())
+ log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from member " + target);
+ messageListener.setStateSet(false);
+ successfulTransfer = channel.getState(target, stateId, configuration.getStateRetrievalTimeout());
+ if (successfulTransfer)
+ {
+ try
+ {
+ messageListener.waitForState();
+ }
+ catch (Exception transferFailed)
+ {
+ if (log.isTraceEnabled()) log.trace("Error while fetching state", transferFailed);
+ successfulTransfer = false;
+ }
+ }
+ if (log.isDebugEnabled())
+ log.debug("Node " + getLocalAddress() + " fetching partial state " + stateId + " from member " + target + (successfulTransfer ? " successful" : " failed"));
+ if (successfulTransfer) break;
+ }
+ catch (IllegalStateException ise)
+ {
+ // thrown by the JGroups channel if state retrieval fails.
+ if (log.isInfoEnabled())
+ log.info("Channel problems fetching state. Continuing on to next provider. ", ise);
+ }
+ }
+
+ if (!successfulTransfer)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Node " + getLocalAddress() + " could not fetch partial state " + stateId + " from any member " + targets);
+ }
+
+ }
+
+ // ------------ END: Partial state transfer methods ------------
+
+ // ------------ START: Informational methods ------------
+
+ public Address getLocalAddress()
+ {
+ return channel != null ? channel.getLocalAddress() : null;
+ }
+
+ public List<Address> getMembers()
+ {
+ if (isInLocalMode) return null;
+ if (members == null)
+ return Collections.emptyList();
+ else
+ return members;
+ }
+
+ public boolean isCoordinator()
+ {
+ return coordinator;
+ }
+
+ public Address getCoordinator()
+ {
+ if (channel == null)
+ {
+ return null;
+ }
+
+ synchronized (coordinatorLock)
+ {
+ while (members == null || members.isEmpty())
+ {
+ log.debug("getCoordinator(): waiting on viewAccepted()");
+ try
+ {
+ coordinatorLock.wait();
+ }
+ catch (InterruptedException e)
+ {
+ log.error("getCoordinator(): Interrupted while waiting for members to be set", e);
+ break;
+ }
+ }
+ return members != null && members.size() > 0 ? members.get(0) : null;
+ }
+ }
+
+ // ------------ END: Informational methods ------------
+
+ /*----------------------- MembershipListener ------------------------*/
+
+ protected class MembershipListenerAdaptor implements ExtendedMembershipListener
+ {
+
+ public void viewAccepted(View newView)
+ {
+ Vector<Address> newMembers = newView.getMembers();
+ if (log.isInfoEnabled()) log.info("Received new cluster view: " + newView);
+ synchronized (coordinatorLock)
+ {
+ boolean needNotification = false;
+ if (newMembers != null)
+ {
+ if (members != null)
+ {
+ // we had a membership list before this event. Check to make sure we haven't lost any members,
+ // and if so, determine what members have been removed
+ // and roll back any tx and break any locks
+ List<Address> removed = new ArrayList<Address>(members);
+ removed.removeAll(newMembers);
+ spi.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
+ // todo fix me
+ NodeSPI root = null; // spi.getRoot();
+ if (root != null)
+ {
+ // todo fix me
+ //removeLocksForDeadMembers(root.getDelegationTarget(), removed);
+ }
+ }
+
+ members = new ArrayList<Address>(newMembers); // defensive copy.
+
+ needNotification = true;
+ }
+
+ // Now that we have a view, figure out if we are the coordinator
+ coordinator = (members != null && members.size() != 0 && members.get(0).equals(getLocalAddress()));
+
+ // now notify listeners - *after* updating the coordinator. - JBCACHE-662
+ if (needNotification && notifier != null)
+ {
+ // TODO: Fix me when we have repl working
+ throw new UnsupportedOperationException("Fix me!");
+// InvocationContext ctx = spi.getInvocationContext();
+// notifier.notifyViewChange(newView, ctx);
+ }
+
+ // Wake up any threads that are waiting to know about who the coordinator is
+ coordinatorLock.notifyAll();
+ }
+ }
+
+ /**
+ * Called when a member is suspected.
+ */
+ public void suspect(Address suspected_mbr)
+ {
+ }
+
+ /**
+ * Indicates that a channel has received a BLOCK event from FLUSH protocol.
+ */
+ public void block()
+ {
+ flushBlockGate.close();
+ if (log.isDebugEnabled()) log.debug("Block received at " + getLocalAddress());
+ notifier.notifyCacheBlocked(true);
+ notifier.notifyCacheBlocked(false);
+
+ if (log.isDebugEnabled()) log.debug("Block processed at " + getLocalAddress());
+ }
+
+ /**
+ * Indicates that a channel has received a UNBLOCK event from FLUSH protocol.
+ */
+ public void unblock()
+ {
+ if (log.isDebugEnabled()) log.debug("UnBlock received at " + getLocalAddress());
+
+ notifier.notifyCacheUnblocked(true);
+ notifier.notifyCacheUnblocked(false);
+
+ if (log.isDebugEnabled()) log.debug("UnBlock processed at " + getLocalAddress());
+ flushBlockGate.open();
+ }
+
+ }
+
+ //jmx operations
+ private void computeStats(boolean success)
+ {
+ if (statisticsEnabled && rpcDispatcher != null)
+ {
+ if (success)
+ {
+ replicationCount++;
+ }
+ else
+ {
+ replicationFailures++;
+ }
+ }
+ }
+
+ @ManagedOperation
+ public void resetStatistics()
+ {
+ this.replicationCount = 0;
+ this.replicationFailures = 0;
+ }
+
+ @ManagedAttribute(description = "number of successful replications")
+ public long getReplicationCount()
+ {
+ return replicationCount;
+ }
+
+ @ManagedAttribute(description = "number of failed replications")
+ public long getReplicationFailures()
+ {
+ return replicationFailures;
+ }
+
+ @ManagedAttribute(description = "whether or not jmx statistics are enabled")
+ public boolean isStatisticsEnabled()
+ {
+ return statisticsEnabled;
+ }
+
+ @ManagedAttribute
+ public void setStatisticsEnabled(boolean statisticsEnabled)
+ {
+ this.statisticsEnabled = statisticsEnabled;
+ }
+
+ @ManagedAttribute
+ public String getSuccessRatio()
+ {
+ if (replicationCount == 0 || !statisticsEnabled)
+ {
+ return "N/A";
+ }
+ double totalCount = replicationCount + replicationFailures;
+ double ration = (double) replicationCount / totalCount * 100d;
+ return NumberFormat.getInstance().format(ration) + "%";
+ }
+
+ /**
+ * Checks to see whether the cache is using an appropriate JGroups config.
+ */
+ private void checkAppropriateConfig()
+ {
+ //if we use a shared transport do not log any warn message
+ if (configuration.getMultiplexerStack() != null)
+ return;
+ //bundling is not good for sync caches
+ Configuration.CacheMode cacheMode = configuration.getCacheMode();
+ if (!cacheMode.equals(Configuration.CacheMode.LOCAL) && configuration.getCacheMode().isSynchronous())
+ {
+ ProtocolStack stack = ((JChannel) channel).getProtocolStack();
+ TP transport = stack.getTransport();
+ if (transport.isEnableBundling())
+ {
+ log.warn("You have enabled jgroups's message bundling, which is not recommended for sync replication. If there is no particular " +
+ "reason for this we strongly recommend to disable message bundling in JGroups config (enable_bundling=\"false\").");
+ }
+ }
+ //bundling is good for async caches
+ if (!cacheMode.isSynchronous())
+ {
+ ProtocolStack stack = ((JChannel) channel).getProtocolStack();
+ TP transport = stack.getTransport();
+ if (!transport.isEnableBundling())
+ {
+ log.warn("You have disabled jgroups's message bundling, which is not recommended for async replication. If there is no particular " +
+ "reason for this we strongly recommend to enable message bundling in JGroups config (enable_bundling=\"true\").");
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ReplicationException.java (from rev 6891, core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ReplicationException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ReplicationException.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,59 @@
+/*
+ * 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.remoting;
+
+import org.jboss.starobrno.CacheException;
+
+/**
+ * Thrown when a replication problem occurred
+ */
+public class ReplicationException extends CacheException
+{
+
+ private static final long serialVersionUID = 33172388691879866L;
+
+ public ReplicationException()
+ {
+ super();
+ }
+
+ public ReplicationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public ReplicationException(String msg)
+ {
+ super(msg);
+ }
+
+ public ReplicationException(String msg, Throwable cause)
+ {
+ super(msg, cause);
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString();
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/remoting/ReplicationException.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java (from rev 6891, core/branches/flat/src/main/java/org/jboss/starobrno/OrderedSynchronizationHandler.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -0,0 +1,119 @@
+/*
+ * 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.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.LinkedList;
+
+/**
+ * Maintains a list of Synchronization handlers. Reason is that we have to
+ * invoke certain handlers <em>before</em> others. See the description in
+ * SyncTxUnitTestCase.testConcurrentPuts(). For example, for synchronous
+ * replication, we have to execute the ReplicationInterceptor's
+ * afterCompletion() <em>before</em> the TransactionInterceptor's.
+ *
+ * @author Bela Ban
+ * @version $Id$
+ */
+public class OrderedSynchronizationHandler implements Synchronization
+{
+ static final Log log = LogFactory.getLog(org.jboss.cache.interceptors.OrderedSynchronizationHandler.class);
+
+ private Transaction tx = null;
+ private final LinkedList<Synchronization> handlers = new LinkedList<Synchronization>();
+
+ public OrderedSynchronizationHandler(Transaction tx) throws SystemException, RollbackException
+ {
+ this.tx = tx;
+ tx.registerSynchronization(this);
+ }
+
+ public void registerAtHead(Synchronization handler)
+ {
+ register(handler, true);
+ }
+
+ public void registerAtTail(Synchronization handler)
+ {
+ register(handler, false);
+ }
+
+ void register(Synchronization handler, boolean head)
+ {
+ if (handler != null && !handlers.contains(handler))
+ {
+ if (head)
+ handlers.addFirst(handler);
+ else
+ handlers.addLast(handler);
+ }
+ }
+
+ public void beforeCompletion()
+ {
+ for (Synchronization sync : handlers)
+ {
+ sync.beforeCompletion();
+ }
+ }
+
+ public void afterCompletion(int status)
+ {
+ RuntimeException exceptionInAfterCompletion = null;
+ for (Synchronization sync : handlers)
+ {
+ try
+ {
+ sync.afterCompletion(status);
+ }
+ catch (Throwable t)
+ {
+ log.error("failed calling afterCompletion() on " + sync, t);
+ exceptionInAfterCompletion = (RuntimeException) t;
+ }
+ }
+
+ // throw the exception so the TM can deal with it.
+ if (exceptionInAfterCompletion != null) throw exceptionInAfterCompletion;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "tx=" + getTxAsString() + ", handlers=" + handlers;
+ }
+
+ private String getTxAsString()
+ {
+ // JBCACHE-1114 -- don't call toString() on tx or it can lead to stack overflow
+ if (tx == null)
+ return null;
+
+ return tx.getClass().getName() + "@" + System.identityHashCode(tx);
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/OrderedSynchronizationHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-10-08 18:56:43 UTC (rev 6891)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-10-09 08:56:47 UTC (rev 6892)
@@ -23,13 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.RPCManager;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.context.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.factories.context.ContextFactory;
+import org.jboss.starobrno.remoting.RPCManager;
import org.jgroups.Address;
import javax.transaction.Status;
17 years, 2 months
JBoss Cache SVN: r6891 - in core/branches/flat/src: main/docbook/userguide/en/modules and 38 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 14:56:43 -0400 (Wed, 08 Oct 2008)
New Revision: 6891
Added:
core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java
core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/NullComponentFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/manager/
core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifier/NotifierImpl.java
core/branches/flat/src/test/java/org/jboss/starobrno/
core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java
Removed:
core/branches/flat/src/main/java/org/jboss/cache/factories/
core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
Modified:
core/branches/flat/src/main/docbook/faq/en/master.xml
core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml
core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java
core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java
core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java
core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/branches/flat/src/main/java/org/jboss/cache/Fqn.java
core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java
core/branches/flat/src/main/java/org/jboss/cache/Node.java
core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java
core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/Region.java
core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java
core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/TreeCacheViewMBean.java
core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
core/branches/flat/src/main/java/org/jboss/cache/Version.java
core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServerMBean.java
core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/CacheListener.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/NodeMoved.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/event/Event.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/event/EventImpl.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java
core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java
core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java
core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java
core/branches/flat/src/test/resources/log4j.xml
Log:
Tried to get a basic test working
Modified: core/branches/flat/src/main/docbook/faq/en/master.xml
===================================================================
--- core/branches/flat/src/main/docbook/faq/en/master.xml 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/docbook/faq/en/master.xml 2008-10-08 18:56:43 UTC (rev 6891)
@@ -90,7 +90,7 @@
<para>JBoss Cache comes in two flavours: Core and Pojo versions. The core library
(using the
- <literal>org.jboss.cache.Cache</literal>
+ <literal>org.jboss.cache.Cache_Legacy</literal>
interface
) is the underlying library that organises data in a tree-like structure and handles all locking,
passivation,
@@ -613,7 +613,7 @@
and
<literal>IsolationLevel</literal>
), do I simply need to create multiple
- <literal>org.jboss.cache.Cache</literal>
+ <literal>org.jboss.cache.Cache_Legacy</literal>
instances with the appropriate configuration?
</para>
</question>
@@ -621,7 +621,7 @@
<answer>
<para>Yes. All the above mentioned properties are per cache
instance. Therefore you will need separate
- <literal>org.jboss.cache.Cache</literal>
+ <literal>org.jboss.cache.Cache_Legacy</literal>
instances.
</para>
</answer>
@@ -630,7 +630,7 @@
<qandaentry>
<question>
<para>Isn't this expensive from a networking standpoint, i.e., needing to create sockets for each
- <literal>org.jboss.cache.Cache</literal>
+ <literal>org.jboss.cache.Cache_Legacy</literal>
instance?
</para>
</question>
@@ -1133,7 +1133,7 @@
or extend
<literal>org.jboss.cache.AbstractCacheListener</literal>
and override for the events you are interested in. You can then register the listener using the
- <literal>org.jboss.cache.Cache.addCacheListener()</literal>
+ <literal>org.jboss.cache.Cache_Legacy.addCacheListener()</literal>
API.
</para>
</answer>
Modified: core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml
===================================================================
--- core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/docbook/userguide/en/modules/deployment.xml 2008-10-08 18:56:43 UTC (rev 6891)
@@ -167,13 +167,13 @@
beans that make up a POJO service.
</para>
<para>
- For each configurable option exposed by the
- <literal>Configuration</literal>
- components, a getter/setter must be defined in the configuration class.
- This is required so that JBoss Microcontainer can, in typical IOC way,
- call these methods when the corresponding properties have been
+ For each configurable option exposed by the
+ <literal>Configuration</literal>
+ components, a getter/setter must be defined in the configuration class.
+ This is required so that JBoss Microcontainer can, in typical IOC way,
+ call these methods when the corresponding properties have been
configured.
- </para>
+ </para>
<para>
The rules for how to deploy the file, how to package it, how to
ensure the required jars are on the classpath, etc. are the same
@@ -194,111 +194,111 @@
<programlisting role="XML"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- First we create a Configuration object for the cache -->
- <bean name="ExampleCacheConfig"
- class="org.jboss.cache.config.Configuration">
-
- <!-- Externally injected services -->
- <property name="runtimeConfig">
- <bean name="ExampleCacheRuntimeConfig" class="org.jboss.cache.config.RuntimeConfig">
- <property name="transactionManager">
- <inject bean="jboss:service=TransactionManager"
- property="TransactionManager"/>
+ <!-- First we create a Configuration object for the cache -->
+ <bean name="ExampleCacheConfig"
+ class="org.jboss.cache.config.Configuration">
+
+ <!-- Externally injected services -->
+ <property name="runtimeConfig">
+ <bean name="ExampleCacheRuntimeConfig" class="org.jboss.cache.config.RuntimeConfig">
+ <property name="transactionManager">
+ <inject bean="jboss:service=TransactionManager"
+ property="TransactionManager"/>
+ </property>
+ <property name="muxChannelFactory"><inject bean="JChannelFactory"/></property>
+ </bean>
</property>
- <property name="muxChannelFactory"><inject bean="JChannelFactory"/></property>
- </bean>
- </property>
-
- <property name="multiplexerStack">udp</property>
- <property name="clusterName">Example-EntityCache</property>
-
- <!--
- Node locking level : SERIALIZABLE
- REPEATABLE_READ (default)
- READ_COMMITTED
- READ_UNCOMMITTED
- NONE
- -->
- <property name="isolationLevel">REPEATABLE_READ</property>
+ <property name="multiplexerStack">udp</property>
- <!-- Valid modes are LOCAL
- REPL_ASYNC
- REPL_SYNC
- -->
- <property name="cacheMode">REPL_SYNC</property>
+ <property name="clusterName">Example-EntityCache</property>
- <!-- The max amount of time (in milliseconds) we wait until the
- initial state (ie. the contents of the cache) are retrieved from
- existing members in a clustered environment
- -->
- <property name="initialStateRetrievalTimeout">15000</property>
+ <!--
+ Node locking level : SERIALIZABLE
+ REPEATABLE_READ (default)
+ READ_COMMITTED
+ READ_UNCOMMITTED
+ NONE
+ -->
+ <property name="isolationLevel">REPEATABLE_READ</property>
- <!-- Number of milliseconds to wait until all responses for a
- synchronous call have been received.
- -->
- <property name="syncReplTimeout">20000</property>
+ <!-- Valid modes are LOCAL
+ REPL_ASYNC
+ REPL_SYNC
+ -->
+ <property name="cacheMode">REPL_SYNC</property>
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <property name="lockAcquisitionTimeout">15000</property>
-
- <property name="exposeManagementStatistics">true</property>
-
- <!-- Must be true if any entity deployment uses a scoped classloader -->
- <property name="useRegionBasedMarshalling">true</property>
- <!-- Must match the value of "useRegionBasedMarshalling" -->
- <property name="inactiveOnStartup">true</property>
+ <!-- The max amount of time (in milliseconds) we wait until the
+ initial state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <property name="initialStateRetrievalTimeout">15000</property>
- <!-- Specific eviction policy configurations. This is LRU -->
- <property name="evictionConfig">
- <bean name="ExampleEvictionConfig"
- class="org.jboss.cache.config.EvictionConfig">
- <property name="defaultEvictionPolicyClass">
- org.jboss.cache.eviction.LRUPolicy
- </property>
- <property name="wakeupIntervalSeconds">5</property>
- <property name="evictionRegionConfigs">
- <list>
- <bean name="ExampleDefaultEvictionRegionConfig"
- class="org.jboss.cache.config.EvictionRegionConfig">
- <property name="regionName">/_default_</property>
- <property name="evictionPolicyConfig">
- <bean name="ExampleDefaultLRUConfig"
- class="org.jboss.cache.eviction.LRUConfiguration">
- <property name="maxNodes">5000</property>
- <property name="timeToLiveSeconds">1000</property>
+ <!-- Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <property name="syncReplTimeout">20000</property>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <property name="lockAcquisitionTimeout">15000</property>
+
+ <property name="exposeManagementStatistics">true</property>
+
+ <!-- Must be true if any entity deployment uses a scoped classloader -->
+ <property name="useRegionBasedMarshalling">true</property>
+ <!-- Must match the value of "useRegionBasedMarshalling" -->
+ <property name="inactiveOnStartup">true</property>
+
+ <!-- Specific eviction policy configurations. This is LRU -->
+ <property name="evictionConfig">
+ <bean name="ExampleEvictionConfig"
+ class="org.jboss.cache.config.EvictionConfig">
+ <property name="defaultEvictionPolicyClass">
+ org.jboss.cache.eviction.LRUPolicy
+ </property>
+ <property name="wakeupIntervalSeconds">5</property>
+ <property name="evictionRegionConfigs">
+ <list>
+ <bean name="ExampleDefaultEvictionRegionConfig"
+ class="org.jboss.cache.config.EvictionRegionConfig">
+ <property name="regionName">/_default_</property>
+ <property name="evictionPolicyConfig">
+ <bean name="ExampleDefaultLRUConfig"
+ class="org.jboss.cache.eviction.LRUConfiguration">
+ <property name="maxNodes">5000</property>
+ <property name="timeToLiveSeconds">1000</property>
+ </bean>
+ </property>
</bean>
- </property>
- </bean>
- </list>
+ </list>
+ </property>
+ </bean>
</property>
+
</bean>
- </property>
-
- </bean>
-
- <!-- Factory to build the Cache. -->
- <bean name="DefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">
- <constructor factoryClass="org.jboss.cache.DefaultCacheFactory"
- factoryMethod="getInstance"/>
- </bean>
-
- <!-- The cache itself -->
- <bean name="ExampleCache" class="org.jboss.cache.Cache">
-
- <constructor factoryMethod="createCache">
- <factory bean="DefaultCacheFactory"/>
- <parameter class="org.jboss.cache.config.Configuration"><inject bean="ExampleCacheConfig"/></parameter>
- <parameter class="boolean">false</false>
- </constructor>
-
- </bean>
-</deployment>
-]]></programlisting>
+ <!-- Factory to build the Cache. -->
+ <bean name="DefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">
+ <constructor factoryClass="org.jboss.cache.DefaultCacheFactory"
+ factoryMethod="getInstance"/>
+ </bean>
+ <!-- The cache itself -->
+ <bean name="ExampleCache" class="org.jboss.cache.Cache_Legacy">
+
+ <constructor factoryMethod="createCache">
+ <factory bean="DefaultCacheFactory"/>
+ <parameter class="org.jboss.cache.config.Configuration"><inject bean="ExampleCacheConfig"/></parameter>
+ <parameter class="boolean">false</false>
+ </constructor>
+
+ </bean>
+
+ </deployment>
+ ]]></programlisting>
+
<para>
See the JBoss Microcontainer documentation
<footnote>
Modified: core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,24 +22,24 @@
package org.jboss.cache;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.mvcc.ReadCommittedNode;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import java.util.Map;
/**
- * Generates new nodes based on the {@link CacheSPI} configuration.
+ * Generates new nodes based on the {@link CacheSPI_Legacy} configuration.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
public abstract class AbstractNodeFactory<K, V> implements NodeFactory<K, V>
{
- protected CacheSPI<K, V> cache;
+ protected CacheSPI_Legacy<K, V> cache;
protected boolean useVersionedNode;
protected Configuration configuration;
protected InvocationContextContainer invocationContextContainer;
@@ -57,7 +57,7 @@
}
@Inject
- public void injectDependencies(CacheSPI<K, V> cache, Configuration configuration,
+ public void injectDependencies(CacheSPI_Legacy<K, V> cache, Configuration configuration,
InvocationContextContainer invocationContextContainer,
InterceptorChain interceptorChain, CommandsFactory commandsFactory)
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -46,7 +46,7 @@
* In addition, methods provide anadditional option to create and return a cache without starting it.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @see org.jboss.cache.Cache
+ * @see Cache_Legacy
* @see org.jboss.cache.DefaultCacheFactory
* @since 2.0.0
*/
@@ -54,24 +54,24 @@
public interface CacheFactory<K, V>
{
/**
- * Creates and starts a {@link Cache} instance using default configuration settings. See {@link Configuration} for default values.
+ * Creates and starts a {@link Cache_Legacy} instance using default configuration settings. See {@link Configuration} for default values.
*
* @return a cache
* @throws ConfigurationException if there are problems with the default configuration
*/
- Cache<K, V> createCache() throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache() throws ConfigurationException;
/**
- * Creates and optionally starts a {@link Cache} instance using default configuration settings. See {@link Configuration} for default values.
+ * Creates and optionally starts a {@link Cache_Legacy} instance using default configuration settings. See {@link Configuration} for default values.
*
* @param start if true, starts the cache
* @return a cache
* @throws ConfigurationException if there are problems with the default configuration
*/
- Cache<K, V> createCache(boolean start) throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache(boolean start) throws ConfigurationException;
/**
- * Creates and starts a {@link org.jboss.cache.Cache} instance. The following are all valid calls:
+ * Creates and starts a {@link Cache_Legacy} instance. The following are all valid calls:
* <pre>
* factory.createCache("myCacheService.xml"); // file is in class path
* factory.createCache("etc/myCacheService.xml"); // file is in etc/ relative to the directory you started the JVM
@@ -79,75 +79,75 @@
* </pre>
*
* @param configFileName the named XML file should exist in the classpath or should be a fully qualified or relative (to your JVM working directory) path to a file on the local file system. Note that the classpath is checked first for the existence of this file.
- * @return a running {@link org.jboss.cache.Cache} instance
+ * @return a running {@link Cache_Legacy} instance
* @throws org.jboss.cache.config.ConfigurationException
* if there are problems with the configuration
*/
- Cache<K, V> createCache(String configFileName) throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache(String configFileName) throws ConfigurationException;
/**
- * Creates {@link Cache} instance, and optionally starts it.
+ * Creates {@link Cache_Legacy} instance, and optionally starts it.
*
* @param configFileName the named XML file should exist in the classpath or should be a fully qualified or relative (to your JVM working directory) path to a file on the local file system. Note that the classpath is checked first for the existence of this file.
* @param start if true, the cache is started before returning.
- * @return an optionally running {@link Cache} instance
+ * @return an optionally running {@link Cache_Legacy} instance
* @throws org.jboss.cache.config.ConfigurationException
* if there are problems with the configuration
* @see #createCache(String) for examples on valid config file names.
*/
- Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException;
/**
- * Creates a {@link Cache} instance based on a {@link org.jboss.cache.config.Configuration} passed in.
+ * Creates a {@link Cache_Legacy} instance based on a {@link org.jboss.cache.config.Configuration} passed in.
* <p/>
* Ensure that the Configuration you pass in is not used by another cache instance in the same JVM,
* as it may be concurrently modified. Clone the configuration, if shared, using
* {@link org.jboss.cache.config.Configuration#clone()}.
*
- * @param configuration the {@link Configuration} object that is passed in to setCache the {@link Cache}.
- * @return a running {@link Cache} instance
+ * @param configuration the {@link Configuration} object that is passed in to setCache the {@link Cache_Legacy}.
+ * @return a running {@link Cache_Legacy} instance
* @throws org.jboss.cache.config.ConfigurationException
* if there are problems with the configuration
*/
- Cache<K, V> createCache(Configuration configuration) throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache(Configuration configuration) throws ConfigurationException;
/**
- * Creates {@link Cache} instance, and optionally starts it, based on a {@link org.jboss.cache.config.Configuration} passed in.
+ * Creates {@link Cache_Legacy} instance, and optionally starts it, based on a {@link org.jboss.cache.config.Configuration} passed in.
* <p/>
* Ensure that the Configuration you pass in is not used by another cache instance in the same JVM,
* as it may be concurrently modified. Clone the configuration, if shared, using
* {@link org.jboss.cache.config.Configuration#clone()}.
*
- * @param configuration the {@link Configuration} object that is passed in to setCache the {@link Cache}.
+ * @param configuration the {@link Configuration} object that is passed in to setCache the {@link Cache_Legacy}.
* @param start if true, the cache is started before returning.
- * @return an optionally running {@link Cache} instance
+ * @return an optionally running {@link Cache_Legacy} instance
* @throws org.jboss.cache.config.ConfigurationException
* if there are problems with the configuration
*/
- Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException;
/**
- * Creates a {@link Cache} instance based on an {@link java.io.InputStream} passed in, which should be a stream to a valid
+ * Creates a {@link Cache_Legacy} instance based on an {@link java.io.InputStream} passed in, which should be a stream to a valid
* XML configuration file.
*
* @param is the {@link java.io.InputStream}
- * @return a running {@link Cache} instance
+ * @return a running {@link Cache_Legacy} instance
* @throws org.jboss.cache.config.ConfigurationException
* if there are problems with the configuration
* @since 2.1.0
*/
- Cache<K, V> createCache(InputStream is) throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache(InputStream is) throws ConfigurationException;
/**
- * Creates a {@link Cache} instance based on an {@link java.io.InputStream} passed in, which should be a stream to a valid
+ * Creates a {@link Cache_Legacy} instance based on an {@link java.io.InputStream} passed in, which should be a stream to a valid
* XML configuration file.
*
* @param is the {@link java.io.InputStream}
* @param start if true, the cache is started before returning.
- * @return a running {@link Cache} instance
+ * @return a running {@link Cache_Legacy} instance
* @throws org.jboss.cache.config.ConfigurationException
* if there are problems with the configuration
* @since 2.1.0
*/
- Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException;
+ org.jboss.starobrno.Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -66,9 +66,9 @@
* optionally instantiating the cache if it hasn't already been
* instantiated.
* <p>
- * The caller is free to invoke the {@link Cache#create()} and
- * {@link Cache#start()} lifecycle methods on the returned cache, but
- * the @link Cache#stop()} and {@link Cache#destroy()} methods should not
+ * The caller is free to invoke the {@link Cache_Legacy#create()} and
+ * {@link Cache_Legacy#start()} lifecycle methods on the returned cache, but
+ * the @link Cache#stop()} and {@link Cache_Legacy#destroy()} methods should not
* be invoked, since it is quite possible other users are still using the
* cache. Use {@link #releaseCache(String)} to notify this
* registry that the caller is no longer using a cache; let the registry
@@ -92,7 +92,7 @@
* does not include <code>configName</code>
* @throws Exception if there is a problem instantiating the cache
*/
- Cache<Object, Object> getCache(String configName, boolean create) throws Exception;
+ Cache_Legacy<Object, Object> getCache(String configName, boolean create) throws Exception;
/**
* Notifies the registry that the caller is no longer using the given
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -44,7 +44,7 @@
private boolean configRegistryInjected;
- private final Map<String, Cache<Object, Object>> caches = new HashMap<String, Cache<Object, Object>>();
+ private final Map<String, Cache_Legacy<Object, Object>> caches = new HashMap<String, Cache_Legacy<Object, Object>>();
private final Map<String, Integer> checkouts = new HashMap<String, Integer>();
@@ -107,9 +107,9 @@
}
}
- public Cache<Object, Object> getCache(String configName, boolean create) throws Exception
+ public Cache_Legacy<Object, Object> getCache(String configName, boolean create) throws Exception
{
- Cache<Object, Object> cache;
+ Cache_Legacy<Object, Object> cache;
synchronized (caches)
{
cache = caches.get(configName);
@@ -140,9 +140,10 @@
* @param config the Configuration for the cache
* @return the Cache
*/
- protected Cache<Object, Object> createCache(Configuration config)
+ protected Cache_Legacy<Object, Object> createCache(Configuration config)
{
- return new DefaultCacheFactory<Object, Object>().createCache(config, false);
+// return new DefaultCacheFactory<Object, Object>().createCache(config, false);
+ return null;
}
public void releaseCache(String configName)
@@ -153,7 +154,7 @@
throw new IllegalStateException(configName + " not registered");
if (decrementCheckout(configName) == 0)
{
- Cache<Object, Object> cache = caches.remove(configName);
+ Cache_Legacy<Object, Object> cache = caches.remove(configName);
destroyCache(cache);
}
}
@@ -177,7 +178,7 @@
this.channelFactory = channelFactory;
}
- public void registerCache(Cache<Object, Object> cache, String configName)
+ public void registerCache(Cache_Legacy<Object, Object> cache, String configName)
{
synchronized (caches)
{
@@ -212,9 +213,9 @@
{
synchronized (caches)
{
- for (Iterator<Map.Entry<String, Cache<Object, Object>>> it = caches.entrySet().iterator(); it.hasNext();)
+ for (Iterator<Map.Entry<String, Cache_Legacy<Object, Object>>> it = caches.entrySet().iterator(); it.hasNext();)
{
- Map.Entry<String, Cache<Object, Object>> entry = it.next();
+ Map.Entry<String, Cache_Legacy<Object, Object>> entry = it.next();
destroyCache(entry.getValue());
it.remove();
}
@@ -260,7 +261,7 @@
}
}
- private void destroyCache(Cache<Object, Object> cache)
+ private void destroyCache(Cache_Legacy<Object, Object> cache)
{
if (cache.getCacheStatus() == CacheStatus.STARTED)
{
Copied: core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java (from rev 6890, core/branches/flat/src/main/java/org/jboss/cache/CacheSPI.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -0,0 +1,354 @@
+/*
+ * 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.cache;
+
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.loader.CacheLoader;
+import org.jboss.cache.loader.CacheLoaderManager;
+import org.jboss.cache.marshall.Marshaller;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.factories.ComponentRegistry;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A more detailed interface to {@link Cache_Legacy}, which is used when writing plugins for or extending JBoss Cache. A reference
+ * to this interface should only be obtained when it is passed in to your code, for example when you write an
+ * {@link org.jboss.cache.interceptors.base.CommandInterceptor} or {@link CacheLoader}.
+ * <p/>
+ * <B><I>You should NEVER attempt to directly cast a {@link Cache_Legacy} instance to this interface. In future, the implementation may not allow it.</I></B>
+ * <p/>
+ * This interface contains overridden method signatures of some methods from {@link Cache_Legacy}, overridden to ensure return
+ * types of {@link Node} are replaced with {@link NodeSPI}.
+ * <p/>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @see NodeSPI
+ * @see Cache_Legacy
+ * @see org.jboss.cache.loader.CacheLoader
+ * @since 2.0.0
+ */
+@ThreadSafe
+public interface CacheSPI_Legacy<K, V> extends Cache_Legacy<K, V>
+{
+ /**
+ * Overrides {@link Cache_Legacy#getRoot()} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
+ */
+ NodeSPI<K, V> getRoot();
+
+ /**
+ * Overrides {@link Cache_Legacy#getNode(String)} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
+ *
+ * @param s string representation of an Fqn
+ * @return a NodeSPI
+ */
+ NodeSPI<K, V> getNode(String s);
+
+ /**
+ * Overrides {@link Cache_Legacy#getNode(Fqn)} to return a {@link org.jboss.cache.NodeSPI} instead of a {@link org.jboss.cache.Node}.
+ *
+ * @param f an Fqn
+ * @return a NodeSPI
+ */
+ NodeSPI<K, V> getNode(Fqn f);
+
+
+ /**
+ * Retrieves a reference to a running {@link javax.transaction.TransactionManager}, if one is configured.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return a TransactionManager
+ */
+ TransactionManager getTransactionManager();
+
+ /**
+ * Retrieves the current Interceptor chain.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return an immutable {@link List} of {@link org.jboss.cache.interceptors.base.CommandInterceptor}s configured for this cache, or
+ * <code>null</code> if {@link Cache_Legacy#create() create()} has not been invoked
+ * and the interceptors thus do not exist.
+ */
+ List<CommandInterceptor> getInterceptorChain();
+
+ /**
+ * Retrieves an instance of a {@link Marshaller}, which is capable of
+ * converting Java objects to bytestreams and back in an efficient manner, which is
+ * also interoperable with bytestreams produced/consumed by other versions of JBoss
+ * Cache.
+ * <p/>
+ * The use of this marshaller is the <b>recommended</b> way of creating efficient,
+ * compatible, byte streams from objects.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return an instance of {@link Marshaller}
+ */
+ Marshaller getMarshaller();
+
+ /**
+ * Adds a custom interceptor to the interceptor chain, at specified position, where the first interceptor in the chain
+ * is at position 0 and the last one at getInterceptorChain().size() - 1.
+ *
+ * @param i the interceptor to add
+ * @param position the position to add the interceptor
+ */
+ void addInterceptor(CommandInterceptor i, int position);
+
+ /**
+ * Adds a custom interceptor to the interceptor chain, after an instance of the specified interceptor type. Throws a
+ * cache exception if it cannot find an interceptor of the specified type.
+ *
+ * @param i interceptor to add
+ * @param afterInterceptor interceptor type after which to place custom interceptor
+ */
+ void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor);
+
+ /**
+ * Removes the interceptor at a specified position, where the first interceptor in the chain
+ * is at position 0 and the last one at getInterceptorChain().size() - 1.
+ *
+ * @param position the position at which to remove an interceptor
+ */
+ void removeInterceptor(int position);
+
+ /**
+ * Removes the interceptor of specified type.
+ *
+ * @param interceptorType type of interceptor to remove
+ */
+ void removeInterceptor(Class<? extends CommandInterceptor> interceptorType);
+
+ /**
+ * Retrieves the current CacheCacheLoaderManager instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return Retrieves a reference to the currently configured {@link org.jboss.cache.loader.CacheLoaderManager} if one or more cache loaders are configured, null otherwise.
+ */
+ CacheLoaderManager getCacheLoaderManager();
+
+ /**
+ * Retrieves the current BuddyManager instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return an instance of {@link BuddyManager} if buddy replication is enabled, null otherwise.
+ */
+ BuddyManager getBuddyManager();
+
+ /**
+ * Retrieves the current TransactionTable instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the current {@link TransactionTable}
+ */
+ TransactionTable getTransactionTable();
+
+ /**
+ * Gets a handle of the RPC manager.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the {@link org.jboss.cache.RPCManager} configured.
+ */
+ RPCManager getRPCManager();
+
+ /**
+ * Retrieves the current StateTransferManager instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the current {@link org.jboss.cache.statetransfer.StateTransferManager}
+ */
+ StateTransferManager getStateTransferManager();
+
+ /**
+ * Retrieves the current RegionManager instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the {@link RegionManager}
+ */
+ RegionManager getRegionManager();
+
+
+ /**
+ * Retrieves the current Notifier instance associated with the current Cache instance.
+ * <p/>
+ * From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the
+ * {@link org.jboss.cache.factories.annotations.Inject} annotation.
+ *
+ * @return the notifier attached with this instance of the cache. See {@link org.jboss.cache.notifications.Notifier}, a class
+ * that is responsible for emitting notifications to registered CacheListeners.
+ */
+ Notifier getNotifier();
+
+ /**
+ * @return the name of the cluster. Null if running in local mode.
+ */
+ String getClusterName();
+
+ /**
+ * @return the number of attributes in the cache.
+ */
+ int getNumberOfAttributes();
+
+ /**
+ * @return the number of nodes in the cache.
+ */
+ int getNumberOfNodes();
+
+ /**
+ * Returns the global transaction for this local transaction.
+ * Optionally creates a new global transaction if it does not exist.
+ *
+ * @param tx the current transaction
+ * @param createIfNotExists if true creates a new transaction if none exists
+ * @return a GlobalTransaction
+ */
+ GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists);
+
+ /**
+ * Returns the transaction associated with the current thread.
+ * If a local transaction exists, but doesn't yet have a mapping to a
+ * GlobalTransaction, a new GlobalTransaction will be created and mapped to
+ * the local transaction. Note that if a local transaction exists, but is
+ * not ACTIVE or PREPARING, null is returned.
+ *
+ * @return A GlobalTransaction, or null if no (local) transaction was associated with the current thread
+ */
+ GlobalTransaction getCurrentTransaction();
+
+ /**
+ * Returns a node without accessing the interceptor chain. Does not return any nodes marked as invalid. Note that this call works
+ * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
+ * loading or activation does not take place, and so the results of this call should not be treated as definitive. Concurrent node
+ * removal, passivation, etc. may affect the results of this call.
+ *
+ * @param fqn the Fqn to look up.
+ * @param includeDeletedNodes if you intend to see nodes marked as deleted within the current tx, set this to true
+ * @return a node if one exists or null
+ */
+ NodeSPI<K, V> peek(Fqn fqn, boolean includeDeletedNodes);
+
+ /**
+ * Returns a node without accessing the interceptor chain, optionally returning nodes that are marked as invalid ({@link org.jboss.cache.Node#isValid()} == false).
+ * Note that this call works
+ * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
+ * loading or activation does not take place, and so the results of this call should not be treated as definitive. Concurrent node
+ * removal, passivation, etc. may affect the results of this call.
+ *
+ * @param fqn the Fqn to look up.
+ * @param includeDeletedNodes if you intend to see nodes marked as deleted within the current tx, set this to true
+ * @param includeInvalidNodes if true, nodes marked as being invalid are also returned.
+ * @return a node if one exists or null
+ */
+ NodeSPI<K, V> peek(Fqn fqn, boolean includeDeletedNodes, boolean includeInvalidNodes);
+
+ /**
+ * Used with buddy replication's data gravitation interceptor. If marshalling is necessary, ensure that the cache is
+ * configured to use {@link org.jboss.cache.config.Configuration#useRegionBasedMarshalling} and the {@link org.jboss.cache.Region}
+ * pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.
+ *
+ * @param fqn the fqn to gravitate
+ * @param searchBuddyBackupSubtrees if true, buddy backup subtrees are searched and if false, they are not.
+ * @param ctx
+ * @return a GravitateResult which contains the data for the gravitation
+ */
+ GravitateResult gravitateData(Fqn fqn, boolean searchBuddyBackupSubtrees, InvocationContext ctx);
+
+ /**
+ * Returns a Set<Fqn> of Fqns of the topmost node of internal regions that
+ * should not included in standard state transfers. Will include
+ * {@link BuddyManager#BUDDY_BACKUP_SUBTREE} if buddy replication is
+ * enabled.
+ *
+ * @return an unmodifiable Set<Fqn>. Will not return <code>null</code>.
+ */
+ Set<Fqn> getInternalFqns();
+
+ int getNumberOfLocksHeld();
+
+ /**
+ * Helper method that does a peek and ensures that the result of the peek is not null. Note that this call works
+ * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
+ * loading or activation does not take place, and so the results of this call should not be treated as definitive.
+ *
+ * @param fqn Fqn to peek
+ * @return true if the peek returns a non-null value.
+ */
+ boolean exists(Fqn fqn);
+
+ /**
+ * A convenience method that takes a String representation of an Fqn. Otherwise identical to {@link #exists(Fqn)}.
+ * Note that this call works
+ * directly on the cache data structure and will not pass through the interceptor chain. Hence node locking, cache
+ * loading or activation does not take place, and so the results of this call should not be treated as definitive.
+ */
+ boolean exists(String fqn);
+
+ /**
+ * Returns all children of a given node. Returns an empty set if there are no children.
+ * The set is unmodifiable.
+ *
+ * @param fqn The fully qualified name of the node
+ * @return Set an unmodifiable set of children names, Object.
+ */
+ Set<Object> getChildrenNames(Fqn fqn);
+
+ /**
+ * Convenience method that takes a String representation of an Fqn. Otherwise identical to {@link #getChildrenNames(Fqn)}
+ *
+ * @param fqn as a string
+ * @return Set an unmodifiable set of children names, Object.
+ */
+ Set<String> getChildrenNames(String fqn);
+
+ /**
+ * Returns the component registry associated with this cache instance.
+ *
+ * @see org.jboss.cache.factories.ComponentRegistry
+ */
+ ComponentRegistry getComponentRegistry();
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/cache/CacheSPI_Legacy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java (from rev 6890, core/branches/flat/src/main/java/org/jboss/cache/Cache.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -0,0 +1,539 @@
+/*
+ * 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.cache;
+
+import net.jcip.annotations.ThreadSafe;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jgroups.Address;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Interface for a Cache where data mappings are grouped and stored in a tree data
+ * structure consisting of {@link Node}s.
+ * <p/>
+ * This is the central construct and basic client API of JBoss Cache and is used for
+ * cache-wide operations.
+ * <p/>
+ * The cache is constructed using a {@link CacheFactory} and is started
+ * using {@link #start}, if not already started by the CacheFactory.
+ * <p/>
+ * Once constructed, the Cache interface can be used to create or access {@link Node}s, which contain data. Once references
+ * to {@link Node}s are obtained, data can be stored in them,
+ * <p/>
+ * As a convenience (and mainly to provide a familiar API to the older JBoss Cache 1.x.x releases) methods are provided that
+ * operate directly on nodes.
+ * <ul>
+ * <li>{@link #put(Fqn,Object,Object)} </li>
+ * <li>{@link #put(Fqn,java.util.Map)} </li>
+ * <li>{@link #get(Fqn,Object)} </li>
+ * <li>{@link #remove(Fqn,Object)} </li>
+ * <li>{@link #removeNode(Fqn)} </li>
+ * </ul>
+ * <p/>
+ * A simple example of usage:
+ * <pre>
+ * // creates with default settings and starts the cache
+ * Cache cache = DefaultCacheFactory.getInstance().createCache();
+ * Fqn personRecords = Fqn.fromString("/org/mycompany/personRecords");
+ * <p/>
+ * Node rootNode = cache.getRoot();
+ * Node personRecordsNode = rootNode.addChild(personRecords);
+ * <p/>
+ * // now add some person records.
+ * Fqn peterGriffin = Fqn.fromString("/peterGriffin");
+ * Fqn stewieGriffin = Fqn.fromString("/stewieGriffin");
+ * <p/>
+ * // the addChild() API uses relative Fqns
+ * Node peter = personRecordsNode.addChild(peterGriffin);
+ * Node stewie = personRecordsNode.addChild(stewieGriffin);
+ * <p/>
+ * peter.put("name", "Peter Griffin");
+ * peter.put("ageGroup", "MidLifeCrisis");
+ * peter.put("homicidal", Boolean.FALSE);
+ * <p/>
+ * stewie.put("name", "Stewie Griffin");
+ * stewie.put("ageGroup", "Infant");
+ * stewie.put("homicidal", Boolean.TRUE);
+ * <p/>
+ * peter.getFqn().toString(); // will print out /org/mycompany/personRecords/peterGriffin
+ * stewie.getFqn().toString(); // will print out /org/mycompany/personRecords/stewieGriffin
+ * <p/>
+ * peter.getFqn().getParent().equals(stewie.getFqn().getParent()); // will return true
+ * <p/>
+ * </pre>
+ * <p/>
+ * For more information, please read the JBoss Cache user guide and tutorial, available on <a href="http://labs.jboss.com/portal/jbosscache/docs/index.html" target="_BLANK">the JBoss Cache documentation site</a>,
+ * and look through the examples <a href="http://labs.jboss.com/portal/jbosscache/download/index.html" target="_BLANK">shipped with the JBoss Cache distribution</a>.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @see Node
+ * @see CacheFactory
+ * @since 2.0.0
+ */
+@ThreadSafe
+public interface Cache_Legacy<K, V>
+{
+ /**
+ * Retrieves the configuration of this cache.
+ *
+ * @return the configuration.
+ */
+ Configuration getConfiguration();
+
+ /**
+ * Returns the root node of this cache.
+ *
+ * @return the root node
+ */
+ Node<K, V> getRoot();
+
+ /**
+ * Adds a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object to the entire cache. The object passed in needs to be properly annotated with the
+ * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
+ *
+ * @param listener listener to add
+ */
+ void addCacheListener(Object listener);
+
+ /**
+ * Removes a {@link org.jboss.cache.notifications.annotation.CacheListener}-annotated object from the cache. The object passed in needs to be properly annotated with the
+ * {@link org.jboss.cache.notifications.annotation.CacheListener} annotation otherwise an {@link org.jboss.cache.notifications.IncorrectCacheListenerException} will be thrown.
+ *
+ * @param listener listener to remove
+ */
+ void removeCacheListener(Object listener);
+
+ /**
+ * Retrieves an immutable {@link List} of objects annotated as {@link org.jboss.cache.notifications.annotation.CacheListener}s attached to the cache.
+ *
+ * @return an immutable {@link List} of objects annotated as {@link org.jboss.cache.notifications.annotation.CacheListener}s attached to the cache.
+ */
+ Set<Object> getCacheListeners();
+
+ /**
+ * Associates the specified value with the specified key for a {@link Node} in this cache.
+ * If the {@link Node} previously contained a mapping for this key, the old value is replaced by the specified value.
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
+ * A <code>null</code> return can also indicate that the Node previously associated <code>null</code> with the specified key, if the implementation supports null values.
+ * @throws IllegalStateException if the cache is not in a started state.
+ */
+ V put(Fqn fqn, K key, V value);
+
+ /**
+ * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #put(Fqn, Object, Object)}
+ *
+ * @param fqn String representation of the Fqn
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
+ * A <code>null</code> return can also indicate that the Node previously associated <code>null</code> with the specified key, if the implementation supports null values.
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+
+ V put(String fqn, K key, V value);
+
+ /**
+ * Under special operating behavior, associates the value with the specified key for a node identified by the Fqn passed in.
+ * <ul>
+ * <li> Only goes through if the node specified does not exist; no-op otherwise.</i>
+ * <li> Force asynchronous mode for replication to prevent any blocking.</li>
+ * <li> invalidation does not take place. </li>
+ * <li> 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a no-op, and swallows the timeout exception.</li>
+ * <li> Ongoing transactions are suspended before this call, so failures here will not affect any ongoing transactions.</li>
+ * <li> Errors and exceptions are 'silent' - logged at a much lower level than normal, and this method does not throw exceptions</li>
+ * </ul>
+ * This method is for caching data that has an external representation in storage, where, concurrent modification and
+ * transactions are not a consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome'
+ * rather than a 'failing outcome'.
+ * <p/>
+ * An example of when this method is useful is when data is read from, for example, a legacy datastore, and is cached before
+ * returning the data to the caller. Subsequent calls would prefer to get the data from the cache and if the data doesn't exist
+ * in the cache, fetch again from the legacy datastore.
+ * <p/>
+ * See <a href="http://jira.jboss.com/jira/browse/JBCACHE-848">JBCACHE-848</a> for details around this feature.
+ * <p/>
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.jboss.cache.CacheStatus#STARTED}.
+ */
+ void putForExternalRead(Fqn fqn, K key, V value);
+
+ /**
+ * Copies all of the mappings from the specified map to a {@link Node}.
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to copy the data to
+ * @param data mappings to copy
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ void put(Fqn fqn, Map<? extends K, ? extends V> data);
+
+ /**
+ * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #put(Fqn, java.util.Map)}
+ *
+ * @param fqn String representation of the Fqn
+ * @param data data map to insert
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ void put(String fqn, Map<? extends K, ? extends V> data);
+
+ /**
+ * Removes the mapping for this key from a Node.
+ * Returns the value to which the Node previously associated the key, or
+ * <code>null</code> if the Node contained no mapping for this key.
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
+ * @param key key whose mapping is to be removed from the Node
+ * @return previous value associated with specified Node's key
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ V remove(Fqn fqn, K key);
+
+ /**
+ * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #remove(Fqn, Object)}
+ *
+ * @param fqn string representation of the Fqn to retrieve
+ * @param key key to remove
+ * @return old value removed, or null if the fqn does not exist
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ V remove(String fqn, K key);
+
+ /**
+ * Removes a {@link Node} indicated by absolute {@link Fqn}.
+ *
+ * @param fqn {@link Node} to remove
+ * @return true if the node was removed, false if the node was not found
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ boolean removeNode(Fqn fqn);
+
+ /**
+ * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #removeNode(Fqn)}
+ *
+ * @param fqn string representation of the Fqn to retrieve
+ * @return true if the node was found and removed, false otherwise
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ boolean removeNode(String fqn);
+
+ /**
+ * A convenience method to retrieve a node directly from the cache. Equivalent to calling cache.getRoot().getChild(fqn).
+ *
+ * @param fqn fqn of the node to retrieve
+ * @return a Node object, or a null if the node does not exist.
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ Node<K, V> getNode(Fqn fqn);
+
+ /**
+ * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #getNode(Fqn)}
+ *
+ * @param fqn string representation of the Fqn to retrieve
+ * @return node, or null if the node does not exist
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ Node<K, V> getNode(String fqn);
+
+
+ /**
+ * Convenience method that allows for direct access to the data in a {@link Node}.
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
+ * @param key key under which value is to be retrieved.
+ * @return returns data held under specified key in {@link Node} denoted by specified Fqn.
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ V get(Fqn fqn, K key);
+
+ /**
+ * Convenience method that takes a string representation of an Fqn. Otherwise identical to {@link #get(Fqn, Object)}
+ *
+ * @param fqn string representation of the Fqn to retrieve
+ * @param key key to fetch
+ * @return value, or null if the fqn does not exist.
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ V get(String fqn, K key);
+
+ /**
+ * Eviction call that evicts the specified {@link Node} from memory.
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be evicted.
+ * @param recursive evicts children as well
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ void evict(Fqn fqn, boolean recursive);
+
+ /**
+ * Eviction call that evicts the specified {@link Node} from memory. Not recursive.
+ *
+ * @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be evicted.
+ * @throws IllegalStateException if the cache is not in a started state
+ */
+ void evict(Fqn fqn);
+
+ /**
+ * Retrieves a {@link Region} for a given {@link Fqn}. If the region does not exist,
+ * and <li>createIfAbsent</li> is true, then one is created.
+ * <p/>
+ * If not, parent Fqns will be consulted in turn for registered regions, gradually working up to
+ * Fqn.ROOT. If no regions are defined in any of the parents either, a null is returned.
+ *
+ * @param fqn Fqn that is contained in a region.
+ * @param createIfAbsent If true, will create a new associated region if not found.
+ * @return a MarshRegion. Null if none is found.
+ * @see Region
+ */
+ Region getRegion(Fqn fqn, boolean createIfAbsent);
+
+ /**
+ * Removes a region denoted by the Fqn passed in.
+ *
+ * @param fqn of the region to remove
+ * @return true if a region did exist and was removed; false otherwise.
+ */
+ boolean removeRegion(Fqn fqn);
+
+ /**
+ * Lifecycle method that initializes configuration state, the root node, etc.
+ *
+ * @throws CacheException if there are creation problems
+ */
+ void create() throws CacheException;
+
+ /**
+ * Lifecycle method that starts the cache loader,
+ * starts cache replication, starts the region manager, etc., and (if configured) warms the cache using a
+ * state transfer or cache loader preload.
+ *
+ * @throws CacheException if there are startup problems
+ */
+ void start() throws CacheException;
+
+ /**
+ * Lifecycle method that stops the cache, including replication,
+ * clustering, cache loading, notifications, etc., and clears all cache in-memory state.
+ * <p/>
+ * State can be reconstituted by using either a cache loader or state transfer when the cache starts again.
+ */
+ void stop();
+
+ /**
+ * Lifecycle method that destroys the cache and removes any interceptors/configuration elements.
+ * Cache can then be restarted (potentially after reconfiguring) using {@link #create()} and {@link #start()}.
+ */
+ void destroy();
+
+ /**
+ * Gets where the cache currently is its lifecycle transitions.
+ *
+ * @return the CacheStatus. Will not return <code>null</code>.
+ */
+ CacheStatus getCacheStatus();
+
+ /**
+ * @return the current invocation context for the current invocation and cache instance.
+ * @throws IllegalStateException if the cache has been destroyed.
+ */
+ InvocationContext getInvocationContext();
+
+ /**
+ * Sets the passed in {@link org.jboss.cache.InvocationContext} as current.
+ *
+ * @param ctx invocation context to use
+ * @throws IllegalStateException if the cache has been destroyed.
+ */
+ void setInvocationContext(InvocationContext ctx);
+
+ /**
+ * Returns the local address of this cache in a cluster, or <code>null</code>
+ * if running in local mode.
+ *
+ * @return the local address of this cache in a cluster, or <code>null</code>
+ * if running in local mode.
+ */
+ Address getLocalAddress();
+
+ /**
+ * Returns a list of members in the cluster, or <code>null</code>
+ * if running in local mode.
+ *
+ * @return a {@link List} of members in the cluster, or <code>null</code>
+ * if running in local mode.
+ */
+ List<Address> getMembers();
+
+ /**
+ * Moves a part of the cache to a different subtree.
+ * <p/>
+ * E.g.:
+ * <p/>
+ * assume a cache structure such as:
+ * <p/>
+ * <pre>
+ * /a/b/c
+ * /a/b/d
+ * /a/b/e
+ * <p/>
+ * <p/>
+ * Fqn f1 = Fqn.fromString("/a/b/c");
+ * Fqn f2 = Fqn.fromString("/a/b/d");
+ * <p/>
+ * cache.move(f1, f2);
+ * </pre>
+ * <p/>
+ * Will result in:
+ * <pre>
+ * <p/>
+ * /a/b/d/c
+ * /a/b/e
+ * <p/>
+ * </pre>
+ * <p/>
+ * and now
+ * <p/>
+ * <pre>
+ * Fqn f3 = Fqn.fromString("/a/b/e");
+ * Fqn f4 = Fqn.fromString("/a");
+ * cache.move(f3, f4);
+ * </pre>
+ * <p/>
+ * will result in:
+ * <pre>
+ * /a/b/d/c
+ * /a/e
+ * </pre>
+ * No-op if the node to be moved is the root node.
+ * <p/>
+ * <b>Note</b>: As of 3.0.0 and when using MVCC locking, more specific behaviour is defined as follows:
+ * <ul>
+ * <li>A no-op if the node is moved unto itself. E.g., <tt>move(fqn, fqn.getParent())</tt> will not do anything.</li>
+ * <li>If a target node does not exist it will be created silently, to be more consistent with other APIs such as <tt>put()</tt> on a nonexistent node.</li>
+ * <li>If the source node does not exist this is a no-op, to be more consistent with other APIs such as <tt>get()</tt> on a nonexistent node.</li>
+ * </ul>
+ *
+ * @param nodeToMove the Fqn of the node to move.
+ * @param newParent new location under which to attach the node being moved.
+ * @throws NodeNotExistsException may throw one of these if the target node does not exist or if a different thread has moved this node elsewhere already.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ */
+ void move(Fqn nodeToMove, Fqn newParent) throws NodeNotExistsException;
+
+ /**
+ * Convenience method that takes in string representations of Fqns. Otherwise identical to {@link #move(Fqn, Fqn)}
+ *
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ */
+ void move(String nodeToMove, String newParent) throws NodeNotExistsException;
+
+ /**
+ * Returns the version of the cache as a string.
+ *
+ * @return the version string of the cache.
+ * @see Version#printVersion
+ */
+ String getVersion();
+
+ /**
+ * Retrieves a defensively copied data map of the underlying node. A convenience method to retrieving a node and
+ * getting data from the node directly.
+ *
+ * @param fqn
+ * @return map of data, or an empty map
+ * @throws CacheException
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ */
+ Map<K, V> getData(Fqn fqn);
+
+ /**
+ * Convenience method that takes in a String represenation of the Fqn. Otherwise identical to {@link #getKeys(Fqn)}.
+ */
+ Set<K> getKeys(String fqn);
+
+ /**
+ * Returns a set of attribute keys for the Fqn.
+ * Returns null if the node is not found, otherwise a Set.
+ * The set is a copy of the actual keys for this node.
+ * <p/>
+ * A convenience method to retrieving a node and
+ * getting keys from the node directly.
+ *
+ * @param fqn name of the node
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ */
+ Set<K> getKeys(Fqn fqn);
+
+ /**
+ * Convenience method that takes in a String represenation of the Fqn. Otherwise identical to {@link #clearData(Fqn)}.
+ *
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ */
+ void clearData(String fqn);
+
+ /**
+ * Removes the keys and properties from a named node.
+ * <p/>
+ * A convenience method to retrieving a node and
+ * getting keys from the node directly.
+ *
+ * @param fqn name of the node
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ */
+ void clearData(Fqn fqn);
+
+ /**
+ * Starts a batch. This is a lightweight batching mechanism that groups cache writes together and finally performs the
+ * write, persistence and/or replication when {@link #endBatch(boolean)} is called rather than for each invocation on the
+ * cache.
+ * <p/>
+ * Note that if there is an existing transaction in scope and the cache has been configured to use a JTA compliant
+ * transaction manager, calls to {@link #startBatch()} and {@link #endBatch(boolean)} are ignored and treated as no-ops.
+ * <p/>
+ *
+ * @see #endBatch(boolean)
+ * @since 3.0
+ */
+ void startBatch();
+
+ /**
+ * Ends an existing ongoing batch. A no-op if a batch has not been started yet.
+ * <p/>
+ * Note that if there is an existing transaction in scope and the cache has been configured to use a JTA compliant
+ * transaction manager, calls to {@link #startBatch()} and {@link #endBatch(boolean)} are ignored and treated as no-ops.
+ * <p/>
+ *
+ * @param successful if <tt>true</tt>, changes made in the batch are committed. If <tt>false</tt>, they are discarded.
+ * @see #startBatch()
+ * @since 3.0
+ */
+ void endBatch(boolean successful);
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/cache/Cache_Legacy.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/ConsoleListener.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -54,7 +54,7 @@
@CacheListener
public class ConsoleListener
{
- private CacheSPI cache;
+ private CacheSPI_Legacy cache;
private boolean startCache;
/**
@@ -65,7 +65,7 @@
*
* @param cache the cache to monitor for replication events.
*/
- public ConsoleListener(CacheSPI cache)
+ public ConsoleListener(CacheSPI_Legacy cache)
throws Exception
{
this(cache, true, true);
@@ -80,7 +80,7 @@
* @param stopCache indicates whether or not the cache should be stopped by
* this class.
*/
- public ConsoleListener(CacheSPI cache,
+ public ConsoleListener(CacheSPI_Legacy cache,
boolean startCache, boolean stopCache)
throws Exception
{
@@ -240,7 +240,7 @@
System.out.print("No xml config file argument is supplied. Will use jboss-cache.xml from classpath");
}
- CacheSPI cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(configFileName);
+ CacheSPI_Legacy cache = (CacheSPI_Legacy) new DefaultCacheFactory<Object, Object>().createCache(configFileName);
ConsoleListener listener = new ConsoleListener(cache);
listener.listen();
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,13 +22,13 @@
package org.jboss.cache;
import org.jboss.cache.annotations.Compat;
-import org.jboss.cache.factories.ComponentFactory;
-import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.jmx.PlatformMBeanServerRegistration;
+import org.jboss.starobrno.CacheDelegate;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.parsing.XmlConfigurationParser;
+import org.jboss.starobrno.factories.ComponentFactory;
+import org.jboss.starobrno.factories.ComponentRegistry;
import java.io.InputStream;
@@ -60,22 +60,22 @@
return new DefaultCacheFactory();
}
- public Cache<K, V> createCache() throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache() throws ConfigurationException
{
return createCache(true);
}
- public Cache<K, V> createCache(boolean start) throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache(boolean start) throws ConfigurationException
{
return createCache(new Configuration(), start);
}
- public Cache<K, V> createCache(String configFileName) throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache(String configFileName) throws ConfigurationException
{
return createCache(configFileName, true);
}
- public Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache(String configFileName, boolean start) throws ConfigurationException
{
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c;
@@ -90,7 +90,7 @@
* @return a cache
* @throws ConfigurationException if there are problems with the cfg
*/
- public Cache<K, V> createCache(Configuration configuration) throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache(Configuration configuration) throws ConfigurationException
{
return createCache(configuration, true);
}
@@ -103,11 +103,11 @@
* @return a cache
* @throws ConfigurationException if there are problems with the cfg
*/
- public Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache(Configuration configuration, boolean start) throws ConfigurationException
{
try
{
- CacheSPI<K, V> cache = createAndWire(configuration);
+ org.jboss.starobrno.CacheSPI<K, V> cache = createAndWire(configuration);
if (start) cache.start();
return cache;
}
@@ -125,9 +125,9 @@
}
}
- protected CacheSPI<K, V> createAndWire(Configuration configuration) throws Exception
+ protected org.jboss.starobrno.CacheSPI<K, V> createAndWire(Configuration configuration) throws Exception
{
- CacheSPI<K, V> spi = new CacheInvocationDelegate<K, V>();
+ org.jboss.starobrno.CacheSPI<K, V> spi = new CacheDelegate<K, V>();
bootstrap(spi, configuration);
return spi;
}
@@ -135,14 +135,14 @@
/**
* Bootstraps this factory with a Configuration and a ComponentRegistry.
*/
- private void bootstrap(CacheSPI spi, Configuration configuration)
+ private void bootstrap(org.jboss.starobrno.CacheSPI spi, Configuration configuration)
{
// injection bootstrap stuff
componentRegistry = new ComponentRegistry(configuration, spi);
componentRegistry.registerDefaultClassLoader(defaultClassLoader);
this.configuration = configuration;
- componentRegistry.registerComponent(spi, CacheSPI.class);
+ componentRegistry.registerComponent(spi, org.jboss.starobrno.CacheSPI.class);
componentRegistry.registerComponent(new PlatformMBeanServerRegistration(), PlatformMBeanServerRegistration.class);
}
@@ -156,7 +156,7 @@
this.defaultClassLoader = loader;
}
- public Cache<K, V> createCache(InputStream is) throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache(InputStream is) throws ConfigurationException
{
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = null;
@@ -164,7 +164,7 @@
return createCache(c);
}
- public Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
+ public org.jboss.starobrno.Cache<K, V> createCache(InputStream is, boolean start) throws ConfigurationException
{
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = parser.parseStream(is);
Modified: core/branches/flat/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Fqn.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/Fqn.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -37,7 +37,7 @@
/**
* A Fully Qualified Name (Fqn) is a list of names (typically Strings but can be any Object),
- * which represent a path to a particular {@link Node} or sometimes a {@link Region} in a {@link Cache}.
+ * which represent a path to a particular {@link Node} or sometimes a {@link Region} in a {@link Cache_Legacy}.
* <p/>
* This name can be absolute (i.e., relative from the root node - {@link #ROOT}), or relative to any node in the cache. Reading the
* documentation on each API call that makes use of {@link org.jboss.cache.Fqn}s will tell you whether the API expects a
Modified: core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -200,7 +200,7 @@
NodeSPI<K, V> getParent();
- CacheSPI<K, V> getCache();
+ CacheSPI_Legacy<K, V> getCache();
NodeLock getLock();
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/Node.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Node.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/Node.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -27,7 +27,7 @@
import java.util.Set;
/**
- * A Node is a {@link Fqn named} logical grouping of data in the JBoss {@link Cache}.
+ * A Node is a {@link Fqn named} logical grouping of data in the JBoss {@link Cache_Legacy}.
* A node should be used to contain data for a single data record, for example
* information about a particular person or account.
* <p/>
@@ -45,7 +45,7 @@
* <p/>
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @see Cache
+ * @see Cache_Legacy
* @since 2.0.0
*/
@ThreadSafe
@@ -110,7 +110,7 @@
/**
* Removes a child node specified by the given relative {@link Fqn}.
* <p/>
- * If you wish to remove children based on absolute {@link Fqn}s, use the {@link Cache} interface instead.
+ * If you wish to remove children based on absolute {@link Fqn}s, use the {@link Cache_Legacy} interface instead.
*
* @param f {@link Fqn} of the child node, relative to the current node.
* @return true if the node was found and removed, false otherwise
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -30,7 +30,7 @@
/**
* A more detailed interface to {@link Node}, which is used when writing plugins for or extending JBoss Cache. References are usually
- * obtained by calling methods on {@link org.jboss.cache.CacheSPI}.
+ * obtained by calling methods on {@link CacheSPI_Legacy}.
* <p/>
* <B><I>You should NEVER attempt to directly cast a {@link Node} instance to this interface. In future, the implementation may not allow it.</I></B>
* <p/>
@@ -57,7 +57,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @see Node
- * @see org.jboss.cache.CacheSPI
+ * @see CacheSPI_Legacy
* @since 2.0.0
*/
@NotThreadSafe
@@ -459,7 +459,7 @@
*
* @return a cache
*/
- CacheSPI<K, V> getCache();
+ CacheSPI_Legacy<K, V> getCache();
// ----------- these methods override their corresponding methods in Node, so that the return types are NodeSPI rather than Node.
Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -24,31 +24,30 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.jmx.annotations.MBean;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.concurrent.ReclosableLatch;
import org.jboss.cache.util.reflect.ReflectionUtil;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.starobrno.transaction.TransactionTable;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.ChannelException;
@@ -110,7 +109,7 @@
private ChannelMessageListener messageListener;
private Configuration configuration;
private Notifier notifier;
- private CacheSPI spi;
+ private CacheSPI_Legacy spi;
private InvocationContextContainer invocationContextContainer;
private final boolean trace = log.isTraceEnabled();
private Marshaller marshaller;
@@ -125,14 +124,15 @@
@Inject
public void setupDependencies(ChannelMessageListener messageListener, Configuration configuration, Notifier notifier,
- CacheSPI spi, Marshaller marshaller, TransactionTable txTable,
+ Marshaller marshaller, TransactionTable txTable,
TransactionManager txManager, InvocationContextContainer container, InterceptorChain interceptorChain,
ComponentRegistry componentRegistry, LockManager lockManager)
{
this.messageListener = messageListener;
this.configuration = configuration;
this.notifier = notifier;
- this.spi = spi;
+ // TODO: Inject cacheSPI when we are ready
+// this.spi = spi;
this.marshaller = marshaller;
this.txManager = txManager;
this.txTable = txTable;
@@ -368,7 +368,9 @@
for (GlobalTransaction deadOwner : deadOwners)
{
boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
- boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+ // TODO: Fix me!!!
+// boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+ boolean broken = true;
if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);
}
@@ -396,7 +398,8 @@
for (GlobalTransaction deadOwner : deadOwners)
{
boolean localTx = deadOwner.getAddress().equals(getLocalAddress());
- boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+// boolean broken = LockUtil.breakTransactionLock(node.getFqn(), lockManager, deadOwner, localTx, txTable, txManager);
+ boolean broken = true; // TODO fix me!!
if (broken && trace) log.trace("Broke lock for node " + node.getFqn() + " held by " + deadOwner);
}
@@ -674,8 +677,10 @@
// now notify listeners - *after* updating the coordinator. - JBCACHE-662
if (needNotification && notifier != null)
{
- InvocationContext ctx = spi.getInvocationContext();
- notifier.notifyViewChange(newView, ctx);
+ // TODO: Fix me when we have repl working
+ throw new UnsupportedOperationException("Fix me!");
+// InvocationContext ctx = spi.getInvocationContext();
+// notifier.notifyViewChange(newView, ctx);
}
// Wake up any threads that are waiting to know about who the coordinator is
Modified: core/branches/flat/src/main/java/org/jboss/cache/Region.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Region.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/Region.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -27,7 +27,7 @@
import org.jboss.starobrno.eviction.EvictionEvent;
/**
- * Defines characteristics such as class loading and eviction of {@link org.jboss.cache.Node}s belonging to a Region in a {@link Cache}.
+ * Defines characteristics such as class loading and eviction of {@link org.jboss.cache.Node}s belonging to a Region in a {@link Cache_Legacy}.
* A Region is described by an {@link #getFqn() Fqn} relative to the root of the cache.
* All nodes and child nodes of this Fqn belong to this region.
* <p/>
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -192,7 +192,7 @@
*/
String dumpRegions();
- CacheSPI getCache();
+ CacheSPI_Legacy getCache();
/**
* @return the eviction timer task attached to the region manager
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -66,7 +66,7 @@
private boolean defaultInactive;
protected static final Log log = LogFactory.getLog(RegionManagerImpl.class);
protected static final boolean trace = log.isTraceEnabled();
- CacheSPI<?, ?> cache;
+ CacheSPI_Legacy<?, ?> cache;
private boolean usingEvictions;
private EvictionConfig evictionConfig;
private final org.jboss.starobrno.eviction.EvictionTimerTask evictionTimerTask = new org.jboss.starobrno.eviction.EvictionTimerTask();
@@ -96,7 +96,7 @@
}
@Inject
- public void injectDependencies(CacheSPI cache, Configuration configuration, RPCManager rpcManager, LockManager lockManager,
+ public void injectDependencies(CacheSPI_Legacy cache, Configuration configuration, RPCManager rpcManager, LockManager lockManager,
BuddyFqnTransformer transformer, RegionRegistry regionsRegistry)
{
this.cache = cache;
@@ -721,7 +721,7 @@
return "RegionManager " + dumpRegions();
}
- public CacheSPI getCache()
+ public CacheSPI_Legacy getCache()
{
return cache;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/TreeCacheViewMBean.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/TreeCacheViewMBean.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/TreeCacheViewMBean.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -39,9 +39,9 @@
void destroy();
- Cache getCache();
+ Cache_Legacy getCache();
- void setCache(Cache cache);
+ void setCache(Cache_Legacy cache);
CacheJmxWrapperMBean getCacheService();
Modified: core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -59,7 +59,7 @@
*/
protected Map<K, V> data;
protected NodeSPI<K, V> delegate;
- protected CacheSPI<K, V> cache;
+ protected CacheSPI_Legacy<K, V> cache;
/**
* Constructs a new node with an FQN of Root.
@@ -81,7 +81,7 @@
initFlags();
}
- public UnversionedNode(Fqn fqn, CacheSPI<K, V> cache, boolean lockForChildInsertRemove)
+ public UnversionedNode(Fqn fqn, CacheSPI_Legacy<K, V> cache, boolean lockForChildInsertRemove)
{
initFlags();
this.cache = cache;
@@ -100,7 +100,7 @@
}
}
- public UnversionedNode(Fqn fqn, CacheSPI<K, V> cache, boolean lockForChildInsertRemove, Map<K, V> data)
+ public UnversionedNode(Fqn fqn, CacheSPI_Legacy<K, V> cache, boolean lockForChildInsertRemove, Map<K, V> data)
{
this(fqn, cache, lockForChildInsertRemove);
if (data != null) this.data = new FastCopyHashMap<K, V>(data);
@@ -144,7 +144,7 @@
// if (data == null) data = new FastCopyHashMap<K, V>();
// }
- public CacheSPI<K, V> getCache()
+ public CacheSPI_Legacy<K, V> getCache()
{
return cache;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Version.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/Version.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -32,7 +32,7 @@
@Immutable
public class Version
{
- public static final String version = "1.0-SNAPSHOT";
+ public static final String version = "1.0.0.SNAPSHOT";
public static final String codename = "Starobrno";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
static final byte[] version_id = {'0', '1', '0', '0', 'S'};
Modified: core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -28,8 +28,8 @@
import javax.transaction.TransactionManager;
/**
- * A container for holding thread locals for batching, to be used with the {@link org.jboss.cache.Cache#startBatch()} and
- * {@link org.jboss.cache.Cache#endBatch(boolean)} calls.
+ * A container for holding thread locals for batching, to be used with the {@link org.jboss.cache.Cache_Legacy#startBatch()} and
+ * {@link org.jboss.cache.Cache_Legacy#endBatch(boolean)} calls.
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 3.0
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
@@ -104,7 +104,7 @@
/**
* back-refernce to the CacheImpl object
*/
- private CacheSPI<?, ?> cache;
+ private CacheSPI_Legacy<?, ?> cache;
private Configuration configuration;
private RegionManager regionManager;
private Notifier notifier;
@@ -208,7 +208,7 @@
}
@Inject
- public void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager,
+ public void injectDependencies(CacheSPI_Legacy cache, Configuration configuration, RegionManager regionManager,
StateTransferManager stateTransferManager, RPCManager rpcManager, Notifier notifier,
CommandsFactory factory, DataContainer dataContainer, BuddyFqnTransformer transformer)
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.commands;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.RPCManager;
@@ -78,14 +78,14 @@
protected InterceptorChain invoker;
protected BuddyManager buddyManager;
protected TransactionTable transactionTable;
- protected CacheSPI cacheSpi;
+ protected CacheSPI_Legacy cacheSpi;
protected Configuration configuration;
protected TransactionManager txManager;
protected BuddyFqnTransformer buddyFqnTransformer;
@Inject
public void initialize(RPCManager rpc, DataContainer dataContainer, Notifier notifier, BuddyManager buddyManager,
- InterceptorChain invoker, TransactionTable transactionTable, CacheSPI cacheSpi,
+ InterceptorChain invoker, TransactionTable transactionTable, CacheSPI_Legacy cacheSpi,
Configuration configuration, TransactionManager txManager, BuddyFqnTransformer buddyFqnTransformer)
{
this.rpcManager = rpc;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -28,7 +28,7 @@
import org.jboss.cache.util.Immutables;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#getData(org.jboss.cache.Fqn)}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#getData(org.jboss.cache.Fqn)}
* <p/>
* This is the equivalent of the old MethodCallDefinitions.getDataMapMethodLocal method call from 2.1.x.
* <p/>
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.read;
import org.apache.commons.logging.Log;
@@ -31,7 +31,7 @@
import org.jboss.cache.notifications.Notifier;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#get(String, Object)}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#get(String, Object)}
* <p/>
* This is the equivalent of the old MethodCallDefinitions.getKeyValueMethodLocal method call from 2.1.x.
* <p/>
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.read;
import org.jboss.cache.Fqn;
@@ -27,7 +27,7 @@
import org.jboss.cache.commands.Visitor;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#getKeys(org.jboss.cache.Fqn)}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#getKeys(org.jboss.cache.Fqn)}
* <p/>
* This is the equivalent of the old MethodCallDefinitions.getKeysMethodLocal method call from 2.1.x.
* <p/>
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.read;
import org.apache.commons.logging.Log;
@@ -29,7 +29,7 @@
import org.jboss.cache.commands.Visitor;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#getNode(org.jboss.cache.Fqn)}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#getNode(org.jboss.cache.Fqn)}
* <p/>
* This is the equivalent of the old MethodCallDefinitions.getNodeMethodLocal method call from 2.1.x.
* <p/>
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
@@ -56,7 +56,7 @@
public static final int METHOD_ID = 35;
/* dependencies */
- private CacheSPI spi;
+ private CacheSPI_Legacy spi;
/* parametres */
protected boolean searchSubtrees;
@@ -78,7 +78,7 @@
this.localAddress = localAddress;
}
- public void initialize(DataContainer dataContainer, CacheSPI spi, BuddyFqnTransformer transformer)
+ public void initialize(DataContainer dataContainer, CacheSPI_Legacy spi, BuddyFqnTransformer transformer)
{
this.dataContainer = dataContainer;
this.spi = spi;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -33,7 +33,7 @@
import java.util.Map;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#clearData(String)}}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#clearData(String)}}
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
@@ -38,7 +38,7 @@
import java.util.List;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#evict(org.jboss.cache.Fqn)}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#evict(org.jboss.cache.Fqn)}
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,29 +1,29 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
@@ -46,7 +46,7 @@
private static final boolean trace = log.isTraceEnabled();
/* dependencies*/
- protected CacheSPI spi;
+ protected CacheSPI_Legacy spi;
protected Notifier notifier;
public InvalidateCommand(Fqn fqn)
@@ -58,7 +58,7 @@
{
}
- public void initialize(CacheSPI cacheSpi, DataContainer dataContainer, Notifier notifier)
+ public void initialize(CacheSPI_Legacy cacheSpi, DataContainer dataContainer, Notifier notifier)
{
this.spi = cacheSpi;
this.dataContainer = dataContainer;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
@@ -37,7 +37,7 @@
import java.util.Map;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)}
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -35,7 +35,7 @@
import java.util.Map;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#put(String, java.util.Map)}.
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#put(String, java.util.Map)}.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -27,7 +27,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
/**
- * Represents the {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn, Object, Object)} method call.
+ * Represents the {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn, Object, Object)} method call.
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.2.0
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -35,7 +35,7 @@
import java.util.Map;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#put(org.jboss.cache.Fqn, Object, Object)}.
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#put(org.jboss.cache.Fqn, Object, Object)}.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -34,7 +34,7 @@
import java.util.Map;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#remove(org.jboss.cache.Fqn, Object)}
+ * Implements functionality defined by {@link org.jboss.cache.Cache_Legacy#remove(org.jboss.cache.Fqn, Object)}
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -32,7 +32,7 @@
import java.util.Map;
/**
- * Implements functionality defined by {@link org.jboss.cache.CacheSPI#removeNode(org.jboss.cache.Fqn)}
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI_Legacy#removeNode(org.jboss.cache.Fqn)}
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -38,8 +38,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.context.ContextFactory;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -51,7 +49,9 @@
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.context.ContextFactory;
import javax.transaction.InvalidTransactionException;
import javax.transaction.Status;
@@ -351,8 +351,9 @@
{
// create a new transaction transactionContext
if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
- transactionContext = contextFactory.createTransactionContext(ltx);
- txTable.put(gtx, transactionContext);
+// transactionContext = contextFactory.createTransactionContext(ltx);
+ throw new RuntimeException("Delete this class!");
+// txTable.put(gtx, transactionContext);
}
setTransactionalContext(ltx, gtx, transactionContext, ctx);
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -33,7 +33,7 @@
* This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
* allowing it to intercept invocations on {@link org.jboss.cache.commands.VisitableCommand}s.
* <p/>
- * Commands are created either by the {@link org.jboss.cache.invocation.CacheInvocationDelegate} (for invocations on the {@link org.jboss.cache.Cache}
+ * Commands are created either by the {@link org.jboss.cache.invocation.CacheInvocationDelegate} (for invocations on the {@link org.jboss.cache.Cache_Legacy}
* public interface), the {@link org.jboss.cache.invocation.NodeInvocationDelegate} for invocations on the {@link org.jboss.cache.Node}
* public interface, or by the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher} for remotely originating invocations, and
* are passed up the interceptor chain by using the {@link org.jboss.cache.interceptors.InterceptorChain} helper class.
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,9 +22,9 @@
package org.jboss.cache.invocation;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
@@ -52,7 +52,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
@@ -67,6 +66,7 @@
import org.jboss.starobrno.config.Configuration.NodeLockingScheme;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.factories.annotations.Start;
@@ -87,7 +87,7 @@
* @since 2.1.0
*/
@NonVolatile
-public class CacheInvocationDelegate<K, V> extends AbstractInvocationDelegate implements CacheSPI<K, V>
+public class CacheInvocationDelegate<K, V> extends AbstractInvocationDelegate implements CacheSPI_Legacy<K, V>
{
private static final Log log = LogFactory.getLog(CacheInvocationDelegate.class);
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,9 +22,9 @@
package org.jboss.cache.invocation;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.factories.context.ContextFactory;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.context.ContextFactory;
/**
* Container and factory for thread locals
@@ -46,7 +46,9 @@
@Override
protected InvocationContext initialValue()
{
+ throw new RuntimeException("Delete this class!");
+ // todo - delete this class, do not use!!
// create if this is initially unset
- return contextFactory.createInvocationContext();
+// return contextFactory.createInvocationContext();
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
@@ -54,7 +54,7 @@
private static final boolean trace = log.isTraceEnabled();
protected volatile InternalNode<K, V> node;
- private CacheSPI<K, V> spi;
+ private CacheSPI_Legacy<K, V> spi;
public NodeInvocationDelegate(InternalNode<K, V> node)
{
@@ -66,7 +66,7 @@
return node;
}
- public void injectDependencies(CacheSPI<K, V> spi)
+ public void injectDependencies(CacheSPI_Legacy<K, V> spi)
{
this.spi = spi;
}
@@ -242,7 +242,7 @@
return node.getChildrenNames();
}
- public CacheSPI<K, V> getCache()
+ public CacheSPI_Legacy<K, V> getCache()
{
return spi;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,10 +23,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.util.CachePrinter;
import org.jboss.starobrno.CacheException;
@@ -80,7 +80,7 @@
private MBeanServer server;
private String cacheObjectName;
private boolean jmxResourceRegistered;
- private CacheSPI<K, V> cache;
+ private CacheSPI_Legacy<K, V> cache;
private Configuration config;
private boolean registerJmxResource = true;
private final AtomicInteger listenerCount = new AtomicInteger(0);
@@ -113,7 +113,7 @@
cacheStatus = CacheStatus.INSTANTIATED;
}
- public CacheJmxWrapper(Cache<K, V> cache)
+ public CacheJmxWrapper(Cache_Legacy<K, V> cache)
{
this();
setCache(cache);
@@ -121,7 +121,7 @@
// --------------------------------------------------- CacheJmxWrapperMBean
- public Cache<K, V> getCache()
+ public Cache_Legacy<K, V> getCache()
{
return cache;
}
@@ -805,7 +805,7 @@
*
* @param cache
*/
- public void setCache(Cache<K, V> cache)
+ public void setCache(Cache_Legacy<K, V> cache)
{
if (cacheStatus != CacheStatus.INSTANTIATED
&& cacheStatus != CacheStatus.CREATING
@@ -814,7 +814,7 @@
throw new IllegalStateException("Cannot set underlying cache after call to create()");
}
- this.cache = (CacheSPI<K, V>) cache;
+ this.cache = (CacheSPI_Legacy<K, V>) cache;
this.config = (cache == null ? null : cache.getConfiguration());
synchronized (listenerCount)
{
@@ -946,11 +946,12 @@
{
log.debug("Constructing Cache");
CacheFactory<K, V> cf = new DefaultCacheFactory<K, V>();
- setCache(cf.createCache(config, false));
- if (multiplexerService != null)
- {
- injectMuxChannel();
- }
+ throw new UnsupportedOperationException("Fix me to use a flat cache!!");
+// setCache(cf.createCache(config, false));
+// if (multiplexerService != null)
+// {
+// injectMuxChannel();
+// }
}
protected boolean registerJmxResources() throws CacheException
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.jmx;
-import org.jboss.cache.Cache;
import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.Configuration;
import org.jgroups.Address;
@@ -30,7 +30,7 @@
import java.util.List;
/**
- * JMX interface to the {@link org.jboss.cache.Cache}. Full access to the cache is not supported, only a certain
+ * JMX interface to the {@link org.jboss.cache.Cache_Legacy}. Full access to the cache is not supported, only a certain
* set of operations are exposed via JMX:
* <p/>
* <ol>
@@ -108,9 +108,9 @@
int getState();
/**
- * Retrieves a reference to the underlying {@link Cache}
+ * Retrieves a reference to the underlying {@link org.jboss.cache.Cache_Legacy}
*/
- Cache<K, V> getCache();
+ Cache_Legacy<K, V> getCache();
/**
* @return an immutable configuration
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,11 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.Cache_Legacy;
+import org.jboss.starobrno.Cache;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.ComponentRegistry;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@@ -87,9 +88,14 @@
processBaseName(objectNameBase);
}
+ public JmxRegistrationManager(MBeanServer mBeanServer, Cache_Legacy cache, String objectNameBase)
+ {
+ throw new UnsupportedOperationException("Remove any code that relies on this!");
+ }
+
/**
* @throws IllegalArgumentException if the supplied objectNameBase name isn't valid
- * @see #JmxRegistrationManager(javax.management.MBeanServer, org.jboss.cache.Cache, javax.management.ObjectName)
+ * @see #JmxRegistrationManager(javax.management.MBeanServer, org.jboss.cache.Cache_Legacy , javax.management.ObjectName)
*/
public JmxRegistrationManager(MBeanServer mBeanServer, Cache cache, String objectNameBase)
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,6 +22,7 @@
package org.jboss.cache.jmx;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.starobrno.config.Configuration;
import javax.management.JMException;
@@ -61,7 +62,7 @@
}
}
- public static String getDefaultCacheObjectName(org.jboss.cache.Cache cache)
+ public static String getDefaultCacheObjectName(Cache_Legacy cache)
{
// get the cache's registration name
return getDefaultCacheObjectName(cache.getConfiguration(), cache.getClass().getName());
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Region;
@@ -60,7 +60,7 @@
*/
public abstract class AbstractCacheLoader implements CacheLoader
{
- protected CacheSPI cache;
+ protected CacheSPI_Legacy cache;
protected RegionManager regionManager;
private static final Log log = LogFactory.getLog(AbstractCacheLoader.class);
private static final boolean trace = log.isTraceEnabled();
@@ -166,7 +166,7 @@
}
- public void setCache(CacheSPI c)
+ public void setCache(CacheSPI_Legacy c)
{
this.cache = c;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
@@ -73,7 +73,7 @@
}
@Override
- public void setCache(CacheSPI c)
+ public void setCache(CacheSPI_Legacy c)
{
super.setCache(c);
cacheLoader.setCache(c);
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,7 +22,7 @@
package org.jboss.cache.loader;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
@@ -43,7 +43,7 @@
* <p/>
* Lifecycle: First an instance of the loader is created, then the
* configuration ({@link #setConfig(org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig)}) and cache ({@link
- * #setCache(CacheSPI)}) are set. After this, {@link #create()} is called.
+ * #setCache(org.jboss.cache.CacheSPI_Legacy)}) are set. After this, {@link #create()} is called.
* Then {@link #start()} is called. When re-deployed, {@link #stop()} will be
* called, followed by another {@link #start()}. Finally, when shut down,
* {@link #destroy()} is called, after which the loader is unusable.
@@ -56,7 +56,7 @@
* <p/>
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @see CacheSPI
+ * @see org.jboss.cache.CacheSPI_Legacy
* @see org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig
* @see org.jboss.cache.loader.AbstractCacheLoader
* @since 2.0.0
@@ -84,13 +84,13 @@
IndividualCacheLoaderConfig getConfig();
/**
- * Sets the {@link CacheSPI} that is maintaining this CacheLoader.
- * This method allows this CacheLoader to set a reference to the {@link CacheSPI}.
+ * Sets the {@link org.jboss.cache.CacheSPI_Legacy} that is maintaining this CacheLoader.
+ * This method allows this CacheLoader to set a reference to the {@link org.jboss.cache.CacheSPI_Legacy}.
* This method is called be called after the CacheLoader instance has been constructed.
*
* @param c The cache on which this loader works
*/
- void setCache(CacheSPI c);
+ void setCache(CacheSPI_Legacy c);
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,10 +23,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.util.reflect.ReflectionUtil;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.config.CacheLoaderConfig;
@@ -34,6 +33,7 @@
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.factories.annotations.Stop;
@@ -83,7 +83,7 @@
{
private static final Log log = LogFactory.getLog(CacheLoaderManager.class);
private CacheLoaderConfig config;
- private CacheSPI cache;
+ private CacheSPI_Legacy cache;
private CacheLoader loader;
private boolean fetchPersistentState;
private Configuration configuration;
@@ -91,11 +91,12 @@
private ComponentRegistry registry;
@Inject
- public void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager, ComponentRegistry registry)
+ public void injectDependencies(Configuration configuration, RegionManager regionManager, ComponentRegistry registry)
{
+ // TODO: Inject CacheSPI once we have the cache loaders not relying on a tree structure
this.regionManager = regionManager;
this.config = configuration.getCacheLoaderConfig();
- this.cache = cache;
+// this.cache = cache;
this.configuration = configuration;
this.registry = registry;
@@ -119,7 +120,7 @@
* @param cache
* @throws CacheException
*/
- public void setConfig(CacheLoaderConfig config, CacheSPI cache, Configuration configuration) throws CacheException
+ public void setConfig(CacheLoaderConfig config, CacheSPI_Legacy cache, Configuration configuration) throws CacheException
{
this.config = config == null ? configuration.getCacheLoaderConfig() : config;
this.cache = cache;
@@ -221,7 +222,7 @@
* @throws Exception
*/
@SuppressWarnings("deprecation")
- private CacheLoader createCacheLoader(CacheLoaderConfig.IndividualCacheLoaderConfig cfg, CacheSPI cache) throws Exception
+ private CacheLoader createCacheLoader(CacheLoaderConfig.IndividualCacheLoaderConfig cfg, CacheSPI_Legacy cache) throws Exception
{
// create loader
CacheLoader tmpLoader = cfg.getCacheLoader() == null ? createInstance(cfg.getClassName()) : cfg.getCacheLoader();
@@ -288,7 +289,7 @@
* @param c instance of cache to be set in cache loader
* @param loader cache loader to which assign the cache instance
*/
- protected void setCacheInLoader(CacheSPI c, CacheLoader loader)
+ protected void setCacheInLoader(CacheSPI_Legacy c, CacheLoader loader)
{
loader.setCache(c);
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -24,9 +24,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.starobrno.config.CacheLoaderConfig;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import java.io.ObjectInputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -53,14 +53,14 @@
{
IndividualCacheLoaderConfig config;
- CacheSPI delegate = null;
+ CacheSPI_Legacy delegate = null;
public void setConfig(IndividualCacheLoaderConfig config)
{
this.config = config;
if (config instanceof LocalDelegatingCacheLoaderConfig)
{
- delegate = (CacheSPI) ((LocalDelegatingCacheLoaderConfig) config).getDelegate();
+ delegate = (CacheSPI_Legacy) ((LocalDelegatingCacheLoaderConfig) config).getDelegate();
}
}
@@ -122,7 +122,7 @@
if (node != null) node.clearData();
}
- protected void setDelegateCache(CacheSPI delegate)
+ protected void setDelegateCache(CacheSPI_Legacy delegate)
{
this.delegate = delegate;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.Cache;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
@@ -30,7 +30,7 @@
{
private static final long serialVersionUID = 4626734068542420865L;
- private transient Cache delegate;
+ private transient Cache_Legacy delegate;
public LocalDelegatingCacheLoaderConfig()
{
@@ -74,12 +74,12 @@
return clone;
}
- public Cache getDelegate()
+ public Cache_Legacy getDelegate()
{
return delegate;
}
- public void setDelegate(Cache delegate)
+ public void setDelegate(Cache_Legacy delegate)
{
this.delegate = delegate;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
@@ -158,7 +158,7 @@
* @param c instance of CacheSPI
*/
@Override
- public void setCache(CacheSPI c)
+ public void setCache(CacheSPI_Legacy c)
{
super.setCache(c);
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -40,7 +40,7 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.loader.AbstractCacheLoader;
@@ -321,7 +321,7 @@
* Sets the CacheImpl owner of this cache loader.
*/
@Override
- public void setCache(CacheSPI c)
+ public void setCache(CacheSPI_Legacy c)
{
super.setCache(c);
checkNotOpen();
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -29,7 +29,7 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.FqnComparator;
import org.jboss.cache.Modification;
@@ -250,7 +250,7 @@
* Sets the CacheImpl owner of this cache loader.
*/
@Override
- public void setCache(CacheSPI c)
+ public void setCache(CacheSPI_Legacy c)
{
super.setCache(c);
checkNotOpen();
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,8 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
@@ -63,7 +63,7 @@
private ServerSocket srv_sock;
private InetAddress bind_addr = null;
private int port = 7500;
- private CacheSPI cache;
+ private CacheSPI_Legacy cache;
private CacheJmxWrapperMBean wrapper;
private String config;
private boolean running = true;
@@ -109,12 +109,12 @@
this.config = config;
}
- public Cache getCache()
+ public Cache_Legacy getCache()
{
return cache;
}
- public void setCache(CacheSPI cache)
+ public void setCache(CacheSPI_Legacy cache)
{
this.cache = cache;
}
@@ -131,7 +131,7 @@
// cache not directly set; get from wrapper or create from config
if (wrapper != null)
{
- cache = (CacheSPI) wrapper.getCache();
+ cache = (CacheSPI_Legacy) wrapper.getCache();
if (cache == null)
{
@@ -142,7 +142,7 @@
}
else if (config != null)
{
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(this.config);
+ cache = (CacheSPI_Legacy) new DefaultCacheFactory<Object, Object>().createCache(this.config);
}
}
@@ -255,10 +255,10 @@
private Socket sock = null;
private ObjectInputStream input = null;
private ObjectOutputStream output = null;
- private CacheSPI c;
+ private CacheSPI_Legacy c;
private Thread t = null;
- public Connection(Socket sock, CacheSPI cache) throws IOException
+ public Connection(Socket sock, CacheSPI_Legacy cache) throws IOException
{
this.sock = sock;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServerMBean.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServerMBean.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServerMBean.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader.tcp;
-import org.jboss.cache.Cache;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.jmx.CacheJmxWrapperMBean;
import java.net.UnknownHostException;
@@ -55,7 +55,7 @@
void setConfig(String config);
- Cache getCache();
+ Cache_Legacy getCache();
void setCacheJmxWrapper(CacheJmxWrapperMBean wrapper);
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
@@ -72,14 +72,14 @@
LockContainer<Fqn> lockContainer;
DataContainer dataContainer;
private Set<Fqn> internalFqns;
- private CacheSPI<?, ?> cache;
+ private CacheSPI_Legacy<?, ?> cache;
private TransactionManager transactionManager;
private InvocationContextContainer invocationContextContainer;
private static final Log log = LogFactory.getLog(MVCCLockManager.class);
private static final boolean trace = log.isTraceEnabled();
@Inject
- public void injectDependencies(DataContainer dataContainer, CacheSPI cache, TransactionManager transactionManager, InvocationContextContainer invocationContextContainer)
+ public void injectDependencies(DataContainer dataContainer, CacheSPI_Legacy cache, TransactionManager transactionManager, InvocationContextContainer invocationContextContainer)
{
this.dataContainer = dataContainer;
this.cache = cache;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -81,10 +81,10 @@
protected boolean useRefs = false;
@Inject
- void injectDependencies(RegionManager regionManager, Configuration configuration, ClassLoader defaultClassLoader)
+ void injectDependencies(Configuration configuration, ClassLoader defaultClassLoader)
{
this.defaultClassLoader = defaultClassLoader;
- this.regionManager = regionManager;
+ this.regionManager = null;
this.configuration = configuration;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -27,11 +27,11 @@
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.util.concurrent.WithinThreadExecutor;
import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.MembershipListener;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,9 +22,9 @@
package org.jboss.cache.marshall;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jgroups.Channel;
import org.jgroups.MembershipListener;
import org.jgroups.Message;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -24,10 +24,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.util.stream.MarshalledValueInputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,7 +22,7 @@
package org.jboss.cache.mvcc;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.Node;
@@ -81,7 +81,7 @@
return delegate.getParent();
}
- public final CacheSPI<K, V> getCache()
+ public final CacheSPI_Legacy<K, V> getCache()
{
return delegate.getCache();
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -24,7 +24,7 @@
import org.jboss.starobrno.CacheException;
/**
- * Thrown when an incorrectly annotated class is added as a cache listener using the {@link org.jboss.cache.Cache#addCacheListener(Object)} API.
+ * Thrown when an incorrectly annotated class is added as a cache listener using the {@link org.jboss.cache.Cache_Legacy#addCacheListener(Object)} API.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,18 +23,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.marshall.MarshalledValueMap;
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.*;
-import static org.jboss.cache.notifications.event.Event.Type.*;
import org.jboss.cache.util.Immutables;
import org.jboss.cache.util.concurrent.WithinThreadExecutor;
+import org.jboss.starobrno.Cache;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Destroy;
import org.jboss.starobrno.factories.annotations.Inject;
@@ -318,7 +317,7 @@
e.setPre(pre);
e.setFqn(fqn);
e.setTransaction(tx);
- e.setType(NODE_CREATED);
+// // e.setType(NODE_CREATED);
for (ListenerInvocation listener : nodeCreatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -340,7 +339,7 @@
e.setTransaction(tx);
e.setModificationType(modificationType);
e.setData(dataCopy);
- e.setType(NODE_MODIFIED);
+// // e.setType(NODE_MODIFIED);
for (ListenerInvocation listener : nodeModifiedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -366,7 +365,7 @@
e.setFqn(fqn);
e.setTransaction(tx);
e.setData(dataCopy);
- e.setType(NODE_REMOVED);
+// // e.setType(NODE_REMOVED);
for (ListenerInvocation listener : nodeRemovedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -383,7 +382,7 @@
e.setPre(pre);
e.setFqn(fqn);
e.setTransaction(tx);
- e.setType(NODE_VISITED);
+// // e.setType(NODE_VISITED);
for (ListenerInvocation listener : nodeVisitedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -403,7 +402,7 @@
e.setFqn(originalFqn);
e.setTargetFqn(newFqn);
e.setTransaction(tx);
- e.setType(NODE_MOVED);
+// // e.setType(NODE_MOVED);
for (ListenerInvocation listener : nodeMovedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -422,7 +421,7 @@
e.setPre(pre);
e.setFqn(fqn);
e.setTransaction(tx);
- e.setType(NODE_EVICTED);
+ // e.setType(NODE_EVICTED);
for (ListenerInvocation listener : nodeEvictedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -441,7 +440,7 @@
e.setPre(pre);
e.setFqn(fqn);
e.setTransaction(tx);
- e.setType(NODE_INVALIDATED);
+ // e.setType(NODE_INVALIDATED);
for (ListenerInvocation listener : nodeInvalidatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -462,7 +461,7 @@
e.setFqn(fqn);
e.setTransaction(tx);
e.setData(dataCopy);
- e.setType(NODE_LOADED);
+ // e.setType(NODE_LOADED);
for (ListenerInvocation listener : nodeLoadedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -483,7 +482,7 @@
e.setFqn(fqn);
e.setTransaction(tx);
e.setData(dataCopy);
- e.setType(NODE_ACTIVATED);
+ // e.setType(NODE_ACTIVATED);
for (ListenerInvocation listener : nodeActivatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -502,7 +501,7 @@
e.setFqn(fqn);
e.setTransaction(tx);
e.setData(dataCopy);
- e.setType(NODE_PASSIVATED);
+ // e.setType(NODE_PASSIVATED);
for (ListenerInvocation listener : nodePassivatedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -518,7 +517,7 @@
{
EventImpl e = new EventImpl();
e.setCache(cache);
- e.setType(CACHE_STARTED);
+ // e.setType(CACHE_STARTED);
for (ListenerInvocation listener : cacheStartedListeners) listener.invoke(e);
}
}
@@ -533,7 +532,7 @@
{
EventImpl e = new EventImpl();
e.setCache(cache);
- e.setType(CACHE_STOPPED);
+ // e.setType(CACHE_STOPPED);
for (ListenerInvocation listener : cacheStoppedListeners) listener.invoke(e);
}
}
@@ -546,7 +545,7 @@
EventImpl e = new EventImpl();
e.setCache(cache);
e.setNewView(newView);
- e.setType(VIEW_CHANGED);
+ // e.setType(VIEW_CHANGED);
for (ListenerInvocation listener : viewChangedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -560,7 +559,7 @@
e.setCache(cache);
e.setBuddyGroup(buddyGroup);
e.setPre(pre);
- e.setType(BUDDY_GROUP_CHANGED);
+ // e.setType(BUDDY_GROUP_CHANGED);
for (ListenerInvocation listener : buddyGroupChangedListeners) listener.invoke(e);
}
}
@@ -576,7 +575,7 @@
e.setOriginLocal(isOriginLocal);
e.setTransaction(transaction);
e.setSuccessful(successful);
- e.setType(TRANSACTION_COMPLETED);
+ // e.setType(TRANSACTION_COMPLETED);
for (ListenerInvocation listener : transactionCompletedListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -592,7 +591,7 @@
e.setCache(cache);
e.setOriginLocal(isOriginLocal);
e.setTransaction(transaction);
- e.setType(TRANSACTION_REGISTERED);
+ // e.setType(TRANSACTION_REGISTERED);
for (ListenerInvocation listener : transactionRegisteredListeners) listener.invoke(e);
restoreInvocationContext(backup);
}
@@ -605,7 +604,7 @@
EventImpl e = new EventImpl();
e.setCache(this.cache);
e.setPre(pre);
- e.setType(CACHE_BLOCKED);
+ // e.setType(CACHE_BLOCKED);
for (ListenerInvocation listener : cacheBlockedListeners) listener.invoke(e);
}
}
@@ -617,7 +616,7 @@
EventImpl e = new EventImpl();
e.setCache(this.cache);
e.setPre(pre);
- e.setType(CACHE_UNBLOCKED);
+ // e.setType(CACHE_UNBLOCKED);
for (ListenerInvocation listener : cacheUnblockedListeners) listener.invoke(e);
}
}
@@ -633,9 +632,13 @@
private void restoreInvocationContext(InvocationContext backup)
{
- InvocationContext currentIC = cache.getInvocationContext();
- backup.putLookedUpNodes(currentIC.getLookedUpNodes());
- cache.setInvocationContext(backup);
+// InvocationContext currentIC = cache.getInvocationContext();
+// backup.clearLookedUpEntries();
+// for (MVCCEntry me : currentIC.getLookedUpEntries().values())
+// {
+// backup.putLookedUpEntry(me);
+// }
+// cache.setInvocationContext(backup);
}
/**
@@ -650,8 +653,11 @@
// wipe current context.
cache.setInvocationContext(null);
// get a new Invocation Context
- InvocationContext newContext = cache.getInvocationContext();
- newContext.putLookedUpNodes(ctx.getLookedUpNodes());
+// InvocationContext newContext = cache.getInvocationContext();
+// for (MVCCEntry me : ctx.getLookedUpEntries().values())
+// {
+// newContext.putLookedUpEntry(me);
+// }
return ctx;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/CacheListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/CacheListener.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/CacheListener.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -28,13 +28,13 @@
/**
* Class-level annotation used to annotate an object as being a valid cache listener. Used with the
- * {@link org.jboss.cache.Cache#addCacheListener(Object)} and related APIs.
+ * {@link org.jboss.cache.Cache_Legacy#addCacheListener(Object)} and related APIs.
* <p/>
* Note that even if a class is annotated with this annotation, it still needs method-level annotation (such as
* {@link org.jboss.cache.notifications.annotation.CacheStarted}) to actually receive notifications.
* <p/>
- * Objects annotated with this annotation - listeners - can be attached to a running {@link org.jboss.cache.Cache} so
- * users can be notified of {@link org.jboss.cache.Cache} events.
+ * Objects annotated with this annotation - listeners - can be attached to a running {@link org.jboss.cache.Cache_Legacy} so
+ * users can be notified of {@link org.jboss.cache.Cache_Legacy} events.
* <p/>
* <p/>
* There can be multiple methods that are annotated to receive the same event,
@@ -313,9 +313,9 @@
* @see TransactionRegistered
* @see BuddyGroupChanged
* @see NodeInvalidated
- * @see org.jboss.cache.Cache#addCacheListener(Object)
- * @see org.jboss.cache.Cache#removeCacheListener(Object)
- * @see org.jboss.cache.Cache#getCacheListeners()
+ * @see org.jboss.cache.Cache_Legacy#addCacheListener(Object)
+ * @see org.jboss.cache.Cache_Legacy#removeCacheListener(Object)
+ * @see org.jboss.cache.Cache_Legacy#getCacheListeners()
* @since 2.0.0
*/
@Retention(RetentionPolicy.RUNTIME)
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/NodeMoved.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/NodeMoved.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/annotation/NodeMoved.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -27,7 +27,7 @@
import java.lang.annotation.Target;
/**
- * This annotation should be used on methods that need to be notified when a node is moved using the {@link org.jboss.cache.Cache#move(org.jboss.cache.Fqn,org.jboss.cache.Fqn)}
+ * This annotation should be used on methods that need to be notified when a node is moved using the {@link org.jboss.cache.Cache_Legacy#move(org.jboss.cache.Fqn,org.jboss.cache.Fqn)}
* API.
* <p/>
* Methods annotated with this annotation should accept a single
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/event/Event.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/event/Event.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/event/Event.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.notifications.event;
-import org.jboss.cache.Cache;
+import org.jboss.starobrno.Cache;
/**
* An interface that defines common characteristics of events
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/event/EventImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/event/EventImpl.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/event/EventImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,9 +21,9 @@
*/
package org.jboss.cache.notifications.event;
-import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.starobrno.Cache;
import org.jgroups.View;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.Node;
@@ -31,7 +31,6 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.marshall.NodeDataExceptionMarker;
-import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
import java.io.IOException;
@@ -48,15 +47,16 @@
private Log log = LogFactory.getLog(getClass().getName());
- private CacheSPI cache;
+ private CacheSPI_Legacy cache;
private Set<Fqn> internalFqns;
- @Inject
- public void inject(CacheSPI cache)
- {
- this.cache = cache;
- }
+ // TODO: Inject CacheSPI when we have this working properly when we have State Transfer not relying on a tree struct.
+// @Inject
+// public void inject(CacheSPI_Legacy cache)
+// {
+// this.cache = cache;
+// }
@Start(priority = 14)
private void start()
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.InvocationContext;
@@ -56,16 +56,17 @@
private static final Log log = LogFactory.getLog(DefaultStateTransferIntegrator.class);
private static final boolean trace = log.isTraceEnabled();
- private CacheSPI<?, ?> cache;
+ private CacheSPI_Legacy<?, ?> cache;
private Set<Fqn> internalFqns;
private Configuration cfg;
private boolean needToPersistState; // for JBCACHE-131
@Inject
- public void inject(CacheSPI<?, ?> cache, Configuration cfg)
+ public void inject(Configuration cfg)
{
- this.cache = cache;
+ // TODO: Inject CacheSPI when we have this working properly when we have State Transfer not relying on a tree struct.
+// this.cache = cache;
this.cfg = cfg;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,18 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.InternalNode;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RegionEmptyException;
import org.jboss.cache.RegionManager;
import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.marshall.InactiveRegionException;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.marshall.NodeDataMarker;
-import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
@@ -88,6 +84,9 @@
public void getState(ObjectOutputStream out, Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Exception
{
+ throw new UnsupportedOperationException("Implement me properly!");
+ /*
+
// can't give state for regions currently being activated/inactivated
boolean canProvideState = (!regionManager.isInactive(fqn) && cache.peek(fqn, false) != null);
if (trace) log.trace("Can provide state? " + canProvideState);
@@ -132,10 +131,13 @@
marshaller.objectToObjectStream(e, out);
if (e != null) throw e;
}
+ */
}
public void setState(ObjectInputStream in, Fqn targetRoot) throws Exception
{
+ throw new UnsupportedOperationException("fix me!");
+ /*
cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
NodeSPI target = cache.getNode(targetRoot);
if (target == null)
@@ -160,6 +162,7 @@
throw new CacheException("Cache instance at " + cache.getLocalAddress()
+ " cannot integrate state since state provider could not provide state due to " + marshaller.objectFromObjectStream(in));
}
+ */
}
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -187,7 +187,7 @@
/**
* Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context.
*
* @return true if the forceAsyncReplication flag is set to true.
@@ -196,7 +196,7 @@
/**
* Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context. Also used by OptimisticReplicationInterceptor when dealing
* with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
* non-transactional context (i.e. with an implicit transaction).
@@ -207,7 +207,7 @@
/**
* Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context.
*
* @return true if the forceAsyncReplication flag is set to true.
@@ -216,7 +216,7 @@
/**
* Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context.
*
* @param forceSyncReplication value of forceSyncReplication
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,12 +21,10 @@
*/
package org.jboss.cache.transaction;
-import org.jboss.cache.Cache;
-
import javax.transaction.TransactionManager;
/**
- * Factory interface, allows {@link Cache} to use different transactional systems.
+ * Factory interface, allows {@link org.jboss.cache.Cache_Legacy} to use different transactional systems.
* Names of implementors of this class can be configured using
* {@link Configuration#setTransactionManagerLookupClass}.
*
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -25,10 +25,10 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.factories.context.ContextFactory;
import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.context.ContextFactory;
import org.jgroups.Address;
import javax.transaction.Status;
@@ -408,18 +408,19 @@
TransactionContext transactionContext;
try
{
- transactionContext = contextFactory.createTransactionContext(tx);
+ throw new RuntimeException("Delete this class!");
+// transactionContext = null; // contextFactory.createTransactionContext(tx); // todo do not use, delete this class!
}
catch (Exception e)
{
throw new CacheException("Unable to create a transaction entry!", e);
}
- put(gtx, transactionContext);
- if (trace)
- {
- log.trace("created new GTX: " + gtx + ", local TX=" + tx);
- }
+// put(gtx, transactionContext);
+// if (trace)
+// {
+// log.trace("created new GTX: " + gtx + ", local TX=" + tx);
+// }
}
return gtx;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/CachePrinter.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,15 +21,15 @@
*/
package org.jboss.cache.util;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.DataContainer;
import org.jboss.cache.DataContainerImpl;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.CacheInvocationDelegate;
/**
- * Helper that prints the contents of a {@link org.jboss.cache.Cache} to a string.
+ * Helper that prints the contents of a {@link org.jboss.cache.Cache_Legacy} to a string.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
@@ -42,7 +42,7 @@
* @param c cache to print
* @return a String representation of the cache
*/
- public static String printCacheDetails(Cache c)
+ public static String printCacheDetails(Cache_Legacy c)
{
// internal cast
DataContainer ci = ((CacheInvocationDelegate) c).getDataContainer();
@@ -55,14 +55,14 @@
* @param c cache to print
* @return a String representation of the cache
*/
- public static String printCacheLockingInfo(Cache c)
+ public static String printCacheLockingInfo(Cache_Legacy c)
{
// internal cast
DataContainerImpl cd = (DataContainerImpl) ((CacheInvocationDelegate) c).getDataContainer();
return cd.printLockInfo();
}
- public static String printCacheInterceptors(CacheSPI<?, ?> cache)
+ public static String printCacheInterceptors(CacheSPI_Legacy<?, ?> cache)
{
StringBuilder b = new StringBuilder();
int index = 0;
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/Caches.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.util;
-import org.jboss.cache.Cache;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
@@ -35,7 +35,7 @@
import java.util.Set;
/**
- * Adaptors for {@link Cache} classes, such as {@link Node}.
+ * Adaptors for {@link org.jboss.cache.Cache_Legacy} classes, such as {@link Node}.
* This is useful for integration of JBoss Cache into existing applications.
* <p/>
* Example use:
@@ -61,7 +61,7 @@
* @return a map representation of the cache
* @see #asMap(Node)
*/
- public static <K, V> Map<K, V> asMap(Cache<K, V> cache)
+ public static <K, V> Map<K, V> asMap(Cache_Legacy<K, V> cache)
{
if (cache == null) throw new NullPointerException("cache");
return asMap(cache.getRoot());
@@ -179,7 +179,7 @@
* @param cache cache to use
* @return a Map representation of the cache
*/
- public static <K, V> Map<K, V> asPartitionedMap(Cache<K, V> cache)
+ public static <K, V> Map<K, V> asPartitionedMap(Cache_Legacy<K, V> cache)
{
return asPartitionedMap(cache.getRoot());
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/Cache.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,6 +21,7 @@
*/
package org.jboss.starobrno;
+import org.jboss.cache.CacheStatus;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.lifecycle.Lifecycle;
@@ -50,4 +51,6 @@
AtomicGroup putAtomicGroup(K key, AtomicGroup group);
AtomicGroup getAtomicGroup(K key);
+
+ CacheStatus getCacheStatus();
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,6 +21,13 @@
*/
package org.jboss.starobrno;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.loader.CacheLoaderManager;
+import org.jboss.cache.marshall.Marshaller;
+import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.commands.read.GetKeyValueCommand;
import org.jboss.starobrno.commands.read.SizeCommand;
@@ -32,30 +39,56 @@
import org.jboss.starobrno.commands.write.ReplaceCommand;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.interceptors.InterceptorChain;
import org.jboss.starobrno.invocation.InvocationContextContainer;
import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.transaction.TransactionTable;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author Mircea.Markus(a)jboss.com
*/
-public class CacheDelegate implements Cache
+@NonVolatile
+public class CacheDelegate<K, V> implements CacheSPI<K, V>
{
protected InvocationContextContainer invocationContextContainer;
protected CommandsFactory commandsFactory;
protected InterceptorChain invoker;
protected Configuration config;
protected Notifier notifier;
+ protected ComponentRegistry componentRegistry;
- public Object putIfAbsent(Object key, Object value)
+ @Inject
+ private void injectDependencies(InvocationContextContainer invocationContextContainer,
+ CommandsFactory commandsFactory,
+ InterceptorChain interceptorChain,
+ Configuration configuration,
+ Notifier notifier,
+ ComponentRegistry componentRegistry)
{
+ this.invocationContextContainer = invocationContextContainer;
+ this.commandsFactory = commandsFactory;
+ this.invoker = interceptorChain;
+ this.config = configuration;
+ this.notifier = notifier;
+ this.componentRegistry = componentRegistry;
+ }
+
+ public V putIfAbsent(K key, V value)
+ {
PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value);
command.setPutIfAbsent(true);
- return invoker.invoke(buildCtx(), command);
+ return (V) invoker.invoke(buildCtx(), command);
}
public boolean remove(Object key, Object value)
@@ -64,16 +97,16 @@
return (Boolean) invoker.invoke(buildCtx(), command);
}
- public boolean replace(Object key, Object oldValue, Object newValue)
+ public boolean replace(K key, V oldValue, V newValue)
{
ReplaceCommand command = commandsFactory.buildReplaceCommand(key, oldValue, newValue);
return (Boolean) invoker.invoke(buildCtx(), command);
}
- public Object replace(Object key, Object value)
+ public V replace(K key, V value)
{
ReplaceCommand command = commandsFactory.buildReplaceCommand(key, value, null);
- return invoker.invoke(buildCtx(), command);
+ return (V) invoker.invoke(buildCtx(), command);
}
public int size()
@@ -100,25 +133,25 @@
throw new UnsupportedOperationException("Go away");
}
- public Object get(Object key)
+ public V get(Object key)
{
GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(key);
- return invoker.invoke(buildCtx(), command);
+ return (V) invoker.invoke(buildCtx(), command);
}
- public Object put(Object key, Object value)
+ public V put(K key, V value)
{
PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(key, value);
- return invoker.invoke(buildCtx(), command);
+ return (V) invoker.invoke(buildCtx(), command);
}
- public Object remove(Object key)
+ public V remove(Object key)
{
RemoveCommand command = commandsFactory.buildRemoveCommand(key, null);
- return invoker.invoke(buildCtx(), command);
+ return (V) invoker.invoke(buildCtx(), command);
}
- public void putAll(Map t)
+ public void putAll(Map<? extends K, ? extends V> t)
{
PutMapCommand command = commandsFactory.buildPutMapCommand(t);
invoker.invoke(buildCtx(), command);
@@ -145,7 +178,7 @@
throw new UnsupportedOperationException("Go away");
}
- public void evict(Object key)
+ public void evict(K key)
{
EvictCommand command = commandsFactory.buildEvictCommand(key);
invoker.invoke(buildCtx(), command);
@@ -182,12 +215,12 @@
else invocationContextContainer.set(ctx);
}
- public AtomicGroup putAtomicGroup(Object key, AtomicGroup group)
+ public AtomicGroup putAtomicGroup(K key, AtomicGroup group)
{
return null; //TODO: Autogenerated. Implement me properly
}
- public AtomicGroup getAtomicGroup(Object key)
+ public AtomicGroup getAtomicGroup(K key)
{
return null; //TODO: Autogenerated. Implement me properly
}
@@ -206,4 +239,99 @@
{
return invocationContextContainer.get();
}
+
+ public TransactionManager getTransactionManager()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public List<CommandInterceptor> getInterceptorChain()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public Marshaller getMarshaller()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public void addInterceptor(CommandInterceptor i, int position)
+ {
+ //TODO: Autogenerated. Implement me properly
+ }
+
+ public void addInterceptor(CommandInterceptor i, Class<? extends CommandInterceptor> afterInterceptor)
+ {
+ //TODO: Autogenerated. Implement me properly
+ }
+
+ public void removeInterceptor(int position)
+ {
+ //TODO: Autogenerated. Implement me properly
+ }
+
+ public void removeInterceptor(Class<? extends CommandInterceptor> interceptorType)
+ {
+ //TODO: Autogenerated. Implement me properly
+ }
+
+ public CacheLoaderManager getCacheLoaderManager()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public BuddyManager getBuddyManager()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public TransactionTable getTransactionTable()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public Object getRPCManager()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public StateTransferManager getStateTransferManager()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public org.jboss.cache.notifications.Notifier getNotifier()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public String getClusterName()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public GlobalTransaction getCurrentTransaction(Transaction tx, boolean createIfNotExists)
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public GlobalTransaction getCurrentTransaction()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public GravitateResult gravitateData(K key, boolean searchBuddyBackupSubtrees, InvocationContext ctx)
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public ComponentRegistry getComponentRegistry()
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public CacheStatus getCacheStatus()
+ {
+ return componentRegistry.getState();
+ }
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheException.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,7 +22,7 @@
package org.jboss.starobrno;
/**
- * Thrown when operations on {@link org.jboss.cache.Cache} or {@link org.jboss.cache.Node} fail unexpectedly.
+ * Thrown when operations on {@link Cache} or {@link org.jboss.cache.Node} fail unexpectedly.
* <p/>
* Specific subclasses such as {@link org.jboss.cache.lock.TimeoutException}, {@link org.jboss.cache.config.ConfigurationException} and {@link org.jboss.cache.lock.LockingException}
* have more specific uses.
Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,200 +0,0 @@
-/*
- * 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.context.InvocationContext;
-import org.jboss.util.NotImplementedException;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @author Mircea.Markus(a)jboss.com
- */
-public class CacheImpl implements Cache
-{
- private ConcurrentHashMap data = new ConcurrentHashMap();
- private Map<String, AtomicGroup> atomicGroups = new ConcurrentHashMap<String, AtomicGroup>();
-// private CacheConfig cacheConfig;
-
-// public CacheImpl(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;
-
- CacheImpl cache = (CacheImpl) o;
-
- if (data != null ? !data.equals(cache.data) : cache.data != null) return false;
-
- return true;
- }
-
- public int hashCode()
- {
- return (data != null ? data.hashCode() : 0);
- }
-
- public void evict(Object key)
- {
- //TODO: Autogenerated. Implement me properly
- }
-
- public Configuration getConfiguration()
- {
- return null; //TODO: Autogenerated. Implement me properly
- }
-
- public void addCacheListener(Object listener)
- {
- //TODO: Autogenerated. Implement me properly
- }
-
- public void removeCacheListener(Object listener)
- {
- //TODO: Autogenerated. Implement me properly
- }
-
- public Set getCacheListeners()
- {
- return null; //TODO: Autogenerated. Implement me properly
- }
-
- public InvocationContext getInvocationContext()
- {
- return null; //TODO: Autogenerated. Implement me properly
- }
-
- public void setInvocationContext(InvocationContext ctx)
- {
- //TODO: Autogenerated. Implement me properly
- }
-
- public void start()
- {
- //TODO: Autogenerated. Implement me properly
- }
-
- public void stop()
- {
- //TODO: Autogenerated. Implement me properly
- }
-
- public AtomicGroup getAtomicGroup(Object key)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public AtomicGroup putAtomicGroup(Object key, AtomicGroup group)
- {
- // TODO Auto-generated method stub
- return null;
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -1,55 +0,0 @@
-/*
- * 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 java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Mircea.Markus(a)jboss.com
- */
-public class CacheManager
-{
- private Configuration config;
- private Map<String, CacheImpl> caches = new HashMap<String, CacheImpl>();
-
- public CacheManager(Configuration config)
- {
- this.config = config;
- }
-
- public CacheImpl getCache(String confName)
- {
- return null; // TODO
-
- /*
- 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);
- CacheImpl result = new CacheImpl(config);
- caches.put(confName, result);
- return result;*/
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheSPI.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -24,21 +24,20 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.statetransfer.StateTransferManager;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.transaction.TransactionTable;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.List;
-import java.util.Set;
/**
* A more detailed interface to {@link Cache}, which is used when writing plugins for or extending JBoss Cache. A reference
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,9 +21,6 @@
*/
package org.jboss.starobrno;
-import org.jboss.cache.*;
-import org.jboss.cache.CacheException;
-
/**
* Thrown when a replication problem occurred
*/
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno;
-import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.commands.ReplicableCommand;
@@ -29,22 +28,31 @@
import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
import org.jboss.starobrno.commands.tx.RollbackCommand;
+import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.context.TransactionContext;
+import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.context.ContextFactory;
import org.jboss.starobrno.interceptors.BaseTransactionalContextInterceptor;
import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.jmx.annotations.ManagedAttribute;
+import org.jboss.starobrno.jmx.annotations.ManagedOperation;
import org.jboss.starobrno.lock.LockManager;
import org.jboss.starobrno.notifier.Notifier;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
-import org.jboss.starobrno.jmx.annotations.ManagedOperation;
-import org.jboss.starobrno.jmx.annotations.ManagedAttribute;
-import org.jboss.starobrno.config.Option;
-import javax.transaction.*;
-import java.util.*;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/read/GravitateDataCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,8 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.DataContainer;
import org.jboss.starobrno.commands.Visitor;
import org.jboss.starobrno.context.InvocationContext;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/write/PutKeyValueCommand.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -27,7 +27,7 @@
import org.jboss.starobrno.mvcc.MVCCEntry;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#put(org.jboss.cache.Fqn, Object, Object)}.
+ * Implements functionality defined by {@link Cache#put(org.jboss.cache.Fqn, Object, Object)}.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -298,8 +298,8 @@
}
/**
- * 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.
+ * Enables invocation batching if set to <tt>true</tt>. You still need to use {@link org.jboss.cache.Cache_Legacy#startBatch()}
+ * and {@link org.jboss.cache.Cache_Legacy#endBatch(boolean)} to demarcate the start and end of batches.
*
* @param enabled if true, batching is enabled.
* @since 3.0
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,8 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.factories.ComponentRegistry;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.factories.annotations.Start;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,8 +21,8 @@
*/
package org.jboss.starobrno.context;
+import org.jboss.starobrno.OrderedSynchronizationHandler;
import org.jboss.starobrno.commands.VisitableCommand;
-import org.jboss.starobrno.OrderedSynchronizationHandler;
import org.jboss.starobrno.config.Option;
import javax.transaction.Transaction;
@@ -186,7 +186,7 @@
/**
* Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context.
*
* @return true if the forceAsyncReplication flag is set to true.
@@ -195,7 +195,7 @@
/**
* Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context. Also used by OptimisticReplicationInterceptor when dealing
* with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
* non-transactional context (i.e. with an implicit transaction).
@@ -206,7 +206,7 @@
/**
* Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context.
*
* @return true if the forceAsyncReplication flag is set to true.
@@ -215,7 +215,7 @@
/**
* Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * when dealing with {@link org.jboss.cache.Cache_Legacy#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
* a transactional context.
*
* @param forceSyncReplication value of forceSyncReplication
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.starobrno.config.Configuration;
@@ -61,7 +61,7 @@
protected boolean allowTombstones = false;
protected Configuration configuration;
protected Fqn regionFqn;
- protected CacheSPI<?, ?> cache;
+ protected CacheSPI_Legacy<?, ?> cache;
/**
* This method will create an EvictionQueue implementation and prepare it for use.
@@ -110,7 +110,7 @@
return evictionAlgorithmConfig;
}
- public void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
+ public void assignToRegion(Fqn fqn, CacheSPI_Legacy<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
{
this.regionFqn = fqn;
this.cache = cache;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,21 +23,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.Fqn;
/**
- * Default eviction action policy that calls {@link org.jboss.cache.Cache#evict(org.jboss.cache.Fqn)} to evict a node.
+ * Default eviction action policy that calls {@link org.jboss.cache.Cache_Legacy#evict(org.jboss.cache.Fqn)} to evict a node.
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 3.0
*/
public class DefaultEvictionActionPolicy implements EvictionActionPolicy
{
- Cache<?, ?> cache;
+ Cache_Legacy<?, ?> cache;
private static final Log log = LogFactory.getLog(DefaultEvictionActionPolicy.class);
- public void setCache(Cache<?, ?> cache)
+ public void setCache(Cache_Legacy<?, ?> cache)
{
this.cache = cache;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.eviction;
-import org.jboss.cache.Cache;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.Fqn;
/**
@@ -37,7 +37,7 @@
*
* @param cache cache
*/
- void setCache(Cache<?, ?> cache);
+ void setCache(Cache_Legacy<?, ?> cache);
/**
* Performs an eviction on a given node.
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.eviction;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.EvictionAlgorithmConfig;
@@ -76,7 +76,7 @@
* @param evictionAlgorithmConfig configuration for the current algorithm instance.
* @param configuration for the entire cache.
*/
- void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration);
+ void assignToRegion(Fqn fqn, CacheSPI_Legacy<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration);
/**
* Tests whether the algorithm would ignore certain event types on certain Fqns.
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.eviction;
-import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheSPI_Legacy;
import org.jboss.cache.Fqn;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.EvictionAlgorithmConfig;
@@ -66,7 +66,7 @@
// no-op
}
- public void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
+ public void assignToRegion(Fqn fqn, CacheSPI_Legacy<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
{
// no-op
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,21 +23,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
+import org.jboss.cache.Cache_Legacy;
import org.jboss.cache.Fqn;
/**
- * An eviction action policy that calls {@link org.jboss.cache.Cache#removeNode(org.jboss.cache.Fqn)} to evict a node.
+ * An eviction action policy that calls {@link org.jboss.cache.Cache_Legacy#removeNode(org.jboss.cache.Fqn)} to evict a node.
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 3.0
*/
public class RemoveOnEvictActionPolicy implements EvictionActionPolicy
{
- Cache<?, ?> cache;
+ Cache_Legacy<?, ?> cache;
private static final Log log = LogFactory.getLog(org.jboss.starobrno.eviction.DefaultEvictionActionPolicy.class);
- public void setCache(Cache<?, ?> cache)
+ public void setCache(Cache_Legacy<?, ?> cache)
{
this.cache = cache;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,8 +21,8 @@
*/
package org.jboss.starobrno.factories;
-import org.jboss.cache.CacheSPI;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
import org.jboss.starobrno.factories.annotations.NonVolatile;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -23,12 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Version;
import org.jboss.cache.util.BeanUtils;
import org.jboss.cache.util.reflect.ReflectionUtil;
import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.RuntimeConfig;
@@ -66,10 +66,10 @@
* <ul>
* <li>INSTANTIATED - when first constructed</li>
* <li>CONSTRUCTED - when created using the DefaultCacheFactory</li>
- * <li>When {@link org.jboss.cache.Cache#create()} is called, the components are rewired.</li>
- * <li>STARTED - when {@link org.jboss.cache.Cache#start()} is called</li>
- * <li>STOPPED - when {@link org.jboss.cache.Cache#stop()} is called</li>
- * <li>DESTROYED - when {@link org.jboss.cache.Cache#destroy()} is called.</li>
+ * <li>When {@link org.jboss.cache.Cache_Legacy#create()} is called, the components are rewired.</li>
+ * <li>STARTED - when {@link org.jboss.cache.Cache_Legacy#start()} is called</li>
+ * <li>STOPPED - when {@link org.jboss.cache.Cache_Legacy#stop()} is called</li>
+ * <li>DESTROYED - when {@link org.jboss.cache.Cache_Legacy#destroy()} is called.</li>
* </ul>
* <p/>
* Cache configuration can only be changed and will only be reinjected if the cache is not in the {@link org.jboss.cache.CacheStatus#STARTED} state.
@@ -195,6 +195,7 @@
s.add(ReplicationQueueFactory.class);
s.add(StateTransferManagerFactory.class);
s.add(StateTransferFactory.class);
+ s.add(NullComponentFactory.class);
return s;
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -31,13 +31,14 @@
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.VersionAwareMarshaller;
import org.jboss.cache.mvcc.MVCCNodeHelper;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.commands.CommandsFactory;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
import org.jboss.starobrno.factories.context.ContextFactory;
import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.notifier.Notifier;
import org.jboss.starobrno.transaction.TransactionTable;
/**
@@ -50,7 +51,7 @@
ChannelMessageListener.class, CacheLoaderManager.class, Marshaller.class, InvocationContextContainer.class,
CacheInvocationDelegate.class, TransactionTable.class, DataContainer.class,
LockStrategyFactory.class, BuddyFqnTransformer.class, BatchContainer.class,
- ContextFactory.class, EntryFactory.class})
+ ContextFactory.class, EntryFactory.class, CommandsFactory.class})
public class EmptyConstructorFactory extends ComponentFactory
{
@Override
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,12 +22,15 @@
package org.jboss.starobrno.factories;
-import org.jboss.cache.interceptors.*;
+import org.jboss.starobrno.TxInterceptor;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.starobrno.config.CustomInterceptorConfig;
import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.interceptors.CallInterceptor;
import org.jboss.starobrno.interceptors.InterceptorChain;
+import org.jboss.starobrno.interceptors.InvocationContextInterceptor;
+import org.jboss.starobrno.interceptors.LockingInterceptor;
import org.jboss.starobrno.interceptors.base.CommandInterceptor;
import java.util.List;
@@ -52,101 +55,118 @@
return new InterceptorChainFactory();
}
- private CommandInterceptor createInterceptor(Class clazz) throws IllegalAccessException, InstantiationException
+ private CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) throws IllegalAccessException, InstantiationException
{
- return null; // todo - un-hack!
-// CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
-// if (chainedInterceptor == null)
-// {
-// chainedInterceptor = clazz.newInstance();
-// componentRegistry.registerComponent(chainedInterceptor, clazz);
-// }
-// else
-// {
-// // wipe next/last chaining!!
-// chainedInterceptor.setNext(null);
-// }
-// return chainedInterceptor;
+ CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
+ if (chainedInterceptor == null)
+ {
+ chainedInterceptor = clazz.newInstance();
+ try
+ {
+ componentRegistry.registerComponent(chainedInterceptor, clazz);
+ }
+ catch (RuntimeException e)
+ {
+ log.warn("Problems creating interceptor " + clazz);
+ throw e;
+ }
+ }
+ else
+ {
+ // wipe next/last chaining!!
+ chainedInterceptor.setNext(null);
+ }
+ return chainedInterceptor;
}
public InterceptorChain buildInterceptorChain() throws IllegalAccessException, InstantiationException, ClassNotFoundException
{
boolean invocationBatching = configuration.isInvocationBatchingEnabled();
// load the icInterceptor first
- CommandInterceptor first = invocationBatching ? createInterceptor(BatchingInterceptor.class) : createInterceptor(InvocationContextInterceptor.class);
+ // TODO: Uncomment once the BatchingInterceptor has been moved to Starobrno
+// CommandInterceptor first = invocationBatching ? createInterceptor(BatchingInterceptor.class) : createInterceptor(InvocationContextInterceptor.class);
+ CommandInterceptor first = createInterceptor(InvocationContextInterceptor.class);
+
InterceptorChain interceptorChain = new InterceptorChain(first);
// add the interceptor chain to the registry first, since some interceptors may ask for it.
componentRegistry.registerComponent(interceptorChain, InterceptorChain.class);
// NOW add the ICI if we are using batching!
- if (invocationBatching)
- interceptorChain.appendIntereceptor(createInterceptor(InvocationContextInterceptor.class));
+// if (invocationBatching)
+// interceptorChain.appendIntereceptor(createInterceptor(InvocationContextInterceptor.class));
// load the cache management interceptor next
- if (configuration.getExposeManagementStatistics())
- interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtInterceptor.class));
+ // TODO: Uncomment once the CacheMGMT has been moved to Starobrno
+// if (configuration.getExposeManagementStatistics())
+// interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtInterceptor.class));
+
// load the tx interceptor
interceptorChain.appendIntereceptor(createInterceptor(TxInterceptor.class));
- if (configuration.isUseLazyDeserialization())
- interceptorChain.appendIntereceptor(createInterceptor(MarshalledValueInterceptor.class));
- interceptorChain.appendIntereceptor(createInterceptor(NotificationInterceptor.class));
+ // TODO: Uncomment once the MarshalledValue, Notification has been moved to Starobrno
+// if (configuration.isUseLazyDeserialization())
+// interceptorChain.appendIntereceptor(createInterceptor(MarshalledValueInterceptor.class));
+// interceptorChain.appendIntereceptor(createInterceptor(NotificationInterceptor.class));
- switch (configuration.getCacheMode())
- {
- case REPL_SYNC:
- case REPL_ASYNC:
- interceptorChain.appendIntereceptor(createInterceptor(ReplicationInterceptor.class));
- break;
- case INVALIDATION_SYNC:
- case INVALIDATION_ASYNC:
- interceptorChain.appendIntereceptor(createInterceptor(InvalidationInterceptor.class));
- break;
- case LOCAL:
- //Nothing...
- }
+ // TODO: Uncomment once the Repl and Inval interceptors has been moved to Starobrno
+// switch (configuration.getCacheMode())
+// {
+// case REPL_SYNC:
+// case REPL_ASYNC:
+// interceptorChain.appendIntereceptor(createInterceptor(ReplicationInterceptor.class));
+// break;
+// case INVALIDATION_SYNC:
+// case INVALIDATION_ASYNC:
+// interceptorChain.appendIntereceptor(createInterceptor(InvalidationInterceptor.class));
+// break;
+// case LOCAL:
+// //Nothing...
+// }
- if (configuration.isUsingCacheLoaders())
- {
- if (configuration.getCacheLoaderConfig().isPassivation())
- {
- interceptorChain.appendIntereceptor(createInterceptor(ActivationInterceptor.class));
- }
- else
- {
- interceptorChain.appendIntereceptor(createInterceptor(CacheLoaderInterceptor.class));
- }
- }
- interceptorChain.appendIntereceptor(createInterceptor(MVCCLockingInterceptor.class));
+ // TODO: Uncomment once the CacheLoader has been moved to Starobrno
+// if (configuration.isUsingCacheLoaders())
+// {
+// if (configuration.getCacheLoaderConfig().isPassivation())
+// {
+// interceptorChain.appendIntereceptor(createInterceptor(ActivationInterceptor.class));
+// }
+// else
+// {
+// interceptorChain.appendIntereceptor(createInterceptor(CacheLoaderInterceptor.class));
+// }
+// }
+ interceptorChain.appendIntereceptor(createInterceptor(LockingInterceptor.class));
- if (configuration.isUsingCacheLoaders())
- {
- if (configuration.getCacheLoaderConfig().isPassivation())
- {
+ // TODO: Uncomment once the CacheLoader has been moved to Starobrno
+// if (configuration.isUsingCacheLoaders())
+// {
+// if (configuration.getCacheLoaderConfig().isPassivation())
+// {
+//
+// interceptorChain.appendIntereceptor(createInterceptor(PassivationInterceptor.class));
+//
+// }
+// else
+// {
+//
+// interceptorChain.appendIntereceptor(createInterceptor(CacheStoreInterceptor.class));
+//
+// }
+// }
+//
+// if (configuration.isUsingBuddyReplication())
+// {
+//
+// interceptorChain.appendIntereceptor(createInterceptor(DataGravitatorInterceptor.class));
+//
+// }
- interceptorChain.appendIntereceptor(createInterceptor(PassivationInterceptor.class));
-
- }
- else
- {
-
- interceptorChain.appendIntereceptor(createInterceptor(CacheStoreInterceptor.class));
-
- }
- }
-
- if (configuration.isUsingBuddyReplication())
- {
-
- interceptorChain.appendIntereceptor(createInterceptor(DataGravitatorInterceptor.class));
-
- }
-
+ // TODO: Uncomment once the EvictionInterceptor has been moved to Starobrno
// eviction interceptor to come before the optimistic node interceptor
- if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
- interceptorChain.appendIntereceptor(createInterceptor(configuration.isUsingBuddyReplication() ? BuddyRegionAwareEvictionInterceptor.class : EvictionInterceptor.class));
+// if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
+// interceptorChain.appendIntereceptor(createInterceptor(configuration.isUsingBuddyReplication() ? BuddyRegionAwareEvictionInterceptor.class : EvictionInterceptor.class));
CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
interceptorChain.appendIntereceptor(callInterceptor);
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/NullComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/NullComponentFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/NullComponentFactory.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -0,0 +1,40 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.RegionManager;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@DefaultFactoryFor(classes = RegionManager.class)
+public class NullComponentFactory extends ComponentFactory
+{
+ protected <T> T construct(Class<T> componentType)
+ {
+ return null;
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/annotations/NonVolatile.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -28,7 +28,7 @@
/**
* This annotation is used for components that will be registered in the {@link org.jboss.cache.factories.ComponentRegistry},
- * that are resilient to changes in configuration. Examples are the {@link org.jboss.cache.CacheSPI} implementation used, which does
+ * that are resilient to changes in configuration. Examples are the {@link org.jboss.cache.CacheSPI_Legacy} implementation used, which does
* not change regardless of the configuration. Components such as the {@link org.jboss.cache.lock.LockManager}, though, should
* <b>never</b> be marked as <tt>@NonVolatile</tt> since based on the configuration, different lock manager implementations
* may be selected. LockManager is, hence, <b>not</b> resilient to changes in the configuration.
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/base/CommandInterceptor.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -33,7 +33,7 @@
* This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
* allowing it to intercept invocations on {@link org.jboss.cache.commands.VisitableCommand}s.
* <p/>
- * Commands are created either by the {@link org.jboss.cache.invocation.CacheInvocationDelegate} (for invocations on the {@link org.jboss.cache.Cache}
+ * Commands are created either by the {@link org.jboss.cache.invocation.CacheInvocationDelegate} (for invocations on the {@link org.jboss.cache.Cache_Legacy}
* public interface), the {@link org.jboss.cache.invocation.NodeInvocationDelegate} for invocations on the {@link org.jboss.cache.Node}
* public interface, or by the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher} for remotely originating invocations, and
* are passed up the interceptor chain by using the {@link org.jboss.cache.interceptors.InterceptorChain} helper class.
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -22,10 +22,10 @@
package org.jboss.starobrno.loader;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.starobrno.CacheSPI;
import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.ObjectInputStream;
@@ -42,7 +42,7 @@
* <p/>
* Lifecycle: First an instance of the loader is created, then the
* configuration ({@link #setConfig(org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig)}) and cache ({@link
- * #setCache(CacheSPI)}) are set. After this, {@link #create()} is called.
+ * #setCache(org.jboss.cache.CacheSPI_Legacy)}) are set. After this, {@link #create()} is called.
* Then {@link #start()} is called. When re-deployed, {@link #stop()} will be
* called, followed by another {@link #start()}. Finally, when shut down,
* {@link #destroy()} is called, after which the loader is unusable.
@@ -55,7 +55,7 @@
* <p/>
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @see CacheSPI
+ * @see org.jboss.cache.CacheSPI_Legacy
* @see org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig
* @see org.jboss.cache.loader.AbstractCacheLoader
* @since 2.0.0
@@ -83,8 +83,8 @@
IndividualCacheLoaderConfig getConfig();
/**
- * Sets the {@link CacheSPI} that is maintaining this CacheLoader.
- * This method allows this CacheLoader to set a reference to the {@link CacheSPI}.
+ * Sets the {@link org.jboss.cache.CacheSPI_Legacy} that is maintaining this CacheLoader.
+ * This method allows this CacheLoader to set a reference to the {@link org.jboss.cache.CacheSPI_Legacy}.
* This method is called be called after the CacheLoader instance has been constructed.
*
* @param c The cache on which this loader works
Added: core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/manager/CacheManager.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -0,0 +1,80 @@
+/*
+ * 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.manager;
+
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.lifecycle.Lifecycle;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class CacheManager implements Lifecycle
+{
+ Configuration c;
+ private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>();
+
+ public CacheManager(Configuration c)
+ {
+ this.c = c;
+ }
+
+ public void start()
+ {
+ // this will bootstrap the cache manager
+ }
+
+ public void stop()
+ {
+ // this will stop the cache manager.
+ }
+
+ public Cache createCache(String cacheName)
+ {
+ if (!caches.containsKey(cacheName))
+ caches.putIfAbsent(cacheName, createNewCache());
+
+ Cache c = caches.get(cacheName);
+ c.start();
+ return c;
+ }
+
+ public void destroyCache(String cacheName)
+ {
+ Cache c = caches.remove(cacheName);
+ if (c != null) c.stop();
+ }
+
+ private Cache createNewCache()
+ {
+ // for now latch on to the existing cache creation mechanisms
+ DefaultCacheFactory dcf = new DefaultCacheFactory();
+ return dcf.createCache(c);
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifier/Notifier.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -21,9 +21,9 @@
*/
package org.jboss.starobrno.notifier;
+import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.notifier.event.NodeModifiedEvent;
-import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jgroups.View;
import javax.transaction.Transaction;
@@ -53,7 +53,7 @@
* listeners are registered for notification then it is pointless building this object - so guard the notification
* with this call.
*/
- public boolean shouldNotifyOnNodeModified();
+ boolean shouldNotifyOnNodeModified();
/**
* Notifies all registered listeners of a nodeRemoved event.
Added: core/branches/flat/src/main/java/org/jboss/starobrno/notifier/NotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/notifier/NotifierImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/notifier/NotifierImpl.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -0,0 +1,744 @@
+/*
+ * 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.notifier;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.marshall.MarshalledValueMap;
+import org.jboss.cache.notifications.IncorrectCacheListenerException;
+import org.jboss.cache.notifications.annotation.*;
+import org.jboss.cache.notifications.event.*;
+import static org.jboss.cache.notifications.event.Event.Type.*;
+import org.jboss.cache.util.Immutables;
+import org.jboss.cache.util.concurrent.WithinThreadExecutor;
+import org.jboss.starobrno.Cache;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.CacheSPI;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.annotations.Destroy;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
+import org.jboss.starobrno.mvcc.MVCCEntry;
+import org.jboss.starobrno.notifier.event.NodeModifiedEvent;
+import org.jgroups.View;
+
+import javax.transaction.Transaction;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Helper class that handles all notifications to registered listeners.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@NonVolatile
+public class NotifierImpl implements Notifier
+{
+ private static final Log log = LogFactory.getLog(NotifierImpl.class);
+
+ private static final Class emptyMap = Collections.emptyMap().getClass();
+
+ private static final Class singletonMap = Collections.singletonMap(null, null).getClass();
+ private static final Class[] allowedMethodAnnotations =
+ {
+ CacheStarted.class, CacheStopped.class, CacheBlocked.class, CacheUnblocked.class, NodeCreated.class, NodeRemoved.class, NodeVisited.class, NodeModified.class, NodeMoved.class,
+ NodeActivated.class, NodePassivated.class, NodeLoaded.class, NodeEvicted.class, TransactionRegistered.class, TransactionCompleted.class, ViewChanged.class, BuddyGroupChanged.class,
+ NodeInvalidated.class
+ };
+ private static final Class[] parameterTypes =
+ {
+ CacheStartedEvent.class, CacheStoppedEvent.class, CacheBlockedEvent.class, CacheUnblockedEvent.class, NodeCreatedEvent.class, NodeRemovedEvent.class, NodeVisitedEvent.class, NodeModifiedEvent.class, NodeMovedEvent.class,
+ NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLoadedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class, BuddyGroupChangedEvent.class,
+ NodeInvalidatedEvent.class
+ };
+
+ final Map<Class<? extends Annotation>, List<ListenerInvocation>> listenersMap = new HashMap<Class<? extends Annotation>, List<ListenerInvocation>>(32);
+ final List<ListenerInvocation> cacheStartedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheStoppedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheBlockedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheUnblockedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeCreatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeRemovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeVisitedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeModifiedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeMovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeActivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodePassivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeLoadedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeInvalidatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> nodeEvictedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> transactionRegisteredListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> transactionCompletedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> viewChangedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> buddyGroupChangedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+
+ // final Map<Class, List<ListenerInvocation>> listenerInvocations = new ConcurrentHashMap<Class, List<ListenerInvocation>>();
+ private Cache cache;
+ private boolean useMarshalledValueMaps;
+ private Configuration config;
+ // two separate executor services, one for sync and one for async listeners
+ private ExecutorService syncProcessor;
+ private ExecutorService asyncProcessor;
+ private static final AtomicInteger asyncNotifierThreadNumber = new AtomicInteger(0);
+
+ public NotifierImpl()
+ {
+ listenersMap.put(CacheStarted.class, cacheStartedListeners);
+ listenersMap.put(CacheStopped.class, cacheStoppedListeners);
+ listenersMap.put(CacheBlocked.class, cacheBlockedListeners);
+ listenersMap.put(CacheUnblocked.class, cacheUnblockedListeners);
+ listenersMap.put(NodeCreated.class, nodeCreatedListeners);
+ listenersMap.put(NodeRemoved.class, nodeRemovedListeners);
+ listenersMap.put(NodeVisited.class, nodeVisitedListeners);
+ listenersMap.put(NodeModified.class, nodeModifiedListeners);
+ listenersMap.put(NodeMoved.class, nodeMovedListeners);
+ listenersMap.put(NodeActivated.class, nodeActivatedListeners);
+ listenersMap.put(NodePassivated.class, nodePassivatedListeners);
+ listenersMap.put(NodeLoaded.class, nodeLoadedListeners);
+ listenersMap.put(NodeEvicted.class, nodeEvictedListeners);
+ listenersMap.put(TransactionRegistered.class, transactionRegisteredListeners);
+ listenersMap.put(TransactionCompleted.class, transactionCompletedListeners);
+ listenersMap.put(ViewChanged.class, viewChangedListeners);
+ listenersMap.put(BuddyGroupChanged.class, buddyGroupChangedListeners);
+ listenersMap.put(NodeInvalidated.class, nodeInvalidatedListeners);
+ }
+
+ @Inject
+ void injectDependencies(CacheSPI cache, Configuration config)
+ {
+ this.cache = cache;
+ this.config = config;
+ }
+
+ @Stop
+ void stop()
+ {
+ syncProcessor.shutdownNow();
+ asyncProcessor.shutdownNow();
+ }
+
+ @Destroy
+ void destroy()
+ {
+ removeAllCacheListeners();
+ }
+
+ @Start
+ void start()
+ {
+ useMarshalledValueMaps = config.isUseLazyDeserialization();
+ syncProcessor = new WithinThreadExecutor();
+
+ // first try and use an injected executor for async listeners
+ if ((asyncProcessor = config.getRuntimeConfig().getAsyncCacheListenerExecutor()) == null)
+ {
+ // create one if needed
+ if (config.getListenerAsyncPoolSize() > 0)
+ {
+ asyncProcessor = Executors.newFixedThreadPool(config.getListenerAsyncPoolSize(), new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ return new Thread(r, "AsyncNotifier-" + asyncNotifierThreadNumber.getAndIncrement());
+ }
+ });
+ }
+ else
+ {
+ // use the same sync executor
+ asyncProcessor = syncProcessor;
+ }
+ }
+ }
+
+ /**
+ * Loops through all valid methods on the object passed in, and caches the relevant methods as {@link NotifierImpl.ListenerInvocation}
+ * for invocation by reflection.
+ *
+ * @param listener object to be considered as a listener.
+ */
+ @SuppressWarnings("unchecked")
+ private void validateAndAddListenerInvocation(Object listener)
+ {
+ boolean sync = testListenerClassValidity(listener.getClass());
+
+ boolean foundMethods = false;
+ // now try all methods on the listener for anything that we like. Note that only PUBLIC methods are scanned.
+ for (Method m : listener.getClass().getMethods())
+ {
+ // loop through all valid method annotations
+ for (int i = 0; i < allowedMethodAnnotations.length; i++)
+ {
+ if (m.isAnnotationPresent(allowedMethodAnnotations[i]))
+ {
+ testListenerMethodValidity(m, parameterTypes[i], allowedMethodAnnotations[i].getName());
+ addListenerInvocation(allowedMethodAnnotations[i], new ListenerInvocation(listener, m, sync));
+ foundMethods = true;
+ }
+ }
+ }
+
+ if (!foundMethods && log.isWarnEnabled())
+ log.warn("Attempted to register listener of class " + listener.getClass() + ", but no valid, public methods annotated with method-level event annotations found! Ignoring listener.");
+ }
+
+ /**
+ * Tests if a class is properly annotated as a CacheListener and returns whether callbacks on this class should be invoked
+ * synchronously or asynchronously.
+ *
+ * @param listenerClass class to inspect
+ * @return true if callbacks on this class should use the syncProcessor; false if it should use the asyncProcessor.
+ */
+ private static boolean testListenerClassValidity(Class<?> listenerClass)
+ {
+ CacheListener cl = listenerClass.getAnnotation(CacheListener.class);
+ if (cl == null)
+ throw new IncorrectCacheListenerException("Cache listener class MUST be annotated with org.jboss.cache.notifications.annotation.CacheListener");
+ if (!Modifier.isPublic(listenerClass.getModifiers()))
+ throw new IncorrectCacheListenerException("Cache listener class MUST be public!");
+ return cl.sync();
+
+ }
+
+ private static void testListenerMethodValidity(Method m, Class allowedParameter, String annotationName)
+ {
+ if (m.getParameterTypes().length != 1 || !m.getParameterTypes()[0].isAssignableFrom(allowedParameter))
+ throw new IncorrectCacheListenerException("Methods annotated with " + annotationName + " must accept exactly one parameter, of assignable from type " + allowedParameter.getName());
+ if (!m.getReturnType().equals(void.class))
+ throw new IncorrectCacheListenerException("Methods annotated with " + annotationName + " should have a return type of void.");
+ }
+
+ private void addListenerInvocation(Class annotation, ListenerInvocation li)
+ {
+ List<ListenerInvocation> result = getListenerCollectionForAnnotation(annotation);
+ result.add(li);
+ }
+
+ public void addCacheListener(Object listener)
+ {
+ validateAndAddListenerInvocation(listener);
+ }
+
+ public void removeCacheListener(Object listener)
+ {
+ for (Class annotation : allowedMethodAnnotations) removeListenerInvocation(annotation, listener);
+ }
+
+ private void removeListenerInvocation(Class annotation, Object listener)
+ {
+ if (listener == null) return;
+ List<ListenerInvocation> l = getListenerCollectionForAnnotation(annotation);
+ Set<Object> markedForRemoval = new HashSet<Object>();
+ for (ListenerInvocation li : l)
+ {
+ if (listener.equals(li.target)) markedForRemoval.add(li);
+ }
+ l.removeAll(markedForRemoval);
+ }
+
+ /**
+ * Removes all listeners from the notifier, including the evictionPolicyListener.
+ */
+ @Stop(priority = 99)
+ public void removeAllCacheListeners()
+ {
+ cacheStartedListeners.clear();
+ cacheStoppedListeners.clear();
+ cacheBlockedListeners.clear();
+ cacheUnblockedListeners.clear();
+ nodeCreatedListeners.clear();
+ nodeRemovedListeners.clear();
+ nodeVisitedListeners.clear();
+ nodeModifiedListeners.clear();
+ nodeMovedListeners.clear();
+ nodeActivatedListeners.clear();
+ nodePassivatedListeners.clear();
+ nodeLoadedListeners.clear();
+ nodeEvictedListeners.clear();
+ transactionRegisteredListeners.clear();
+ transactionCompletedListeners.clear();
+ viewChangedListeners.clear();
+ buddyGroupChangedListeners.clear();
+ }
+
+ public Set<Object> getCacheListeners()
+ {
+ Set<Object> result = new HashSet<Object>();
+ for (List<ListenerInvocation> list : listenersMap.values())
+ {
+ for (ListenerInvocation li : list) result.add(li.target);
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ public void notifyNodeCreated(Object key, boolean pre, InvocationContext ctx)
+ {
+ if (!nodeCreatedListeners.isEmpty())
+ {
+ boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setType(NODE_CREATED);
+ for (ListenerInvocation listener : nodeCreatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodeModified(Object key, boolean pre, NodeModifiedEvent.ModificationType modificationType, Map data, InvocationContext ctx)
+ {
+ if (!nodeModifiedListeners.isEmpty())
+ {
+ boolean originLocal = ctx.isOriginLocal();
+ Map dataCopy = copy(data, useMarshalledValueMaps);
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+// e.setModificationType(modificationType); // TODO fix types
+ e.setData(dataCopy);
+ e.setType(NODE_MODIFIED);
+ for (ListenerInvocation listener : nodeModifiedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public boolean shouldNotifyOnNodeModified()
+ {
+ return !nodeModifiedListeners.isEmpty();
+ }
+
+ public void notifyNodeRemoved(Object key, boolean pre, Map data, InvocationContext ctx)
+ {
+ if (!nodeRemovedListeners.isEmpty())
+ {
+ boolean originLocal = ctx.isOriginLocal();
+ Map dataCopy = copy(data, useMarshalledValueMaps);
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setData(dataCopy);
+ e.setType(NODE_REMOVED);
+ for (ListenerInvocation listener : nodeRemovedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodeVisited(Object key, boolean pre, InvocationContext ctx)
+ {
+ if (!nodeVisitedListeners.isEmpty())
+ {
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setType(NODE_VISITED);
+ for (ListenerInvocation listener : nodeVisitedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodeMoved(Fqn originalFqn, Fqn newFqn, boolean pre, InvocationContext ctx)
+ {
+ if (!nodeMovedListeners.isEmpty())
+ {
+ boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+ e.setFqn(originalFqn);
+ e.setTargetFqn(newFqn);
+ e.setTransaction(tx);
+ e.setType(NODE_MOVED);
+ for (ListenerInvocation listener : nodeMovedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodeEvicted(final Object key, final boolean pre, InvocationContext ctx)
+ {
+ if (!nodeEvictedListeners.isEmpty())
+ {
+ final boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setType(NODE_EVICTED);
+ for (ListenerInvocation listener : nodeEvictedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodeInvalidated(final Object key, final boolean pre, InvocationContext ctx)
+ {
+ if (!nodeInvalidatedListeners.isEmpty())
+ {
+ final boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setType(NODE_INVALIDATED);
+ for (ListenerInvocation listener : nodeInvalidatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodeLoaded(Object key, boolean pre, Map data, InvocationContext ctx)
+ {
+ if (!nodeLoadedListeners.isEmpty())
+ {
+ boolean originLocal = ctx.isOriginLocal();
+ Map dataCopy = copy(data, useMarshalledValueMaps);
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setData(dataCopy);
+ e.setType(NODE_LOADED);
+ for (ListenerInvocation listener : nodeLoadedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodeActivated(Object key, boolean pre, Map data, InvocationContext ctx)
+ {
+ if (!nodeActivatedListeners.isEmpty())
+ {
+ boolean originLocal = ctx.isOriginLocal();
+ Map dataCopy = copy(data, useMarshalledValueMaps);
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setData(dataCopy);
+ e.setType(NODE_ACTIVATED);
+ for (ListenerInvocation listener : nodeActivatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyNodePassivated(Object key, boolean pre, Map data, InvocationContext ctx)
+ {
+ if (!nodePassivatedListeners.isEmpty())
+ {
+ Map dataCopy = copy(data, useMarshalledValueMaps);
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setPre(pre);
+// e.setFqn(fqn); // TODO - attach key
+ e.setTransaction(tx);
+ e.setData(dataCopy);
+ e.setType(NODE_PASSIVATED);
+ for (ListenerInvocation listener : nodePassivatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ /**
+ * Notifies all registered listeners of a cacheStarted event.
+ */
+ @Start(priority = 99)
+ public void notifyCacheStarted()
+ {
+ if (!cacheStartedListeners.isEmpty())
+ {
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setType(CACHE_STARTED);
+ for (ListenerInvocation listener : cacheStartedListeners) listener.invoke(e);
+ }
+ }
+
+ /**
+ * Notifies all registered listeners of a cacheStopped event.
+ */
+ @Stop(priority = 98)
+ public void notifyCacheStopped()
+ {
+ if (!cacheStoppedListeners.isEmpty())
+ {
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setType(CACHE_STOPPED);
+ for (ListenerInvocation listener : cacheStoppedListeners) listener.invoke(e);
+ }
+ }
+
+ public void notifyViewChange(final View newView, InvocationContext ctx)
+ {
+ if (!viewChangedListeners.isEmpty())
+ {
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setNewView(newView);
+ e.setType(VIEW_CHANGED);
+ for (ListenerInvocation listener : viewChangedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyBuddyGroupChange(final BuddyGroup buddyGroup, boolean pre)
+ {
+ if (!buddyGroupChangedListeners.isEmpty())
+ {
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setBuddyGroup(buddyGroup);
+ e.setPre(pre);
+ e.setType(BUDDY_GROUP_CHANGED);
+ for (ListenerInvocation listener : buddyGroupChangedListeners) listener.invoke(e);
+ }
+ }
+
+ public void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx)
+ {
+ if (!transactionCompletedListeners.isEmpty())
+ {
+ boolean isOriginLocal = ctx.isOriginLocal();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(isOriginLocal);
+ e.setTransaction(transaction);
+ e.setSuccessful(successful);
+ e.setType(TRANSACTION_COMPLETED);
+ for (ListenerInvocation listener : transactionCompletedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx)
+ {
+ if (!transactionRegisteredListeners.isEmpty())
+ {
+ boolean isOriginLocal = ctx.isOriginLocal();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(isOriginLocal);
+ e.setTransaction(transaction);
+ e.setType(TRANSACTION_REGISTERED);
+ for (ListenerInvocation listener : transactionRegisteredListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheBlocked(boolean pre)
+ {
+ if (!cacheBlockedListeners.isEmpty())
+ {
+ EventImpl e = new EventImpl();
+ e.setCache(this.cache);
+ e.setPre(pre);
+ e.setType(CACHE_BLOCKED);
+ for (ListenerInvocation listener : cacheBlockedListeners) listener.invoke(e);
+ }
+ }
+
+ public void notifyCacheUnblocked(boolean pre)
+ {
+ if (!cacheUnblockedListeners.isEmpty())
+ {
+ EventImpl e = new EventImpl();
+ e.setCache(this.cache);
+ e.setPre(pre);
+ e.setType(CACHE_UNBLOCKED);
+ for (ListenerInvocation listener : cacheUnblockedListeners) listener.invoke(e);
+ }
+ }
+
+ private static Map copy(Map data, boolean useMarshalledValueMaps)
+ {
+ if (data == null) return null;
+ if (data.isEmpty()) return Collections.emptyMap();
+ if (safe(data)) return useMarshalledValueMaps ? new MarshalledValueMap(data) : data;
+ Map defensivelyCopiedData = Immutables.immutableMapCopy(data);
+ return useMarshalledValueMaps ? new MarshalledValueMap(defensivelyCopiedData) : defensivelyCopiedData;
+ }
+
+ private void restoreInvocationContext(InvocationContext backup)
+ {
+ InvocationContext currentIC = cache.getInvocationContext();
+ backup.clearLookedUpEntries();
+ for (MVCCEntry me : currentIC.getLookedUpEntries().values())
+ {
+ backup.putLookedUpEntry(me);
+ }
+ cache.setInvocationContext(backup);
+ }
+
+ /**
+ * Resets the current (passed-in) invocation, and returns a temp InvocationContext containing its state so it can
+ * be restored later using {@link #restoreInvocationContext(org.jboss.cache.InvocationContext)}
+ *
+ * @param ctx the current context to be reset
+ * @return a clone of ctx, before it was reset
+ */
+ private InvocationContext resetInvocationContext(InvocationContext ctx)
+ {
+ // wipe current context.
+ cache.setInvocationContext(null);
+ // get a new Invocation Context
+ InvocationContext newContext = cache.getInvocationContext();
+ for (MVCCEntry me : ctx.getLookedUpEntries().values())
+ {
+ newContext.putLookedUpEntry(me);
+ }
+ return ctx;
+ }
+
+ /**
+ * A map is deemed 'safe' to be passed as-is to a listener, if either of the following are true:
+ * <ul>
+ * <li>It is null</li>
+ * <li>It is an instance of {@link org.jboss.cache.util.ImmutableMapCopy}, which is immutable</li>
+ * <li>It is an instance of {@link java.util.Collections#emptyMap()}, which is also immutable</li>
+ * <li>It is an instance of {@link java.util.Collections#singletonMap(Object,Object)}, which is also immutable</li>
+ * </ul>
+ *
+ * @param map
+ * @return
+ */
+ private static boolean safe(Map map)
+ {
+ return map == null || Immutables.isImmutable(map) || map.getClass().equals(emptyMap) || map.getClass().equals(singletonMap);
+ }
+
+ /**
+ * Class that encapsulates a valid invocation for a given registered listener - containing a reference to the
+ * method to be invoked as well as the target object.
+ */
+ class ListenerInvocation
+ {
+ private final Object target;
+ private final Method method;
+ private final boolean sync;
+
+ public ListenerInvocation(Object target, Method method, boolean sync)
+ {
+ this.target = target;
+ this.method = method;
+ this.sync = sync;
+ }
+
+ public void invoke(final Event e)
+ {
+ Runnable r = new Runnable()
+ {
+
+ public void run()
+ {
+ try
+ {
+ method.invoke(target, e);
+ }
+ catch (InvocationTargetException exception)
+ {
+ Throwable cause = exception.getCause();
+ if (cause != null)
+ throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, cause);
+ else
+ throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, exception);
+ }
+ catch (IllegalAccessException exception)
+ {
+ log.warn("Unable to invoke method " + method + " on Object instance " + target + " - removing this target object from list of listeners!", exception);
+ removeCacheListener(target);
+ }
+ }
+ };
+
+ if (sync)
+ syncProcessor.execute(r);
+ else
+ asyncProcessor.execute(r);
+
+ }
+
+ }
+
+ private List<ListenerInvocation> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation)
+ {
+ List<ListenerInvocation> list = listenersMap.get(annotation);
+ if (list == null) throw new CacheException("Unknown listener annotation: " + annotation);
+ return list;
+ }
+}
Added: core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java
===================================================================
--- core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/jboss/starobrno/BasicTest.java 2008-10-08 18:56:43 UTC (rev 6891)
@@ -0,0 +1,80 @@
+/*
+ * 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.manager.CacheManager;
+import org.testng.annotations.Test;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@Test
+public class BasicTest
+{
+ public void basicTest()
+ {
+ // create a cache manager
+ Configuration c = new Configuration(); // LOCAL mode
+ c.setFetchInMemoryState(false);
+ CacheManager cm = new CacheManager(c);
+ try
+ {
+ cm.start();
+ Cache cache = cm.createCache("test");
+ String key = "key", value = "value";
+
+ assert cache.isEmpty();
+ assert cache.size() == 0;
+ assert !cache.containsKey(key);
+
+ cache.put(key, value);
+ assert cache.size() == 1;
+ assert cache.containsKey(key);
+ assert !cache.isEmpty();
+
+ assert cache.remove(key).equals(value);
+
+ assert cache.isEmpty();
+ assert cache.size() == 0;
+ assert !cache.containsKey(key);
+ }
+ finally
+ {
+ cm.destroyCache("test");
+ cm.stop();
+ }
+ }
+
+ public void concurrentMapMethodTest()
+ {
+
+ }
+
+ public void transactionalTest()
+ {
+
+ }
+}
Modified: core/branches/flat/src/test/resources/log4j.xml
===================================================================
--- core/branches/flat/src/test/resources/log4j.xml 2008-10-08 17:53:15 UTC (rev 6890)
+++ core/branches/flat/src/test/resources/log4j.xml 2008-10-08 18:56:43 UTC (rev 6891)
@@ -46,11 +46,11 @@
<!-- ================ -->
<category name="org.jboss.cache">
- <priority value="WARN"/>
+ <priority value="TRACE"/>
</category>
<category name="org.jboss.cache.factories">
- <priority value="WARN"/>
+ <priority value="TRACE"/>
</category>
<category name="org.jboss.tm">
@@ -66,8 +66,8 @@
<!-- ======================= -->
<root>
- <!--<appender-ref ref="CONSOLE"/>-->
- <appender-ref ref="FILE"/>
+ <appender-ref ref="CONSOLE"/>
+ <!--<appender-ref ref="FILE"/>-->
</root>
</log4j:configuration>
17 years, 2 months
JBoss Cache SVN: r6890 - core/branches/flat/src/main/java/org/jboss/starobrno.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-08 13:53:15 -0400 (Wed, 08 Oct 2008)
New Revision: 6890
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java
Log:
work on progress
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java 2008-10-08 17:13:48 UTC (rev 6889)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java 2008-10-08 17:53:15 UTC (rev 6890)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno;
-import org.jboss.cache.config.Option;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.starobrno.commands.CommandsFactory;
@@ -42,6 +41,7 @@
import org.jboss.starobrno.transaction.TransactionTable;
import org.jboss.starobrno.jmx.annotations.ManagedOperation;
import org.jboss.starobrno.jmx.annotations.ManagedAttribute;
+import org.jboss.starobrno.config.Option;
import javax.transaction.*;
import java.util.*;
17 years, 2 months
JBoss Cache SVN: r6889 - in core/branches/flat/src/main/java/org/jboss/starobrno: commands and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-10-08 13:13:48 -0400 (Wed, 08 Oct 2008)
New Revision: 6889
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/OrderedSynchronizationHandler.java
core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java
core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/jmx/
core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/
core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/MBean.java
core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedAttribute.java
core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedOperation.java
Modified:
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
Log:
work on progress
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/OrderedSynchronizationHandler.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/OrderedSynchronizationHandler.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/OrderedSynchronizationHandler.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -0,0 +1,119 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.LinkedList;
+
+/**
+ * Maintains a list of Synchronization handlers. Reason is that we have to
+ * invoke certain handlers <em>before</em> others. See the description in
+ * SyncTxUnitTestCase.testConcurrentPuts(). For example, for synchronous
+ * replication, we have to execute the ReplicationInterceptor's
+ * afterCompletion() <em>before</em> the TransactionInterceptor's.
+ *
+ * @author Bela Ban
+ * @version $Id$
+ */
+public class OrderedSynchronizationHandler implements Synchronization
+{
+ static final Log log = LogFactory.getLog(org.jboss.cache.interceptors.OrderedSynchronizationHandler.class);
+
+ private Transaction tx = null;
+ private final LinkedList<Synchronization> handlers = new LinkedList<Synchronization>();
+
+ public OrderedSynchronizationHandler(Transaction tx) throws SystemException, RollbackException
+ {
+ this.tx = tx;
+ tx.registerSynchronization(this);
+ }
+
+ public void registerAtHead(Synchronization handler)
+ {
+ register(handler, true);
+ }
+
+ public void registerAtTail(Synchronization handler)
+ {
+ register(handler, false);
+ }
+
+ void register(Synchronization handler, boolean head)
+ {
+ if (handler != null && !handlers.contains(handler))
+ {
+ if (head)
+ handlers.addFirst(handler);
+ else
+ handlers.addLast(handler);
+ }
+ }
+
+ public void beforeCompletion()
+ {
+ for (Synchronization sync : handlers)
+ {
+ sync.beforeCompletion();
+ }
+ }
+
+ public void afterCompletion(int status)
+ {
+ RuntimeException exceptionInAfterCompletion = null;
+ for (Synchronization sync : handlers)
+ {
+ try
+ {
+ sync.afterCompletion(status);
+ }
+ catch (Throwable t)
+ {
+ log.error("failed calling afterCompletion() on " + sync, t);
+ exceptionInAfterCompletion = (RuntimeException) t;
+ }
+ }
+
+ // throw the exception so the TM can deal with it.
+ if (exceptionInAfterCompletion != null) throw exceptionInAfterCompletion;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "tx=" + getTxAsString() + ", handlers=" + handlers;
+ }
+
+ private String getTxAsString()
+ {
+ // JBCACHE-1114 -- don't call toString() on tx or it can lead to stack overflow
+ if (tx == null)
+ return null;
+
+ return tx.getClass().getName() + "@" + System.identityHashCode(tx);
+ }
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/ReplicationException.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/ReplicationException.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+
+/**
+ * Thrown when a replication problem occurred
+ */
+public class ReplicationException extends CacheException
+{
+
+ private static final long serialVersionUID = 33172388691879866L;
+
+ public ReplicationException()
+ {
+ super();
+ }
+
+ public ReplicationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public ReplicationException(String msg)
+ {
+ super(msg);
+ }
+
+ public ReplicationException(String msg, Throwable cause)
+ {
+ super(msg, cause);
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString();
+ }
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/TxInterceptor.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -0,0 +1,1040 @@
+/*
+ * 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;
+
+import org.jboss.cache.config.Option;
+import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+import org.jboss.starobrno.commands.CommandsFactory;
+import org.jboss.starobrno.commands.ReplicableCommand;
+import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
+import org.jboss.starobrno.commands.tx.PrepareCommand;
+import org.jboss.starobrno.commands.tx.RollbackCommand;
+import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.context.TransactionContext;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.context.ContextFactory;
+import org.jboss.starobrno.interceptors.BaseTransactionalContextInterceptor;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.lock.LockManager;
+import org.jboss.starobrno.notifier.Notifier;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jboss.starobrno.transaction.TransactionTable;
+import org.jboss.starobrno.jmx.annotations.ManagedOperation;
+import org.jboss.starobrno.jmx.annotations.ManagedAttribute;
+
+import javax.transaction.*;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * This interceptor is the new default at the head of all interceptor chains,
+ * and makes transactional attributes available to all interceptors in the chain.
+ * This interceptor is also responsible for registering for synchronisation on
+ * transaction completion.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
+ */
+public class TxInterceptor extends BaseTransactionalContextInterceptor
+{
+ protected CommandsFactory commandsFactory;
+ protected RPCManager rpcManager;
+ private Notifier notifier;
+ private InvocationContextContainer invocationContextContainer;
+ private ComponentRegistry componentRegistry;
+ private ContextFactory contextFactory;
+
+ /**
+ * List <Transaction>that we have registered for
+ */
+ private final Set<Transaction> transactions = new ConcurrentHashSet<Transaction>();
+ private final Map<Transaction, GlobalTransaction> rollbackTransactions = new ConcurrentHashMap<Transaction, GlobalTransaction>(16);
+ private long prepares = 0;
+ private long commits = 0;
+ private long rollbacks = 0;
+ protected boolean optimistic = false;
+ private LockManager lockManager;
+ private boolean statsEnabled;
+
+ @Inject
+ public void intialize(RPCManager rpcManager, ContextFactory contextFactory,
+ Notifier notifier, InvocationContextContainer icc,
+ CommandsFactory factory, ComponentRegistry componentRegistry, LockManager lockManager)
+ {
+ this.contextFactory = contextFactory;
+ this.commandsFactory = factory;
+ this.rpcManager = rpcManager;
+ this.notifier = notifier;
+ this.invocationContextContainer = icc;
+ this.componentRegistry = componentRegistry;
+ this.lockManager = lockManager;
+ setStatisticsEnabled(configuration.isExposeManagementStatistics());
+ }
+
+ @Override
+ public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ Object result = null;
+
+ // this is a prepare, commit, or rollback.
+ if (log.isDebugEnabled()) log.debug("Got gtx from invocation context " + ctx.getGlobalTransaction());
+ try
+ {
+ if (ctx.getGlobalTransaction().isRemote())
+ {
+ result = handleRemotePrepare(ctx, command);
+ if (getStatisticsEnabled()) prepares++;
+ }
+ else
+ {
+ if (trace) log.trace("received my own message (discarding it)");
+ result = null;
+ }
+ }
+ catch (Throwable e)
+ {
+ ctx.throwIfNeeded(e);
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
+ {
+ if (!ctx.getGlobalTransaction().isRemote())
+ {
+ if (trace) log.trace("received my own message (discarding it)");
+ return null;
+ }
+ try
+ {
+ if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") call on command [" + command + "]");
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ Transaction ltx = txTable.getLocalTransaction(gtx, true);
+ // disconnect if we have a current tx associated
+ Transaction currentTx = txManager.getTransaction();
+ boolean resumeCurrentTxOnCompletion = false;
+ try
+ {
+ if (!ltx.equals(currentTx))
+ {
+ currentTx = txManager.suspend();
+ resumeCurrentTxOnCompletion = true;
+ txManager.resume(ltx);
+ // make sure we set this in the ctx
+ ctx.setTransaction(ltx);
+ }
+ if (log.isDebugEnabled()) log.debug(" executing commit() with local TX " + ltx + " under global tx " + gtx);
+ txManager.commit();
+ if (getStatisticsEnabled()) commits++;
+ }
+ finally
+ {
+ //resume the old transaction if we suspended it
+ if (resumeCurrentTxOnCompletion)
+ {
+ resumeTransactionOnCompletion(ctx, currentTx);
+ }
+ // remove from local lists.
+ transactions.remove(ltx);
+ // this tx has completed. Clean up in the tx table.
+ txTable.remove(gtx, ltx);
+ }
+ if (log.isDebugEnabled()) log.debug("Finished remote rollback method for " + gtx);
+ }
+ catch (Throwable throwable)
+ {
+ ctx.throwIfNeeded(throwable);
+ }
+ return null;
+ }
+
+ @Override
+ public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ if (!ctx.getGlobalTransaction().isRemote())
+ {
+ if (trace) log.trace("received my own message (discarding it)");
+ return null;
+ }
+ try
+ {
+ if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") call on command [" + command + "]");
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ Transaction ltx = txTable.getLocalTransaction(gtx);
+ if (ltx == null)
+ {
+ log.warn("No local transaction for this remotely originating rollback. Possibly rolling back before a prepare call was broadcast?");
+ txTable.remove(gtx);
+ return null;
+ }
+ // disconnect if we have a current tx associated
+ Transaction currentTx = txManager.getTransaction();
+ boolean resumeCurrentTxOnCompletion = false;
+ try
+ {
+ if (!ltx.equals(currentTx))
+ {
+ currentTx = txManager.suspend();
+ resumeCurrentTxOnCompletion = true;
+ txManager.resume(ltx);
+ // make sure we set this in the ctx
+ ctx.setTransaction(ltx);
+ }
+ if (log.isDebugEnabled()) log.debug("executing with local TX " + ltx + " under global tx " + gtx);
+ txManager.rollback();
+ if (getStatisticsEnabled()) rollbacks++;
+ }
+ finally
+ {
+ //resume the old transaction if we suspended it
+ if (resumeCurrentTxOnCompletion)
+ {
+ resumeTransactionOnCompletion(ctx, currentTx);
+ }
+
+ // remove from local lists.
+ transactions.remove(ltx);
+
+ // this tx has completed. Clean up in the tx table.
+ txTable.remove(gtx, ltx);
+ }
+ if (log.isDebugEnabled()) log.debug("Finished remote commit/rollback method for " + gtx);
+ }
+ catch (Throwable throwable)
+ {
+ ctx.throwIfNeeded(throwable);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ try
+ {
+ return attachGtxAndPassUpChain(ctx, command);
+ }
+ catch (Throwable throwable)
+ {
+ ctx.throwIfNeeded(throwable);
+ return null;
+ }
+ }
+
+ protected Object attachGtxAndPassUpChain(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ Transaction tx = ctx.getTransaction();
+ if (tx != null) attachGlobalTransaction(ctx, tx, command);
+ return invokeNextInterceptor(ctx, command);
+ }
+
+ // ------------------------------------------------------------------------
+ // JMX statistics
+ // ------------------------------------------------------------------------
+
+ // --------------------------------------------------------------
+
+ /**
+ * Handles a remotely originating prepare call, by creating a local transaction for the remote global transaction
+ * and replaying modifications in this new local transaction.
+ *
+ * @param ctx invocation context
+ * @param command prepare command
+ * @return result of the prepare, typically a null.
+ * @throws Throwable in the event of problems.
+ */
+ private Object handleRemotePrepare(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ // the InvocationContextInterceptor would have set this for us
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+
+ // Is there a local transaction associated with GTX? (not the current tx associated with the thread, which may be
+ // in the invocation context
+ Transaction ltx = txTable.getLocalTransaction(gtx);
+ Transaction currentTx = txManager.getTransaction();
+
+ Object retval = null;
+ boolean success = false;
+ try
+ {
+ if (ltx == null)
+ {
+ if (currentTx != null) txManager.suspend();
+ // create a new local transaction
+ ltx = createLocalTx();
+ // associate this with a global tx
+ txTable.put(ltx, gtx);
+ if (trace) log.trace("Created new tx for gtx " + gtx);
+
+ if (log.isDebugEnabled())
+ log.debug("Started new local tx as result of remote prepare: local tx=" + ltx + " (status=" + ltx.getStatus() + "), gtx=" + gtx);
+ }
+ else
+ {
+ //this should be valid
+ if (!TransactionTable.isValid(ltx))
+ throw new CacheException("Transaction " + ltx + " not in correct state to be prepared");
+
+ //associate this thread with the local transaction associated with the global transaction, IF the localTx is NOT the current tx.
+ if (currentTx == null || !ltx.equals(currentTx))
+ {
+ if (trace) log.trace("Suspending current tx " + currentTx);
+ txManager.suspend();
+ txManager.resume(ltx);
+ }
+ }
+ if (trace) log.trace("Resuming existing tx " + ltx + ", global tx=" + gtx);
+
+ // at this point we have a non-null ltx
+
+ // Asssociate the local TX with the global TX. Create new
+ // transactionContext for TX in txTable, the modifications
+ // below will need this transactionContext to add their modifications
+ // under the GlobalTx key
+ TransactionContext transactionContext = txTable.get(gtx);
+ if (transactionContext == null)
+ {
+ // create a new transaction transactionContext
+ if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
+ transactionContext = contextFactory.createTransactionContext(ltx);
+ txTable.put(gtx, transactionContext);
+ }
+
+ setTransactionalContext(ltx, gtx, transactionContext, ctx);
+
+ // register a sync handler for this tx.
+ registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, transactionContext), ctx);
+
+ success = false;
+
+ // replay modifications
+ replayModifications(ctx, ltx, command);
+
+ success = true; // no exceptions were thrown above!!
+
+ // now pass the prepare command up the chain as well.
+ if (command.isOnePhaseCommit())
+ {
+ if (trace)
+ log.trace("Using one-phase prepare. Not propagating the prepare call up the stack until called to do so by the sync handler.");
+ }
+ else
+ {
+ // now pass up the prepare method itself.
+ invokeNextInterceptor(ctx, command);
+ }
+ // JBCACHE-361 Confirm that the transaction is ACTIVE
+ assertTxIsStillValid(ltx);
+ }
+ finally
+ {
+ // if we are running a one-phase commit, perform a commit or rollback now.
+ if (trace) log.trace("Are we running a 1-phase commit? " + command.isOnePhaseCommit());
+
+ if (command.isOnePhaseCommit())
+ {
+ try
+ {
+ if (success)
+ {
+ ltx.commit();
+ }
+ else
+ {
+ ltx.rollback();
+ }
+ }
+ catch (Throwable t)
+ {
+ log.error("Commit/rollback failed.", t);
+ if (success)
+ {
+ // try another rollback...
+ try
+ {
+ log.info("Attempting anotehr rollback");
+ //invokeOnePhaseCommitMethod(globalTransaction, modifications.size() > 0, false);
+ ltx.rollback();
+ }
+ catch (Throwable t2)
+ {
+ log.error("Unable to rollback", t2);
+ }
+ }
+ }
+ finally
+ {
+ transactions.remove(ltx);// JBAS-298
+ }
+ }
+
+ txManager.suspend();// suspends ltx - could be null
+ // resume whatever else we had going.
+ if (currentTx != null) txManager.resume(currentTx);
+ if (log.isDebugEnabled()) log.debug("Finished remote prepare " + gtx);
+ }
+
+ return retval;
+ }
+
+ private ReplicableCommand attachGlobalTransaction(InvocationContext ctx, Transaction tx, VisitableCommand command) throws Throwable
+ {
+ if (trace)
+ {
+ log.trace(" local transaction exists - registering global tx if not present for " + Thread.currentThread());
+ }
+ if (trace)
+ {
+ GlobalTransaction tempGtx = txTable.get(tx);
+ log.trace("Associated gtx in txTable is " + tempGtx);
+ }
+
+ // register a sync handler for this tx - only if the globalTransaction is not remotely initiated.
+ GlobalTransaction gtx = registerTransaction(tx, ctx);
+ if (gtx == null)
+ {
+ // get the current globalTransaction from the txTable.
+ gtx = txTable.get(tx);
+ }
+
+ // make sure we attach this globalTransaction to the invocation context.
+ ctx.setGlobalTransaction(gtx);
+
+ return command;
+ }
+
+ /**
+ * Replays modifications
+ */
+ protected void replayModifications(InvocationContext ctx, Transaction ltx, PrepareCommand command) throws Throwable
+ {
+ try
+ {
+ // replay modifications
+ for (VisitableCommand modification : command.getModifications())
+ {
+ invokeNextInterceptor(ctx, modification);
+ assertTxIsStillValid(ltx);
+ }
+ }
+ catch (Throwable th)
+ {
+ log.error("prepare failed!", th);
+ throw th;
+ }
+ }
+
+ private void resumeTransactionOnCompletion(InvocationContext ctx, Transaction currentTx)
+ throws SystemException, InvalidTransactionException
+ {
+ if (trace) log.trace("Resuming suspended transaction " + currentTx);
+ txManager.suspend();
+ if (currentTx != null)
+ {
+ txManager.resume(currentTx);
+ ctx.setTransaction(currentTx);
+ }
+ }
+
+ /**
+ * Handles a commit or a rollback. Called by the synch handler. Simply tests that we are in the correct tx and
+ * passes the meth call up the interceptor chain.
+ *
+ * @throws Throwable
+ */
+ @SuppressWarnings("deprecation")
+ private Object handleCommitRollback(InvocationContext ctx, VisitableCommand command) throws Throwable
+ {
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ Object result;
+ VisitableCommand originalCommand = ctx.getCommand();
+ ctx.setCommand(command);
+ try
+ {
+ result = invokeNextInterceptor(ctx, command);
+ }
+ finally
+ {
+ ctx.setCommand(originalCommand);
+ }
+ if (log.isDebugEnabled()) log.debug("Finished local commit/rollback method for " + gtx);
+ return result;
+ }
+
+ // --------------------------------------------------------------
+ // Transaction phase runners
+ // --------------------------------------------------------------
+
+ protected PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, boolean onePhaseCommit)
+ {
+ return commandsFactory.buildPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(), onePhaseCommit);
+ }
+
+ /**
+ * creates a commit()
+ */
+ protected void runCommitPhase(InvocationContext ctx, GlobalTransaction gtx, List modifications, boolean onePhaseCommit)
+ {
+ try
+ {
+ VisitableCommand commitCommand = onePhaseCommit ? buildPrepareCommand(gtx, modifications, true) : commandsFactory.buildCommitCommand(gtx);
+
+ if (trace) log.trace("Running commit for " + gtx);
+
+ handleCommitRollback(ctx, commitCommand);
+ }
+ catch (Throwable e)
+ {
+ log.warn("Commit failed. Clearing stale locks.");
+ try
+ {
+ cleanupStaleLocks(ctx);
+ }
+ catch (RuntimeException re)
+ {
+ log.error("Unable to clear stale locks", re);
+ throw re;
+ }
+ catch (Throwable e2)
+ {
+ log.error("Unable to clear stale locks", e2);
+ throw new RuntimeException(e2);
+ }
+ if (e instanceof RuntimeException)
+ throw (RuntimeException) e;
+ else
+ throw new RuntimeException("Commit failed.", e);
+ }
+ }
+
+ protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
+ {
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null) lockManager.unlock(ctx);
+ }
+
+ /**
+ * creates a rollback()
+ */
+ protected void runRollbackPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx)
+ {
+ try
+ {
+ // JBCACHE-457
+ VisitableCommand rollbackCommand = commandsFactory.buildRollbackCommand(gtx);
+ if (trace) log.trace(" running rollback for " + gtx);
+
+ //JBCACHE-359 Store a lookup for the globalTransaction so a listener
+ // callback can find it
+ rollbackTransactions.put(tx, gtx);
+
+ handleCommitRollback(ctx, rollbackCommand);
+ }
+ catch (Throwable e)
+ {
+ log.warn("Rollback had a problem", e);
+ }
+ finally
+ {
+ rollbackTransactions.remove(tx);
+ }
+ }
+
+ private boolean isOnePhaseCommit()
+ {
+ if (!configuration.getCacheMode().isSynchronous())
+ {
+ // this is a REPL_ASYNC call - do 1-phase commit. break!
+ if (trace) log.trace("This is a REPL_ASYNC call (1 phase commit) - do nothing for beforeCompletion()");
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Handles a local prepare - invoked by the sync handler. Tests if the current tx matches the gtx passed in to the
+ * method call and passes the prepare() call up the chain.
+ */
+ @SuppressWarnings("deprecation")
+ public Object runPreparePhase(InvocationContext ctx, GlobalTransaction gtx, List<VisitableCommand> modifications) throws Throwable
+ {
+ // running a 2-phase commit.
+ VisitableCommand prepareCommand = buildPrepareCommand(gtx, modifications, false);
+
+ Object result;
+
+ // Is there a local transaction associated with GTX ?
+ Transaction ltx = ctx.getTransaction();
+
+ //if ltx is not null and it is already running
+ Transaction currentTransaction = txManager.getTransaction();
+ if (currentTransaction != null && ltx != null && currentTransaction.equals(ltx))
+ {
+ VisitableCommand originalCommand = ctx.getCommand();
+ ctx.setCommand(prepareCommand);
+ try
+ {
+ result = invokeNextInterceptor(ctx, prepareCommand);
+ }
+ finally
+ {
+ ctx.setCommand(originalCommand);
+ }
+ }
+ else
+ {
+ log.warn("Local transaction does not exist or does not match expected transaction " + gtx);
+ throw new CacheException(" local transaction " + ltx + " does not exist or does not match expected transaction " + gtx);
+ }
+ return result;
+ }
+
+ // --------------------------------------------------------------
+ // Private helper methods
+ // --------------------------------------------------------------
+
+ protected void assertTxIsStillValid(Transaction tx)
+ {
+ if (!TransactionTable.isActive(tx))
+ {
+ try
+ {
+ throw new ReplicationException("prepare() failed -- local transaction status is not STATUS_ACTIVE; is " + tx.getStatus());
+ }
+ catch (SystemException e)
+ {
+ throw new ReplicationException("prepare() failed -- local transaction status is not STATUS_ACTIVE; Unable to retrieve transaction status.");
+ }
+ }
+ }
+
+ /**
+ * Creates a gtx (if one doesnt exist), a sync handler, and registers the tx.
+ */
+ private GlobalTransaction registerTransaction(Transaction tx, InvocationContext ctx) throws Exception
+ {
+ GlobalTransaction gtx;
+
+ if (TransactionTable.isValid(tx) && transactions.add(tx))
+ {
+ gtx = txTable.getCurrentTransaction(tx, true);
+ TransactionContext transactionContext;
+ if (ctx.getGlobalTransaction() == null)
+ {
+ ctx.setGlobalTransaction(gtx);
+ transactionContext = txTable.get(gtx);
+ ctx.setTransactionContext(transactionContext);
+ }
+ else
+ {
+ transactionContext = ctx.getTransactionContext();
+ }
+ if (gtx.isRemote())
+ {
+ // should be no need to register a handler since this a remotely initiated globalTransaction
+ if (trace) log.trace("is a remotely initiated gtx so no need to register a tx for it");
+ }
+ else
+ {
+ if (trace) log.trace("Registering sync handler for tx " + tx + ", gtx " + gtx);
+
+ // see the comment in the LocalSyncHandler for the last isOriginLocal param.
+ LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, transactionContext, !ctx.isOriginLocal());
+ registerHandler(tx, myHandler, ctx);
+ }
+ }
+ else if ((gtx = rollbackTransactions.get(tx)) != null)
+ {
+ if (trace) log.trace("Transaction " + tx + " is already registered and is rolling back.");
+ }
+ else
+ {
+ if (trace) log.trace("Transaction " + tx + " is already registered.");
+ }
+ return gtx;
+ }
+
+ /**
+ * Registers a sync hander against a tx.
+ */
+ private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx) throws Exception
+ {
+ OrderedSynchronizationHandler orderedHandler = ctx.getTransactionContext().getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
+
+ if (trace) log.trace("registering for TX completion: SynchronizationHandler(" + handler + ")");
+
+ orderedHandler.registerAtHead(handler);// needs to be invoked first on TX commit
+
+ notifier.notifyTransactionRegistered(tx, ctx);
+ }
+
+ /**
+ * Creates and starts a local tx
+ *
+ * @throws Exception
+ */
+ protected Transaction createLocalTx() throws Exception
+ {
+ if (trace)
+ {
+ log.trace("Creating transaction for thread " + Thread.currentThread());
+ }
+ Transaction localTx;
+ if (txManager == null) throw new Exception("Failed to create local transaction; TransactionManager is null");
+ txManager.begin();
+ localTx = txManager.getTransaction();
+ return localTx;
+ }
+
+ // ------------------------------------------------------------------------
+ // Synchronization classes
+ // ------------------------------------------------------------------------
+
+ // this controls the whole transaction
+
+ private class RemoteSynchronizationHandler implements Synchronization
+ {
+ Transaction tx = null;
+ GlobalTransaction gtx = null;
+ List<VisitableCommand> modifications = null;
+ TransactionContext transactionContext = null;
+ protected InvocationContext ctx; // the context for this call.
+
+ RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionContext entry)
+ {
+ this.gtx = gtx;
+ this.tx = tx;
+ this.transactionContext = entry;
+ }
+
+ public void beforeCompletion()
+ {
+ if (trace) log.trace("Running beforeCompletion on gtx " + gtx);
+
+ if (transactionContext == null)
+ {
+ log.error("Transaction has a null transaction entry - beforeCompletion() will fail.");
+ throw new IllegalStateException("cannot find transaction entry for " + gtx);
+ }
+
+ modifications = transactionContext.getModifications();
+ ctx = invocationContextContainer.get();
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+
+ if (ctx.isOptionsUninitialised() && transactionContext.getOption() != null)
+ ctx.setOptionOverrides(transactionContext.getOption());
+
+ assertCanContinue();
+
+ ctx.setOriginLocal(false);
+ }
+
+ // this should really not be done here -
+ // it is supposed to be post commit not actually run the commit
+ public void afterCompletion(int status)
+ {
+ // could happen if a rollback is called and beforeCompletion() doesn't get called.
+ if (ctx == null)
+ {
+ ctx = invocationContextContainer.get();
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+
+ if (ctx.isOptionsUninitialised() && transactionContext != null && transactionContext.getOption() != null)
+ {
+ // use the options from the transaction entry instead
+ ctx.setOptionOverrides(transactionContext.getOption());
+ }
+ }
+
+ try
+ {
+ assertCanContinue();
+
+ try
+ {
+ if (txManager.getTransaction() != null && !txManager.getTransaction().equals(tx)) txManager.resume(tx);
+ }
+ catch (Exception e)
+ {
+ log.error("afterCompletion error: " + status, e);
+ }
+
+ if (trace) log.trace("calling aftercompletion for " + gtx);
+
+ // set any transaction wide options as current for this thread.
+ if (transactionContext != null)
+ {
+ // this should ideally be set in beforeCompletion(), after compacting the list.
+ if (modifications == null) modifications = transactionContext.getModifications();
+ ctx.setOptionOverrides(transactionContext.getOption());
+ }
+ if (tx != null) transactions.remove(tx);
+
+ switch (status)
+ {
+ case Status.STATUS_COMMITTED:
+ boolean onePhaseCommit = isOnePhaseCommit();
+ if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
+ runCommitPhase(ctx, gtx, modifications, onePhaseCommit);
+ log.debug("Finished commit phase");
+ break;
+ case Status.STATUS_UNKNOWN:
+ log.warn("Received JTA STATUS_UNKNOWN in afterCompletion()! XA resources may not be in sync. The app should manually clean up resources at this point.");
+ case Status.STATUS_MARKED_ROLLBACK:
+ case Status.STATUS_ROLLEDBACK:
+ log.debug("Running rollback phase");
+ runRollbackPhase(ctx, gtx, tx);
+ log.debug("Finished rollback phase");
+ break;
+
+ default:
+ throw new IllegalStateException("illegal status: " + status);
+ }
+ }
+ catch (Exception th)
+ {
+ log.trace("Caught exception ", th);
+
+ }
+ finally
+ {
+ // clean up the tx table
+ txTable.remove(gtx);
+ txTable.remove(tx);
+ setTransactionalContext(null, null, null, ctx);
+ cleanupInternalState();
+ }
+ }
+
+ private void assertCanContinue()
+ {
+ if (!componentRegistry.invocationsAllowed(true) && (ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isSkipCacheStatusCheck()))
+ throw new IllegalStateException("Cache not in STARTED state!");
+ }
+
+ /**
+ * Cleans out (nullifies) member variables held by the sync object for easier gc. Could be (falsely) seen as a mem
+ * leak if the TM implementation hangs on to the synchronizations for an unnecessarily long time even after the tx
+ * completes. See JBCACHE-1007.
+ */
+ private void cleanupInternalState()
+ {
+ tx = null;
+ gtx = null;
+ modifications = null;
+ if (transactionContext != null) transactionContext.reset();
+ transactionContext = null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TxInterceptor.RemoteSynchronizationHandler(gtx=" + gtx + ", tx=" + getTxAsString() + ")";
+ }
+
+ protected String getTxAsString()
+ {
+ // JBCACHE-1114 -- don't call toString() on tx or it can lead to stack overflow
+ if (tx == null)
+ return null;
+
+ return tx.getClass().getName() + "@" + System.identityHashCode(tx);
+ }
+ }
+
+ private class LocalSynchronizationHandler extends RemoteSynchronizationHandler
+ {
+ private boolean localRollbackOnly = true;
+ // a VERY strange situation where a tx has remote origins, but since certain buddy group org methods perform local
+ // cleanups even when remotely triggered, and optimistic locking is used, you end up with an implicit local tx.
+ // This is STILL remotely originating though and this needs to be made explicit here.
+ // this can be checked by inspecting the InvocationContext.isOriginLocal() at the time of registering the sync.
+ private boolean remoteLocal = false;
+ private Option originalOptions, transactionalOptions;
+
+ /**
+ * A Synchronization for locally originating txs.
+ * <p/>
+ * a VERY strange situation where a tx has remote origins, but since certain buddy group org methods perform local
+ * cleanups even when remotely triggered, and optimistic locking is used, you end up with an implicit local tx.
+ * This is STILL remotely originating though and this needs to be made explicit here.
+ * this can be checked by inspecting the InvocationContext.isOriginLocal() at the time of registering the sync.
+ *
+ * @param gtx
+ * @param tx
+ * @param remoteLocal
+ */
+ LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionContext transactionContext, boolean remoteLocal)
+ {
+ super(gtx, tx, transactionContext);
+ this.remoteLocal = remoteLocal;
+ }
+
+ @Override
+ public void beforeCompletion()
+ {
+ super.beforeCompletion();
+ ctx.setOriginLocal(!remoteLocal); // this is the LOCAL sync handler after all!
+ // fetch the modifications before the transaction is committed
+ // (and thus removed from the txTable)
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+ if (!transactionContext.hasModifications())
+ {
+ if (trace) log.trace("No modifications in this tx. Skipping beforeCompletion()");
+ modifications = Collections.emptyList();
+ return;
+ }
+ else
+ {
+ modifications = transactionContext.getModifications();
+ }
+
+ // set any transaction wide options as current for this thread, caching original options that would then be reset
+ originalOptions = ctx.getOptionOverrides();
+ transactionalOptions = transactionContext.getOption();
+ ctx.setOptionOverrides(transactionalOptions);
+
+ try
+ {
+ switch (tx.getStatus())
+ {
+ // if we are active or preparing then we can go ahead
+ case Status.STATUS_ACTIVE:
+ case Status.STATUS_PREPARING:
+ // run a prepare call.
+
+ Object result = isOnePhaseCommit() ? null : runPreparePhase(ctx, gtx, modifications);
+
+ if (result instanceof Throwable)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Transaction needs to be rolled back - the cache returned an instance of Throwable for this prepare call (tx=" + tx + " and gtx=" + gtx + ")", (Throwable) result);
+ tx.setRollbackOnly();
+ throw (Throwable) result;
+ }
+ break;
+ default:
+ throw new CacheException("transaction " + tx + " in status " + tx.getStatus() + " unable to start transaction");
+ }
+ }
+ catch (Throwable t)
+ {
+ if (log.isWarnEnabled()) log.warn("Caught exception, will now set transaction to roll back", t);
+ try
+ {
+ tx.setRollbackOnly();
+ }
+ catch (SystemException se)
+ {
+ throw new RuntimeException("setting tx rollback failed ", se);
+ }
+ if (t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ else
+ throw new RuntimeException("", t);
+ }
+ finally
+ {
+ localRollbackOnly = false;
+ setTransactionalContext(null, null, null, ctx);
+ ctx.setOptionOverrides(originalOptions);
+ }
+ }
+
+ @Override
+ public void afterCompletion(int status)
+ {
+ // could happen if a rollback is called and beforeCompletion() doesn't get called.
+ if (ctx == null) ctx = invocationContextContainer.get();
+ ctx.setLocalRollbackOnly(localRollbackOnly);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+ if (transactionalOptions != null) ctx.setOptionOverrides(transactionalOptions);
+ try
+ {
+ super.afterCompletion(status);
+ }
+ finally
+ {
+ ctx.setOptionOverrides(originalOptions);
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "TxInterceptor.LocalSynchronizationHandler(gtx=" + gtx + ", tx=" + getTxAsString() + ")";
+ }
+ }
+
+ @ManagedOperation
+ public void resetStatistics()
+ {
+ prepares = 0;
+ commits = 0;
+ rollbacks = 0;
+ }
+
+ @ManagedOperation
+ public Map<String, Object> dumpStatistics()
+ {
+ Map<String, Object> retval = new HashMap<String, Object>(3);
+ retval.put("Prepares", prepares);
+ retval.put("Commits", commits);
+ retval.put("Rollbacks", rollbacks);
+ return retval;
+ }
+
+ @ManagedAttribute
+ public boolean getStatisticsEnabled()
+ {
+ return this.statsEnabled;
+ }
+
+ @ManagedAttribute
+ public void setStatisticsEnabled(boolean enabled)
+ {
+ this.statsEnabled = enabled;
+ }
+
+ @ManagedAttribute(description = "number of transaction prepares")
+ public long getPrepares()
+ {
+ return prepares;
+ }
+
+ @ManagedAttribute(description = "number of transaction commits")
+ public long getCommits()
+ {
+ return commits;
+ }
+
+ @ManagedAttribute(description = "number of transaction rollbacks")
+ public long getRollbacks()
+ {
+ return rollbacks;
+ }
+}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java 2008-10-08 16:37:44 UTC (rev 6888)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactory.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -24,8 +24,14 @@
import org.jboss.starobrno.commands.write.*;
import org.jboss.starobrno.commands.read.SizeCommand;
import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+import org.jboss.starobrno.commands.tx.PrepareCommand;
+import org.jboss.starobrno.commands.tx.RollbackCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
+import org.jboss.starobrno.transaction.GlobalTransaction;
+import org.jgroups.Address;
import java.util.Map;
+import java.util.List;
/**
* @author Mircea.Markus(a)jboss.com
@@ -47,4 +53,10 @@
ClearCommand buildClearCommand();
EvictCommand buildEvictCommand(Object key);
+
+ PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, Address localAddress, boolean onePhaseCommit);
+
+ CommitCommand buildCommitCommand(GlobalTransaction gtx);
+
+ RollbackCommand buildRollbackCommand(GlobalTransaction gtx);
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-08 16:37:44 UTC (rev 6888)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/commands/CommandsFactoryImpl.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -24,10 +24,16 @@
import org.jboss.starobrno.commands.write.*;
import org.jboss.starobrno.commands.read.SizeCommand;
import org.jboss.starobrno.commands.read.GetKeyValueCommand;
+import org.jboss.starobrno.commands.tx.PrepareCommand;
+import org.jboss.starobrno.commands.tx.RollbackCommand;
+import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.notifier.Notifier;
+import org.jgroups.Address;
import java.util.Map;
+import java.util.List;
/**
* @author Mircea.Markus(a)jboss.com
@@ -76,4 +82,19 @@
{
return new EvictCommand();
}
+
+ public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, Address localAddress, boolean onePhaseCommit)
+ {
+ return new PrepareCommand(gtx, modifications, localAddress, onePhaseCommit);
+ }
+
+ public CommitCommand buildCommitCommand(GlobalTransaction gtx)
+ {
+ return new CommitCommand(gtx);
+ }
+
+ public RollbackCommand buildRollbackCommand(GlobalTransaction gtx)
+ {
+ return new RollbackCommand(gtx);
+ }
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 16:37:44 UTC (rev 6888)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -21,8 +21,8 @@
*/
package org.jboss.starobrno.context;
-import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.OrderedSynchronizationHandler;
import org.jboss.starobrno.config.Option;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-08 16:37:44 UTC (rev 6888)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -21,11 +21,11 @@
*/
package org.jboss.starobrno.context;
-import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.mvcc.MVCCEntry;
+import org.jboss.starobrno.OrderedSynchronizationHandler;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/MBean.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/jmx/annotations/MBean.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/MBean.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/MBean.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -0,0 +1,48 @@
+/*
+ * 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.jmx.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Classes anotaded with this will be exposed as MBeans.
+ * If you are looking for more fined grained way of exposing jmx attributes/operations, take a look at
+ * {@link org.jboss.cache.jmx.annotations.ManagedAttribute} and {@link org.jboss.cache.jmx.annotations.ManagedOperation}
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE})
+@Inherited
+public @interface MBean
+{
+ public abstract String objectName() default "";
+
+ public abstract boolean exposeAll() default false;
+
+ public abstract String description() default "";
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedAttribute.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/jmx/annotations/ManagedAttribute.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedAttribute.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedAttribute.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -0,0 +1,46 @@
+/*
+ * 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.jmx.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that a public method or a field (any visibility) in
+ * an MBean class defines an MBean attribute. This annotation can
+ * be applied to either a field or a public setter and/or getter
+ * method of a public class that is itself is optionally annotated
+ * with an @MBean annotation, or inherits such an annotation from
+ * a superclass.
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.METHOD, ElementType.FIELD})
+public @interface ManagedAttribute
+{
+ public abstract String description() default "";
+
+ public abstract String name() default "";
+
+ public abstract boolean writable() default false;
+}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedOperation.java (from rev 6858, core/branches/flat/src/main/java/org/jboss/cache/jmx/annotations/ManagedOperation.java)
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedOperation.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/jmx/annotations/ManagedOperation.java 2008-10-08 17:13:48 UTC (rev 6889)
@@ -0,0 +1,41 @@
+/*
+ * 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.jmx.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that a method in an MBean class defines an MBean
+ * operation. @ManagedOperation annotation can be applied to a
+ * public method of a public class that is itself optionally
+ * annotated with an @MBean annotation, or inherits such an
+ * annotation from a superclass.
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.METHOD})
+public @interface ManagedOperation
+{
+ public abstract String description() default "";
+}
\ No newline at end of file
17 years, 2 months
JBoss Cache SVN: r6888 - in core/branches/flat/src/main/java/org/jboss/starobrno/config: parsing and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 12:37:44 -0400 (Wed, 08 Oct 2008)
New Revision: 6888
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/JGroupsStackParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ParsedAttributes.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/RootElementBuilder.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/BuddyElementParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/LoadersElementParser.java
Log:
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,140 @@
+/*
+ * 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.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.util.FileLookup;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Parser able to parse a series of cache configurations stored in an
+ * XML document with the following structure:
+ * <pre>
+ * <cache-configs>
+ * <cache-config name="configA">
+ * ....
+ * </cache-config>
+ * <cache-config name="configB">
+ * ....
+ * </cache-config>
+ * </cache-configs>
+ * </pre>
+ * <p/>
+ * The '....' represents the normal content of the mbean element in a
+ * JBC -service.xml config file.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.1 $
+ */
+public class CacheConfigsXmlParser
+{
+ /**
+ * Name of the root element in a cache configs XML document
+ */
+ public static final String DOCUMENT_ROOT = "cache-configs";
+ /**
+ * Name of the element that represents an individual cache configuration
+ * in a cache configs XML document.
+ */
+ public static final String CONFIG_ROOT = "cache-config";
+ public static final String QUALIFIED_CONFIG_ROOT = "registry:cache-config";
+
+ /**
+ * Name of the attribute in a {@link #CONFIG_ROOT cache-config} element that specifies
+ * the name of the configuration.
+ */
+ public static final String CONFIG_NAME = "name";
+
+ private static final Log log = LogFactory.getLog(CacheConfigsXmlParser.class);
+
+
+ public Map<String, Configuration> parseConfigs(String fileName) throws CloneNotSupportedException
+ {
+ FileLookup fileLookup = new FileLookup();
+ InputStream is = fileLookup.lookupFile(fileName);
+ if (is == null)
+ {
+ throw new ConfigurationException("Unable to find config file " + fileName + " either in classpath or on the filesystem!");
+ }
+
+ return parseConfigs(is);
+ }
+
+ public Map<String, Configuration> parseConfigs(InputStream stream) throws CloneNotSupportedException
+ {
+ // loop through all elements in XML.
+ Element root = getDocumentRoot(stream);
+
+ NodeList list = root.getElementsByTagName(CONFIG_ROOT);
+ if (list == null || list.getLength() == 0)
+ {
+ // try looking for a QUALIFIED_CONFIG_ROOT
+ list = root.getElementsByTagName(QUALIFIED_CONFIG_ROOT);
+ if (list == null || list.getLength() == 0)
+ throw new ConfigurationException("Can't find " + CONFIG_ROOT + " or " + QUALIFIED_CONFIG_ROOT + " tag");
+ }
+
+ Map<String, Configuration> result = new HashMap<String, Configuration>();
+
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node node = list.item(i);
+ if (node.getNodeType() != Node.ELEMENT_NODE)
+ {
+ continue;
+ }
+
+ Element element = (Element) node;
+ String name = element.getAttribute(CONFIG_NAME);
+ if (name == null || name.trim().length() == 0)
+ throw new ConfigurationException("Element " + element + " has no name attribute");
+
+ XmlConfigurationParser parser = new XmlConfigurationParser();
+ Configuration c = null;
+ if (parser.isValidElementRoot(element))
+ {
+ c = parser.parseElementIgnoringRoot(element);
+ }
+
+ // Prove that we can successfully clone it
+ c = c.clone();
+ result.put(name.trim(), c);
+ }
+
+ return result;
+ }
+
+ private Element getDocumentRoot(InputStream stream)
+ {
+ RootElementBuilder rootElementBuilder = new RootElementBuilder(false);
+ return rootElementBuilder.readRoot(stream);
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/CacheConfigsXmlParser.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ConfigFilesConvertor.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,139 @@
+/*
+ * 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.parsing;
+
+import org.jboss.cache.util.FileLookup;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Class used for converting a config file from from 2.x version to 3.x verison.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class ConfigFilesConvertor
+{
+ /**
+ * Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
+ * as <b>is</b>. Transformation is performed according to the <b>xsltFile</b>. The xslt file is looked up using a
+ * {@link org.jboss.cache.util.FileLookup}
+ */
+ public void parse(InputStream is, OutputStream os, String xsltFile) throws Exception
+ {
+ InputStream xsltInStream = new FileLookup().lookupFile(xsltFile);
+
+ Document document = getInputDocument(is);
+
+ // Use a Transformer for output
+ Transformer transformer = getTransformer(xsltInStream);
+
+ DOMSource source = new DOMSource(document);
+ StreamResult result = new StreamResult(os);
+ transformer.transform(source, result);
+ xsltInStream.close();
+ }
+
+ /**
+ * Writes to the <b>os</b> the 3.x configuration file resulted by transforming the 2.x configuration file passed in
+ * as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he xslt
+ * file are looked up using a {@link org.jboss.cache.util.FileLookup}
+ */
+ public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception
+ {
+ InputStream stream = new FileLookup().lookupFile(inputFile);
+ try
+ {
+ parse(stream, os, xsltFile);
+ }
+ finally
+ {
+ stream.close();
+ }
+ }
+
+ /**
+ * usage : java org.jboss.cache.config.parsing.ConfigFilesConvertor -Dsource=config-2.x.xml -Ddestination=config-3.x.xnl
+ */
+ public static void main(String[] argv) throws Exception
+ {
+ String sourceName = System.getProperty("source");
+ if (sourceName == null)
+ {
+ System.err.println("Missing property 'source'.");
+ System.exit(1);
+ }
+ String destinationName = System.getProperty("destination");
+ if (destinationName == null)
+ {
+ System.err.println("Missing property 'destination'.");
+ System.exit(1);
+ }
+ File oldConfig = new File(sourceName);
+ if (!oldConfig.exists())
+ {
+ System.err.println("File specified as input ('" + sourceName + ") does not exist.");
+ System.exit(1);
+ }
+ ConfigFilesConvertor convertor = new ConfigFilesConvertor();
+ File destination = new File(destinationName);
+ if (!destination.exists()) destination.createNewFile();
+
+ FileInputStream is = new FileInputStream(oldConfig);
+ FileOutputStream fos = new FileOutputStream(destinationName);
+ convertor.parse(is, fos, "config2to3.xslt");
+ is.close();
+ System.out.println("File successfully created.");
+ }
+
+ private Transformer getTransformer(InputStream xsltInStream)
+ throws TransformerConfigurationException
+ {
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+ StreamSource stylesource = new StreamSource(xsltInStream);
+ return tFactory.newTransformer(stylesource);
+ }
+
+ private Document getInputDocument(InputStream is)
+ throws ParserConfigurationException, SAXException, IOException
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ return builder.parse(is);
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/JGroupsStackParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/JGroupsStackParser.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/JGroupsStackParser.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,107 @@
+/*
+ * 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.parsing;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.NodeList;
+
+/**
+ * The purpose of this class is to parse the jgroups configuration from the config file into an compact string
+ * that can be passed as a config to the channel.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class JGroupsStackParser
+{
+ /**
+ * Parses the cluster config which is used to start a JGroups channel
+ *
+ * @param config an old-style JGroups protocol config String
+ */
+ public String parseClusterConfigXml(Element config)
+ {
+ StringBuilder buffer = new StringBuilder();
+ NodeList stack = config.getChildNodes();
+ int length = stack.getLength();
+
+ for (int s = 0; s < length; s++)
+ {
+ org.w3c.dom.Node node = stack.item(s);
+ if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+ {
+ continue;
+ }
+
+ // Ignore Namespace until JGroups defines one
+ Element tag = (Element) node;
+ String protocol = tag.getLocalName();
+ if (protocol == null)
+ {
+ protocol = tag.getNodeName(); // try a non-namespace aware version
+ }
+ buffer.append(protocol);
+ processAttributes(buffer, tag);
+ buffer.append(':');
+ }
+ if (buffer.length() > 0)
+ {
+ //Remove the trailing ':'
+ buffer.setLength(buffer.length() - 1);
+ }
+ return buffer.toString();
+ }
+
+ private void processAttributes(StringBuilder buffer, Element tag)
+ {
+ NamedNodeMap attrs = tag.getAttributes();
+ int attrLength = attrs.getLength();
+ if (attrLength > 0)
+ {
+ buffer.append('(');
+ }
+ for (int a = 0; a < attrLength; a++)
+ {
+ Attr attr = (Attr) attrs.item(a);
+ processSingleAttribute(buffer, attr);
+ if (a < attrLength - 1)
+ {
+ buffer.append(';');
+ }
+ }
+ if (attrLength > 0)
+ {
+ buffer.append(')');
+ }
+ }
+
+ private void processSingleAttribute(StringBuilder buffer, Attr attr)
+ {
+ String name = attr.getName();
+ String value = attr.getValue();
+ buffer.append(name);
+ buffer.append('=');
+ buffer.append(value);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ParsedAttributes.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ParsedAttributes.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/ParsedAttributes.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,44 @@
+/*
+ * 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.parsing;
+
+import org.w3c.dom.Element;
+
+import java.util.Map;
+
+/**
+ * Helper class for holding attributes defined in configuration file.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class ParsedAttributes
+{
+ public final Map<String, String> stringAttribs;
+ public final Map<String, Element> xmlAttribs;
+
+ ParsedAttributes(Map strings, Map elements)
+ {
+ this.stringAttribs = strings;
+ this.xmlAttribs = elements;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/RootElementBuilder.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/RootElementBuilder.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/RootElementBuilder.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,146 @@
+/*
+ * 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.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.util.xml.JBossEntityResolver;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.InputStream;
+
+/**
+ * Parses an xml files and validates xml elements form {@link RootElementBuilder#JBOSSCACHE_CORE_NS} namespace
+ * according to the configured schema.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class RootElementBuilder
+{
+
+ private static final JBossEntityResolver resolver = new JBossEntityResolver();
+
+ public static final String JBOSSCACHE_CORE_NS = "urn:jboss:jbosscache-core:config:3.0";
+ public static final String JBOSSCACHE_REPO_NS = "urn:jboss:jbosscache-core:cache-repo:3.0";
+
+ static
+ {
+ // Globally register this namespace
+ JBossEntityResolver.registerEntity(JBOSSCACHE_CORE_NS, "jbosscache-config-3.0.xsd");
+ JBossEntityResolver.registerEntity(JBOSSCACHE_REPO_NS, "jbosscache-registry-3.0.xsd");
+ }
+
+ private static final Log log = LogFactory.getLog(RootElementBuilder.class);
+ private ErrorHandler errorHandler;
+ private boolean isValidating;
+ public static final String VALIDATING_SYSTEM_PROPERTY = "jbosscache.config.validate";
+
+ public RootElementBuilder(ErrorHandler errorHandler)
+ {
+ this.errorHandler = errorHandler;
+ isValidating = System.getProperty(VALIDATING_SYSTEM_PROPERTY) == null || Boolean.getBoolean(VALIDATING_SYSTEM_PROPERTY);
+ }
+
+ public RootElementBuilder(ErrorHandler errorHandler, boolean validating)
+ {
+ this.errorHandler = errorHandler;
+ isValidating = validating;
+ }
+
+ public RootElementBuilder()
+ {
+ this(new FailureErrorHandler());
+ }
+
+ public RootElementBuilder(boolean validating)
+ {
+ this(new FailureErrorHandler(), validating);
+ }
+
+ public Element readRoot(InputStream config)
+ {
+ try
+ {
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ docBuilderFactory.setNamespaceAware(true);
+ if (isValidating)
+ {
+ docBuilderFactory.setValidating(true);
+ docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
+ String[] value = {JBOSSCACHE_CORE_NS, JBOSSCACHE_REPO_NS};
+ docBuilderFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", value);
+ }
+ DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+ parser.setEntityResolver(resolver);
+ parser.setErrorHandler(errorHandler);
+ Document doc = parser.parse(config);
+ Element root = doc.getDocumentElement();
+ root.normalize();
+ return root;
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ throw new ConfigurationException("Could not parse the config file");
+ }
+ }
+
+ /**
+ * Default schema validation error handler, that throws an exception on validation errors.
+ */
+ private static class FailureErrorHandler implements ErrorHandler
+ {
+ public void warning(SAXParseException exception) throws SAXException
+ {
+ logAndThrowException(exception);
+ }
+
+ public void error(SAXParseException exception) throws SAXException
+ {
+ logAndThrowException(exception);
+ }
+
+ public void fatalError(SAXParseException exception) throws SAXException
+ {
+ logAndThrowException(exception);
+ }
+
+ private void logAndThrowException(SAXParseException exception)
+ {
+ log.error("Configuration warning: " + exception.getMessage());
+ throw new ConfigurationException("Incorrect configuration file. Use '-Djbosscache.config.validate=false' to disable validation.", exception);
+ }
+ }
+
+ public boolean isValidating()
+ {
+ return isValidating;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigHelper.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,616 @@
+/*
+ * 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.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.util.BeanUtils;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * A simple XML utility class for reading configuration elements
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+public class XmlConfigHelper
+{
+ private static final Log log = LogFactory.getLog(XmlConfigHelper.class);
+
+ /**
+ * The root of a JBoss Cache configuration XML file. This is the <tt><mbean></tt> tag.
+ */
+ public static final String ROOT = "mbean";
+
+ /**
+ * The <tt><attribute></tt> tag which forms the bulk of JBoss Cache configuration elements
+ */
+ public static final String ATTR = "attribute";
+
+ /**
+ * The <tt><config></tt> tag may be embedded in the contents of an <tt><attribute></tt>, to specify more
+ * complex configuration for certain parameters.
+ */
+ public static final String CONFIG_ATTR = "config";
+
+ /**
+ * The <tt><name></tt> attribute to an <tt><attribute></tt> tag.
+ */
+ public static final String NAME = "name";
+
+
+ /**
+ * Returns the contents of a specific node of given element name, provided a certain attribute exists and is set to value.
+ * E.g., if you have a {@link Element} which represents the following XML snippet:
+ * <pre>
+ * <ItemQuantity Colour="Red">100</ItemQuantity>
+ * <ItemQuantity Colour="Blue">30</ItemQuantity>
+ * <ItemQuantity Colour="Black">10</ItemQuantity>
+ * <pre>
+ * <p/>
+ * The following results could be expected:
+ * </p>
+ * <pre>
+ * getTagContents(element, "Red", "ItemQuantity", "Colour"); // 100
+ * getTagContents(element, "Black", "ItemQuantity", "Colour"); // 10
+ * getTagContents(element, "Blah", "ItemQuantity", "Colour"); // null
+ * getTagContents(element, "Red", "Blah", "Colour"); // null
+ * getTagContents(element, "Black", "ItemQuantity", "Blah"); // null
+ * </pre>
+ * <p/>
+ * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+ * </p>
+ *
+ * @param elem - element to search through.
+ * @param value - expected value to match against
+ * @param elementName - element name
+ * @param attributeName - attribute name of the element that would contain the expected value.
+ * @return the contents of the matched element, or null if not found/matched
+ */
+ public static String getTagContents(Element elem, String value, String elementName, String attributeName)
+ {
+ NodeList list = elem.getElementsByTagName(elementName);
+
+ for (int s = 0; s < list.getLength(); s++)
+ {
+ org.w3c.dom.Node node = list.item(s);
+ if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+ continue;
+
+ Element element = (Element) node;
+ String name = element.getAttribute(attributeName);
+ if (name.equals(value))
+ {
+ return getElementContent(element, true);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Retrieves the value of a given attribute for the first encountered instance of a tag in an element.
+ * <p/>
+ * E.g., if you have a {@link Element} which represents the following XML snippet:
+ * </p>
+ * <pre>
+ * <ItemQuantity Colour="Red">100</ItemQuantity>
+ * <ItemQuantity Colour="Blue">30</ItemQuantity>
+ * <ItemQuantity Colour="Black">10</ItemQuantity>
+ * <pre>
+ * <p/>
+ * The following results could be expected:
+ * </p>
+ * <pre>
+ * getAttributeValue(element, "ItemQuantity", "Colour"); // "Red"
+ * getTagContents(element, "Blah", "Colour"); // null
+ * getTagContents(element, "ItemQuantity", "Blah"); // null
+ * </pre>
+ * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+ *
+ * @param elem - element to search through.
+ * @param elementName - element name
+ * @param attributeName - attribute name of the element that would contain the expected value.
+ * @return the contents of the matched attribute, or null if not found/matched
+ */
+ public static String getAttributeValue(Element elem, String elementName, String attributeName)
+ {
+ NodeList list = elem.getElementsByTagName(elementName);
+
+ for (int s = 0; s < list.getLength(); s++)
+ {
+ org.w3c.dom.Node node = list.item(s);
+ if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
+ continue;
+
+ Element element = (Element) node;
+ String value = element.getAttribute(attributeName);
+ return value == null ? null : StringPropertyReplacer.replaceProperties(value);
+
+ }
+ return null;
+ }
+
+ /**
+ * Returns a named sub-element of the current element passed in.
+ * <p/>
+ * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+ *
+ * @param element - element to search through.
+ * @param subElementName - the name of a sub element to look for
+ * @return the first matching sub element, if found, or null otherwise.
+ */
+ public static Element getSubElement(Element element, String subElementName)
+ {
+ NodeList nl = element.getChildNodes();
+ for (int i = 0; i < nl.getLength(); i++)
+ {
+ Node node = nl.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE && subElementName.equals(((Element) node).getTagName()))
+ {
+ return (Element) node;
+ }
+ }
+
+ if (log.isDebugEnabled()) log.debug("getSubElement(): Does not exist for " + subElementName);
+ return null;
+ }
+
+ /**
+ * Reads the contents of the element passed in.
+ * <p/>
+ * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+ *
+ * @param element - element to search through.
+ * @param trim - if true, whitespace is trimmed before returning
+ * @return the contents of the element passed in. Will return an empty String if the element is empty.
+ */
+ public static String getElementContent(Element element, boolean trim)
+ {
+ NodeList nl = element.getChildNodes();
+ String attributeText = "";
+ for (int i = 0; i < nl.getLength(); i++)
+ {
+ Node n = nl.item(i);
+ if (n instanceof Text)
+ {
+ attributeText += StringPropertyReplacer.replaceProperties(((Text) n).getData());
+ }
+ } // end of for ()
+ if (trim)
+ attributeText = attributeText.trim();
+ return attributeText;
+ }
+
+ /**
+ * Reads the contents of the first occurence of elementName under the given element, trimming results of whitespace.
+ * <p/>
+ * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+ *
+ * @param element - element to search through.
+ * @param elementName - name of the element to find within the element passed in
+ * @return may return an empty String of not found.
+ */
+ public static String readStringContents(Element element, String elementName)
+ {
+ NodeList nodes = element.getElementsByTagName(elementName);
+ if (nodes.getLength() > 0)
+ {
+ Node node = nodes.item(0);
+ Element ne = (Element) node;
+ NodeList nl2 = ne.getChildNodes();
+ Node node2 = nl2.item(0);
+ if (node2 != null)
+ {
+ String value = node2.getNodeValue();
+ if (value == null)
+ return "";
+ return StringPropertyReplacer.replaceProperties(value.trim());
+ }
+ else
+ {
+ return "";
+ }
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ /**
+ * Escapes backslashes ('\') with additional backslashes in a given String, returning a new, escaped String.
+ *
+ * @param value String to escape. Cannot be null.
+ * @return escaped String. Never is null.
+ */
+ public static String escapeBackslashes(String value)
+ {
+ StringBuilder buf = new StringBuilder(value);
+ for (int looper = 0; looper < buf.length(); looper++)
+ {
+ char curr = buf.charAt(looper);
+ char next = 0;
+ if (looper + 1 < buf.length())
+ next = buf.charAt(looper + 1);
+
+ if (curr == '\\')
+ {
+ if (next != '\\')
+ { // only if not already escaped
+ buf.insert(looper, '\\'); // escape backslash
+ }
+ looper++; // skip past extra backslash (either the one we added or existing)
+ }
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Reads the contents of a named sub element within a given element, and attempts to parse the contents as a Java
+ * properties file.
+ * <p/>
+ * E.g., if you have a {@link Element} which represents the following XML snippet:
+ * <p/>
+ * <pre>
+ * <props>
+ * my.attrib.1 = blah
+ * my.attrib.2 = blahblah
+ * </props>
+ * <pre>
+ * <p/>
+ * The following results could be expected:
+ * <p/>
+ * <pre>
+ * Properties p = readPropertiesContents(element, "props");
+ * p.getProperty("my.attrib.1"); // blah
+ * p.getProperty("my.attrib.2"); // blahblah
+ * </pre>
+ * None of the parameters should be null - otherwise the method may throw a NullPointerException.
+ *
+ * @param element - element to search through.
+ * @param elementName - name of the element to find within the element passed in
+ * @return a {@link Properties} object, never null.
+ * @throws IOException if unable to parse the contents of the element
+ */
+ public static Properties readPropertiesContents(Element element, String elementName)
+ {
+ String stringContents = readStringContents(element, elementName);
+ if (stringContents == null) return new Properties();
+ // JBCACHE-531: escape all backslash characters
+ stringContents = escapeBackslashes(stringContents);
+ ByteArrayInputStream is = null;
+ Properties properties = null;
+ try
+ {
+ is = new ByteArrayInputStream(stringContents.trim().getBytes("ISO8859_1"));
+ properties = new Properties();
+ properties.load(is);
+ is.close();
+ }
+ catch (IOException e)
+ {
+ log.warn("Unexpected", e);
+ throw new ConfigurationException("Exception occured while reading properties from XML document", e);
+ }
+ return properties;
+ }
+
+ /**
+ * Similar to {@link #readStringContents(org.w3c.dom.Element,String)} except that it returns a boolean.
+ *
+ * @param element - element to search through.
+ * @param elementName - name of the element to find within the element passed in
+ * @return the contents of the element as a boolean, or false if not found.
+ */
+ public static boolean readBooleanContents(Element element, String elementName)
+ {
+ return readBooleanContents(element, elementName, false);
+ }
+
+ /**
+ * Similar to {@link #readStringContents(org.w3c.dom.Element,String)} except that it returns a boolean.
+ *
+ * @param element - element to search through.
+ * @param elementName - name of the element to find within the element passed in
+ * @param defaultValue - value to return if the element is not found or cannot be parsed.
+ * @return the contents of the element as a boolean
+ */
+ public static boolean readBooleanContents(Element element, String elementName, boolean defaultValue)
+ {
+ String val = readStringContents(element, elementName);
+ if (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))
+ {
+ // needs to be done this way because of JBBUILD-351
+ return Boolean.valueOf(val);
+ //return Boolean.parseBoolean(val);
+ }
+ return defaultValue;
+ }
+
+ /**
+ * Converts a String representing an XML snippet into an {@link org.w3c.dom.Element}.
+ *
+ * @param xml snippet as a string
+ * @return a DOM Element
+ * @throws Exception if unable to parse the String or if it doesn't contain valid XML.
+ */
+ public static Element stringToElementInCoreNS(String xml) throws Exception
+ {
+ xml = "<wrapper xmlns='" + RootElementBuilder.JBOSSCACHE_CORE_NS + "'>" + xml + "</wrapper>";
+ ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document d = builder.parse(bais);
+ bais.close();
+ return getFirstChildElement(d.getDocumentElement());
+ }
+
+ /**
+ * Converts a String representing an XML snippet into an {@link org.w3c.dom.Element}.
+ *
+ * @param xml snippet as a string
+ * @return a DOM Element
+ * @throws Exception if unable to parse the String or if it doesn't contain valid XML.
+ */
+ public static Element stringToElement(String xml) throws Exception
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(xml.getBytes("utf8"));
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document d = builder.parse(bais);
+ bais.close();
+ return d.getDocumentElement();
+ }
+
+ /**
+ * Gets the first child element of an element
+ *
+ * @param element the parent
+ * @return the first child element or null if there isn't one
+ */
+ public static Element getFirstChildElement(Element element)
+ {
+ Node child = element.getFirstChild();
+ while (child != null && child.getNodeType() != Node.ELEMENT_NODE)
+ child = child.getNextSibling();
+
+ return (Element) child;
+ }
+
+ /**
+ * Returns the root element of a given input stream
+ *
+ * @param is stream to parse
+ * @return XML DOM element, or null if unable to parse stream
+ */
+ public static Element getDocumentRoot(InputStream is)
+ {
+ Document doc;
+ try
+ {
+ InputSource xmlInp = new InputSource(is);
+
+ DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+ docBuilderFactory.setNamespaceAware(true);
+ DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
+ doc = parser.parse(xmlInp);
+ Element root = doc.getDocumentElement();
+ root.normalize();
+ return root;
+ }
+ catch (SAXParseException err)
+ {
+ log.error("Configurator SAXParse error", err);
+ }
+ catch (SAXException e)
+ {
+ log.error("Configurator SAX error", e);
+ }
+ catch (Exception pce)
+ {
+ log.error("Configurator general error", pce);
+ }
+ return null;
+ }
+
+ /**
+ * Retrieves the boolean value of a given attribute for the first encountered instance of elementName
+ *
+ * @param elem - element to search
+ * @param elementName - name of element to find
+ * @param attributeName - name of attribute to retrieve the value of
+ * @param defaultValue - default value to return if not found
+ */
+ public static boolean readBooleanAttribute(Element elem, String elementName, String attributeName, boolean defaultValue)
+ {
+ String val = getAttributeValue(elem, elementName, attributeName);
+ if (val != null)
+ {
+ if (val.equalsIgnoreCase("true") || val.equalsIgnoreCase("false"))
+ {
+ //return Boolean.parseBoolean(val);
+ // needs to be done this way because of JBBUILD-351
+ return Boolean.valueOf(val);
+ }
+ }
+
+ return defaultValue;
+ }
+
+ public static void setValues(Object target, Map<?, ?> attribs, boolean isXmlAttribs, boolean failOnMissingSetter)
+ {
+ Class objectClass = target.getClass();
+
+ // go thru simple string setters first.
+ for (Map.Entry entry : attribs.entrySet())
+ {
+ String propName = (String) entry.getKey();
+ String setter = BeanUtils.setterName(propName);
+ Method method;
+
+ try
+ {
+ if (isXmlAttribs)
+ {
+ method = objectClass.getMethod(setter, Element.class);
+ method.invoke(target, entry.getValue());
+ }
+ else
+ {
+ method = objectClass.getMethod(setter, String.class);
+ method.invoke(target, entry.getValue());
+ }
+
+ continue;
+ }
+ catch (NoSuchMethodException me)
+ {
+ // this is ok, but certainly log this as a warning
+ // this is hugely noisy!
+ //if (log.isWarnEnabled()) log.warn("Unrecognised attribute " + propName + ". Please check your configuration. Ignoring!!");
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
+ }
+
+ boolean setterFound = false;
+ // if we get here, we could not find a String or Element setter.
+ for (Method m : objectClass.getMethods())
+ {
+ if (setter.equals(m.getName()))
+ {
+ Class paramTypes[] = m.getParameterTypes();
+ if (paramTypes.length != 1)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Rejecting setter " + m + " on class " + objectClass + " due to incorrect number of parameters");
+ continue; // try another param with the same name.
+ }
+
+ Class parameterType = paramTypes[0];
+ PropertyEditor editor = PropertyEditorManager.findEditor(parameterType);
+ if (editor == null)
+ {
+ throw new ConfigurationException("Couldn't find a property editor for parameter type " + parameterType);
+ }
+
+ editor.setAsText((String) attribs.get(propName));
+
+ Object parameter = editor.getValue();
+ //if (log.isDebugEnabled()) log.debug("Invoking setter method: " + setter + " with parameter \"" + parameter + "\" of type " + parameter.getClass());
+
+ try
+ {
+ m.invoke(target, parameter);
+ setterFound = true;
+ break;
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
+ }
+ }
+ }
+ if (!setterFound && failOnMissingSetter)
+ throw new ConfigurationException("Couldn't find a setter named [" + setter + "] which takes a single parameter, for parameter " + propName + " on class [" + objectClass + "]");
+ }
+ }
+
+ public static ParsedAttributes extractAttributes(Element source)
+ {
+ Map<String, String> stringAttribs = new HashMap<String, String>();
+ Map<String, Element> xmlAttribs = new HashMap<String, Element>();
+ NodeList list = source.getElementsByTagName(ATTR);
+ if (log.isDebugEnabled()) log.debug("Attribute size: " + list.getLength());
+
+ // loop through attributes
+ for (int loop = 0; loop < list.getLength(); loop++)
+ {
+ Node node = list.item(loop);
+ if (node.getNodeType() != Node.ELEMENT_NODE) continue;
+
+ // for each element (attribute) ...
+ Element element = (Element) node;
+ String name = element.getAttribute(NAME);
+ String valueStr = getElementContent(element, true);
+
+ Element valueXml = null;
+ if (valueStr.length() == 0)
+ {
+ // This may be an XML element ...
+ valueXml = getSubElement(element, CONFIG_ATTR);
+ if (valueXml != null) xmlAttribs.put(name, valueXml);
+ }
+ else
+ {
+ if (valueStr.length() > 0) stringAttribs.put(name, valueStr);
+ }
+ }
+ return new ParsedAttributes(stringAttribs, xmlAttribs);
+ }
+
+ public static String toString(Element e)
+ {
+ try
+ {
+ TransformerFactory tfactory = TransformerFactory.newInstance();
+ Transformer xform = tfactory.newTransformer();
+ Source src = new DOMSource(e);
+ java.io.StringWriter writer = new StringWriter();
+ Result result = new javax.xml.transform.stream.StreamResult(writer);
+ xform.transform(src, result);
+ return writer.toString();
+ }
+ catch (Exception ex)
+ {
+ return "Unable to convert to string: " + ex.toString();
+ }
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlConfigurationParser.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,406 @@
+/*
+ * 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.parsing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.util.FileLookup;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.CustomInterceptorConfig;
+import org.jboss.starobrno.config.parsing.element.BuddyElementParser;
+import org.jboss.starobrno.config.parsing.element.CustomInterceptorsElementParser;
+import org.jboss.starobrno.config.parsing.element.EvictionElementParser;
+import org.jboss.starobrno.config.parsing.element.LoadersElementParser;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.ErrorHandler;
+
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.Configuration} object.
+ * By default this class uses a validating parser (configurable).
+ * <p/>
+ * Following system properties can be used for customizing parser behavior:
+ * <ul>
+ * <li> <b>-Djbosscache.config.validate=false</b> will make the parser non-validating </li>
+ * <li> <b>-Djbosscache.config.schemaLocation=url</b> allows one to specify a validation schema that would override the one specified in the the xml document </li>
+ * </ul>
+ * This class is stateful and one instance should be used for parsing a single configuration file.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @see org.jboss.cache.config.parsing.RootElementBuilder
+ * @since 3.0
+ */
+public class XmlConfigurationParser extends XmlParserBase
+{
+
+ private static final Log log = LogFactory.getLog(XmlConfigurationParser.class);
+ private RootElementBuilder rootElementBuilder;
+
+ /**
+ * the resulting configuration.
+ */
+ private Configuration config = new Configuration();
+ private Element root;
+
+ /**
+ * If validation is on (default) one can specify an error handler for handling validation errors.
+ * The default error handler just logs parsing errors received.
+ */
+ public XmlConfigurationParser(ErrorHandler errorHandler)
+ {
+ rootElementBuilder = new RootElementBuilder(errorHandler);
+ }
+
+ /**
+ * Same as {@link #XmlConfigurationParser(org.xml.sax.ErrorHandler)}.
+ *
+ * @param validating should the underlaying parser disable the validation?
+ */
+ public XmlConfigurationParser(boolean validating, ErrorHandler errorHandler)
+ {
+ rootElementBuilder = new RootElementBuilder(errorHandler, validating);
+ }
+
+ /**
+ * Constructs a parser having validation enabled with a ErrorHandler that only logs the parser errors.
+ */
+ public XmlConfigurationParser()
+ {
+ rootElementBuilder = new RootElementBuilder();
+ }
+
+ /**
+ * Parses an XML file and returns a new configuration.
+ * For looking up the file, {@link org.jboss.cache.util.FileLookup} is used.
+ *
+ * @see org.jboss.cache.util.FileLookup
+ */
+ public Configuration parseFile(String filename)
+ {
+ InputStream is = new FileLookup().lookupFile(filename);
+ if (is == null)
+ {
+ throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!");
+ }
+ return parseStream(is);
+ }
+
+ /**
+ * Similar to {@link #parseFile(String)}, just that it does not create the input stream.
+ */
+ public Configuration parseStream(InputStream configStream)
+ {
+ readRoot(configStream);
+ return processElements(false);
+ }
+
+ /**
+ * Root should be the <b>jbosscache</b> element in the configuration file.
+ */
+ public Configuration parseElement(Element root)
+ {
+ this.root = root;
+ this.root.normalize();
+ return processElements(false);
+ }
+
+ public Configuration parseElementIgnoringRoot(Element root)
+ {
+ this.root = root;
+ this.root.normalize();
+ return processElements(true);
+ }
+
+ public boolean isValidating()
+ {
+ return rootElementBuilder.isValidating();
+ }
+
+ private Configuration processElements(boolean ignoreRoot)
+ {
+ if (!ignoreRoot)
+ {
+ if (!"jbosscache".equals(root.getLocalName()) || !RootElementBuilder.JBOSSCACHE_CORE_NS.equals(root.getNamespaceURI()))
+ throw new ConfigurationException("Expected root element {" + RootElementBuilder.JBOSSCACHE_CORE_NS + "}" + "jbosscache");
+ }
+
+ try
+ {
+ configureLocking(getSingleElement("locking"));
+ configureTransaction(getSingleElement("transaction"));
+ configureReplication(getSingleElement("replication"));
+ configureSerialization(getSingleElement("serialization"));
+ configureInvalidation(getSingleElement("invalidation"));
+ configureStartup(getSingleElement("startup"));
+ configureStateRetrieval(getSingleElement("stateRetrieval"));
+ configureTransport(getSingleElement("transport"));
+ configureShutdown(getSingleElement("shutdown"));
+ configureJmxStatistics(getSingleElement("jmxStatistics"));
+ configureEviction(getSingleElement("eviction"));
+ configureCacheLoaders(getSingleElement("loaders"));
+ configureCustomInterceptors(getSingleElement("customInterceptors"));
+ configureListeners(getSingleElement("listeners"));
+ configureInvocationBatching(getSingleElement("invocationBatching"));
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unexpected exception while parsing the configuration file", e);
+ }
+ return config;
+ }
+
+ private void configureStateRetrieval(Element element)
+ {
+ if (element == null) return; //we might not have this configured
+ String fetchInMemoryState = getAttributeValue(element, "fetchInMemoryState");
+ if (existsAttribute(fetchInMemoryState)) config.setFetchInMemoryState(getBoolean(fetchInMemoryState));
+ String stateRetrievalTimeout = getAttributeValue(element, "timeout");
+ if (existsAttribute(stateRetrievalTimeout)) config.setStateRetrievalTimeout(getLong(stateRetrievalTimeout));
+
+ }
+
+ private void configureTransaction(Element element)
+ {
+ if (element == null) return;
+ String attrName = "transactionManagerLookupClass";
+ String txMngLookupClass = getAttributeValue(element, attrName);
+ if (existsAttribute(txMngLookupClass)) config.setTransactionManagerLookupClass(txMngLookupClass);
+ String syncRollbackPhase = getAttributeValue(element, "syncRollbackPhase");
+ if (existsAttribute(syncRollbackPhase)) config.setSyncRollbackPhase(getBoolean(syncRollbackPhase));
+ String syncCommitPhase = getAttributeValue(element, "syncCommitPhase");
+ if (existsAttribute(syncCommitPhase)) config.setSyncCommitPhase(getBoolean(syncCommitPhase));
+ }
+
+ private void configureSerialization(Element element)
+ {
+ if (element == null) return;
+ String objectInputStreamPoolSize = getAttributeValue(element, "objectInputStreamPoolSize");
+ if (existsAttribute(objectInputStreamPoolSize))
+ config.setObjectInputStreamPoolSize(getInt(objectInputStreamPoolSize));
+ String objectOutputStreamPoolSize = getAttributeValue(element, "objectOutputStreamPoolSize");
+ if (existsAttribute(objectOutputStreamPoolSize))
+ config.setObjectOutputStreamPoolSize(getInt(objectOutputStreamPoolSize));
+ String version = getAttributeValue(element, "version");
+ if (existsAttribute(version)) config.setReplVersionString(version);
+ String marshallerClass = getAttributeValue(element, "marshallerClass");
+ if (existsAttribute(marshallerClass)) config.setMarshallerClass(marshallerClass);
+ String useLazyDeserialization = getAttributeValue(element, "useLazyDeserialization");
+ if (existsAttribute(useLazyDeserialization)) config.setUseLazyDeserialization(getBoolean(useLazyDeserialization));
+ String useRegionBasedMarshalling = getAttributeValue(element, "useRegionBasedMarshalling");
+ if (existsAttribute(useRegionBasedMarshalling))
+ config.setUseRegionBasedMarshalling(getBoolean(useRegionBasedMarshalling));
+ }
+
+ private void configureCustomInterceptors(Element element)
+ {
+ if (element == null) return; //this element might be missing
+ CustomInterceptorsElementParser parser = new CustomInterceptorsElementParser();
+ List<CustomInterceptorConfig> interceptorConfigList = parser.parseCustomInterceptors(element);
+ config.setCustomInterceptors(interceptorConfigList);
+ }
+
+ private void configureListeners(Element element)
+ {
+ if (element == null) return; //this element is optional
+ String asyncPoolSizeStr = getAttributeValue(element, "asyncPoolSize");
+ if (existsAttribute(asyncPoolSizeStr))
+ {
+ try
+ {
+ config.setListenerAsyncPoolSize(Integer.parseInt(asyncPoolSizeStr));
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new ConfigurationException("Unable to parse the asyncPoolSize attribute of the listeners element. Was [" + asyncPoolSizeStr + "]");
+ }
+ }
+ }
+
+ private void configureInvocationBatching(Element element)
+ {
+ if (element == null) return; //this element is optional
+ boolean enabled = getBoolean(getAttributeValue(element, "enabled"));
+ config.setInvocationBatchingEnabled(enabled);
+ }
+
+ private void configureBuddyReplication(Element element)
+ {
+ if (element == null) return;//buddy config might not exist, expect that
+ BuddyElementParser buddyElementParser = new BuddyElementParser();
+ BuddyReplicationConfig brConfig = buddyElementParser.parseBuddyElement(element);
+ config.setBuddyReplicationConfig(brConfig);
+ }
+
+ private void configureCacheLoaders(Element element)
+ {
+ if (element == null) return; //null cache loaders are allowed
+ LoadersElementParser clElementParser = new LoadersElementParser();
+ CacheLoaderConfig cacheLoaderConfig = clElementParser.parseLoadersElement(element);
+ config.setCacheLoaderConfig(cacheLoaderConfig);
+ }
+
+ private void configureEviction(Element element)
+ {
+ if (element == null) return; //no eviction might be configured
+ EvictionElementParser evictionElementParser = new EvictionElementParser();
+ config.setEvictionConfig(evictionElementParser.parseEvictionElement(element));
+ }
+
+ private void configureJmxStatistics(Element element)
+ {
+ if (element == null) return; //might not be specified
+ String enabled = getAttributeValue(element, "enabled");
+ config.setExposeManagementStatistics(getBoolean(enabled));
+ }
+
+ private void configureShutdown(Element element)
+ {
+ if (element == null) return;
+ String hookBehavior = getAttributeValue(element, "hookBehavior");
+ if (existsAttribute(hookBehavior)) config.setShutdownHookBehavior(hookBehavior);
+ }
+
+ private void configureTransport(Element element)
+ {
+ if (element == null) return; //transport might be missing
+ String clusterName = getAttributeValue(element, "clusterName");
+ if (existsAttribute(clusterName)) config.setClusterName(clusterName);
+ String multiplexerStack = getAttributeValue(element, "multiplexerStack");
+ if (existsAttribute(multiplexerStack)) config.setMultiplexerStack(multiplexerStack);
+ Element clusterConfig = getSingleElementInCoreNS("jgroupsConfig", element);
+ if (clusterConfig != null)
+ {
+ JGroupsStackParser stackParser = new JGroupsStackParser();
+ String clusterConfigStr = stackParser.parseClusterConfigXml(clusterConfig);
+ if (clusterConfigStr != null && clusterConfigStr.trim().length() > 0)
+ config.setClusterConfig(clusterConfigStr);
+ }
+ }
+
+ private void configureStartup(Element element)
+ {
+ if (element == null) return; //we might not have this configured
+ String inactiveOnStartup = getAttributeValue(element, "regionsInactiveOnStartup");
+ if (existsAttribute(inactiveOnStartup)) config.setInactiveOnStartup(getBoolean(inactiveOnStartup));
+ }
+
+ private void configureInvalidation(Element element)
+ {
+ if (element == null) return; //might be replication
+ Element async = getSingleElement("async");
+ if (async != null)
+ {
+ config.setCacheMode(Configuration.CacheMode.INVALIDATION_ASYNC);
+ configureAsyncMode(getSingleElementInCoreNS("async", element));
+ }
+ Element sync = getSingleElement("sync");
+ if (sync != null)
+ {
+ config.setCacheMode(Configuration.CacheMode.INVALIDATION_SYNC);
+ configureSyncMode(getSingleElementInCoreNS("sync", element));
+ }
+ }
+
+ private void configureReplication(Element element)
+ {
+ if (element == null) return; //might be we do not have a replication enabled
+ Element async = getSingleElement("async");
+ if (async != null)
+ {
+ config.setCacheMode(Configuration.CacheMode.REPL_ASYNC);
+ configureAsyncMode(getSingleElementInCoreNS("async", element));
+ }
+ Element sync = getSingleElement("sync");
+ if (sync != null)
+ {
+ config.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ configureSyncMode(getSingleElementInCoreNS("sync", element));
+ }
+ configureBuddyReplication(getSingleElementInCoreNS("buddy", element));
+ }
+
+ private void configureSyncMode(Element element)
+ {
+ String replTimeout = getAttributeValue(element, "replTimeout");
+ if (existsAttribute(replTimeout)) config.setSyncReplTimeout(getLong(replTimeout));
+ }
+
+ private void configureAsyncMode(Element element)
+ {
+ String useReplQueue = getAttributeValue(element, "useReplQueue");
+ if (existsAttribute(useReplQueue)) config.setUseReplQueue(getBoolean(useReplQueue));
+ String replQueueInterval = getAttributeValue(element, "replQueueInterval");
+ if (existsAttribute(replQueueInterval)) config.setReplQueueInterval(getLong(replQueueInterval));
+ String replQueueMaxElements = getAttributeValue(element, "replQueueMaxElements");
+ if (existsAttribute(replQueueMaxElements)) config.setReplQueueMaxElements(getInt(replQueueMaxElements));
+ String serializationExecutorPoolSize = getAttributeValue(element, "serializationExecutorPoolSize");
+ if (existsAttribute(serializationExecutorPoolSize))
+ config.setSerializationExecutorPoolSize(getInt(serializationExecutorPoolSize));
+ }
+
+ private void configureLocking(Element element)
+ {
+ String isolationLevel = getAttributeValue(element, "isolationLevel");
+ if (existsAttribute(isolationLevel)) config.setIsolationLevel(IsolationLevel.valueOf(isolationLevel));
+ String lockParentForChildInsertRemove = getAttributeValue(element, "lockParentForChildInsertRemove");
+ if (existsAttribute(lockParentForChildInsertRemove))
+ config.setLockParentForChildInsertRemove(getBoolean(lockParentForChildInsertRemove));
+ String lockAcquisitionTimeout = getAttributeValue(element, "lockAcquisitionTimeout");
+ if (existsAttribute(lockAcquisitionTimeout)) config.setLockAcquisitionTimeout(getLong(lockAcquisitionTimeout));
+ String nodeLockingScheme = getAttributeValue(element, "nodeLockingScheme");
+ if (existsAttribute(nodeLockingScheme)) config.setNodeLockingScheme(nodeLockingScheme);
+ String writeSkewCheck = getAttributeValue(element, "writeSkewCheck");
+ if (existsAttribute(writeSkewCheck)) config.setWriteSkewCheck(getBoolean(writeSkewCheck));
+ String concurrencyLevel = getAttributeValue(element, "concurrencyLevel");
+ if (existsAttribute(concurrencyLevel)) config.setConcurrencyLevel(getInt(concurrencyLevel));
+ }
+
+ private Element getSingleElement(String elementName)
+ {
+ return getSingleElementInCoreNS(elementName, root);
+ }
+
+ private void readRoot(InputStream config)
+ {
+ root = rootElementBuilder.readRoot(config);
+ }
+
+ /**
+ * Tests whether the element passed in is a modern (3.0) config element rather than a legacy one.
+ *
+ * @param element element to test
+ * @return true of the element is a modern one and can be parsed using the current parser.
+ */
+ public boolean isValidElementRoot(Element element)
+ {
+ // simply test for the "jbosscache" element.
+ NodeList elements = element.getElementsByTagName("jbosscache");
+ return elements != null && elements.getLength() > 0;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/XmlParserBase.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,102 @@
+/*
+ * 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.parsing;
+
+import org.jboss.util.StringPropertyReplacer;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+/**
+ * Contains utility methods that might be useful to most of the parsers.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public abstract class XmlParserBase
+{
+
+ /**
+ * @see Integer#parseInt(String)
+ */
+ protected int getInt(String intStr)
+ {
+ return Integer.parseInt(intStr);
+ }
+
+ /**
+ * @see Long#parseLong(String)
+ */
+ protected long getLong(String longStr)
+ {
+ return Long.parseLong(longStr);
+ }
+
+ /**
+ * @see Boolean#valueOf(String)
+ */
+ protected boolean getBoolean(String str)
+ {
+ return str == null ? false : Boolean.valueOf(str);
+ }
+
+ /**
+ * @return true if the given value is not empty.
+ */
+ protected boolean existsAttribute(String attrValue)
+ {
+ return attrValue != null && attrValue.length() > 0;
+ }
+
+ /**
+ * Convenient method for retrieving a single element with the give name.
+ */
+ protected Element getSingleElement(String namespace, String elementName, Element parent)
+ {
+ NodeList nodeList = parent.getElementsByTagNameNS(namespace, elementName);
+ if (nodeList.getLength() == 0)
+ {
+ return null;
+ }
+ return (Element) nodeList.item(0);
+ }
+
+ /**
+ * Convenient method for retrieving a single element with the give name.
+ */
+ protected Element getSingleElementInCoreNS(String elementName, Element parent)
+ {
+ return getSingleElement(RootElementBuilder.JBOSSCACHE_CORE_NS, elementName, parent);
+ }
+
+ /**
+ * Beside querying the element for its attribute value, it will look into the value, if any, and replace the
+ * jboss properties(e.g. ${someValue:defaultValue}.
+ * <p/>
+ * {@link org.jboss.util.StringPropertyReplacer#replaceProperties(String)}
+ */
+ protected String getAttributeValue(Element element, String attrName)
+ {
+ if (element == null || attrName == null) return null;
+ String value = element.getAttribute(attrName);
+ return value == null ? null : StringPropertyReplacer.replaceProperties(value);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/BuddyElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/BuddyElementParser.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/BuddyElementParser.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,94 @@
+/*
+ * 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.parsing.element;
+
+import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
+import org.w3c.dom.Element;
+
+import java.util.Properties;
+
+/**
+ * Utility class for parsing 'buddy' element in the .xml configuration file.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class BuddyElementParser extends XmlParserBase
+{
+ public BuddyReplicationConfig parseBuddyElement(Element element)
+ {
+ BuddyReplicationConfig brc = new BuddyReplicationConfig();
+ String enabled = getAttributeValue(element, "enabled");
+ brc.setEnabled(getBoolean(enabled));
+ String buddyPoolName = getAttributeValue(element, "poolName");
+ if (existsAttribute(buddyPoolName)) brc.setBuddyPoolName(buddyPoolName);
+ String buddyCommunicationTimeout = getAttributeValue(element, "communicationTimeout");
+ if (existsAttribute(buddyCommunicationTimeout))
+ brc.setBuddyCommunicationTimeout(getInt(buddyCommunicationTimeout));
+
+ parseDataGravitationElement(getSingleElementInCoreNS("dataGravitation", element), brc);
+ BuddyReplicationConfig.BuddyLocatorConfig blc = parseBuddyLocatorConfig(getSingleElementInCoreNS("locator", element));
+ brc.setBuddyLocatorConfig(blc);
+ return brc;
+ }
+
+ private BuddyReplicationConfig.BuddyLocatorConfig parseBuddyLocatorConfig(Element element)
+ {
+ if (element == null) return defaultBuddyLocatorConfig();
+ BuddyReplicationConfig.BuddyLocatorConfig result = new BuddyReplicationConfig.BuddyLocatorConfig();
+ String buddyLocatorClass = getAttributeValue(element, "class");
+ if (existsAttribute(buddyLocatorClass)) result.setBuddyLocatorClass(buddyLocatorClass);
+ Properties existing = new Properties();
+ Properties configured = XmlConfigHelper.readPropertiesContents(element, "properties");
+ existing.putAll(configured);
+ result.setBuddyLocatorClass(buddyLocatorClass);
+ result.setBuddyLocatorProperties(existing);
+ return result;
+ }
+
+ private BuddyReplicationConfig.BuddyLocatorConfig defaultBuddyLocatorConfig()
+ {
+ BuddyReplicationConfig.BuddyLocatorConfig result = new BuddyReplicationConfig.BuddyLocatorConfig();
+ result.setBuddyLocatorClass(NextMemberBuddyLocator.class.getName());
+ Properties props = new Properties();
+ result.setBuddyLocatorProperties(props);
+ return result;
+ }
+
+ private void parseDataGravitationElement(Element element, BuddyReplicationConfig brc)
+ {
+ if (element == null) return;
+ String auto = getAttributeValue(element, "auto");
+ if (existsAttribute(auto)) brc.setAutoDataGravitation(getBoolean(auto));
+ String removeOnFind = getAttributeValue(element, "removeOnFind");
+ if (existsAttribute(removeOnFind)) brc.setDataGravitationRemoveOnFind(getBoolean(removeOnFind));
+ String searchBackupTrees = getAttributeValue(element, "searchBackupTrees");
+ if (existsAttribute(searchBackupTrees)) brc.setDataGravitationSearchBackupTrees(getBoolean(searchBackupTrees));
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/CustomInterceptorsElementParser.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,114 @@
+/*
+ * 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.parsing.element;
+
+
+import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.CustomInterceptorConfig;
+import org.jboss.starobrno.config.parsing.ParsedAttributes;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utility class for parsing 'buddy' element in the .xml configuration file.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class CustomInterceptorsElementParser extends XmlParserBase
+{
+ /**
+ * Iterates within the given element looking for custom interceptors.
+ *
+ * @param element should not be null
+ * @return a list which might be empty, never null
+ */
+ public List<CustomInterceptorConfig> parseCustomInterceptors(Element element)
+ {
+ NodeList interceptorNodes = element.getElementsByTagName("interceptor");
+ List<CustomInterceptorConfig> interceptorConfigs = new ArrayList<CustomInterceptorConfig>(interceptorNodes.getLength());
+ for (int i = 0; i < interceptorNodes.getLength(); i++)
+ {
+ boolean first = false;
+ boolean last = false;
+ int index = -1;
+ String after = null;
+ String before = null;
+
+ Element interceptorElement = (Element) interceptorNodes.item(i);
+ String position = getAttributeValue(interceptorElement, "position");
+ if (existsAttribute(position) && "first".equalsIgnoreCase(position))
+ {
+ first = true;
+ }
+ if (existsAttribute(position) && "last".equalsIgnoreCase(position))
+ {
+ last = true;
+ }
+ String indexStr = getAttributeValue(interceptorElement, "index");
+ index = existsAttribute(indexStr) ? getInt(indexStr) : -1;
+
+ before = getAttributeValue(interceptorElement, "before");
+ if (!existsAttribute(before)) before = null;
+ after = getAttributeValue(interceptorElement, "after");
+ if (!existsAttribute(after)) after = null;
+
+ CommandInterceptor interceptor = buildCommandInterceptor(interceptorElement);
+
+ CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig(interceptor, first, last, index, after, before);
+ interceptorConfigs.add(customInterceptorConfig);
+ }
+ return interceptorConfigs;
+ }
+
+ /**
+ * Builds the interceptor based on the interceptor class and also sets all its attributes.
+ */
+ private CommandInterceptor buildCommandInterceptor(Element element)
+ {
+ String interceptorClass = getAttributeValue(element, "class");
+ if (!existsAttribute(interceptorClass)) throw new ConfigurationException("Interceptor class cannot be empty!");
+ CommandInterceptor result;
+ try
+ {
+ result = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("CommandInterceptor class is not properly loaded in classloader", e);
+ }
+ ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
+ XmlConfigHelper.setValues(result, attributes.stringAttribs, false, true);
+ return result;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/EvictionElementParser.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,192 @@
+/*
+ * 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.parsing.element;
+
+import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.config.EvictionConfig;
+import org.jboss.starobrno.config.EvictionRegionConfig;
+import org.jboss.starobrno.config.MissingPolicyException;
+import org.jboss.starobrno.config.parsing.ParsedAttributes;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
+import org.jboss.starobrno.eviction.EvictionAlgorithm;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Knows how to parse the <b>eviction</b> xml element.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class EvictionElementParser extends XmlParserBase
+{
+ public EvictionConfig parseEvictionElement(Element evictionElement)
+ {
+ EvictionConfig evictionConfig = new EvictionConfig();
+ String wakeUpInterval = getAttributeValue(evictionElement, "wakeUpInterval");
+ if (existsAttribute(wakeUpInterval))
+ {
+ evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
+ }
+ else
+ {
+ throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
+ }
+
+ List<EvictionRegionConfig> evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+ Element defaultRegion = getSingleElementInCoreNS("default", evictionElement);
+
+ if (defaultRegion != null)
+ {
+ EvictionRegionConfig defaultRegionConfig = getEvictionRegionConfig(defaultRegion, null, true);
+ if (defaultRegionConfig.getEvictionAlgorithmConfig() == null)
+ throw new MissingPolicyException("Default eviction region should have an evictionAlgorithmClass defined.");
+ evictionConfig.setDefaultEvictionRegionConfig(defaultRegionConfig);
+ }
+
+ NodeList regions = evictionElement.getElementsByTagName("region");
+ for (int i = 0; i < regions.getLength(); i++)
+ {
+ Element regionConfig = (Element) regions.item(i);
+ EvictionRegionConfig erc = getEvictionRegionConfig(regionConfig, evictionConfig.getDefaultEvictionRegionConfig(), false);
+ evictionConfig.applyDefaults(erc);
+ evictionRegionConfigs.add(erc);
+ }
+ evictionConfig.setEvictionRegionConfigs(evictionRegionConfigs);
+ return evictionConfig;
+ }
+
+ @SuppressWarnings("unchecked")
+ private EvictionRegionConfig getEvictionRegionConfig(Element element, EvictionRegionConfig defaultRegion, boolean isDefault)
+ {
+ EvictionRegionConfig erc = new EvictionRegionConfig();
+ erc.setRegionName(getAttributeValue(element, "name"));
+ String queueSize = getAttributeValue(element, "eventQueueSize");
+ if (existsAttribute(queueSize))
+ {
+ erc.setEventQueueSize(getInt(queueSize));
+ }
+ else if (defaultRegion == null)
+ {
+ erc.setEventQueueSize(EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
+ }
+
+ String algorithmClassName = getAttributeValue(element, "algorithmClass");
+ EvictionAlgorithmConfig algorithmConfig = null; // every eviction region config needs an algorithm config.
+
+ if (existsAttribute(algorithmClassName))
+ {
+ EvictionAlgorithm algorithm;
+ Class<? extends EvictionAlgorithm> algorithmClass;
+ // try using a 'getInstance()' factory.
+
+ try
+ {
+ algorithmClass = Util.loadClass(algorithmClassName);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to load eviction algorithm class [" + algorithmClassName + "]", e);
+ }
+
+
+ try
+ {
+ algorithm = Util.getInstance(algorithmClass);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to construct eviction algorithm class [" + algorithmClassName + "]", e);
+ }
+
+ try
+ {
+ algorithmConfig = Util.getInstance(algorithm.getConfigurationClass());
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Failed to instantiate eviction algorithm configuration class [" +
+ algorithm.getConfigurationClass() + "]", e);
+ }
+ }
+ else
+ {
+ if (!isDefault)
+ {
+ if (defaultRegion == null || defaultRegion.getEvictionAlgorithmConfig() == null)
+ {
+ throw new MissingPolicyException("There is no Eviction Algorithm Class specified on the region or for the entire cache!");
+ }
+ else
+ {
+ try
+ {
+ algorithmConfig = defaultRegion.getEvictionAlgorithmConfig().clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new ConfigurationException("Unable to clone eviction algorithm configuration from default", e);
+ }
+ }
+ }
+ }
+
+ if (algorithmConfig != null)
+ {
+ parseEvictionPolicyConfig(element, algorithmConfig);
+
+ erc.setEvictionAlgorithmConfig(algorithmConfig);
+ }
+
+ String actionPolicyClass = getAttributeValue(element, "actionPolicyClass");
+ if (existsAttribute(actionPolicyClass))
+ {
+ erc.setEvictionActionPolicyClassName(actionPolicyClass);
+ }
+ else if (defaultRegion == null)
+ {
+ // this is the default region. Make sure we set the default EvictionActionPolicyClass.
+ erc.setEvictionActionPolicyClassName(EvictionConfig.EVICTION_ACTION_POLICY_CLASS_DEFAULT);
+ }
+
+
+ return erc;
+ }
+
+ public static void parseEvictionPolicyConfig(Element element, EvictionAlgorithmConfig target)
+ {
+ target.reset();
+ ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
+ XmlConfigHelper.setValues(target, attributes.stringAttribs, false, true);
+ XmlConfigHelper.setValues(target, attributes.xmlAttribs, true, true);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/LoadersElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/LoadersElementParser.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/parsing/element/LoadersElementParser.java 2008-10-08 16:37:44 UTC (rev 6888)
@@ -0,0 +1,125 @@
+/*
+ * 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.parsing.element;
+
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.util.Properties;
+
+/**
+ * Utility class for parsing the 'loaders' element in the .xml configuration file.
+ * <pre>
+ * Note: class does not rely on element position in the configuration file.
+ * It does not rely on element's name either.
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class LoadersElementParser extends XmlParserBase
+{
+ public CacheLoaderConfig parseLoadersElement(Element element)
+ {
+ CacheLoaderConfig cacheLoaderConfig = new CacheLoaderConfig();
+ String passivation = getAttributeValue(element, "passivation");
+ if (existsAttribute(passivation)) cacheLoaderConfig.setPassivation(getBoolean(passivation));
+ String shared = getAttributeValue(element, "shared");
+ if (existsAttribute(shared)) cacheLoaderConfig.setShared(getBoolean(shared));
+ String preload = getPreloadString(getSingleElementInCoreNS("preload", element));
+ if (preload != null) cacheLoaderConfig.setPreload(preload);
+
+ NodeList cacheLoaderNodes = element.getElementsByTagName("loader");
+ for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
+ {
+ Element indivElement = (Element) cacheLoaderNodes.item(i);
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc = parseIndividualCacheLoaderConfig(indivElement);
+ cacheLoaderConfig.addIndividualCacheLoaderConfig(iclc);
+ }
+ return cacheLoaderConfig;
+ }
+
+ private CacheLoaderConfig.IndividualCacheLoaderConfig parseIndividualCacheLoaderConfig(Element indivElement)
+ {
+ CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
+
+ String async = getAttributeValue(indivElement, "async");
+ if (existsAttribute(async)) iclc.setAsync(getBoolean(async));
+ String fetchPersistentState = getAttributeValue(indivElement, "fetchPersistentState");
+ if (existsAttribute(fetchPersistentState)) iclc.setFetchPersistentState(getBoolean(fetchPersistentState));
+ String ignoreModifications = getAttributeValue(indivElement, "ignoreModifications");
+ if (existsAttribute(ignoreModifications)) iclc.setIgnoreModifications(getBoolean(ignoreModifications));
+ String purgeOnStartup = getAttributeValue(indivElement, "purgeOnStartup");
+ if (existsAttribute(purgeOnStartup)) iclc.setPurgeOnStartup(getBoolean(purgeOnStartup));
+ String clClass = getAttributeValue(indivElement, "class");
+ if (!existsAttribute(clClass))
+ throw new ConfigurationException("Missing 'class' attribute for cache loader configuration");
+ iclc.setClassName(clClass);
+ iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement, "properties"));
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = parseSingletonStoreConfig(getSingleElementInCoreNS("singletonStore", indivElement));
+ if (ssc != null)
+ {
+ iclc.setSingletonStoreConfig(ssc);
+ }
+ return iclc;
+ }
+
+ private String getPreloadString(Element preloadElement)
+ {
+ if (preloadElement == null) return null; //might be no preload
+ NodeList nodesToPreload = preloadElement.getElementsByTagName("node");
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < nodesToPreload.getLength(); i++)
+ {
+ Element node = (Element) nodesToPreload.item(i);
+ String fqn2preload = getAttributeValue(node, "fqn");
+ if (!existsAttribute(fqn2preload))
+ throw new ConfigurationException("Missing 'fqn' attribute in 'preload' element");
+ if (i > 0) result.append(",");
+ result.append(fqn2preload);
+ }
+ //no elements defined for preload so by default load the root
+ if (nodesToPreload.getLength() == 0)
+ {
+ result.append("/");
+ }
+ return result.toString();
+ }
+
+ public CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig parseSingletonStoreConfig(Element element)
+ {
+ if (element == null) return null; //might happen, this config option is not mandatory
+ boolean singletonStoreEnabled = getBoolean(getAttributeValue(element, "enabled"));
+ String singletonStoreClass = getAttributeValue(element, "class");
+ CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = new CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig();
+ if (existsAttribute(singletonStoreClass)) ssc.setSingletonStoreClass(singletonStoreClass);
+ Properties singletonStoreproperties = XmlConfigHelper.readPropertiesContents(element, "properties");
+ ssc.setSingletonStoreEnabled(singletonStoreEnabled);
+ ssc.setSingletonStoreClass(singletonStoreClass);
+ ssc.setSingletonStoreproperties(singletonStoreproperties);
+ return ssc;
+ }
+}
17 years, 2 months
JBoss Cache SVN: r6886 - core/branches/flat/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 12:29:32 -0400 (Wed, 08 Oct 2008)
New Revision: 6886
Removed:
core/branches/flat/src/main/java/org/jboss/cache/LegacyRegionManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/PessimisticNodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
core/branches/flat/src/main/java/org/jboss/cache/VersionedNode.java
core/branches/flat/src/main/java/org/jboss/cache/eviction/
core/branches/flat/src/main/java/org/jboss/cache/optimistic/
Modified:
core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java
core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java
core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/NodeNotExistsException.java
core/branches/flat/src/main/java/org/jboss/cache/NodeNotValidException.java
core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java
core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/Region.java
core/branches/flat/src/main/java/org/jboss/cache/RegionEmptyException.java
core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java
core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/RegionNotEmptyException.java
core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java
core/branches/flat/src/main/java/org/jboss/cache/ReplicationException.java
core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java
core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
Log:
Moved stuff
Modified: core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -1,37 +1,38 @@
-/*
- * 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.
- */
+/*
+ * 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.cache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.marshall.NodeData;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.Configuration.NodeLockingScheme;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import java.util.ArrayList;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -22,14 +22,13 @@
package org.jboss.cache;
import org.jboss.cache.annotations.Compat;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.XmlConfigurationParser;
-import org.jboss.cache.config.parsing.XmlConfigurationParser2x;
import org.jboss.cache.factories.ComponentFactory;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.jmx.PlatformMBeanServerRegistration;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.parsing.XmlConfigurationParser;
import java.io.InputStream;
@@ -80,17 +79,7 @@
{
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c;
- try
- {
- c = parser.parseFile(configFileName);
- }
- catch (ConfigurationException e)
- {
- XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
- c = oldParser.parseFile(configFileName);
- if (c != null)
- log.warn("Detected legacy configuration file format when parsing [" + configFileName + "]. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
- }
+ c = parser.parseFile(configFileName);
return createCache(c, start);
}
@@ -171,17 +160,7 @@
{
XmlConfigurationParser parser = new XmlConfigurationParser();
Configuration c = null;
- try
- {
- c = parser.parseStream(is);
- }
- catch (ConfigurationException e)
- {
- XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
- c = oldParser.parseStream(is);
- if (c != null)
- log.warn("Detected legacy configuration file format when parsing configuration file. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
- }
+ c = parser.parseStream(is);
return createCache(c);
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/InternalNode.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -22,7 +22,6 @@
package org.jboss.cache;
import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Map;
@@ -203,9 +202,5 @@
CacheSPI<K, V> getCache();
- void setVersion(DataVersion version);
-
- DataVersion getVersion();
-
NodeLock getLock();
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/InvocationContext.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -25,12 +25,12 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.annotations.Compat;
import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.config.Option;
import javax.transaction.Transaction;
import java.util.Collections;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/LegacyRegionManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/LegacyRegionManagerImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/LegacyRegionManagerImpl.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -1,169 +0,0 @@
-/*
- * 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.cache;
-
-import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import static org.jboss.cache.lock.LockType.WRITE;
-
-import java.util.ArrayList;
-import java.util.Set;
-
-/**
- * For optimistic and pessimistically locked caches
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 2.0.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@ThreadSafe
-@Deprecated
-public class LegacyRegionManagerImpl extends RegionManagerImpl
-{
- /**
- * Causes the cache to stop accepting replication events for the subtree
- * rooted at <code>subtreeFqn</code> and evict all nodes in that subtree.
- * <p/>
- * This is legacy code and should not be called directly. This is a private method for now and will be refactored out.
- * You should be using {@link #activate(Fqn)} and {@link #deactivate(Fqn)}
- * <p/>
- *
- * @param fqn Fqn string indicating the uppermost node in the
- * portion of the cache that should be activated.
- * @throws CacheException if there is a problem evicting nodes
- * @throws IllegalStateException if {@link org.jboss.cache.config.Configuration#isUseRegionBasedMarshalling()} is <code>false</code>
- */
- @Override
- protected void inactivateRegion(Fqn fqn) throws CacheException
- {
- NodeSPI parent = null;
- NodeSPI subtreeRoot = null;
- boolean parentLocked = false;
- boolean subtreeLocked = false;
-
- try
- {
- // Record that this fqn is in status change, so can't provide state
- lock(fqn);
-
- if (!isInactive(fqn))
- {
- deactivate(fqn);
- }
-
- // Create a list with the Fqn in the main cache and any buddy backup trees
- BuddyManager buddyManager = cache.getBuddyManager();
- ArrayList<Fqn> list = new ArrayList<Fqn>();
- list.add(fqn);
-
- if (buddyManager != null)
- {
- Set buddies = cache.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, false, false).getChildrenNames();
- if (buddies != null)
- {
- for (Object buddy : buddies)
- {
- list.add(buddyFqnTransformer.getBackupFqn((String) buddy, fqn));
- }
- }
- }
-
- long stateFetchTimeout = cache.getConfiguration().getLockAcquisitionTimeout() + 5000;
- // Remove the subtree from the main cache and any buddy backup trees
- for (Fqn subtree : list)
- {
- subtreeRoot = cache.peek(subtree, false);
- if (subtreeRoot != null)
- {
- // Acquire locks
- subtreeLocked = lockManager.lockAll(subtreeRoot, WRITE, getOwnerForLock(), stateFetchTimeout);
-
- // Lock the parent, as we're about to write to it
- parent = subtreeRoot.getParentDirect();
- if (parent != null)
- parentLocked = lockManager.lockAll(parent, WRITE, getOwnerForLock(), stateFetchTimeout);
-
- // Remove the subtree
- cache.evict(subtree, true);
-
- // Release locks
- if (parent != null)
- {
- log.debug("forcing release of locks in parent");
- lockManager.unlockAll(parent);
- }
-
- parentLocked = false;
-
- log.debug("forcing release of all locks in subtree");
- lockManager.unlockAll(subtreeRoot);
- subtreeLocked = false;
- }
- }
- }
- catch (InterruptedException e)
- {
- throw new CacheException(e);
- }
- finally
- {
- // If we didn't succeed, undo the marshalling change
- // NO. Since we inactivated, we may have missed changes
- //if (!success && !inactive)
- // marshaller_.activate(subtreeFqn);
-
- // If necessary, release locks
- if (parentLocked)
- {
- log.debug("forcing release of locks in parent");
- try
- {
- if (parent != null) lockManager.unlockAll(parent);
- }
- catch (Throwable t)
- {
- log.error("failed releasing locks", t);
- }
- }
- if (subtreeLocked)
- {
- log.debug("forcing release of all locks in subtree");
- try
- {
- if (subtreeRoot != null) lockManager.unlockAll(subtreeRoot);
- }
- catch (Throwable t)
- {
- log.error("failed releasing locks", t);
- }
- }
-
- unlock(fqn);
- }
- }
-
- private Object getOwnerForLock()
- {
- Object owner = cache.getCurrentTransaction();
- return owner == null ? Thread.currentThread() : owner;
- }
-}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeFactory.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -22,8 +22,6 @@
package org.jboss.cache;
import org.jboss.cache.mvcc.ReadCommittedNode;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
import java.util.Map;
@@ -38,8 +36,6 @@
{
ReadCommittedNode createWrappedNode(InternalNode<K, V> node, InternalNode<K, V> parent);
- WorkspaceNode<K, V> createWrappedNode(NodeSPI<K, V> dataNode, TransactionWorkspace workspace);
-
/**
* Creates a new node and populates its attributes.
* <p/>
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeNotExistsException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeNotExistsException.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeNotExistsException.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -21,7 +21,9 @@
*/
package org.jboss.cache;
+import org.jboss.starobrno.CacheException;
+
/**
* Thrown when an operation is attempted on a non-existing node in the cache
*
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeNotValidException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeNotValidException.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeNotValidException.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -21,6 +21,8 @@
*/
package org.jboss.cache;
+import org.jboss.starobrno.CacheException;
+
/**
* Thrown whenever operations are attempted on a node that is no longer valid. See {@link org.jboss.cache.Node#isValid()}
* for details.
Modified: core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/NodeSPI.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -23,7 +23,6 @@
import net.jcip.annotations.NotThreadSafe;
import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Map;
@@ -191,7 +190,6 @@
* @param version data version to apply
* @throws UnsupportedOperationException if versioning is not supported
*/
- void setVersion(DataVersion version);
/**
* Returns the data version of this node if versioning is supported.
@@ -199,7 +197,6 @@
* @return data version
* @throws UnsupportedOperationException if versioning is not supported
*/
- DataVersion getVersion();
// ------- these XXXDirect() methods work directly on the node and bypass the interceptor chain.
Deleted: core/branches/flat/src/main/java/org/jboss/cache/PessimisticNodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/PessimisticNodeFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/PessimisticNodeFactory.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -1,55 +0,0 @@
-/*
- * 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.cache;
-
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.lock.LockStrategyFactory;
-
-import java.util.Map;
-
-/**
- * Node factory specific to pessimistic locking.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class PessimisticNodeFactory<K, V> extends AbstractNodeFactory<K, V>
-{
- private LockStrategyFactory lockStrategyFactory;
-
- @Inject
- private void injectLockStrategyFactory(LockStrategyFactory lockStrategyFactory)
- {
- this.lockStrategyFactory = lockStrategyFactory;
- }
-
- @Override
- protected UnversionedNode<K, V> createInternalNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data)
- {
- PessimisticUnversionedNode<K, V> internal = new PessimisticUnversionedNode<K, V>(childName, fqn, data, cache);
- internal.injectDependencies(cache, commandsFactory, this);
- internal.injectLockStrategyFactory(lockStrategyFactory);
- return internal;
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -1,445 +0,0 @@
-/*
- * 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.cache;
-
-import static org.jboss.cache.AbstractNode.NodeFlags.VALID;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
-import org.jboss.cache.lock.IdentityLock;
-import org.jboss.cache.lock.LockStrategyFactory;
-import org.jboss.cache.marshall.MarshalledValue;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.util.FastCopyHashMap;
-import org.jboss.cache.util.Immutables;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * UnversionedNode specific to pessimistic locking, with legacy code.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@SuppressWarnings("deprecation")
-@Deprecated
-public class PessimisticUnversionedNode<K, V> extends UnversionedNode<K, V>
-{
- /**
- * Lock manager that manages locks to be acquired when accessing the node inside a transaction. Lazy set just in case
- * locking is not needed.
- */
- protected transient IdentityLock lock = null;
- protected LockStrategyFactory lockStrategyFactory;
- CommandsFactory commandsFactory;
- protected NodeFactory<K, V> nodeFactory;
-
- public PessimisticUnversionedNode(Object name, Fqn fqn, Map<K, V> data, CacheSPI<K, V> cache)
- {
- super(fqn, cache, false);
- if (!fqn.isRoot() && !name.equals(fqn.getLastElement()))
- throw new IllegalArgumentException("Child " + name + " must be last part of " + fqn);
-
-
- if (data != null && !data.isEmpty())
- setInternalState(data);
- else
- this.data = new FastCopyHashMap<K, V>();
-
- setLockForChildInsertRemove(cache != null && cache.getConfiguration() != null && cache.getConfiguration().isLockParentForChildInsertRemove());
-
-
- }
-
- /**
- * @return a genericized version of the child map.
- */
- @SuppressWarnings("unchecked")
- private ConcurrentMap<Object, Node<K, V>> children()
- {
- return children;
- }
-
- // ------ lock-per-node paradigm
-
- public void injectLockStrategyFactory(LockStrategyFactory lockStrategyFactory)
- {
- this.lockStrategyFactory = lockStrategyFactory;
- }
-
- public void injectDependencies(CacheSPI<K, V> spi, CommandsFactory commandsFactory, NodeFactory<K, V> nodeFactory)
- {
- this.cache = spi;
- this.commandsFactory = commandsFactory;
- this.nodeFactory = nodeFactory;
- }
-
-
- protected synchronized void initLock()
- {
- if (lock == null)
- {
- lock = new IdentityLock(lockStrategyFactory, delegate);
- }
- }
-
- @Override
- public IdentityLock getLock()
- {
- initLock();
- return lock;
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder(super.toString());
- if (lock != null)
- {
- if (lock.isReadLocked())
- {
- sb.append(" RL");
- }
- if (lock.isWriteLocked())
- {
- sb.append(" WL");
- }
- }
- return sb.toString();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public InternalNode<K, V> copy()
- {
- PessimisticUnversionedNode<K, V> n = new PessimisticUnversionedNode<K, V>(fqn.getLastElement(), fqn, data, cache);
- copyInternals(n);
- n.children = children;
- n.lockStrategyFactory = lockStrategyFactory;
- n.commandsFactory = commandsFactory;
- n.nodeFactory = nodeFactory;
- return n;
- }
-
- // ------ legacy addChild methods that used a lot of implicit locks.
-
- @Override
- public void addChildDirect(NodeSPI<K, V> child)
- {
- Fqn childFqn = child.getFqn();
- if (childFqn.isDirectChildOf(fqn))
- {
- synchronized (this)
- {
- children().put(child.getFqn().getLastElement(), child);
- }
- }
- else
- throw new CacheException("Attempting to add a child [" + child.getFqn() + "] to [" + getFqn() + "]. Can only add direct children.");
- }
-
- private NodeSPI<K, V> getOrCreateChild(Object childName, GlobalTransaction gtx, boolean createIfNotExists, boolean notify)
- {
- NodeSPI<K, V> child;
- if (childName == null)
- {
- throw new IllegalArgumentException("null child name");
- }
-
- child = (NodeSPI<K, V>) children().get(childName);
- InvocationContext ctx = cache.getInvocationContext();
- if (createIfNotExists && child == null)
- {
- // construct the new child outside the synchronized block to avoid
- // spending any more time than necessary in the synchronized section
- Fqn childFqn = Fqn.fromRelativeElements(fqn, childName);
- NodeSPI<K, V> newChild = nodeFactory.createNode(childFqn, delegate);
- if (newChild == null)
- {
- throw new IllegalStateException();
- }
- synchronized (this)
- {
- // check again to see if the child exists
- // after acquiring exclusive lock
- child = (NodeSPI<K, V>) children().get(childName);
- if (child == null)
- {
- if (notify) cache.getNotifier().notifyNodeCreated(childFqn, true, ctx);
- child = newChild;
- children().put(childName, child);
- }
- }
-
- // notify if we actually created a new child
- if (newChild == child)
- {
- if (trace) log.trace("created child: fqn=" + childFqn);
-
- if (gtx != null)
- {
- CreateNodeCommand createNodeCommand = commandsFactory.buildCreateNodeCommand(childFqn);
- ctx.getTransactionContext().addLocalModification(createNodeCommand);
- }
- if (notify) cache.getNotifier().notifyNodeCreated(childFqn, false, ctx);
- }
- }
- return child;
- }
-
- @Override
- public NodeSPI<K, V> addChildDirect(Fqn f, boolean notify)
- {
- if (f.size() == 1)
- {
- GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
- return getOrCreateChild(f.getLastElement(), gtx, true, notify);
- }
- else
- {
- throw new UnsupportedOperationException("Cannot directly create children which aren't directly under the current node.");
- }
- }
-
- @Override
- public NodeSPI<K, V> addChildDirect(Object o, boolean notify)
- {
- GlobalTransaction gtx = cache.getInvocationContext().getGlobalTransaction();
- return getOrCreateChild(o, gtx, true, notify);
- }
-
- @Override
- public NodeSPI<K, V> getChildDirect(Fqn fqn)
- {
- if (fqn.size() == 1)
- {
- return getChildDirect(fqn.getLastElement());
- }
- else
- {
- NodeSPI<K, V> currentNode = delegate;
- for (int i = 0; i < fqn.size(); i++)
- {
- Object nextChildName = fqn.get(i);
- currentNode = currentNode.getChildDirect(nextChildName);
- if (currentNode == null) return null;
- }
- return currentNode;
- }
- }
-
- @Override
- public NodeSPI<K, V> getChildDirect(Object childName)
- {
- if (childName == null) return null;
- return (NodeSPI<K, V>) children().get(childName);
- }
-
- @Override
- public Set<NodeSPI<K, V>> getChildrenDirect()
- {
- // strip out deleted child nodes...
- if (children == null || children.size() == 0) return Collections.emptySet();
-
- Set<NodeSPI<K, V>> exclDeleted = new HashSet<NodeSPI<K, V>>();
- for (Node<K, V> n : children().values())
- {
- NodeSPI<K, V> spi = (NodeSPI<K, V>) n;
- if (!spi.isDeleted()) exclDeleted.add(spi);
- }
- exclDeleted = Collections.unmodifiableSet(exclDeleted);
- return exclDeleted;
- }
-
- @Override
- public Map<Object, Node<K, V>> getChildrenMapDirect()
- {
- return children();
- }
-
- @Override
- public void setChildrenMapDirect(Map<Object, Node<K, V>> children)
- {
- if (children == null)
- this.children = null;
- else
- {
- this.children.clear();
- this.children().putAll(children);
- }
- }
-
- @Override
- public void addChildDirect(Object nodeName, Node<K, V> nodeToAdd)
- {
- if (nodeName != null)
- {
- children().put(nodeName, nodeToAdd);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Set<NodeSPI<K, V>> getChildrenDirect(boolean includeMarkedForRemoval)
- {
- if (includeMarkedForRemoval)
- {
- if (children != null && !children.isEmpty())
- {
- return Immutables.immutableSetConvert(children.values());
- }
- else
- {
- return Collections.emptySet();
- }
- }
- else
- {
- return getChildrenDirect();
- }
- }
-
- @Override
- public NodeSPI<K, V> addChildDirect(Fqn f)
- {
- return addChildDirect(f, true);
- }
-
- @Override
- public NodeSPI<K, V> getOrCreateChild(Object childName, GlobalTransaction gtx)
- {
- return getOrCreateChild(childName, gtx, true, true);
- }
-
- @Override
- public void markAsRemoved(boolean marker, boolean recursive)
- {
- setFlag(NodeFlags.REMOVED, marker);
-
- if (recursive && children != null)
- {
- synchronized (this)
- {
- for (Node<?, ?> child : children().values())
- {
- ((NodeSPI) child).markAsDeleted(marker, true);
- }
- }
- }
- }
-
- @Override
- public void setValid(boolean valid, boolean recursive)
- {
- setFlag(VALID, valid);
-
- if (trace) log.trace("Marking node " + getFqn() + " as " + (valid ? "" : "in") + "valid");
- if (recursive)
- {
- for (Node<K, V> child : children().values())
- {
- ((NodeSPI<K, V>) child).setValid(valid, recursive);
- }
- }
- }
-
- /**
- * Adds details of the node into a map as strings.
- */
- @Override
- protected void printDetailsInMap(StringBuilder sb, int indent)
- {
- printIndent(sb, indent);
- indent += 2;// increse it
- sb.append(Fqn.SEPARATOR);
- if (!fqn.isRoot()) sb.append(fqn.getLastElement());
- sb.append(" ");
- sb.append(data);
- for (Node n : children().values())
- {
- sb.append("\n");
- ((NodeSPI) n).printDetails(sb, indent);
- }
- }
-
-
- @Override
- public void setFqn(Fqn fqn)
- {
- if (trace)
- {
- log.trace(getFqn() + " set FQN " + fqn);
- }
- this.fqn = fqn;
-
- if (children == null)
- {
- return;
- }
-
- // invoke children
- for (Map.Entry<Object, ? extends Node<K, V>> me : children().entrySet())
- {
- NodeSPI<K, V> n = (NodeSPI<K, V>) me.getValue();
- Fqn cfqn = Fqn.fromRelativeElements(fqn, me.getKey());
- n.setFqn(cfqn);
- }
- }
-
- @Override
- public void releaseObjectReferences(boolean recursive)
- {
- if (recursive && children != null)
- {
- for (Node<K, V> child : children().values())
- {
- child.releaseObjectReferences(recursive);
- }
- }
-
- if (data != null)
- {
- for (K key : data.keySet())
- {
- // get the key first, before attempting to serialize stuff since data.get() may deserialize the key if doing
- // a hashcode() or equals().
-
- Object value = data.get(key);
- if (key instanceof MarshalledValue)
- {
- ((MarshalledValue) key).compact(true, true);
- }
-
- if (value instanceof MarshalledValue)
- {
- ((MarshalledValue) value).compact(true, true);
- }
-
- }
- }
- }
-
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -24,13 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.jmx.annotations.MBean;
@@ -49,6 +43,12 @@
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.concurrent.ReclosableLatch;
import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.ChannelException;
@@ -659,16 +659,7 @@
NodeSPI root = spi.getRoot();
if (root != null)
{
- // UGH!!! What a shameless hack!
- if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC)
- {
-
- removeLocksForDeadMembers(root.getDelegationTarget(), removed);
- }
- else
- {
- removeLocksForDeadMembers(root, removed);
- }
+ removeLocksForDeadMembers(root.getDelegationTarget(), removed);
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/Region.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Region.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/Region.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -22,12 +22,9 @@
package org.jboss.cache;
import org.jboss.cache.annotations.Compat;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.EvictedEventNode;
-import org.jboss.cache.eviction.EvictionEvent;
-import org.jboss.cache.eviction.EvictionPolicy;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.EvictionRegionConfig;
+import org.jboss.starobrno.eviction.EvictionEvent;
/**
* Defines characteristics such as class loading and eviction of {@link org.jboss.cache.Node}s belonging to a Region in a {@link Cache}.
@@ -157,19 +154,19 @@
* Registers an eviction event on the region's eviction event queue for later processing by
* {@link #processEvictionQueues()}.
*
- * @param fqn passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
- * @param eventType passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
- * @param elementDifference passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
+ * @param fqn passed in to the constructor of {@link org.jboss.starobrno.eviction.EvictionEvent}
+ * @param eventType passed in to the constructor of {@link org.jboss.starobrno.eviction.EvictionEvent}
+ * @param elementDifference passed in to the constructor of {@link org.jboss.starobrno.eviction.EvictionEvent}
* @return an EvictedEventNode that has been created for this queue
*/
- EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType, int elementDifference);
+ org.jboss.starobrno.eviction.EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType, int elementDifference);
/**
- * An overloaded version of {@link #registerEvictionEvent(Fqn, org.jboss.cache.eviction.EvictionEvent.Type, int)} which
+ * An overloaded version of {@link #registerEvictionEvent(Fqn, org.jboss.starobrno.eviction.EvictionEvent.Type, int)} which
* uses a default elementDifference value.
*
- * @param fqn passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
- * @param eventType passed in to the constructor of {@link org.jboss.cache.eviction.EvictionEvent}
+ * @param fqn passed in to the constructor of {@link org.jboss.starobrno.eviction.EvictionEvent}
+ * @param eventType passed in to the constructor of {@link org.jboss.starobrno.eviction.EvictionEvent}
* @return an EvictedEventNode that has been created for this queue
*/
EvictionEvent registerEvictionEvent(Fqn fqn, EvictionEvent.Type eventType);
@@ -177,7 +174,7 @@
/**
* Marks a {@link org.jboss.cache.Node} as currently in use, by adding an event to the eviction queue.
* If there is an {@link org.jboss.cache.config.EvictionRegionConfig} associated with this region, and
- * it respects this event (e.g., {@link org.jboss.cache.eviction.LRUAlgorithm} does), then the {@link org.jboss.cache.Node} will not
+ * it respects this event (e.g., {@link org.jboss.starobrno.eviction.LRUAlgorithm} does), then the {@link org.jboss.cache.Node} will not
* be evicted until {@link #unmarkNodeCurrentlyInUse(Fqn)} is invoked.
* <p/>
* This mechanism can be used to prevent eviction of data that the application
@@ -225,107 +222,4 @@
* @return a new Region instance.
*/
Region copy(Fqn newRoot);
-
- // -------- deprecated interfaces retained for compatibility with 2.x. -----------
-
-
- /**
- * Configures an eviction policy for this region.
- * <p/>
- * <b>Note:</b> This is deprecated since this is an internal method and never was
- * meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release
- * and its functionality is not guaranteed.
- * <p/>
- *
- * @param evictionPolicyConfig configuration to set
- * @deprecated
- */
- @Deprecated
- @Compat
- void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig);
-
- /**
- * Returns an eviction policy configuration.
- * <p/>
- * <b>Note:</b> This is deprecated since this is an internal method and never was
- * meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release
- * and its functionality is not guaranteed.
- * <p/>
- *
- * @return an eviction policy configuration
- * @deprecated
- */
- @Deprecated
- @Compat
- EvictionPolicyConfig getEvictionPolicyConfig();
-
- /**
- * Returns an eviction policy.
- * <p/>
- * <b>Note:</b> This is deprecated since this is an internal method and never was
- * meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release
- * and its functionality is not guaranteed.
- * <p/>
- *
- * @return an eviction policy
- * @deprecated
- */
- @Deprecated
- @Compat
- EvictionPolicy getEvictionPolicy();
-
- /**
- * Returns the size of the node event queue, used by the eviction thread.
- * <p/>
- * <b>Note:</b> This is deprecated since this is an internal method and never was
- * meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release
- * and its functionality is not guaranteed.
- * <p/>
- *
- * @return number of events
- * @deprecated
- */
- @Deprecated
- @Compat
- int nodeEventQueueSize();
-
- /**
- * Returns the most recent {@link org.jboss.cache.eviction.EvictedEventNode} added to the event queue by
- * {@link #putNodeEvent(org.jboss.cache.eviction.EvictedEventNode)}.
- * <p/>
- * <b>Note:</b> This is deprecated since this is an internal method and never was
- * meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release
- * and its functionality is not guaranteed.
- * <p/>
- *
- * @return the last {@link org.jboss.cache.eviction.EvictedEventNode}, or null if no more events exist
- * @deprecated
- */
- @Compat
- @Deprecated
- EvictedEventNode takeLastEventNode();
-
- /**
- * Adds an {@link org.jboss.cache.eviction.EvictedEventNode} to the internal queue for processing
- * by the eviction thread.
- * <p/>
- * <b>Note:</b> This is deprecated since this is an internal method and never was
- * meant to be a part of the public API. Please do not treat this as public API, it may be removed in a future release
- * and its functionality is not guaranteed.
- * <p/>
- *
- * @param event event to add
- * @deprecated
- */
- @Deprecated
- @Compat
- void putNodeEvent(EvictedEventNode event);
-
- /**
- * @return a clone
- * @deprecated
- */
- @Deprecated
- @Compat
- Region clone() throws CloneNotSupportedException;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionEmptyException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionEmptyException.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionEmptyException.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -21,6 +21,8 @@
*/
package org.jboss.cache;
+import org.jboss.starobrno.CacheException;
+
/**
* Exception to represent a region being empty when state was expected in that region.
*
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionImpl.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -23,21 +23,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.annotations.Compat;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionAlgorithmConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.EvictedEventNode;
-import org.jboss.cache.eviction.EvictionActionPolicy;
-import org.jboss.cache.eviction.EvictionAlgorithm;
-import org.jboss.cache.eviction.EvictionEvent;
-import org.jboss.cache.eviction.EvictionPolicy;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.config.EvictionRegionConfig;
+import org.jboss.starobrno.eviction.EvictionActionPolicy;
+import org.jboss.starobrno.eviction.EvictionEvent;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
/**
* Default implementation of a {@link Region}
@@ -55,7 +49,7 @@
private BlockingQueue<EvictionEvent> evictionEventQueue = null;
private int capacityWarnThreshold = 0;
private EvictionRegionConfig evictionRegionConfig;
- private EvictionAlgorithm evictionAlgorithm;
+ private org.jboss.starobrno.eviction.EvictionAlgorithm evictionAlgorithm;
/**
@@ -230,7 +224,7 @@
{
if (evictionAlgorithm.canIgnoreEvent(eventType)) return null;
- EvictionEvent event = new EvictionEvent(fqn, eventType, elementDifference);
+ org.jboss.starobrno.eviction.EvictionEvent event = new EvictionEvent(fqn, eventType, elementDifference);
registerEvictionEvent(event);
return event;
}
@@ -275,7 +269,7 @@
}
}
- private EvictionAlgorithm createEvictionAlgorithm(EvictionAlgorithmConfig algoConfig, String evictionActionPolicyClass)
+ private org.jboss.starobrno.eviction.EvictionAlgorithm createEvictionAlgorithm(EvictionAlgorithmConfig algoConfig, String evictionActionPolicyClass)
{
if (algoConfig == null)
throw new IllegalArgumentException("Eviction algorithm class must not be null!");
@@ -290,7 +284,7 @@
actionPolicy.setCache(regionManager.getCache());
if (trace) log.trace("Instantiating " + algoConfig.getEvictionAlgorithmClassName());
- EvictionAlgorithm algorithm = (EvictionAlgorithm) Util.getInstance(algoConfig.getEvictionAlgorithmClassName());
+ org.jboss.starobrno.eviction.EvictionAlgorithm algorithm = (org.jboss.starobrno.eviction.EvictionAlgorithm) Util.getInstance(algoConfig.getEvictionAlgorithmClassName());
algorithm.setEvictionActionPolicy(actionPolicy);
algorithm.assignToRegion(fqn, regionManager.getCache(), algoConfig, regionManager.getConfiguration());
return algorithm;
@@ -315,70 +309,4 @@
}
return clone;
}
-
- @Deprecated
- @Compat
- @SuppressWarnings("deprecation")
- public void setEvictionPolicy(EvictionPolicyConfig evictionPolicyConfig)
- {
- //TODO: Autogenerated. Implement me properly
- }
-
- @Deprecated
- @Compat
- @SuppressWarnings("deprecation")
- public EvictionPolicyConfig getEvictionPolicyConfig()
- {
- return null; //TODO: Autogenerated. Implement me properly
- }
-
- @Deprecated
- @Compat
- @SuppressWarnings("deprecation")
- public EvictionPolicy getEvictionPolicy()
- {
- return null; //TODO: Autogenerated. Implement me properly
- }
-
- @Deprecated
- @Compat
- public int nodeEventQueueSize()
- {
- BlockingQueue<?> q = getEvictionEventQueue();
- return q == null ? 0 : q.size();
- }
-
- @Compat
- @Deprecated
- @SuppressWarnings("deprecation")
- public EvictedEventNode takeLastEventNode()
- {
- try
- {
- EvictionEvent ee = getEvictionEventQueue().poll(0, TimeUnit.SECONDS);
- if (ee instanceof EvictedEventNode) return (EvictedEventNode) ee;
- else return new EvictedEventNode(ee);
- }
- catch (InterruptedException e)
- {
- log.debug("trace", e);
- }
- return null;
-
- }
-
- @Deprecated
- @Compat
- @SuppressWarnings("deprecation")
- public void putNodeEvent(EvictedEventNode event)
- {
- this.registerEvictionEvent(event);
- }
-
- @Deprecated
- @Compat
- public Region clone() throws CloneNotSupportedException
- {
- return (Region) super.clone();
- }
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManager.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -22,9 +22,8 @@
package org.jboss.cache;
import org.jboss.cache.annotations.Compat;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.eviction.EvictionTimerTask;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.EvictionConfig;
import java.util.List;
@@ -198,7 +197,7 @@
/**
* @return the eviction timer task attached to the region manager
*/
- EvictionTimerTask getEvictionTimerTask();
+ org.jboss.starobrno.eviction.EvictionTimerTask getEvictionTimerTask();
/**
* @return the configuration
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -27,18 +27,18 @@
import static org.jboss.cache.Region.Type.*;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.eviction.EvictionTimerTask;
-import org.jboss.cache.factories.annotations.Destroy;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.util.concurrent.locks.LockContainer;
import org.jboss.cache.util.concurrent.locks.ReentrantLockContainer;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.EvictionConfig;
+import org.jboss.starobrno.config.EvictionRegionConfig;
+import org.jboss.starobrno.factories.annotations.Destroy;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import org.jgroups.Address;
import java.util.ArrayList;
@@ -69,7 +69,7 @@
CacheSPI<?, ?> cache;
private boolean usingEvictions;
private EvictionConfig evictionConfig;
- private final EvictionTimerTask evictionTimerTask = new EvictionTimerTask();
+ private final org.jboss.starobrno.eviction.EvictionTimerTask evictionTimerTask = new org.jboss.starobrno.eviction.EvictionTimerTask();
private final LockContainer<Fqn> regionLocks = new ReentrantLockContainer<Fqn>(4);
protected Configuration configuration;
@@ -295,7 +295,7 @@
return true;
}
- public EvictionTimerTask getEvictionTimerTask()
+ public org.jboss.starobrno.eviction.EvictionTimerTask getEvictionTimerTask()
{
return evictionTimerTask;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionNotEmptyException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionNotEmptyException.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionNotEmptyException.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -21,6 +21,8 @@
*/
package org.jboss.cache;
+import org.jboss.starobrno.CacheException;
+
/**
* Thrown when an attempt is made to {@link RegionManager#activate(Fqn)} activate a subtree}
* root in Fqn that already has an existing node in the cache.
Modified: core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/RegionRegistry.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache;
-import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
import java.util.concurrent.ConcurrentHashMap;
Modified: core/branches/flat/src/main/java/org/jboss/cache/ReplicationException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/ReplicationException.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/ReplicationException.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -21,6 +21,8 @@
*/
package org.jboss.cache;
+import org.jboss.starobrno.CacheException;
+
/**
* Thrown when a replication problem occurred
*/
Modified: core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/SuspectException.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -21,6 +21,8 @@
*/
package org.jboss.cache;
+import org.jboss.starobrno.CacheException;
+
/**
* Thrown when a member is suspected during remote method invocation
*
Modified: core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/UnversionedNode.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -28,6 +28,7 @@
import org.jboss.cache.util.FastCopyHashMap;
import org.jboss.cache.util.Immutables;
import org.jboss.cache.util.concurrent.SelfInitializingConcurrentHashMap;
+import org.jboss.starobrno.CacheException;
import java.util.Collections;
import java.util.HashMap;
@@ -332,11 +333,6 @@
sb.append("[ ").append(fqn);
}
- if (this instanceof VersionedNode)
- {
- sb.append(" version=").append(this.getVersion());
- }
-
if (data != null)
{
if (trace)
@@ -461,7 +457,7 @@
{
// replace key!
Entry<? extends K, ? extends V> e = data.entrySet().iterator().next();
- this.data = Collections.singletonMap((K)e.getKey(), (V)e.getValue());
+ this.data = Collections.singletonMap((K) e.getKey(), (V) e.getValue());
}
else
{
Deleted: core/branches/flat/src/main/java/org/jboss/cache/VersionedNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/VersionedNode.java 2008-10-08 16:28:04 UTC (rev 6885)
+++ core/branches/flat/src/main/java/org/jboss/cache/VersionedNode.java 2008-10-08 16:29:32 UTC (rev 6886)
@@ -1,136 +0,0 @@
-/*
- * 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.cache;
-
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.lock.IdentityLock;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DefaultDataVersion;
-
-import java.util.Map;
-
-/**
- * VersionedNode extends the {@link org.jboss.cache.UnversionedNode} by adding a {@link org.jboss.cache.optimistic.DataVersion} property.
- * <p/>
- * Unlike {@link org.jboss.cache.UnversionedNode}, this node supports {@link #getVersion} and {@link #setVersion(org.jboss.cache.optimistic.DataVersion)}
- * defined in {@link org.jboss.cache.NodeSPI}
- * <p/>
- * Typically used when the cache mode configured is {@link org.jboss.cache.config.Configuration.NodeLockingScheme#OPTIMISTIC}
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @since 2.0.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class VersionedNode<K, V> extends PessimisticUnversionedNode<K, V>
-{
- private static final String DATA_VERSION_INTERNAL_KEY = "_JBOSS_INTERNAL_OPTIMISTIC_DATA_VERSION";
- private DataVersion version; // make sure this is NOT initialized to anything, even a null! Since the UnversionedNode constructor may set this value based on a data version passed along in the data map.
-
- static
- {
- log = LogFactory.getLog(VersionedNode.class);
- }
-
- /**
- * Although this object has a reference to the CacheImpl, the optimistic
- * node is actually disconnected from the CacheImpl itself.
- * The parent could be looked up from the TransactionWorkspace.
- */
- private NodeSPI<K, V> parent;
-
- public VersionedNode(Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, CacheSPI<K, V> cache)
- {
- super(fqn.getLastElement(), fqn, data, cache);
- if (parent == null && !fqn.isRoot()) throw new NullPointerException("parent");
- if (version == null) version = DefaultDataVersion.ZERO;
- this.parent = parent;
- }
-
- /**
- * Returns the version id of this node.
- *
- * @return the version
- */
- @Override
- public DataVersion getVersion()
- {
- return version;
- }
-
- /**
- * Returns the parent.
- */
- @Override
- public NodeSPI<K, V> getParent()
- {
- return parent;
- }
-
- /**
- * Sets the version id of this node.
- *
- * @param version
- */
- @Override
- public void setVersion(DataVersion version)
- {
- this.version = version;
- }
-
- /**
- * Optimistically locked nodes (VersionedNodes) will always use repeatable read.
- */
- @Override
- protected synchronized void initLock()
- {
- if (lock == null) lock = new IdentityLock(lockStrategyFactory, delegate);
- }
-
- @Override
- public Map getInternalState(boolean onlyInternalState)
- {
- Map state = super.getInternalState(onlyInternalState);
- state.put(DATA_VERSION_INTERNAL_KEY, version);
- return state;
- }
-
- @Override
- public void setInternalState(Map state)
- {
- if (state != null)
- {
- DataVersion dv = (DataVersion) state.remove(DATA_VERSION_INTERNAL_KEY);
- if (dv != null) version = dv;
- }
- super.setInternalState(state);
- }
-
- @Override
- public VersionedNode copy()
- {
- VersionedNode n = new VersionedNode(fqn, getParent(), data, cache);
- copyInternals(n);
- n.version = version;
- return n;
- }
-}
17 years, 2 months
JBoss Cache SVN: r6885 - in core/branches/flat/src/main/java/org/jboss/cache: batch and 25 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 12:28:04 -0400 (Wed, 08 Oct 2008)
New Revision: 6885
Removed:
core/branches/flat/src/main/java/org/jboss/cache/CacheException.java
core/branches/flat/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/cache/commands/legacy/
core/branches/flat/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
core/branches/flat/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java
core/branches/flat/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/annotations/
core/branches/flat/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/Interceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheStoreInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferGenerator.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferManager.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManagerLookup.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java
Modified:
core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java
core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/Cache.java
core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java
core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java
core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java
core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyLocator.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyNotInitException.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java
core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorConfig.java
core/branches/flat/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java
core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/branches/flat/src/main/java/org/jboss/cache/factories/BootstrapFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/CommandsMetaFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/jboss/cache/factories/ContextMetaFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/LockManagerFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/RegionManagerFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/ReplicationQueueFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferManagerFactory.java
core/branches/flat/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/JmxStatsCommandInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java
core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java
core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreDefaultConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3Exception.java
core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3LoaderConfig.java
core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
core/branches/flat/src/main/java/org/jboss/cache/lock/AbstractLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java
core/branches/flat/src/main/java/org/jboss/cache/lock/LockingException.java
core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller300.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionException.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValue.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValueMap.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/MethodCall.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java
core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java
core/branches/flat/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java
core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java
core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java
core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
Log:
Moved stuff
Modified: core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/AbstractNode.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,7 +24,6 @@
import static org.jboss.cache.AbstractNode.NodeFlags.REMOVED;
import static org.jboss.cache.AbstractNode.NodeFlags.RESIDENT;
import org.jboss.cache.lock.IdentityLock;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Map;
@@ -180,17 +179,6 @@
throw new UnsupportedOperationException("Not supported in this implementation!");
}
- // versioning
- public void setVersion(DataVersion version)
- {
- throw new UnsupportedOperationException("Versioning not supported");
- }
-
- public DataVersion getVersion()
- {
- throw new UnsupportedOperationException("Versioning not supported");
- }
-
@Override
public boolean equals(Object another)
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,15 +22,13 @@
package org.jboss.cache;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.mvcc.ReadCommittedNode;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
import java.util.Map;
@@ -115,11 +113,6 @@
throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
}
- public WorkspaceNode<K, V> createWrappedNode(NodeSPI<K, V> dataNode, TransactionWorkspace workspace)
- {
- throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
- }
-
public ReadCommittedNode createWrappedNode(InternalNode<K, V> node, InternalNode<K, V> parent)
{
throw new UnsupportedOperationException("Unsupported in this implementation (" + getClass().getSimpleName() + ")!");
Modified: core/branches/flat/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/Cache.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/Cache.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,7 +22,8 @@
package org.jboss.cache;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.config.Configuration;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
import org.jgroups.Address;
import java.util.List;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/CacheException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheException.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheException.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,57 +0,0 @@
-/*
- * 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.cache;
-
-/**
- * Thrown when operations on {@link org.jboss.cache.Cache} or {@link org.jboss.cache.Node} fail unexpectedly.
- * <p/>
- * Specific subclasses such as {@link org.jboss.cache.lock.TimeoutException}, {@link org.jboss.cache.config.ConfigurationException} and {@link org.jboss.cache.lock.LockingException}
- * have more specific uses.
- *
- * @author <a href="mailto:bela@jboss.org">Bela Ban</a>
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- */
-public class CacheException extends RuntimeException
-{
-
- private static final long serialVersionUID = -4386393072593859164L;
-
- public CacheException()
- {
- super();
- }
-
- public CacheException(Throwable cause)
- {
- super(cause);
- }
-
- public CacheException(String msg)
- {
- super(msg);
- }
-
- public CacheException(String msg, Throwable cause)
- {
- super(msg, cause);
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,8 +22,8 @@
package org.jboss.cache;
import net.jcip.annotations.ThreadSafe;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
import java.io.InputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache;
-import org.jboss.cache.config.Configuration;
import org.jgroups.ChannelFactory;
import java.util.Set;
Modified: core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/CacheManagerImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,9 +21,9 @@
*/
package org.jboss.cache;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationRegistry;
-import org.jboss.cache.config.XmlParsingConfigurationRegistry;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationRegistry;
+import org.jboss.starobrno.config.XmlParsingConfigurationRegistry;
import org.jgroups.ChannelFactory;
import java.util.HashMap;
Modified: core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/batch/BatchContainer.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.batch;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.factories.annotations.Inject;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,28 +1,28 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.buddyreplication;
-import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
+import org.jboss.starobrno.CacheException;
import org.jgroups.Address;
import java.util.ArrayList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyLocator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyLocator.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyLocator.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.buddyreplication;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jgroups.Address;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
@@ -40,13 +39,6 @@
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.notifications.Notifier;
@@ -56,6 +48,14 @@
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.BuddyReplicationConfig.BuddyLocatorConfig;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.jgroups.Address;
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyNotInitException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyNotInitException.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/BuddyNotInitException.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.buddyreplication;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
/**
* Exception to depict that a buddy has not been initialised to participate in any comms
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.buddyreplication;
import org.jboss.cache.Fqn;
@@ -26,7 +26,6 @@
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -35,7 +34,6 @@
import org.jboss.cache.commands.read.GetNodeCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -210,19 +208,6 @@
return factory.buildRollbackCommand(null);
}
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- List<WriteCommand> transformed = transformBatch(command.getModifications());
- return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getLocalAddress(), command.isOnePhaseCommit());
- }
-
- @Override
- public Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- return factory.buildCreateNodeCommand(getBackupFqn(command.getFqn()));
- }
-
public List<WriteCommand> transformBatch(List<WriteCommand> toTransform) throws Throwable
{
List<WriteCommand> transformedCommands = new ArrayList<WriteCommand>(toTransform.size());
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,7 +24,7 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
+import org.jboss.starobrno.config.BuddyReplicationConfig.BuddyLocatorConfig;
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
Modified: core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/buddyreplication/NextMemberBuddyLocatorConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,9 +21,9 @@
*/
package org.jboss.cache.buddyreplication;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
-import org.jboss.cache.config.Dynamic;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.BuddyReplicationConfig.BuddyLocatorConfig;
+import org.jboss.starobrno.config.Dynamic;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -27,10 +27,10 @@
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import java.util.ArrayList;
import java.util.LinkedList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,28 +1,27 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -31,7 +30,6 @@
import org.jboss.cache.commands.read.GetNodeCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -150,16 +148,6 @@
return handleDefault(ctx, command);
}
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
- public Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
/**
* A default handler for all commands visited. This is called for any visit method called, unless a visit command is
* appropriately overridden.
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -38,7 +37,6 @@
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -119,8 +117,6 @@
RollbackCommand buildRollbackCommand(GlobalTransaction gtx);
- OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, Address address, boolean onePhaseCommit);
-
AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address, String buddyPoolName);
RemoveFromBuddyGroupCommand buildRemoveFromBuddyGroupCommand(String groupName);
@@ -129,8 +125,6 @@
ClusteredGetCommand buildClusteredGetCommand(Boolean searchBackupSubtrees, DataCommand dataCommand);
- CreateNodeCommand buildCreateNodeCommand(Fqn fqn);
-
/**
* Builds a cache command based on the ID passed in and an object array of parameters
*
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,27 +1,26 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
@@ -29,7 +28,6 @@
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -44,7 +42,6 @@
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -56,12 +53,13 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
import org.jgroups.Address;
import javax.transaction.TransactionManager;
@@ -227,11 +225,6 @@
return new RollbackCommand(gtx);
}
- public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, Address address, boolean onePhaseCommit)
- {
- return new OptimisticPrepareCommand(gtx, modifications, address, onePhaseCommit);
- }
-
public AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address, String buddyPoolName)
{
AnnounceBuddyPoolNameCommand command = new AnnounceBuddyPoolNameCommand(address, buddyPoolName);
@@ -288,11 +281,6 @@
return cmd;
}
- public CreateNodeCommand buildCreateNodeCommand(Fqn fqn)
- {
- throw new UnsupportedOperationException("Not supported in MVCC!");
- }
-
public ReplicableCommand fromStream(int id, Object[] parameters)
{
ReplicableCommand command;
@@ -398,10 +386,6 @@
command = returnValue;
break;
}
- case CreateNodeCommand.METHOD_ID:
- {
- throw new UnsupportedOperationException("CreateNodeCommand is not supported in MVCC!");
- }
// --- transactional method calls
case PrepareCommand.METHOD_ID:
@@ -410,12 +394,6 @@
break;
}
- case OptimisticPrepareCommand.METHOD_ID:
- {
- command = new OptimisticPrepareCommand();
- break;
- }
-
case CommitCommand.METHOD_ID:
{
command = new CommitCommand();
Deleted: core/branches/flat/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/OptimisticCommandsFactoryImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,115 +0,0 @@
-/*
- * 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.cache.commands;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.legacy.read.LegacyGravitateDataCommand;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
-import org.jboss.cache.commands.legacy.write.LegacyEvictCommand;
-import org.jboss.cache.commands.legacy.write.VersionedInvalidateCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-
-/**
- * Extends the default commands factory impl for optimistic locking.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed with opt locking
- */
-@Deprecated
-@SuppressWarnings("deprecation")
-public class OptimisticCommandsFactoryImpl extends CommandsFactoryImpl
-{
- @Override
- public EvictCommand buildEvictFqnCommand(Fqn fqn)
- {
- EvictCommand command = new LegacyEvictCommand(fqn);
- command.initialize(notifier, dataContainer);
- return command;
- }
-
- @Override
- public InvalidateCommand buildInvalidateCommand(Fqn fqn)
- {
- VersionedInvalidateCommand command = new VersionedInvalidateCommand(fqn);
- command.initialize(txManager);
- command.initialize(cacheSpi, dataContainer, notifier);
- return command;
- }
-
- @Override
- public GravitateDataCommand buildGravitateDataCommand(Fqn fqn, Boolean searchSubtrees)
- {
- LegacyGravitateDataCommand command = new LegacyGravitateDataCommand(fqn, searchSubtrees, rpcManager.getLocalAddress());
- command.initialize(dataContainer, cacheSpi, buddyFqnTransformer);
- return command;
- }
-
- @Override
- public CreateNodeCommand buildCreateNodeCommand(Fqn fqn)
- {
- CreateNodeCommand command = new CreateNodeCommand(fqn);
- command.initialize(dataContainer);
- return command;
- }
-
-
- @Override
- public ReplicableCommand fromStream(int id, Object[] parameters)
- {
- ReplicableCommand command;
- boolean skipSetParams = false;
- switch (id)
- {
- case CreateNodeCommand.METHOD_ID:
- {
- CreateNodeCommand returnValue = new CreateNodeCommand(null);
- returnValue.initialize(dataContainer);
- command = returnValue;
- break;
- }
- case GravitateDataCommand.METHOD_ID:
- {
- LegacyGravitateDataCommand returnValue = new LegacyGravitateDataCommand(rpcManager.getLocalAddress());
- returnValue.initialize(dataContainer, cacheSpi, buddyFqnTransformer);
- command = returnValue;
- break;
- }
- case InvalidateCommand.METHOD_ID:
- {
- VersionedInvalidateCommand returnValue = new VersionedInvalidateCommand(null);
- returnValue.initialize(cacheSpi, dataContainer, notifier);
- command = returnValue;
- break;
- }
- default:
- // pass up to superclass
- command = super.fromStream(id, parameters);
- skipSetParams = true;
- }
-
- if (!skipSetParams) command.setParameters(id, parameters);
- return command;
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,219 +0,0 @@
-/*
- * 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.cache.commands;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.legacy.read.PessGetChildrenNamesCommand;
-import org.jboss.cache.commands.legacy.write.PessClearDataCommand;
-import org.jboss.cache.commands.legacy.write.PessMoveCommand;
-import org.jboss.cache.commands.legacy.write.PessPutDataMapCommand;
-import org.jboss.cache.commands.legacy.write.PessPutForExternalReadCommand;
-import org.jboss.cache.commands.legacy.write.PessPutKeyValueCommand;
-import org.jboss.cache.commands.legacy.write.PessRemoveKeyCommand;
-import org.jboss.cache.commands.legacy.write.PessRemoveNodeCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.transaction.GlobalTransaction;
-
-import java.util.Map;
-
-/**
- * This specific implementation of {@link CommandsFactory} specifically creates
- * pessimistic commands where appropriate, with the ability to roll back.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @see org.jboss.cache.commands.legacy.ReversibleCommand
- * @since 3.0
- * @deprecated will be removed with possimistic locking
- */
-@Deprecated
-@SuppressWarnings("deprecation")
-public class PessimisticCommandsFactoryImpl extends OptimisticCommandsFactoryImpl
-{
- @Override
- public GetChildrenNamesCommand buildGetChildrenNamesCommand(Fqn fqn)
- {
- GetChildrenNamesCommand command = new PessGetChildrenNamesCommand(fqn);
- command.initialize(dataContainer);
- return command;
- }
-
- @Override
- public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map data)
- {
- PutDataMapCommand cmd = new PessPutDataMapCommand(gtx, fqn, data);
- cmd.initialize(notifier, dataContainer);
- return cmd;
- }
-
- @Override
- public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
- {
- PutKeyValueCommand cmd = new PessPutKeyValueCommand(gtx, fqn, key, value);
- cmd.initialize(notifier, dataContainer);
- return cmd;
- }
-
- @Override
- public PutForExternalReadCommand buildPutForExternalReadCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
- {
- PutForExternalReadCommand cmd = new PessPutForExternalReadCommand(gtx, fqn, key, value);
- cmd.initialize(notifier, dataContainer);
- return cmd;
- }
-
- @Override
- public RemoveNodeCommand buildRemoveNodeCommand(GlobalTransaction gtx, Fqn fqn)
- {
- RemoveNodeCommand cmd = new PessRemoveNodeCommand(gtx, fqn);
- cmd.initialize(notifier, dataContainer);
- return cmd;
- }
-
- @Override
- public ClearDataCommand buildClearDataCommand(GlobalTransaction gtx, Fqn fqn)
- {
- ClearDataCommand cmd = new PessClearDataCommand(gtx, fqn);
- cmd.initialize(notifier, dataContainer);
- return cmd;
- }
-
- @Override
- public RemoveKeyCommand buildRemoveKeyCommand(GlobalTransaction tx, Fqn fqn, Object key)
- {
- RemoveKeyCommand cmd = new PessRemoveKeyCommand(tx, fqn, key);
- cmd.initialize(notifier, dataContainer);
- return cmd;
- }
-
- @Override
- public MoveCommand buildMoveCommand(Fqn from, Fqn to)
- {
- MoveCommand cmd = new PessMoveCommand(from, to);
- cmd.initialize(notifier, dataContainer);
- return cmd;
- }
-
- @Override
- public InvalidateCommand buildInvalidateCommand(Fqn fqn)
- {
- InvalidateCommand command = new InvalidateCommand(fqn);
- command.initialize(cacheSpi, dataContainer, notifier);
- return command;
- }
-
- @Override
- public ReplicableCommand fromStream(int id, Object[] parameters)
- {
- ReplicableCommand command;
- boolean skipSetParams = false;
- switch (id)
- {
- case GetChildrenNamesCommand.METHOD_ID:
- {
- GetChildrenNamesCommand returnValue = new PessGetChildrenNamesCommand();
- returnValue.initialize(dataContainer);
- command = returnValue;
- break;
- }
- case MoveCommand.METHOD_ID:
- {
- MoveCommand returnValue = new PessMoveCommand();
- returnValue.initialize(notifier, dataContainer);
- command = returnValue;
- break;
- }
- case PutDataMapCommand.METHOD_ID:
- case PutDataMapCommand.ERASE_METHOD_ID:
- case PutDataMapCommand.ERASE_VERSIONED_METHOD_ID:
- case PutDataMapCommand.VERSIONED_METHOD_ID:
- {
- PutDataMapCommand returnValue = new PessPutDataMapCommand();
- returnValue.initialize(notifier, dataContainer);
- command = returnValue;
- break;
- }
- case PutKeyValueCommand.METHOD_ID:
- case PutKeyValueCommand.VERSIONED_METHOD_ID:
- {
- PutKeyValueCommand returnValue = new PessPutKeyValueCommand();
- returnValue.initialize(notifier, dataContainer);
- command = returnValue;
- break;
- }
- case PutForExternalReadCommand.METHOD_ID:
- case PutForExternalReadCommand.VERSIONED_METHOD_ID:
- {
- PutForExternalReadCommand returnValue = new PessPutForExternalReadCommand();
- returnValue.initialize(notifier, dataContainer);
- command = returnValue;
- break;
- }
- case ClearDataCommand.METHOD_ID:
- case ClearDataCommand.VERSIONED_METHOD_ID:
- {
- ClearDataCommand returnValue = new PessClearDataCommand();
- returnValue.initialize(notifier, dataContainer);
- command = returnValue;
- break;
- }
- case RemoveKeyCommand.METHOD_ID:
- case RemoveKeyCommand.VERSIONED_METHOD_ID:
- {
- RemoveKeyCommand returnValue = new PessRemoveKeyCommand();
- returnValue.initialize(notifier, dataContainer);
- command = returnValue;
- break;
- }
-
- case RemoveNodeCommand.METHOD_ID:
- case RemoveNodeCommand.VERSIONED_METHOD_ID:
- {
- RemoveNodeCommand returnValue = new PessRemoveNodeCommand();
- returnValue.initialize(notifier, dataContainer);
- command = returnValue;
- break;
- }
- case InvalidateCommand.METHOD_ID:
- {
- InvalidateCommand returnValue = new InvalidateCommand(null);
- returnValue.initialize(cacheSpi, dataContainer, notifier);
- command = returnValue;
- break;
- }
- default:
- // pass up to superclass
- command = super.fromStream(id, parameters);
- skipSetParams = true;
- }
-
- if (!skipSetParams) command.setParameters(id, parameters);
- return command;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/VersionedDataCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,28 +1,26 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands;
-import org.jboss.cache.optimistic.DataVersion;
-
/**
* Just like a {@link org.jboss.cache.commands.DataCommand}, except that these are versioned and reversible too. Versioning
* is currently used by optimistic locking, and in future will be used by MVCC as well.
@@ -36,14 +34,13 @@
/**
* @return the DataVersion pertaining to this command.
*/
- DataVersion getDataVersion();
+// DataVersion getDataVersion();
/**
* Sets the DataVersion pertaining to this command.
*
* @param dataVersion to set
*/
- void setDataVersion(DataVersion dataVersion);
/**
* Has data version set? (i.e. not null)
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/Visitor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,28 +1,27 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -31,7 +30,6 @@
import org.jboss.cache.commands.read.GetNodeCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -245,26 +243,4 @@
*/
Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable;
- /**
- * Visits a OptimisticPrepareCommand.
- *
- * @param ctx invocation context
- * @param command command to visit
- * @return response from the visit
- * @throws Throwable in the event of problems.
- */
- Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable;
-
-
- /**
- * Visits a CreateNodeCommand.
- *
- * @param ctx invocation context
- * @param command command to visit
- * @return response from the visit
- * @throws Throwable in the event of problems.
- * @deprecated in 3.0. Will be removed once optimistic and pessimistic locking is removed.
- */
- @Deprecated
- Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable;
}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,107 +0,0 @@
-/*
- * 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.cache.commands.tx;
-
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jgroups.Address;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An optimistic version of {@link PrepareCommand}.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public class OptimisticPrepareCommand extends PrepareCommand
-{
- public static final int METHOD_ID = 18;
-
- public OptimisticPrepareCommand(GlobalTransaction gtx, List<WriteCommand> modifications, Address address, boolean onePhaseCommit)
- {
- super(gtx, modifications, address, onePhaseCommit);
- }
-
- public OptimisticPrepareCommand()
- {
- }
-
- @Override
- public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
- {
- return visitor.visitOptimisticPrepareCommand(ctx, this);
- }
-
- @Override
- public int getCommandId()
- {
- return METHOD_ID;
- }
-
- @Override
- public Object[] getParameters()
- {
- // the null is needed for wire-level compat with pre-command versions
- return new Object[]{globalTransaction, modifications, null, localAddress, onePhaseCommit};
- }
-
- /**
- * A shallow copy of all fields except collections.
- *
- * @return a copy of this command
- */
- @Override
- public OptimisticPrepareCommand copy()
- {
- OptimisticPrepareCommand copy = new OptimisticPrepareCommand();
- copy.globalTransaction = globalTransaction;
- copy.localAddress = localAddress;
- copy.modifications = modifications == null ? null : new ArrayList<WriteCommand>(modifications);
- copy.onePhaseCommit = onePhaseCommit;
- return copy;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void setParameters(int commandId, Object[] args)
- {
- globalTransaction = (GlobalTransaction) args[0];
- modifications = (List<WriteCommand>) args[1];
- //args[2] is probably null.
- localAddress = (Address) args[3];
- onePhaseCommit = (Boolean) args[4];
- }
-
- @Override
- public String toString()
- {
- return "OptimisticPrepareCommand{" +
- "modifications=" + modifications +
- ", localAddress=" + localAddress +
- ", onePhaseCommit=" + onePhaseCommit +
- '}';
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -28,8 +28,6 @@
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.read.AbstractDataCommand;
import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DataVersioningException;
import org.jboss.cache.transaction.GlobalTransaction;
/**
@@ -42,7 +40,7 @@
{
protected Notifier notifier;
- protected DataVersion dataVersion;
+ // protected DataVersion dataVersion;
protected GlobalTransaction globalTransaction;
public void initialize(Notifier notifier, DataContainer dataContainer)
@@ -51,16 +49,6 @@
this.dataContainer = dataContainer;
}
- public DataVersion getDataVersion()
- {
- return dataVersion;
- }
-
- public void setDataVersion(DataVersion dataVersion)
- {
- this.dataVersion = dataVersion;
- }
-
public GlobalTransaction getGlobalTransaction()
{
return globalTransaction;
@@ -73,17 +61,14 @@
public boolean isVersioned()
{
- return dataVersion != null;
+ return false;
}
// basic implementations
@Override
public Object[] getParameters()
{
- if (isVersioned())
- return new Object[]{fqn, dataVersion};
- else
- return new Object[]{fqn};
+ return new Object[]{fqn};
}
// basic implementations
@@ -91,7 +76,6 @@
public void setParameters(int commandId, Object[] args)
{
fqn = (Fqn) args[0];
- if (isVersionedId(commandId)) dataVersion = (DataVersion) args[1];
}
protected abstract boolean isVersionedId(int id);
@@ -107,7 +91,7 @@
@Override
public int hashCode()
{
- return 31 * super.hashCode() + (dataVersion != null ? dataVersion.hashCode() : 0);
+ return 31 * super.hashCode();
}
/**
@@ -120,12 +104,6 @@
*/
protected NodeSPI peekVersioned(InvocationContext ctx)
{
- NodeSPI n = ctx.lookUpNode(fqn);
- if (n != null && isVersioned() && n.getVersion().newerThan(dataVersion))
- {
- String errMsg = new StringBuilder("Node found, but version is not equal to or less than the expected [").append(dataVersion).append("]. Is [").append(n.getVersion()).append("] instead!").toString();
- throw new DataVersioningException(errMsg);
- }
- return n;
+ throw new UnsupportedOperationException();
}
}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
@@ -28,7 +28,6 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Map;
@@ -94,10 +93,7 @@
@Override
public Object[] getParameters()
{
- if (isVersioned())
- return new Object[]{globalTransaction, fqn, true, dataVersion};
- else
- return new Object[]{globalTransaction, fqn, true};
+ return new Object[]{globalTransaction, fqn, true};
}
@Override
@@ -105,7 +101,6 @@
{
globalTransaction = (GlobalTransaction) args[0];
fqn = (Fqn) args[1];
- if (isVersionedId(commandId)) dataVersion = (DataVersion) args[3];
}
@Override
@@ -137,7 +132,6 @@
{
return "RemoveDataCommand{" +
"fqn=" + fqn +
- ", dataVersion=" + dataVersion +
", globalTransaction=" + globalTransaction +
'}';
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
@@ -29,7 +29,6 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Collections;
@@ -122,10 +121,7 @@
@Override
public Object[] getParameters()
{
- if (isVersioned())
- return new Object[]{globalTransaction, fqn, data, false, dataVersion};
- else
- return new Object[]{globalTransaction, fqn, data, false};
+ return new Object[]{globalTransaction, fqn, data, false};
}
@Override
@@ -134,7 +130,6 @@
globalTransaction = (GlobalTransaction) args[0];
fqn = (Fqn) args[1];
data = (Map) args[2];
- if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
}
@Override
@@ -171,7 +166,6 @@
{
return "PutDataMapCommand{" +
"fqn=" + fqn +
- ", dataVersion=" + dataVersion +
", data=" + data +
", globalTransaction=" + globalTransaction +
'}';
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
@@ -29,7 +29,6 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Collections;
@@ -135,10 +134,7 @@
@Override
public Object[] getParameters()
{
- if (isVersioned())
- return new Object[]{globalTransaction, fqn, key, value, false, dataVersion};
- else
- return new Object[]{globalTransaction, fqn, key, value, false};
+ return new Object[]{globalTransaction, fqn, key, value, false};
}
@Override
@@ -148,7 +144,6 @@
fqn = (Fqn) args[1];
key = args[2];
value = args[3];
- if (isVersionedId(commandId)) dataVersion = (DataVersion) args[5];
}
@Override
@@ -189,7 +184,6 @@
{
return getClass().getSimpleName() + "{" +
"fqn=" + fqn +
- ", dataVersion=" + dataVersion +
", globalTransaction=" + globalTransaction +
", key=" + key +
", value=" + value +
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
@@ -28,7 +28,6 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Collections;
@@ -114,10 +113,7 @@
@Override
public Object[] getParameters()
{
- if (isVersioned())
- return new Object[]{globalTransaction, fqn, key, true, dataVersion};
- else
- return new Object[]{globalTransaction, fqn, key, true};
+ return new Object[]{globalTransaction, fqn, key, true};
}
@Override
@@ -126,7 +122,6 @@
globalTransaction = (GlobalTransaction) args[0];
fqn = (Fqn) args[1];
key = args[2];
- if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
}
@Override
@@ -165,7 +160,6 @@
{
return "RemoveKeyCommand{" +
"fqn=" + fqn +
- ", dataVersion=" + dataVersion +
", globalTransaction=" + globalTransaction +
", key=" + key +
'}';
Modified: core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.commands.write;
import org.apache.commons.logging.Log;
@@ -27,7 +27,6 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Map;
@@ -138,10 +137,7 @@
@Override
public Object[] getParameters()
{
- if (isVersioned())
- return new Object[]{globalTransaction, fqn, true, skipSendingNodeEvents, dataVersion};
- else
- return new Object[]{globalTransaction, fqn, true, skipSendingNodeEvents};
+ return new Object[]{globalTransaction, fqn, true, skipSendingNodeEvents};
}
@Override
@@ -150,7 +146,6 @@
globalTransaction = (GlobalTransaction) args[0];
fqn = (Fqn) args[1];
skipSendingNodeEvents = (Boolean) args[3];
- if (isVersionedId(commandId)) dataVersion = (DataVersion) args[4];
}
@Override
@@ -194,7 +189,6 @@
{
return "RemoveNodeCommand{" +
"fqn=" + fqn +
- ", dataVersion=" + dataVersion +
", globalTransaction=" + globalTransaction +
", skipSendingNodeEvents=" + skipSendingNodeEvents +
", parentFqn=" + parentFqn +
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/BootstrapFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/BootstrapFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/BootstrapFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,11 +21,11 @@
*/
package org.jboss.cache.factories;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
-import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
/**
* Factory for setting up bootstrap components
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/BuddyManagerFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,8 +22,8 @@
package org.jboss.cache.factories;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Buddy manager factory
Deleted: core/branches/flat/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/CacheConfigsXmlParser.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,35 +0,0 @@
-/*
- * 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.cache.factories;
-
-import org.jboss.cache.annotations.Compat;
-
-/**
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated here for compatibility reasons. Use the class with the same name in the <tt>org.jboss.cache.config.parsing</tt> package.
- */
-@Compat
-@Deprecated
-public class CacheConfigsXmlParser extends org.jboss.cache.config.parsing.CacheConfigsXmlParser
-{
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/CommandsMetaFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/CommandsMetaFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/CommandsMetaFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,10 +23,7 @@
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.CommandsFactoryImpl;
-import org.jboss.cache.commands.OptimisticCommandsFactoryImpl;
-import org.jboss.cache.commands.PessimisticCommandsFactoryImpl;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* COnstructs commands factory
@@ -40,15 +37,6 @@
@SuppressWarnings("deprecation")
protected <T> T construct(Class<T> componentType)
{
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- return componentType.cast(new CommandsFactoryImpl());
- case OPTIMISTIC:
- return componentType.cast(new OptimisticCommandsFactoryImpl());
- case PESSIMISTIC:
- return componentType.cast(new PessimisticCommandsFactoryImpl());
- }
- throw new ConfigurationException("Unknown locking scheme " + configuration.getNodeLockingScheme());
+ return componentType.cast(new CommandsFactoryImpl());
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,9 +23,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.annotations.Inject;
/**
* Factory that creates components used internally within JBoss Cache, and also wires dependencies into the components.
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,21 +23,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.Version;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.RuntimeConfig;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
-import org.jboss.cache.factories.annotations.Destroy;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.util.BeanUtils;
import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.annotations.Destroy;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import javax.management.MBeanServerFactory;
import java.lang.reflect.Method;
@@ -189,7 +189,7 @@
s.add(BootstrapFactory.class);
s.add(BuddyManagerFactory.class);
s.add(EmptyConstructorFactory.class);
- s.add(InterceptorChainFactory.class);
+// s.add(InterceptorChainFactory.class);
s.add(RuntimeConfigAwareFactory.class);
s.add(TransactionManagerFactory.class);
s.add(ReplicationQueueFactory.class);
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/ContextMetaFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/ContextMetaFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/ContextMetaFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,12 +21,9 @@
*/
package org.jboss.cache.factories;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.factories.context.ContextFactory;
import org.jboss.cache.factories.context.MVCCContextFactory;
-import org.jboss.cache.factories.context.OptimisticContextFactory;
-import org.jboss.cache.factories.context.PessimisticContextFactory;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Responsible for creating the appropriate {@link org.jboss.cache.factories.context.ContextFactory} based on configuration used.
@@ -40,19 +37,6 @@
@SuppressWarnings("deprecation")
protected <T> T construct(Class<T> componentType)
{
- if (log.isTraceEnabled()) log.trace("Cache configuration is " + configuration.getNodeLockingScheme());
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- if (log.isTraceEnabled()) log.trace("Creating an MVCC context factory");
- return componentType.cast(new MVCCContextFactory());
- case OPTIMISTIC:
- if (log.isTraceEnabled()) log.trace("Creating an optimistic context factory");
- return componentType.cast(new OptimisticContextFactory());
- case PESSIMISTIC:
- if (log.isTraceEnabled()) log.trace("Creating a pessimistic context factory");
- return componentType.cast(new PessimisticContextFactory());
- }
- throw new ConfigurationException("Unknown configuration node locking scheme");
+ return componentType.cast(new MVCCContextFactory());
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,8 +25,6 @@
import org.jboss.cache.RegionRegistry;
import org.jboss.cache.batch.BatchContainer;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.loader.CacheLoaderManager;
@@ -37,6 +35,8 @@
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Simple factory that just uses reflection and an empty constructor of the component type.
Deleted: core/branches/flat/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,240 +0,0 @@
-/*
- * 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.cache.factories;
-
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.CustomInterceptorConfig;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
-import org.jboss.cache.interceptors.*;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-
-import java.util.List;
-
-/**
- * Factory class that builds an interceptor chain based on cache configuration.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-@DefaultFactoryFor(classes = InterceptorChain.class)
-public class InterceptorChainFactory extends ComponentFactory
-{
- /**
- * Note - this method used to return a singleton instance, and since 2.1.0 returns a new instance. The method is
- * deprecated and you should use the no-arg constructor to create a new instance of this factory.
- *
- * @return a NEW instance of this class.
- */
- @Deprecated
- public static InterceptorChainFactory getInstance()
- {
- return new InterceptorChainFactory();
- }
-
- private CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) throws IllegalAccessException, InstantiationException
- {
- CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
- if (chainedInterceptor == null)
- {
- chainedInterceptor = clazz.newInstance();
- componentRegistry.registerComponent(chainedInterceptor, clazz);
- }
- else
- {
- // wipe next/last chaining!!
- chainedInterceptor.setNext(null);
- }
- return chainedInterceptor;
- }
-
- public InterceptorChain buildInterceptorChain() throws IllegalAccessException, InstantiationException, ClassNotFoundException
- {
- boolean optimistic = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
- boolean invocationBatching = configuration.isInvocationBatchingEnabled();
- // load the icInterceptor first
- CommandInterceptor first = invocationBatching ? createInterceptor(BatchingInterceptor.class) : createInterceptor(InvocationContextInterceptor.class);
- InterceptorChain interceptorChain = new InterceptorChain(first);
-
- // add the interceptor chain to the registry first, since some interceptors may ask for it.
- componentRegistry.registerComponent(interceptorChain, InterceptorChain.class);
-
- // NOW add the ICI if we are using batching!
- if (invocationBatching)
- interceptorChain.appendIntereceptor(createInterceptor(InvocationContextInterceptor.class));
-
- // load the cache management interceptor next
- if (configuration.getExposeManagementStatistics())
- interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtInterceptor.class));
-
- // load the tx interceptor
- interceptorChain.appendIntereceptor(createInterceptor(optimistic ? OptimisticTxInterceptor.class : TxInterceptor.class));
-
- if (configuration.isUseLazyDeserialization())
- interceptorChain.appendIntereceptor(createInterceptor(MarshalledValueInterceptor.class));
- interceptorChain.appendIntereceptor(createInterceptor(NotificationInterceptor.class));
-
- switch (configuration.getCacheMode())
- {
- case REPL_SYNC:
- case REPL_ASYNC:
- interceptorChain.appendIntereceptor(optimistic ? createInterceptor(OptimisticReplicationInterceptor.class) : createInterceptor(ReplicationInterceptor.class));
- break;
- case INVALIDATION_SYNC:
- case INVALIDATION_ASYNC:
- interceptorChain.appendIntereceptor(createInterceptor(InvalidationInterceptor.class));
- break;
- case LOCAL:
- //Nothing...
- }
-
- if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC)
- {
- // if MVCC, then the CLI or AI must come before the MVCCLI.
- if (configuration.isUsingCacheLoaders())
- {
- if (configuration.getCacheLoaderConfig().isPassivation())
- {
- interceptorChain.appendIntereceptor(createInterceptor(ActivationInterceptor.class));
- }
- else
- {
- interceptorChain.appendIntereceptor(createInterceptor(CacheLoaderInterceptor.class));
- }
- }
- interceptorChain.appendIntereceptor(createInterceptor(MVCCLockingInterceptor.class));
- }
- else if (configuration.getNodeLockingScheme() == NodeLockingScheme.PESSIMISTIC)
- {
- interceptorChain.appendIntereceptor(createInterceptor(PessimisticLockInterceptor.class));
- }
-
- if (configuration.isUsingCacheLoaders())
- {
- if (configuration.getCacheLoaderConfig().isPassivation())
- {
- if (configuration.getNodeLockingScheme() != NodeLockingScheme.MVCC)
- {
- interceptorChain.appendIntereceptor(createInterceptor(LegacyActivationInterceptor.class));
- interceptorChain.appendIntereceptor(createInterceptor(LegacyPassivationInterceptor.class));
- }
- else
- {
- interceptorChain.appendIntereceptor(createInterceptor(PassivationInterceptor.class));
- }
- }
- else
- {
- if (configuration.getNodeLockingScheme() != NodeLockingScheme.MVCC)
- {
- interceptorChain.appendIntereceptor(createInterceptor(LegacyCacheLoaderInterceptor.class));
- interceptorChain.appendIntereceptor(createInterceptor(LegacyCacheStoreInterceptor.class));
- }
- else
- {
- interceptorChain.appendIntereceptor(createInterceptor(CacheStoreInterceptor.class));
- }
- }
- }
-
- if (configuration.isUsingBuddyReplication())
- {
- if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC)
- interceptorChain.appendIntereceptor(createInterceptor(DataGravitatorInterceptor.class));
- else
- interceptorChain.appendIntereceptor(createInterceptor(LegacyDataGravitatorInterceptor.class));
- }
-
-
- if (optimistic)
- {
- interceptorChain.appendIntereceptor(createInterceptor(OptimisticLockingInterceptor.class));
- interceptorChain.appendIntereceptor(createInterceptor(OptimisticValidatorInterceptor.class));
- interceptorChain.appendIntereceptor(createInterceptor(OptimisticCreateIfNotExistsInterceptor.class));
- }
- // eviction interceptor to come before the optimistic node interceptor
- if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
- interceptorChain.appendIntereceptor(createInterceptor(configuration.isUsingBuddyReplication() ? BuddyRegionAwareEvictionInterceptor.class : EvictionInterceptor.class));
-
- if (optimistic) interceptorChain.appendIntereceptor(createInterceptor(OptimisticNodeInterceptor.class));
- CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
- interceptorChain.appendIntereceptor(callInterceptor);
- if (log.isTraceEnabled()) log.trace("Finished building default interceptor chain.");
- buildCustomInterceptors(interceptorChain, configuration.getCustomInterceptors());
- return interceptorChain;
- }
-
- private void buildCustomInterceptors(InterceptorChain interceptorChain, List<CustomInterceptorConfig> customInterceptors)
- {
- for (CustomInterceptorConfig config : customInterceptors)
- {
- if (interceptorChain.containsInstance(config.getInterceptor())) continue;
- if (config.isFirst())
- {
- interceptorChain.addInterceptor(config.getInterceptor(), 0);
- }
- if (config.isLast()) interceptorChain.appendIntereceptor(config.getInterceptor());
- if (config.getIndex() >= 0) interceptorChain.addInterceptor(config.getInterceptor(), config.getIndex());
- if (config.getAfterClass() != null)
- {
- List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClassName(config.getAfterClass());
- if (withClassName.isEmpty())
- {
- throw new ConfigurationException("Cannot add after class: " + config.getAfterClass()
- + " as no such iterceptor exists in the default chain");
- }
- interceptorChain.addAfterInterceptor(config.getInterceptor(), withClassName.get(0).getClass());
- }
- if (config.getBeforeClass() != null)
- {
- List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClassName(config.getBeforeClass());
- if (withClassName.isEmpty())
- {
- throw new ConfigurationException("Cannot add before class: " + config.getAfterClass()
- + " as no such iterceptor exists in the default chain");
- }
- interceptorChain.addBeforeInterceptor(config.getInterceptor(), withClassName.get(0).getClass());
- }
- }
- }
-
- @Override
- protected <T> T construct(Class<T> componentType)
- {
- try
- {
- return componentType.cast(buildInterceptorChain());
- }
- catch (Exception e)
- {
- throw new ConfigurationException("Unable to build interceptor chain", e);
- }
- }
-
- public static InterceptorChainFactory getInstance(ComponentRegistry componentRegistry, Configuration configuration)
- {
- InterceptorChainFactory icf = new InterceptorChainFactory();
- icf.componentRegistry = componentRegistry;
- icf.configuration = configuration;
- return icf;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/LockManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/LockManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/LockManagerFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,11 +21,9 @@
*/
package org.jboss.cache.factories;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.MVCCLockManager;
-import org.jboss.cache.lock.NodeBasedLockManager;
-import org.jboss.cache.lock.PessimisticNodeBasedLockManager;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Creates lock managers
@@ -40,16 +38,6 @@
@SuppressWarnings("deprecation")
protected <T> T construct(Class<T> componentType)
{
- if (log.isTraceEnabled()) log.trace("Cache configuration is " + configuration.getNodeLockingScheme());
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- return componentType.cast(super.construct(MVCCLockManager.class));
- case OPTIMISTIC:
- return componentType.cast(super.construct(NodeBasedLockManager.class));
- case PESSIMISTIC:
- default:
- return componentType.cast(super.construct(PessimisticNodeBasedLockManager.class));
- }
+ return componentType.cast(super.construct(MVCCLockManager.class));
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/NodeMetaFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,11 +22,8 @@
package org.jboss.cache.factories;
import org.jboss.cache.NodeFactory;
-import org.jboss.cache.PessimisticNodeFactory;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.mvcc.MVCCNodeFactory;
-import org.jboss.cache.optimistic.OptimisticNodeFactory;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Creates node factories.
@@ -40,16 +37,6 @@
@SuppressWarnings("deprecation")
protected <T> T construct(Class<T> componentType)
{
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- return componentType.cast(new MVCCNodeFactory());
- case OPTIMISTIC:
- return componentType.cast(new OptimisticNodeFactory());
- case PESSIMISTIC:
- return componentType.cast(new PessimisticNodeFactory());
- default:
- throw new ConfigurationException("Unknown locking scheme " + configuration.getNodeLockingScheme());
- }
+ return componentType.cast(new MVCCNodeFactory());
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/RegionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/RegionManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/RegionManagerFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,10 +21,9 @@
*/
package org.jboss.cache.factories;
-import org.jboss.cache.LegacyRegionManagerImpl;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Creates region managers
@@ -38,12 +37,6 @@
@SuppressWarnings("deprecation")
protected <T> T construct(Class<T> componentType)
{
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- return componentType.cast(new RegionManagerImpl());
- default:
- return componentType.cast(new LegacyRegionManagerImpl());
- }
+ return componentType.cast(new RegionManagerImpl());
}
}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/ReplicationQueueFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/ReplicationQueueFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/ReplicationQueueFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,8 +22,8 @@
package org.jboss.cache.factories;
import org.jboss.cache.cluster.ReplicationQueue;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* RPCManager factory
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/RuntimeConfigAwareFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,10 +22,10 @@
package org.jboss.cache.factories;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.RuntimeConfig;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.util.BeanUtils;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
import java.lang.reflect.Method;
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,13 +21,11 @@
*/
package org.jboss.cache.factories;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.statetransfer.DefaultStateTransferGenerator;
import org.jboss.cache.statetransfer.DefaultStateTransferIntegrator;
-import org.jboss.cache.statetransfer.LegacyStateTransferGenerator;
-import org.jboss.cache.statetransfer.LegacyStateTransferIntegrator;
import org.jboss.cache.statetransfer.StateTransferGenerator;
import org.jboss.cache.statetransfer.StateTransferIntegrator;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Factory class able to create {@link org.jboss.cache.statetransfer.StateTransferGenerator} and
@@ -48,23 +46,11 @@
{
if (componentType.equals(StateTransferIntegrator.class))
{
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- return componentType.cast(new DefaultStateTransferIntegrator());
- default:
- return componentType.cast(new LegacyStateTransferIntegrator());
- }
+ return componentType.cast(new DefaultStateTransferIntegrator());
}
else
{
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- return componentType.cast(new DefaultStateTransferGenerator());
- default:
- return componentType.cast(new LegacyStateTransferGenerator());
- }
+ return componentType.cast(new DefaultStateTransferGenerator());
}
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/StateTransferManagerFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,10 +21,9 @@
*/
package org.jboss.cache.factories;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
-import org.jboss.cache.statetransfer.LegacyStateTransferManager;
import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
/**
* Constructs {@link org.jboss.cache.statetransfer.StateTransferManager} instances.
@@ -38,12 +37,6 @@
@SuppressWarnings("deprecation")
protected <T> T construct(Class<T> componentType)
{
- switch (configuration.getNodeLockingScheme())
- {
- case MVCC:
- return componentType.cast(new DefaultStateTransferManager());
- default:
- return componentType.cast(new LegacyStateTransferManager());
- }
+ return componentType.cast(new DefaultStateTransferManager());
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/TransactionManagerFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,10 +21,10 @@
*/
package org.jboss.cache.factories;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.transaction.BatchModeTransactionManager;
import org.jboss.cache.transaction.TransactionManagerLookup;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
import javax.transaction.TransactionManager;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/context/OptimisticContextFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,47 +0,0 @@
-/*
- * 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.cache.factories.context;
-
-import org.jboss.cache.transaction.OptimisticTransactionContext;
-import org.jboss.cache.transaction.TransactionContext;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-
-/**
- * Constructs contexts for optimistic locking
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed when optimistic locking is removed.
- */
-@Deprecated
-@SuppressWarnings("deprecation")
-public class OptimisticContextFactory extends PessimisticContextFactory
-{
- @Override
- public TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException
- {
- return new OptimisticTransactionContext(tx);
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,63 +0,0 @@
-/*
- * 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.cache.factories.context;
-
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.LegacyInvocationContext;
-import org.jboss.cache.transaction.PessimisticTransactionContext;
-import org.jboss.cache.transaction.TransactionContext;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-
-/**
- * Constructs contexts for pessimistic locking
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed when pessimistic locking is removed.
- */
-@Deprecated
-@SuppressWarnings("deprecation")
-public class PessimisticContextFactory implements ContextFactory
-{
- DataContainer container;
-
- @Inject
- public void inject(DataContainer container)
- {
- this.container = container;
- }
-
- public InvocationContext createInvocationContext()
- {
- return new LegacyInvocationContext(container);
- }
-
- public TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException
- {
- return new PessimisticTransactionContext(tx);
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -30,7 +30,6 @@
import org.jboss.cache.commands.read.GetKeyValueCommand;
import org.jboss.cache.commands.read.GetKeysCommand;
import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.MoveCommand;
@@ -39,12 +38,12 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -246,17 +245,6 @@
}
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- Object retval = invokeNextInterceptor(ctx, command);
- if (inTransaction())
- {
- prepareCacheLoader(ctx);
- }
- return retval;
- }
-
private boolean inTransaction() throws SystemException
{
return txMgr != null && txMgr.getTransaction() != null;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -28,13 +28,13 @@
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import org.jgroups.Address;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,12 +22,12 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.annotations.Inject;
import javax.transaction.Status;
import javax.transaction.SystemException;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,8 +24,8 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.batch.BatchContainer;
import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.starobrno.factories.annotations.Inject;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,7 +24,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Inject;
/**
* A subclass of EvictionInterceptor that is aware of and able to deal with buddy regions.
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
@@ -40,11 +39,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Configuration;
-import static org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -54,6 +48,10 @@
import org.jboss.cache.mvcc.NullMarkerNode;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import java.util.Collections;
import java.util.HashMap;
@@ -235,10 +233,6 @@
@Override
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- if (configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC && command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), null, false, false, false, false, false, false, false);
- }
return invokeNextInterceptor(ctx, command);
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -28,10 +28,10 @@
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
+import org.jboss.starobrno.factories.annotations.Inject;
import java.util.HashMap;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -30,7 +30,6 @@
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -40,10 +39,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.SkipCheckChainedInterceptor;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -51,9 +46,11 @@
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import javax.transaction.SystemException;
-import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.ArrayList;
import java.util.HashMap;
@@ -102,7 +99,7 @@
{
// this should only happen after the CacheLoaderManager has started, since the CacheLoaderManager only creates the CacheLoader instance in its @Start method.
loader = loaderManager.getCacheLoader();
- optimistic = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
+ optimistic = false;
this.setStatisticsEnabled(configuration.getExposeManagementStatistics());
}
@@ -200,12 +197,6 @@
}
@Override
- protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- return handlePrepareCommand(ctx, command);
- }
-
- @Override
protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
if (inTransaction())
@@ -319,30 +310,7 @@
private void storeInternalState(Set<Fqn> affectedFqns, InvocationContext ctx) throws Exception
{
- if (configuration.getNodeLockingScheme().isVersionedScheme())
- {
- // we need to suspend any txs here since they would be in the tx-committed state and if the loader attempts to
- // use JTA (E.g., a JDBC CL using connections from a tx aware datasource) it will fail since the tx is in an
- // illegal state to perform writes. See JBCACHE-1408.
- Transaction tx = txMgr.suspend();
- try
- {
- for (Fqn f : affectedFqns)
- {
- // NOT going to store tombstones!!
- NodeSPI n = ctx.lookUpNode(f);
- if (n != null && !n.isDeleted())
- {
- Map internalState = n.getInternalState(false);
- loader.put(f, internalState);
- }
- }
- }
- finally
- {
- txMgr.resume(tx);
- }
- }
+ // no op
}
private void recursiveMove(Fqn fqn, Fqn newFqn) throws Exception
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -26,7 +26,6 @@
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -36,10 +35,9 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.factories.annotations.Start;
import javax.transaction.Transaction;
@@ -61,7 +59,7 @@
@Start
protected void start()
{
- notOptimisticLocking = configuration.getNodeLockingScheme() != NodeLockingScheme.OPTIMISTIC;
+ notOptimisticLocking = true;
}
@Override
@@ -72,13 +70,6 @@
}
@Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- if (trace) log.trace("Suppressing invocation of method handleOptimisticPrepareCommand.");
- return null;
- }
-
- @Override
public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
if (trace) log.trace("Suppressing invocation of method handleCommitCommand.");
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,39 +21,13 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.mvcc.MVCCNodeHelper;
-import org.jboss.cache.mvcc.ReadCommittedNode;
-
/**
* MVCC specific version of the LegacyDataGravitatorInterceptor
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 3.0
*/
-public class DataGravitatorInterceptor extends LegacyDataGravitatorInterceptor
+public class DataGravitatorInterceptor
{
- MVCCNodeHelper helper;
-
- @Inject
- public void injectMvccNodeHelper(MVCCNodeHelper helper)
- {
- this.helper = helper;
- }
-
- @Override
- protected boolean nodeDoesNotExist(InvocationContext ctx, Fqn fqn)
- {
- ReadCommittedNode node = (ReadCommittedNode) ctx.lookUpNode(fqn);
- return node == null || node.isNullNode();
- }
-
-
- @Override
- protected void wrapIfNeeded(InvocationContext ctx, Fqn fqnToWrap) throws InterruptedException
- {
- helper.wrapNodeForReading(ctx, fqnToWrap, true);
- }
+ // DO NOTHING
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -36,10 +36,9 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.eviction.EvictionEvent;
-import static org.jboss.cache.eviction.EvictionEvent.Type.*;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import static org.jboss.starobrno.eviction.EvictionEvent.Type.*;
+import org.jboss.starobrno.factories.annotations.Inject;
/**
* Eviction Interceptor.
@@ -241,7 +240,7 @@
return retVal;
}
- private void registerEvictionEventToRegionManager(Fqn fqn, EvictionEvent.Type type, int elementDifference, Region region)
+ private void registerEvictionEventToRegionManager(Fqn fqn, org.jboss.starobrno.eviction.EvictionEvent.Type type, int elementDifference, Region region)
{
//we do not trigger eviction events for resident nodes
if (dataContainer.isResident(fqn)) return;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,103 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-
-/**
- * Class representing an interceptor.
- *
- * @author Bela Ban
- * @version $Id$
- * @deprecated this will be removed in a 3.x release. Please use {@link org.jboss.cache.interceptors.base.CommandInterceptor} instead, since it provides strongly typed callbacks which are more efficient.
- */
-@Deprecated
-public abstract class Interceptor extends CommandInterceptor
-{
- protected CacheSPI<?, ?> cache;
- protected boolean trace;
-
- public void setCache(CacheSPI cache)
- {
- this.cache = cache;
- }
-
- @Start
- private void start()
- {
- // for backward compatibility, this must only be done when the cache starts.
- setCache(cache);
- }
-
- @Inject
- private void injectDependencies(CacheSPI cache)
- {
- this.cache = cache;
- }
-
- /**
- * Using this method call for forwarding a call in the chain is not redable and error prone in the case of interceptors
- * extending other interceptors. This metod rather refers to interceptor doing its business operations rather than
- * delegating to the nextInterceptor interceptor in chain. For delegation please use {@link #nextInterceptor(org.jboss.cache.InvocationContext)}
- */
- public Object invoke(InvocationContext ctx) throws Throwable
- {
- return handleDefault(ctx, null);
- }
-
- /**
- * Forwards the call to the nextInterceptor interceptor in the chain.
- * This is here for backward compatibility.
- */
- public Object nextInterceptor(InvocationContext ctx) throws Throwable
- {
- return invokeNextInterceptor(ctx, null);
- }
-
- @Override
- public String toString()
- {
- return getClass().getName()
- + "{next: "
- + (getNext() == null ? null : getNext().getClass())
- + "}";
- }
-
- @Override
- @SuppressWarnings("deprecation")
- public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
- {
- if (command != null) //call originated from a command's accept() method.
- {
- return invoke(ctx);
- }
-
- //this means that another Interceptor called this method, we have to dispatch the call to the appropriate method. Probably called directly using super.invoke().
- command = ctx.getCommand();
- return command.acceptVisitor(ctx, getNext());
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,36 +1,36 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.interceptors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.util.CachePrinter;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import java.util.ArrayList;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -27,33 +27,24 @@
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.legacy.write.VersionedInvalidateCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -94,7 +85,7 @@
@Start
private void initTxMap()
{
- optimistic = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
+ optimistic = false;
if (optimistic) txMods = new ConcurrentHashMap<GlobalTransaction, List<WriteCommand>>();
this.setStatisticsEnabled(configuration.getExposeManagementStatistics());
}
@@ -180,29 +171,6 @@
}
@Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- Object retval = invokeNextInterceptor(ctx, command);
- Transaction tx = ctx.getTransaction();
- if (tx != null)
- {
- // here we just record the modifications but actually do the invalidate in commit.
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionContext transactionContext = ctx.getTransactionContext();
- if (transactionContext == null)
- throw new IllegalStateException("cannot find transaction transactionContext for " + gtx);
-
- if (transactionContext.hasModifications())
- {
- List<WriteCommand> mods = new ArrayList<WriteCommand>(transactionContext.getModifications());
- if (transactionContext.hasLocalModifications()) mods.removeAll(transactionContext.getLocalModifications());
- txMods.put(gtx, mods);
- }
- }
- return retval;
- }
-
- @Override
public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
Object retval = invokeNextInterceptor(ctx, command);
@@ -281,8 +249,7 @@
{
try
{
- TransactionWorkspace workspace = optimistic ? getWorkspace(ctx) : null;
- for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
+ for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, null, defaultSynchronous, ctx);
}
catch (Throwable t)
{
@@ -369,8 +336,9 @@
}
- protected void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace workspace, boolean synchronous, InvocationContext ctx) throws Throwable
+ protected void invalidateAcrossCluster(Fqn fqn, Object workspace, boolean synchronous, InvocationContext ctx) throws Throwable
{
+ /*
if (!isLocalModeForced(ctx))
{
// increment invalidations counter if statistics maintained
@@ -382,6 +350,7 @@
// voila, invalidated!
replicateCall(ctx, command, synchronous, ctx.getOptionOverrides());
}
+ */
}
private void incrementInvalidations()
@@ -389,28 +358,6 @@
if (getStatisticsEnabled()) invalidations++;
}
- protected DataVersion getNodeVersion(TransactionWorkspace w, Fqn f)
- {
- if (w == null) return null;
- WorkspaceNode wn = w.getNode(f);
- if (wn == null) return null; // JBCACHE-1297
- DataVersion v = wn.getVersion();
-
- if (wn.isVersioningImplicit())
- {
- // then send back an incremented version
- v = ((DefaultDataVersion) v).increment();
- }
-
- return v;
- }
-
- protected TransactionWorkspace getWorkspace(InvocationContext ctx)
- {
- OptimisticTransactionContext entry = (OptimisticTransactionContext) ctx.getTransactionContext();
- return entry.getTransactionWorkSpace();
- }
-
@ManagedOperation
public void resetStatistics()
{
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -26,7 +26,6 @@
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -35,10 +34,10 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.annotations.Inject;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
@@ -119,12 +118,6 @@
}
@Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- return handleAll(ctx, command, command.getGlobalTransaction(), true);
- }
-
- @Override
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
{
return handleAll(ctx, command, null, false);
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,417 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Modification;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.AbstractVisitor;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.jmx.annotations.ManagedOperation;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionContext;
-
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Loads nodes that don't exist at the time of the call into memory from the CacheLoader.
- * If the nodes were evicted earlier then we remove them from the cache loader after
- * their attributes have been initialized and their children have been loaded in memory.
- *
- * @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
- * @version $Id$
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class LegacyActivationInterceptor extends LegacyCacheLoaderInterceptor
-{
-
- protected TransactionManager txMgr = null;
- private long activations = 0;
- ActivationModificationsBuilder builder;
-
- /**
- * List<Transaction> that we have registered for
- */
- protected ConcurrentHashMap transactions = new ConcurrentHashMap(16);
- protected static final Object NULL = new Object();
-
- public LegacyActivationInterceptor()
- {
- isActivation = true;
- useCacheStore = false;
- }
-
- @Inject
- public void injectTransactionManager(TransactionManager txMgr)
- {
- this.txMgr = txMgr;
- }
-
- @Start
- public void createModificationsBuilder()
- {
- builder = new ActivationModificationsBuilder();
- }
-
- @Override
- public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- Object returnValue = super.visitClearDataCommand(ctx, command);
- if (trace)
- log.trace("This is a remove data operation; removing the data from the loader, no activation processing needed.");
- loader.removeData(command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- Object returnValue = super.visitRemoveNodeCommand(ctx, command);
- if (trace)
- log.trace("This is a remove operation; removing the node from the loader, no activation processing needed.");
- loader.remove(command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- Object returnValue = super.visitGetChildrenNamesCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- Object returnValue = super.visitGetKeysCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- Object returnValue = super.visitGetNodeCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- Object returnValue = super.visitGetKeyValueCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- return visitPutKeyValueCommand(ctx, command);
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- Object returnValue = super.visitPutKeyValueCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- Object returnValue = super.visitPutDataMapCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- Object returnValue = super.visitRemoveKeyCommand(ctx, command);
- removeNodeFromCacheLoader(ctx, command.getFqn());
- return returnValue;
- }
-
- @Override
- public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- Object returnValue = super.visitMoveCommand(ctx, command);
- if (trace)
- log.trace("This is a move operation; removing the FROM node from the loader, no activation processing needed.");
- loader.remove(command.getFqn());
- removeNodeFromCacheLoader(ctx, command.getFqn().getParent());
- removeNodeFromCacheLoader(ctx, command.getTo());
- return returnValue;
- }
-
-
- /**
- * Remove the node from the cache loader if it exists in memory,
- * its attributes have been initialized, its children have been loaded,
- * AND it was found in the cache loader (nodeLoaded = true).
- * Then notify the listeners that the node has been activated.
- */
- private void removeNodeFromCacheLoader(InvocationContext ctx, Fqn fqn) throws Throwable
- {
- NodeSPI n;
- if (((n = dataContainer.peek(fqn, true, false)) != null) && n.isDataLoaded() && loader.exists(fqn))
- {
- // node not null and attributes have been loaded?
- if (!n.getChildrenDirect().isEmpty())
- {
- boolean result = childrenLoaded(n);
- if (result)
- {
- log.debug("children all initialized");
- remove(fqn);
- }
- }
- else if (loaderNoChildren(fqn))
- {
- if (log.isDebugEnabled()) log.debug("no children " + n);
- remove(fqn);
- }
- }
- }
-
- private static boolean childrenLoaded(NodeSPI<?, ?> node)
- {
- if (!node.isChildrenLoaded())
- {
- return false;
- }
- for (NodeSPI child : node.getChildrenDirect())
- {
- if (!child.isDataLoaded())
- {
- return false;
- }
- }
- return true;
-
- }
-
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- Object retval = invokeNextInterceptor(ctx, command);
- if (inTransaction())
- {
- prepareCacheLoader(ctx);
- }
- return retval;
- }
-
- private boolean inTransaction() throws SystemException
- {
- return txMgr != null && txMgr.getTransaction() != null;
- }
-
- @Override
- public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
- {
- Object retval = invokeNextInterceptor(ctx, command);
- if (inTransaction())
- {
- prepareCacheLoader(ctx);
- }
- return retval;
- }
-
- private void remove(Fqn fqn) throws Exception
- {
- loader.remove(fqn);
- if (getStatisticsEnabled()) activations++;
- }
-
- /**
- * Returns true if the loader indicates no children for this node.
- * Return false on error.
- */
- private boolean loaderNoChildren(Fqn fqn)
- {
- try
- {
- Set childrenNames = loader.getChildrenNames(fqn);
- return (childrenNames == null);
- }
- catch (Exception e)
- {
- log.error("failed getting the children names for " + fqn + " from the cache loader", e);
- return false;
- }
- }
-
- public long getActivations()
- {
- return activations;
- }
-
- private void prepareCacheLoader(InvocationContext ctx) throws Throwable
- {
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionContext tCtx = ctx.getTransactionContext();
- if (tCtx == null)
- {
- throw new Exception("tCtx for transaction " + gtx + " not found in transaction table");
- }
- List<Modification> cacheLoaderModifications = new ArrayList<Modification>();
-
- builder.visitCollection(ctx, tCtx.getModifications());
- if (cacheLoaderModifications.size() > 0)
- {
- loader.prepare(gtx, cacheLoaderModifications, false);
- }
- }
-
- public class ActivationModificationsBuilder extends AbstractVisitor
- {
-
- private List<Modification> cacheLoaderModifications = new ArrayList<Modification>();
-
- private int txActs = 0;
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand removeNodeCommand) throws Throwable
- {
- Modification mod = new Modification(Modification.ModificationType.REMOVE_NODE, removeNodeCommand.getFqn());
- cacheLoaderModifications.add(mod);
- return null;
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- Fqn fqn = command.getFqn();
- handlePutCommand(ctx, fqn);
- return null;
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- Fqn fqn = command.getFqn();
- handlePutCommand(ctx, fqn);
- return null;
- }
-
- // On the way out, remove the node from the cache loader.
- // Only remove the node if it exists in memory, its attributes have
- // been initialized, its children have been loaded
- // AND it was found in the cache loader (nodeLoaded = true).
- // Then notify the listeners that the node has been activated.
- private void handlePutCommand(InvocationContext ctx, Fqn fqn)
- throws Exception
- {
- if (fqn != null && dataContainer.peek(fqn, false, false) != null && loader.exists(fqn))
- {
- NodeSPI n = dataContainer.peek(fqn, true, false);// don't load
- // node not null and attributes have been loaded?
- if (n != null && n.isDataLoaded())
- {
- // has children?
- boolean result = childrenLoaded(n);
- if (!n.getChildrenDirect().isEmpty() && result)
- {
- // children have been loaded, remove the node
- addRemoveMod(ctx, cacheLoaderModifications, fqn, n.getDataDirect());
- txActs++;
- }
- // doesn't have children, check the cache loader
- else if (loaderNoChildren(fqn))
- {
- addRemoveMod(ctx, cacheLoaderModifications, fqn, n.getDataDirect());
- txActs++;
- }
- }
- }
- }
-
- private boolean loaderNoChildren(Fqn fqn) throws Exception
- {
- return loader.getChildrenNames(fqn) != null;
- }
-
- private void addRemoveMod(InvocationContext ctx, List<Modification> l, Fqn fqn, Map data)
- {
- Modification mod = new Modification(Modification.ModificationType.REMOVE_NODE, fqn);
- l.add(mod);
- notifier.notifyNodeActivated(fqn, false, data, ctx);
- }
-
- public List<Modification> getCacheLoaderModifications()
- {
- return cacheLoaderModifications;
- }
-
- public int getTxActs()
- {
- return txActs;
- }
-
- }
-
- @ManagedOperation
- public void resetStatistics()
- {
- super.resetStatistics();
- activations = 0;
- }
-
- @ManagedOperation
- public Map<String, Object> dumpStatistics()
- {
- Map<String, Object> retval = super.dumpStatistics();
- if (retval == null)
- {
- retval = new HashMap<String, Object>();
- }
- retval.put("Activations", activations);
- return retval;
- }
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,610 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Configuration;
-import static org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
-import org.jboss.cache.jmx.annotations.ManagedAttribute;
-import org.jboss.cache.jmx.annotations.ManagedOperation;
-import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.lock.LockType;
-import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.transaction.TransactionContext;
-import org.jboss.cache.transaction.TransactionTable;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Loads nodes that don't exist at the time of the call into memory from the CacheLoader
- *
- * @author Bela Ban
- * @version $Id$
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class LegacyCacheLoaderInterceptor extends JmxStatsCommandInterceptor
-{
- private long cacheLoads = 0;
- private long cacheMisses = 0;
- private CacheLoaderManager clm;
- private LockManager lockManager;
-
- protected TransactionTable txTable = null;
- protected CacheLoader loader;
- protected DataContainer dataContainer;
- protected Notifier notifier;
-
- protected boolean isActivation = false;
- protected boolean usingVersionedInvalidation = false;
-
-
- /**
- * True if CacheStoreInterceptor is in place.
- * This allows us to skip loading keys for remove(Fqn, key) and put(Fqn, key).
- * It also affects removal of node data and listing children.
- */
- protected boolean useCacheStore = true;
-
- @Inject
- protected void injectDependencies(TransactionTable txTable, CacheLoaderManager clm, Configuration configuration,
- DataContainer dataContainer, LockManager lockManager, Notifier notifier)
- {
- this.txTable = txTable;
- this.clm = clm;
- CacheMode mode = configuration.getCacheMode();
- usingVersionedInvalidation = configuration.getNodeLockingScheme().isVersionedScheme() && mode.isInvalidation();
- this.dataContainer = dataContainer;
- this.lockManager = lockManager;
- this.notifier = notifier;
- }
-
- @Start
- protected void startInterceptor()
- {
- loader = clm.getCacheLoader();
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- if (command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), null, true, true, false, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- if (command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore, !useCacheStore, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- return visitPutKeyValueCommand(ctx, command);
- }
-
- @Override
- public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- if (command.getFqn() != null)
- {
- if (command.getTo() != null)
- {
- loadIfNeeded(ctx, command.getTo(), null, false, false, true, ctx.getTransactionContext(), false, true, false);
- }
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionContext(), true, true, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- if (command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
-
- @Override
- public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- if (command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionContext(), false, false, !usingVersionedInvalidation);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- Fqn fqn = command.getFqn();
- if (fqn != null)
- {
- loadIfNeeded(ctx, fqn, null, false, false, false, ctx.getTransactionContext(), false, false, true);
- NodeSPI n = dataContainer.peek(fqn, true, true);
- loadChildren(fqn, n, false, false, ctx);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
-
- @Override
- public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- if (command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- if (command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- // clean up nodesCreated map
- if (trace) log.trace("Removing temporarily created nodes from treecache");
-
- // this needs to be done in reverse order.
- List list = ctx.getTransactionContext().getDummyNodesCreatedByCacheLoader();
- if (list != null && list.size() > 0)
- {
- ListIterator i = list.listIterator(list.size());
- while (i.hasPrevious())
- {
- Fqn fqn = (Fqn) i.previous();
- try
- {
- dataContainer.evict(fqn, false);
- }
- catch (CacheException e)
- {
- if (trace) log.trace("Unable to evict node " + fqn, e);
- }
- }
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- if (configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC && command.getFqn() != null)
- {
- loadIfNeeded(ctx, command.getFqn(), null, false, false, false, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- if (command.getFqn() != null && !useCacheStore)
- {
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- Fqn fqn = command.getFqn();
- if (fqn != null && !useCacheStore)
- {
- loadIfNeeded(ctx, fqn, null, false, true, false, ctx.getTransactionContext(), false, false, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireLock, TransactionContext transactionContext, boolean recursive, boolean isMove, boolean bypassLoadingData) throws Throwable
- {
- NodeSPI n = dataContainer.peek(fqn, true, true);
- Object lockOwner = lockManager.getLockOwner(ctx);
- boolean needLock = n != null && !lockManager.ownsLock(fqn, lockOwner);
- boolean mustLoad = false;
- try
- {
- if (needLock)
- {
- if (!lockManager.lock(n, LockType.READ, lockOwner))
- throw new TimeoutException("Unable to acquire lock on " + fqn + ". Lock info: " + lockManager.printLockInfo(n));
- }
- mustLoad = mustLoad(n, key, allKeys || isMove);
- }
- finally
- {
- if (needLock) lockManager.unlock(n, lockOwner);
- }
-
- if (trace)
- {
- log.trace("load element " + fqn + " mustLoad=" + mustLoad);
- }
- if (mustLoad)
- {
- if (initNode)
- {
- n = createTempNode(fqn, transactionContext);
- }
-
- // Only attempt to acquire this lock if we need to - i.e., if
- // the lock hasn't already been acquired by the Lock
- // interceptor. CRUD methods (put, remove) would have acquired
- // this lock - even if the node is not in memory and needs to be
- // loaded. Non-CRUD methods (put) would NOT have acquired this
- // lock so if we are to load the node from cache loader, we need
- // to acquire a write lock here. as a 'catch-all', DO NOT
- // attempt to acquire a lock here *anyway*, even for CRUD
- // methods - this leads to a deadlock when you have threads
- // simultaneously trying to create a node. See
- // org.jboss.cache.loader.deadlock.ConcurrentCreationDeadlockTest
- // - Manik Surtani (21 March 2006)
- if (acquireLock)
- {
- lock(fqn, LockType.WRITE, false, ctx);// non-recursive for now
- }
-
-// if (!initNode && !wasRemovedInTx(fqn, ctx.getGlobalTransaction()))
- if (!wasRemovedInTx(fqn, ctx))
- {
- if (bypassLoadingData)
- {
- if (n == null && loader.exists(fqn))
- {
- // just create a dummy node in memory
- n = createTempNode(fqn, transactionContext);
- }
- }
- else
- {
- n = loadNode(ctx, fqn, n, transactionContext);
- }
- }
- }
-
- // The complete list of children aren't known without loading them
- if (recursive)
- {
- loadChildren(fqn, n, recursive, isMove, ctx);
- }
- }
-
- /**
- * Load the children.
- *
- * @param node may be null if the node was not found.
- * @param ctxt
- */
- private void loadChildren(Fqn fqn, NodeSPI node, boolean recursive, boolean isMove, InvocationContext ctxt) throws Throwable
- {
-
- if (node != null && node.isChildrenLoaded())
- {
- if (trace) log.trace("Children already loaded!");
- return;
- }
- Set childrenNames;
- try
- {
- childrenNames = loader.getChildrenNames(fqn);
- }
- catch (Exception e)
- {
- if (log.isInfoEnabled()) log.info("Cache loader was unable to load state", e);
- // return!
- return;
- }
-
- if (trace)
- {
- log.trace("load children " + fqn + " children=" + childrenNames);
- }
-
- // For getChildrenNames null means no children
- if (childrenNames == null)
- {
- if (node != null)
- {
- if (useCacheStore)
- {
- node.removeChildrenDirect();//getChildrenMapDirect().clear();
- }
- node.setChildrenLoaded(true);
- }
- return;
- }
-
- // Create if node had not been created already
- if (node == null)
- {
- node = createNodes(fqn, null);// dont care about local transactions
- }
-
- // Create one DataNode per child, mark as UNINITIALIZED
- for (Object name : childrenNames)
- {
- Fqn childFqn = Fqn.fromElements(name);// this is a RELATIVE Fqn!!
-
- // create child if it didn't exist
- NodeSPI child = node.addChildDirect(childFqn);
- if ((isMove || isActivation) && recursive)
- {
- // load data for children as well!
- child.setInternalState(loader.get(child.getFqn()));
- child.setDataLoaded(true);
- }
-
- if (recursive)
- {
- loadChildren(child.getFqn(), child, true, isMove, ctxt);
- }
- }
- lock(fqn, recursive ? LockType.WRITE : LockType.READ, true, ctxt);// recursive=true: lock entire subtree
- node.setChildrenLoaded(true);
- }
-
- private boolean mustLoad(NodeSPI n, Object key, boolean allKeys)
- {
- if (n == null)
- {
- if (trace) log.trace("must load, node null");
- return true;
- }
-
- // check this first!!!
- if (!n.isValid() && configuration.getNodeLockingScheme().isVersionedScheme())
- {
- // attempt to load again; this only happens if we have tombstones lying around, or we are using invalidation.
- if (trace) log.trace("loading again from cache loader since in-memory node is marked as invalid");
- return true;
- }
-
- // JBCACHE-1172 Skip single-key optimization if request needs all keys
- if (!allKeys)
- {
- // if we are not looking for a specific key don't bother loading!
- if (key == null)
- {
- if (trace) log.trace("don't load, key requested is null");
- return false;
- }
- if (n.getKeysDirect().contains(key))
- {
- if (trace) log.trace("don't load, already have necessary key in memory");
- return false;
- }
- }
- if (!n.isDataLoaded())
- {
- if (trace) log.trace("must Load, uninitialized");
- return true;
- }
- return false;
- }
-
- protected void lock(Fqn fqn, LockType lockType, boolean recursive, InvocationContext ctx) throws Throwable
- {
- if (configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC) return;
-
- if (recursive)
- lockManager.lockAllAndRecord(fqn, lockType, ctx);
- else
- lockManager.lockAndRecord(fqn, lockType, ctx);
- }
-
- /**
- * Returns true if the FQN or parent was removed during the current
- * transaction.
- * This is O(N) WRT to the number of modifications so far.
- */
- private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx)
- {
- TransactionContext transactionContext = ctx.getTransactionContext();
- if (transactionContext == null) return false;
-
- for (WriteCommand txCacheCommand : transactionContext.getModifications())
- {
- if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(txCacheCommand.getFqn())) return true;
- }
- return false;
- }
-
- /**
- * Loads a node from disk; if it exists creates parent TreeNodes.
- * If it doesn't exist on disk but in memory, clears the
- * uninitialized flag, otherwise returns null.
- */
- private NodeSPI loadNode(InvocationContext ctx, Fqn fqn, NodeSPI n, TransactionContext transactionContext) throws Exception
- {
- if (trace) log.trace("loadNode " + fqn);
- Map nodeData = loadData(fqn);
- if (nodeData != null)
- {
- if (trace) log.trace("Node data is not null, loading");
-
- notifier.notifyNodeLoaded(fqn, true, Collections.emptyMap(), ctx);
- if (isActivation)
- {
- notifier.notifyNodeActivated(fqn, true, Collections.emptyMap(), ctx);
- }
-
- n = createNodes(fqn, transactionContext);
-// n.clearDataDirect();
- n.setInternalState(nodeData);
-
- // set this node as valid?
- if (usingVersionedInvalidation) n.setValid(true, false);
-
- notifier.notifyNodeLoaded(fqn, false, nodeData, ctx);
- if (isActivation)
- {
- notifier.notifyNodeActivated(fqn, false, nodeData, ctx);
- }
- }
- if (n != null && !n.isDataLoaded())
- {
- if (trace) log.trace("Setting dataLoaded to true");
- n.setDataLoaded(true);
- }
- return n;
- }
-
- /**
- * Creates a new memory node in preparation for storage.
- */
- private NodeSPI createTempNode(Fqn fqn, TransactionContext transactionContext) throws Exception
- {
- NodeSPI n = createNodes(fqn, transactionContext);
- n.setDataLoaded(false);
- if (trace)
- {
- log.trace("createTempNode n " + n);
- }
- return n;
- }
-
- @SuppressWarnings("unchecked")
- private NodeSPI<?, ?> createNodes(Fqn fqn, TransactionContext transactionContext) throws Exception
- {
- Object[] results = dataContainer.createNodes(fqn);
- List<NodeSPI<?, ?>> createdNodes = (List<NodeSPI<?, ?>>) results[0];
-
- NodeSPI lastCreated = null;
- for (NodeSPI node : createdNodes)
- {
- node.setDataLoaded(false);
- if (transactionContext != null)
- {
- transactionContext.addDummyNodeCreatedByCacheLoader(node.getFqn());
- }
- lastCreated = node;
- }
-
- // mark the leaf node as data loaded since that is what we are doing in this interceptor.
- if (lastCreated != null) lastCreated.setDataLoaded(true);
-
- // regardless of whether the last node was created, return it.
- return (NodeSPI) results[1];
- }
-
- private Map loadData(Fqn fqn) throws Exception
- {
-
- Map nodeData = loader.get(fqn);
- boolean nodeExists = (nodeData != null);
- if (trace) log.trace("nodeExists " + nodeExists);
-
- if (getStatisticsEnabled())
- {
- if (nodeExists)
- {
- cacheLoads++;
- }
- else
- {
- cacheMisses++;
- }
- }
- return nodeData;
- }
-
- @ManagedAttribute(description = "number of cache loader node loads")
- public long getCacheLoaderLoads()
- {
- return cacheLoads;
- }
-
- @ManagedAttribute(description = "number of cache loader node misses")
- public long getCacheLoaderMisses()
- {
- return cacheMisses;
- }
-
- @ManagedOperation
- public void resetStatistics()
- {
- cacheLoads = 0;
- cacheMisses = 0;
- }
-
- @ManagedOperation
- public Map<String, Object> dumpStatistics()
- {
- Map<String, Object> retval = new HashMap<String, Object>();
- retval.put("CacheLoaderLoads", cacheLoads);
- retval.put("CacheLoaderMisses", cacheMisses);
- return retval;
- }
-
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheStoreInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheStoreInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyCacheStoreInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,37 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.annotations.Compat;
-
-@Compat
-@Deprecated
-public class LegacyCacheStoreInterceptor extends CacheStoreInterceptor
-{
- @Override
- protected void storeStateForPutDataMap(Fqn f, InvocationContext ctx) throws Exception
- {
- loader.put(f, ctx.lookUpNode(f).getDataDirect());
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,464 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.DataCommand;
-import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jgroups.Address;
-import org.jgroups.blocks.GroupRequest;
-import org.jgroups.blocks.RspFilter;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * The Data Gravitator interceptor intercepts cache misses and attempts to
- * gravitate data from other parts of the cluster.
- * <p/>
- * Only used if Buddy Replication is enabled. Also, the interceptor only kicks
- * in if an {@link org.jboss.cache.config.Option} is passed in to force Data
- * Gravitation for a specific invocation or if <b>autoDataGravitation</b> is
- * set to <b>true</b> when configuring Buddy Replication.
- * <p/>
- * See the JBoss Cache User Guide for more details on configuration options.
- * There is a section dedicated to Buddy Replication in the Replication
- * chapter.
- * <p/>
- * In terms of functionality, if a gravitation call has occured and a cleanup call is needed (based on
- * how BR is configured), a cleanup call will be broadcast immediately after the gravitation call (no txs)
- * or if txs are used, an <i>asynchronous</i> call is made to perform the cleanup <i>outside</i> the scope
- * of the tx that caused the gravitation event.
- * <p/>
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @deprecated will be removed with optimistic and pessimistic locking.
- */
-@Deprecated
-public class LegacyDataGravitatorInterceptor extends BaseRpcInterceptor
-{
- private BuddyManager buddyManager;
- /**
- * Map that contains commands that need cleaning up. This is keyed on global transaction, and contains a list of
- * cleanup commands corresponding to all gravitate calls made during the course of the transaction in question.
- */
- private Map<GlobalTransaction, List<ReplicableCommand>> cleanupCommands = new ConcurrentHashMap<GlobalTransaction, List<ReplicableCommand>>();
- private DataContainer dataContainer;
- private CommandsFactory commandsFactory;
- private CacheSPI cacheSPI;
- private BuddyFqnTransformer buddyFqnTransformer;
-
- @Inject
- public void injectComponents(BuddyManager buddyManager, DataContainer dataContainer, CommandsFactory commandsFactory, CacheSPI cacheSPI, BuddyFqnTransformer transformer)
- {
- this.buddyManager = buddyManager;
- this.dataContainer = dataContainer;
- this.commandsFactory = commandsFactory;
- this.cacheSPI = cacheSPI;
- buddyFqnTransformer = transformer;
- }
-
- @Override
- public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- return handleGetMethod(ctx, command);
- }
-
- @Override
- public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- return handleGetMethod(ctx, command);
- }
-
- @Override
- public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- return handleGetMethod(ctx, command);
- }
-
- @Override
- public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- return handleGetMethod(ctx, command);
- }
-
- @Override
- public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- return handleGetMethod(ctx, command);
- }
-
- @Override
- public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- try
- {
- return invokeNextInterceptor(ctx, command);
- }
- finally
- {
- cleanupCommands.remove(ctx.getGlobalTransaction());
- }
- }
-
- @Override
- public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- try
- {
- doCommit(gtx);
- return invokeNextInterceptor(ctx, command);
- }
- finally
- {
- cleanupCommands.remove(gtx);
- }
- }
-
- /**
- * @param ctx invocation context
- * @param fqn fqn to test
- * @return true if the node does not exist; false otherwise.
- */
- protected boolean nodeDoesNotExist(InvocationContext ctx, Fqn fqn)
- {
- return !dataContainer.exists(fqn);
- }
-
- private Object handleGetMethod(InvocationContext ctx, DataCommand command) throws Throwable
- {
- if (isGravitationEnabled(ctx))
- {
- // test that the Fqn being requested exists locally in the cache.
- if (trace) log.trace("Checking local existence of requested fqn " + command.getFqn());
- if (buddyFqnTransformer.isBackupFqn(command.getFqn()))
- {
- log.info("Is call for a backup Fqn, not performing any gravitation. Direct calls on internal backup nodes are *not* supported.");
- }
- else
- {
- if (nodeDoesNotExist(ctx, command.getFqn()))
- {
- // gravitation is necessary.
-
- if (trace) log.trace("Gravitating from local backup tree");
- BackupData data = localBackupGet(command.getFqn(), ctx);
-
- if (data == null)
- {
- if (trace) log.trace("Gravitating from remote backup tree");
- // gravitate remotely.
- data = remoteBackupGet(command.getFqn());
- }
-
- if (data != null)
- {
- if (trace)
- log.trace("Passing the put call locally to make sure state is persisted and ownership is correctly established.");
- // store the gravitated node locally. This will cause it being backed up in the current instance's buddy.
- createNode(data.backupData);
- cleanBackupData(data, ctx);
- wrapIfNeeded(ctx, data.primaryFqn);
- }
- }
- else
- {
- if (trace) log.trace("No need to gravitate; have this already.");
- }
- }
- }
- else
- {
- if (trace)
- {
- log.trace("Suppressing data gravitation for this call.");
- }
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- protected void wrapIfNeeded(InvocationContext ctx, Fqn fqnToWrap) throws InterruptedException
- {
- // no op
- }
-
- private boolean isGravitationEnabled(InvocationContext ctx)
- {
- boolean enabled = ctx.isOriginLocal();
- if (enabled)
- {
- if (!buddyManager.isAutoDataGravitation())
- {
- enabled = ctx.getOptionOverrides().getForceDataGravitation();
- }
- }
- return enabled;
- }
-
- private void doCommit(GlobalTransaction gtx) throws Throwable
- {
- if (cleanupCommands.containsKey(gtx))
- {
- if (trace) log.trace("Broadcasting cleanup commands for gtx " + gtx);
-
- for (ReplicableCommand command : cleanupCommands.get(gtx))
- {
- try
- {
- doCleanup(command);
- }
- catch (Throwable th)
- {
- log.warn("Problems performing gravitation cleanup. Cleanup command: " + command, th);
- }
- }
- }
- else
- {
- if (trace) log.trace("No cleanups to broadcast in commit phase for gtx " + gtx);
- }
- }
-
- private BackupData remoteBackupGet(Fqn name) throws Exception
- {
- BackupData result = null;
- GravitateResult gr = gravitateData(name);
- if (gr.isDataFound())
- {
- if (trace)
- {
- log.trace("Got response " + gr);
- }
-
- result = new BackupData(name, gr);
- }
- return result;
- }
-
- private void cleanBackupData(BackupData backup, InvocationContext ctx) throws Throwable
- {
-
- DataGravitationCleanupCommand cleanupCommand = commandsFactory.buildDataGravitationCleanupCommand(backup.primaryFqn, backup.backupFqn);
- GlobalTransaction gtx = ctx.getGlobalTransaction();
-
- if (gtx == null)
- {
- // broadcast removes
- // remove main Fqn
- if (trace) log.trace("Performing cleanup on [" + backup.primaryFqn + "]");
- // remove backup Fqn
- doCleanup(cleanupCommand);
- }
- else
- {
- if (trace)
- log.trace("Data gravitation performed under global transaction " + gtx + ". Not broadcasting cleanups until the tx commits. Recording cleanup command for later use.");
- List<ReplicableCommand> commands;
- if (cleanupCommands.containsKey(gtx))
- {
- commands = cleanupCommands.get(gtx);
- }
- else
- {
- commands = new LinkedList<ReplicableCommand>();
- }
-
- commands.add(cleanupCommand);
- cleanupCommands.put(gtx, commands);
- }
- }
-
- private void doCleanup(ReplicableCommand cleanupCommand) throws Throwable
- {
- // cleanup commands are always ASYNCHRONOUS and is broadcast to *everyone* (even members of the current buddy
- // group as they may be members of > 1 buddy group)
- replicateCall(null, cleanupCommand, false, false, false, true, -1);
- }
-
- @SuppressWarnings("deprecation")
- private GravitateResult gravitateData(Fqn fqn) throws Exception
- {
- if (trace) log.trace("Requesting data gravitation for Fqn " + fqn);
-
- List<Address> mbrs = rpcManager.getMembers();
- Boolean searchSubtrees = buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE;
- GravitateDataCommand command = commandsFactory.buildGravitateDataCommand(fqn, searchSubtrees);
- // doing a GET_ALL is crappy but necessary since JGroups' GET_FIRST could return null results from nodes that do
- // not have either the primary OR backup, and stop polling other valid nodes.
- List resps = rpcManager.callRemoteMethods(null, command, GroupRequest.GET_ALL, buddyManager.getBuddyCommunicationTimeout(), new ResponseValidityFilter(mbrs, rpcManager.getLocalAddress()), false);
-
- if (trace) log.trace("got responses " + resps);
-
- if (resps == null)
- {
- if (mbrs.size() > 1) log.error("No replies to call " + command);
- return GravitateResult.noDataFound();
- }
-
- // test for and remove exceptions
- GravitateResult result = GravitateResult.noDataFound();
- for (Object o : resps)
- {
- if (o instanceof Throwable)
- {
- if (log.isDebugEnabled())
- {
- log.debug("Found remote Throwable among responses - removing from responses list", (Exception) o);
- }
- }
- else if (o != null)
- {
- result = (GravitateResult) o;
- if (result.isDataFound())
- {
- break;
- }
- }
- else if (!configuration.isUseRegionBasedMarshalling())
- {
- // Null is OK if we are using region based marshalling; it
- // is what is returned if a region is inactive. Otherwise
- // getting a null is an error condition
- log.error("Unexpected null response to call " + command + ".");
- }
-
- }
-
- return result;
- }
-
- @SuppressWarnings("unchecked")
- private void createNode(List<NodeData> nodeData) throws CacheException
- {
- for (NodeData data : nodeData)
- {
- cacheSPI.put(data.getFqn(), data.getAttributes());
- }
- }
-
- private BackupData localBackupGet(Fqn fqn, InvocationContext ctx) throws CacheException
- {
- GravitateResult result = cacheSPI.gravitateData(fqn, true, ctx);// a "local" gravitation
- boolean found = result.isDataFound();
- BackupData data = null;
-
- if (found)
- {
- Fqn backupFqn = result.getBuddyBackupFqn();
- data = new BackupData(fqn, result);
- // now the cleanup
- if (buddyManager.isDataGravitationRemoveOnFind())
- {
- // Remove locally only; the remote call will
- // be broadcast later
- ctx.getOptionOverrides().setCacheModeLocal(true);
- cacheSPI.removeNode(backupFqn);
- }
- else
- {
- cacheSPI.evict(backupFqn, true);
- }
- }
-
- if (trace) log.trace("Retrieved data " + data + " found = " + found);
- return data;
- }
-
- private static class BackupData
- {
- Fqn primaryFqn;
- Fqn backupFqn;
- List<NodeData> backupData;
-
- public BackupData(Fqn primaryFqn, GravitateResult gr)
- {
- this.primaryFqn = primaryFqn;
- this.backupFqn = gr.getBuddyBackupFqn();
- this.backupData = gr.getNodeData();
- }
-
- public String toString()
- {
- return "BackupData{" +
- "primaryFqn=" + primaryFqn +
- ", backupFqn=" + backupFqn +
- ", backupData=" + backupData +
- '}';
- }
- }
-
- public static class ResponseValidityFilter implements RspFilter
- {
- private int numValidResponses = 0;
- private List<Address> pendingResponders;
-
- public ResponseValidityFilter(List<Address> expected, Address localAddress)
- {
- // so for now I used a list to keep it consistent
- this.pendingResponders = new ArrayList<Address>(expected);
- // We'll never get a response from ourself
- this.pendingResponders.remove(localAddress);
- }
-
- public boolean isAcceptable(Object object, Address address)
- {
- pendingResponders.remove(address);
-
- if (object instanceof GravitateResult)
- {
- GravitateResult response = (GravitateResult) object;
- if (response.isDataFound()) numValidResponses++;
- }
- // always return true to make sure a response is logged by the JGroups RpcDispatcher.
- return true;
- }
-
- public boolean needMoreResponses()
- {
- return numValidResponses < 1 && pendingResponders.size() > 0;
- }
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,69 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.factories.annotations.Inject;
-
-import java.util.List;
-
-/**
- * Passivation interceptor for optimistic and pessimistic locking
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class LegacyPassivationInterceptor extends PassivationInterceptor
-{
- private DataContainer dataContainer;
-
- @Inject
- private void injectDataContainer(DataContainer dataContainer)
- {
- this.dataContainer = dataContainer;
- }
-
- @Override
- public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
- {
- if (command.isRecursive())
- {
- for (Fqn f : getNodeList(command.getFqn())) passivate(ctx, f);
- }
- else
- {
- passivate(ctx, command.getFqn());
- }
-
- return invokeNextInterceptor(ctx, command);
- }
-
- private List<Fqn> getNodeList(Fqn startingPoint)
- {
- return dataContainer.getNodesForEviction(startingPoint, true);
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -46,10 +46,10 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.mvcc.MVCCNodeHelper;
+import org.jboss.starobrno.factories.annotations.Inject;
import java.util.Collections;
import java.util.LinkedList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -63,10 +63,6 @@
@Override
public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- if (command.getDataVersion() != null)
- {
- return invokeNextInterceptor(ctx, command);
- }
Set<MarshalledValue> marshalledValues = new HashSet<MarshalledValue>();
command.setData(wrapMap(command.getData(), marshalledValues, ctx));
Object retVal = invokeNextInterceptor(ctx, command);
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,8 +25,8 @@
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.notifications.Notifier;
+import org.jboss.starobrno.factories.annotations.Inject;
/**
* The interceptor in charge of firing off notifications to cache listeners
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,294 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeFactory;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.GlobalTransaction;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Used to create new {@link NodeSPI} instances in the main data structure and then copy it into the
- * {@link TransactionWorkspace} as {@link WorkspaceNode}s as needed. This is only invoked if nodes needed do not exist
- * in the underlying structure, they are added and the corresponding {@link org.jboss.cache.optimistic.WorkspaceNode#isCreated()}
- * would return <tt>true</tt> to denote that this node has been freshly created in the underlying structure.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class OptimisticCreateIfNotExistsInterceptor extends OptimisticInterceptor
-{
- /**
- * A reference to the node factory registered with the cache instance, used to create both WorkspaceNodes as well as
- * NodeSPI objects in the underlying data structure.
- */
- private NodeFactory nodeFactory;
-
- private DataContainer dataContainer;
-
- private CacheSPI cache;
-
- private long lockAcquisitionTimeout;
-
- @Inject
- private void injectDependencies(NodeFactory nodeFactory, DataContainer dataContainer, CacheSPI cacheSPI)
- {
- this.nodeFactory = nodeFactory;
- this.dataContainer = dataContainer;
- this.cache = cacheSPI;
- }
-
- @Start
- private void init()
- {
- lockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- createNode(ctx, command.getFqn(), false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- createNode(ctx, command.getFqn(), false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- createNode(ctx, command.getFqn(), false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- List<Fqn> fqns = new ArrayList<Fqn>();
- fqns.add(command.getTo());
- // peek into Node and get a hold of all child fqns as these need to be in the workspace.
- NodeSPI node = dataContainer.peek(command.getFqn(), true, true);
- greedyGetFqns(fqns, node, command.getTo());
- if (trace) log.trace("Adding Fqns " + fqns + " for a move() operation.");
- for (Fqn f : fqns)
- {
- createNode(ctx, f, true);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- /**
- * The only method that should be creating nodes.
- *
- * @param targetFqn
- * @throws CacheException
- */
- private void createNode(InvocationContext ctx, Fqn targetFqn, boolean suppressNotification) throws CacheException
- {
- if (dataContainer.peek(targetFqn, false, false) != null) return;
- // we do nothing if targetFqn is null
- if (targetFqn == null) return;
-
- boolean debug = log.isDebugEnabled();
-
- GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
-
- WorkspaceNode workspaceNode;
-
- List<Fqn> nodesCreated = new ArrayList<Fqn>();
-
- DataVersion version = null;
- if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
- {
- version = ctx.getOptionOverrides().getDataVersion();
- workspace.setVersioningImplicit(false);
- }
-
- // start with the ROOT node and then work our way down to the node necessary, creating nodes along the way.
- workspaceNode = workspace.getNode(Fqn.ROOT);
- if (debug) log.debug("GlobalTransaction: " + gtx + "; Root: " + workspaceNode);
-
- // we do not have the root in the workspace! Put it into thr workspace now.
- if (workspaceNode == null)
- {
- NodeSPI node = dataContainer.getRoot();
- workspaceNode = lockAndCreateWorkspaceNode(nodeFactory, node, workspace, gtx, lockAcquisitionTimeout);
- workspace.addNode(workspaceNode);
- log.debug("Created root node in workspace.");
- }
- else
- {
- log.debug("Found root node in workspace.");
- }
-
- // iterate through the target Fqn's elements.
- int targetFqnSize = targetFqn.size(), currentDepth = 1;
- for (Object childName : targetFqn.peekElements())
- {
- boolean isTargetFqn = (currentDepth == targetFqnSize);
- currentDepth++;
-
- // current workspace node canot be null.
- // try and get the child of current node
-
- if (debug) log.debug("Attempting to get child " + childName);
- NodeSPI currentNode = workspaceNode.getNode().getChildDirect(childName);
-
- if (currentNode == null)
- {
- // first test that it exists in the workspace and has been created in thix tx!
- WorkspaceNode peekInWorkspace = workspace.getNode(Fqn.fromRelativeElements(workspaceNode.getFqn(), childName));
- if (peekInWorkspace != null && peekInWorkspace.isCreated())
- {
- // exists in workspace and has just been created.
- currentNode = peekInWorkspace.getNode();
- if (peekInWorkspace.isRemoved())
- {
- peekInWorkspace.setRemoved(false);
- // add in parent again
- workspaceNode.addChild(peekInWorkspace);
- }
- }
- }
-
- if (currentNode == null)
- {
- // no child exists with this name; create it in the underlying data structure and then add it to the workspace.
- if (trace) log.trace("Creating new child, since it doesn't exist in the cache.");
- // we put the parent node into the workspace as we are changing its children.
- // at this point "workspaceNode" refers to the parent of the current node. It should never be null if
- // you got this far!
- if (workspaceNode.isRemoved())
- {
- //add a new one or overwrite an existing one that has been deleted
- if (trace)
- log.trace("Parent node doesn't exist in workspace or has been deleted. Adding to workspace.");
- workspace.addNode(workspaceNode);
- if (!(workspaceNode.getVersion() instanceof DefaultDataVersion))
- workspaceNode.setVersioningImplicit(false);
- }
- else
- {
- if (trace) log.trace("Parent node exists: " + workspaceNode);
- }
-
- // get the version passed in, if we need to use explicit versioning.
- DataVersion versionToPassIn = null;
- if (isTargetFqn && !workspace.isVersioningImplicit()) versionToPassIn = version;
-
- NodeSPI newUnderlyingChildNode = workspaceNode.createChild(childName, workspaceNode.getNode(), cache, versionToPassIn);
-
- // now assign "workspaceNode" to the new child created.
- workspaceNode = lockAndCreateWorkspaceNode(nodeFactory, newUnderlyingChildNode, workspace, gtx, lockAcquisitionTimeout);
- workspaceNode.setVersioningImplicit(versionToPassIn == null || !isTargetFqn);
- if (trace)
- log.trace("setting versioning of " + workspaceNode.getFqn() + " to be " + (workspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
-
- // now add the wrapped child node into the transaction space
- workspace.addNode(workspaceNode);
- workspaceNode.markAsCreated();
- // save in list so we can broadcast our created nodes outside
- // the synch block
- nodesCreated.add(workspaceNode.getFqn());
- }
- else
- {
- // node does exist but might not be in the workspace
- workspaceNode = workspace.getNode(currentNode.getFqn());
- // wrap it up so we can put it in later if we need to
- if (workspaceNode == null)
- {
- if (trace)
- log.trace("Child node " + currentNode.getFqn() + " doesn't exist in workspace or has been deleted. Adding to workspace in gtx " + gtx);
-
- workspaceNode = lockAndCreateWorkspaceNode(nodeFactory, currentNode, workspace, gtx, lockAcquisitionTimeout);
-
- // if the underlying node is a tombstone then mark the workspace node as newly created
- if (!currentNode.isValid()) workspaceNode.markAsCreated();
-
- if (isTargetFqn && !workspace.isVersioningImplicit())
- {
- workspaceNode.setVersion(version);
- workspaceNode.setVersioningImplicit(false);
- }
- else
- {
- workspaceNode.setVersioningImplicit(true);
- }
- if (trace)
- log.trace("setting versioning of " + workspaceNode.getFqn() + " to be " + (workspaceNode.isVersioningImplicit() ? "implicit" : "explicit"));
- workspace.addNode(workspaceNode);
- }
- else if (workspaceNode.isRemoved())
- {
- if (trace) log.trace("Found node but it is deleted in this workspace. Needs resurrecting.");
- undeleteWorkspaceNode(workspaceNode, workspace);
- }
- else
- {
- if (trace) log.trace("Found child node in the workspace: " + currentNode);
-
- }
- }
- }
-
- if (!suppressNotification)
- {
- if (nodesCreated.size() > 0)
- {
- Notifier n = cache.getNotifier();
- for (Fqn temp : nodesCreated)
- {
- n.notifyNodeCreated(temp, true, ctx);
- n.notifyNodeCreated(temp, false, ctx);
- if (trace) log.trace("Notifying cache of node created in workspace " + temp);
- }
- }
- }
- }
-
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,152 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeFactory;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.lock.LockManager;
-import static org.jboss.cache.lock.LockType.READ;
-import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionContext;
-import org.jboss.cache.transaction.TransactionTable;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.List;
-
-/**
- * Abstract interceptor for optimistic locking
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public abstract class OptimisticInterceptor extends CommandInterceptor
-{
- protected TransactionManager txManager;
- protected TransactionTable txTable;
- protected LockManager lockManager;
-
- @Inject
- private void injectDependencies(TransactionManager txManager, TransactionTable txTable, LockManager lockManager)
- {
- this.txManager = txManager;
- this.txTable = txTable;
- this.lockManager = lockManager;
- }
-
- protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws CacheException
- {
- OptimisticTransactionContext transactionContext = (OptimisticTransactionContext) ctx.getTransactionContext();
-
- if (transactionContext == null)
- {
- throw new CacheException("Unable to map global transaction " + ctx.getGlobalTransaction() + " to transaction entry when trying to retrieve transaction workspace.");
- }
-
- // try and get the workspace from the transaction
- return transactionContext.getTransactionWorkSpace();
- }
-
- /**
- * Adds the Fqn of the node as well as all children and childrens children to the list.
- */
- protected void greedyGetFqns(List<Fqn> list, NodeSPI<?, ?> n, Fqn newBase)
- {
- list.add(n.getFqn());
- Fqn newFqn = Fqn.fromRelativeElements(newBase, n.getFqn().getLastElement());
- list.add(newFqn);
-
- for (NodeSPI child : n.getChildrenDirect())
- {
- greedyGetFqns(list, child, newFqn);
- }
- }
-
- /**
- * @return the {@link org.jboss.cache.transaction.GlobalTransaction}, extracted from the current {@link org.jboss.cache.InvocationContext}.
- * @throws CacheException if the {@link org.jboss.cache.transaction.GlobalTransaction} or {@link javax.transaction.Transaction} associated with the
- * {@link org.jboss.cache.InvocationContext} is null.
- */
- protected GlobalTransaction getGlobalTransaction(InvocationContext ctx) throws CacheException
- {
- Transaction tx = ctx.getTransaction();
- if (tx == null) throw new CacheException("Transaction associated with the current invocation is null!");
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- if (gtx == null) throw new CacheException("GlobalTransaction associated with the current invocation is null!");
- return gtx;
- }
-
- protected void undeleteWorkspaceNode(WorkspaceNode nodeToUndelete, TransactionWorkspace workspace)
- {
- undeleteWorkspaceNode(nodeToUndelete, workspace.getNode(nodeToUndelete.getFqn().getParent()));
- }
-
- /**
- * Undeletes a node that already exists in the workspace, by setting appropriate flags and re-adding to parent's child map.
- *
- * @param nodeToUndelete WorkspaceNode to undelete
- * @param parent parent of node to undelete
- */
- @SuppressWarnings("unchecked")
- protected void undeleteWorkspaceNode(WorkspaceNode nodeToUndelete, WorkspaceNode parent)
- {
- nodeToUndelete.setRemoved(false);
- nodeToUndelete.clearData();
- // add in parent again
- parent.addChild(nodeToUndelete);
- nodeToUndelete.markAsResurrected(true);
- }
-
- @SuppressWarnings("unchecked")
- protected WorkspaceNode lockAndCreateWorkspaceNode(NodeFactory<?, ?> nodeFactory, NodeSPI node, TransactionWorkspace<?, ?> workspace, GlobalTransaction gtx, long timeout)
- {
- boolean locked;
- try
- {
- locked = lockManager.lock(node, READ, gtx, timeout);
- }
- catch (InterruptedException e)
- {
- // test if we acquired the lock
- locked = lockManager.getReadOwners(node).contains(gtx);
- }
-
- if (!locked)
- throw new TimeoutException("Unable to lock node " + node.getFqn() + " after timeout " + timeout + " for copying into workspace");
-
- WorkspaceNode<?, ?> wn = nodeFactory.createWrappedNode(node, workspace);
-
- lockManager.unlock(node, gtx);
- return wn;
- }
-
-
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,156 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.factories.annotations.Start;
-import static org.jboss.cache.lock.LockType.READ;
-import static org.jboss.cache.lock.LockType.WRITE;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.BatchModeTransactionManager;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionContext;
-
-/**
- * Locks nodes during transaction boundaries. Only affects prepare/commit/rollback method calls; other method calls
- * are simply passed up the interceptor stack.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class OptimisticLockingInterceptor extends OptimisticInterceptor
-{
- @Start
- private void init()
- {
- if (txManager == null || txManager.getClass().equals(BatchModeTransactionManager.class))
- log.fatal("No transaction manager lookup class has been defined. Transactions cannot be used and thus OPTIMISTIC locking cannot be used! Expect errors!!");
- }
-
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- //try and acquire the locks - before passing on
- GlobalTransaction gtx = getGlobalTransaction(ctx);
-
- boolean succeeded = false;
- try
- {
- TransactionWorkspace<?, ?> workspace = getTransactionWorkspace(ctx);
- if (log.isDebugEnabled()) log.debug("Locking nodes in transaction workspace for GlobalTransaction " + gtx);
-
- for (WorkspaceNode workspaceNode : workspace.getNodes().values())
- {
- NodeSPI node = workspaceNode.getNode();
-
- boolean isWriteLockNeeded = workspaceNode.isDirty() || (workspaceNode.isChildrenModified() && (configuration.isLockParentForChildInsertRemove() || node.isLockForChildInsertRemove()));
-
- boolean acquired = lockManager.lockAndRecord(node, isWriteLockNeeded ? WRITE : READ, ctx);
- if (acquired)
- {
- if (trace) log.trace("Acquired lock on node " + node.getFqn());
- }
- else
- {
- throw new CacheException("Unable to acquire lock on node " + node.getFqn());
- }
-
- }
-
- // locks have acquired so lets pass on up
- Object retval = invokeNextInterceptor(ctx, command);
- succeeded = true;
- return retval;
- }
- catch (Throwable e)
- {
- succeeded = false;
- log.debug("Caught exception attempting to lock nodes ", e);
- //we have failed - set to rollback and throw exception
- throw e;
- }
- finally
- {
- if (!succeeded) unlock(ctx);
- }
- }
-
- @Override
- public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- return transactionFinalized(ctx, command);
- }
-
- @Override
- public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- return transactionFinalized(ctx, command);
- }
-
- private Object transactionFinalized(InvocationContext ctx, VisitableCommand command) throws Throwable
- {
- Object retval = null;
- // we need to let the stack run its commits or rollbacks first -
- // we unlock last - even if an exception occurs
- try
- {
- retval = invokeNextInterceptor(ctx, command);
- }
- finally
- {
- unlock(ctx);
- }
- return retval;
- }
-
- /**
- * Releases all locks held by the specified global transaction.
- *
- * @param ctx Invocation Context
- */
- private void unlock(InvocationContext ctx)
- {
- try
- {
- TransactionContext transactionContext = ctx.getTransactionContext();
- if (transactionContext != null)
- {
- lockManager.unlock(ctx);
- }
- }
- catch (Exception e)
- {
- // we have failed to unlock - now what?
- log.error("Failed to unlock nodes after a commit or rollback! Locks are possibly in a very inconsistent state now!", e);
- }
- }
-
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,617 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeFactory;
-import org.jboss.cache.NodeNotExistsException;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.notifications.Notifier;
-import static org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType.*;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.GlobalTransaction;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.SortedMap;
-
-/**
- * Operations on nodes are done on the copies that exist in the workspace rather than passed down
- * to the {@link org.jboss.cache.interceptors.CallInterceptor}. These operations happen in this interceptor.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class OptimisticNodeInterceptor extends OptimisticInterceptor
-{
- /**
- * Needed for the creation of workspace nodes based on underlying nodes in the cache.
- */
- private NodeFactory nodeFactory;
- private Notifier notifier;
- private DataContainer dataContainer;
- private long lockAcquisitionTimeout;
-
- @Inject
- protected void injectDependencies(Notifier notifier, NodeFactory nodeFactory, DataContainer dataContainer)
- {
- this.notifier = notifier;
- this.nodeFactory = nodeFactory;
- this.dataContainer = dataContainer;
- }
-
- @Start
- private void init()
- {
- lockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
- }
-
- public OptimisticNodeInterceptor()
- {
- log = LogFactory.getLog(getClass());
- trace = log.isTraceEnabled();
- }
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, true);
- if (workspaceNode != null)
- {
- setVersioning(ctx, workspace, workspaceNode);
- }
- Object result = removeNode(workspace, workspaceNode, true, ctx);
- addToModificationList(command, ctx);
- return result;
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- return visitPutKeyValueCommand(ctx, command);
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
- if (workspaceNode != null)
- {
- setVersioning(ctx, workspace, workspaceNode);
- }
- else
- {
- // "fail-more-silently" patch thanks to Owen Taylor - JBCACHE-767
- if ((ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isFailSilently()))
- {
- throw new CacheException("Unable to set node version for " + command.getFqn() + ", node is null.");
- }
- }
- Object result = putDataKeyValueAndNotify(command.getKey(), command.getValue(), workspace, workspaceNode, ctx);
- addToModificationList(command, ctx);
- return result;
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
- if (workspaceNode != null)
- {
- setVersioning(ctx, workspace, workspaceNode);
- }
- else
- {
- // "fail-more-silently" patch thanks to Owen Taylor - JBCACHE-767
- if ((ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isFailSilently()))
- {
- throw new CacheException("Unable to set node version for " + command.getFqn() + ", node is null.");
- }
- }
- putDataMapAndNotify(command.getData(), workspace, workspaceNode, ctx);
- addToModificationList(command, ctx);
- return null;
- }
-
-
- @Override
- public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
- if (ctx.isOriginLocal() && ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
- {
- throw new CacheException("Setting a data version while performing a move() is not supported!!");
- }
- if (workspaceNode != null)
- {
- setVersioning(ctx, workspace, workspaceNode);
- }
- moveNodeAndNotify(command.getTo(), workspaceNode, workspace, ctx);
- addToModificationList(command, ctx);
- return null;
- }
-
- @Override
- public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
-
- if (workspaceNode != null)
- {
- setVersioning(ctx, workspace, workspaceNode);
- }
- Object result = removeKeyAndNotify(command.getKey(), workspace, workspaceNode, ctx);
- addToModificationList(command, ctx);
- return result;
- }
-
- @Override
- public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, true, true);
- if (workspaceNode != null)
- {
- setVersioning(ctx, workspace, workspaceNode);
- }
- removeDataAndNotify(workspace, workspaceNode, ctx);
- addToModificationList(command, ctx);
- return null;
- }
-
- @Override
- public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- Object result;
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
-
- if (workspaceNode == null)
- {
- if (trace) log.debug("Unable to find node " + command.getFqn() + " in workspace.");
- result = null;
- }
- else
- {
- //add this node into the wrokspace
- notifier.notifyNodeVisited(command.getFqn(), true, ctx);
- Object val = workspaceNode.get(command.getKey());
- workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(command.getFqn(), false, ctx);
- result = val;
- }
- return result;
- }
-
- @Override
- public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- Object result;
- Fqn fqn = command.getFqn();
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, fqn, workspace, false, false);
- if (workspaceNode == null)
- {
- if (trace) log.trace("unable to find node " + fqn + " in workspace.");
- result = null;
- }
- else
- {
- notifier.notifyNodeVisited(fqn, true, ctx);
- Object keySet = workspaceNode.getKeys();
- workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(fqn, false, ctx);
- result = keySet;
- }
- return result;
- }
-
- @Override
- public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- Object result;
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
- if (workspaceNode == null)
- {
- if (trace) log.trace("unable to find node " + command.getFqn() + " in workspace.");
- result = null;
- }
- else
- {
- notifier.notifyNodeVisited(command.getFqn(), true, ctx);
- Object data = workspaceNode.getData();
- workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(command.getFqn(), false, ctx);
- result = data;
- }
- return result;
- }
-
- @Override
- public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- Object result;
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
- if (workspaceNode == null)
- {
- if (trace) log.trace("Unable to find node " + command.getFqn() + " in workspace.");
- result = null;
- }
- else
- {
- notifier.notifyNodeVisited(command.getFqn(), true, ctx);
- Object nameSet = workspaceNode.getChildrenNames();
- workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(command.getFqn(), false, ctx);
- result = nameSet;
- }
- return result;
- }
-
- @Override
- public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
- Object result;
- WorkspaceNode workspaceNode = fetchWorkspaceNode(ctx, command.getFqn(), workspace, false, false);
- if (workspaceNode == null)
- {
- if (trace) log.trace("Unable to find node " + command.getFqn() + " in workspace.");
- result = null;
- }
- else if (workspaceNode.isRemoved())
- {
- if (trace) log.trace("Attempted to retrieve node " + command.getFqn() + " but it has been deleted!");
- result = null;
- }
- else
- {
- notifier.notifyNodeVisited(command.getFqn(), true, ctx);
- workspace.addNode(workspaceNode);
- notifier.notifyNodeVisited(command.getFqn(), false, ctx);
- result = workspaceNode.getNode();
- }
- return result;
- }
-
- private void setVersioning(InvocationContext ctx, TransactionWorkspace workspace, WorkspaceNode workspaceNode)
- {
- // use explicit versioning
- if (ctx.getOptionOverrides() != null && ctx.getOptionOverrides().getDataVersion() != null)
- {
- workspace.setVersioningImplicit(false);
- DataVersion version = ctx.getOptionOverrides().getDataVersion();
-
- workspaceNode.setVersion(version);
- if (trace) log.trace("Setting versioning for node " + workspaceNode.getFqn() + " to explicit");
-
- workspaceNode.setVersioningImplicit(false);
- }
- else
- {
- if (trace) log.trace("Setting versioning for node " + workspaceNode.getFqn() + " to implicit");
- workspaceNode.setVersioningImplicit(true);
- }
- }
-
- /**
- * Retrieves a backup fqn in an array of arguments. This is typically used to parse arguments from a data gravitation cleanup method.
- *
- * @param args array of arguments to parse
- * @return an Fqn
- */
- private Fqn getBackupFqn(Object[] args)
- {
- return (Fqn) args[1];
- }
-
- /**
- * Adds a method call to the modification list of a given transaction's transaction entry
- */
- private void addToModificationList(WriteCommand command, InvocationContext ctx)
- {
- // Option opt = ctx.getOptionOverrides();
- ctx.getTransactionContext().addModification(command);
- if (log.isDebugEnabled()) log.debug("Adding command " + command + " to modification list");
- }
-
- // -----------------------------------------------------------------
-
- // Methods that mimic core functionality in the cache, except that they work on WorkspaceNodes in the TransactionWorkspace.
-
- // -----------------------------------------------------------------
-
-
- /**
- * Performs a move within the workspace.
- *
- * @param parentFqn parent under which the node is to be moved
- * @param node node to move
- * @param ws transaction workspace
- * @param ctx
- */
- private void moveNodeAndNotify(Fqn parentFqn, WorkspaceNode node, TransactionWorkspace ws, InvocationContext ctx)
- {
- Fqn nodeFqn = node.getFqn();
- if (nodeFqn.isRoot())
- {
- log.warn("Attempting to move the root node. Not taking any action, treating this as a no-op.");
- return;
- }
-
- WorkspaceNode oldParent = fetchWorkspaceNode(ctx, nodeFqn.getParent(), ws, false, true);
- if (oldParent == null) throw new NodeNotExistsException("Node " + nodeFqn.getParent() + " does not exist!");
-
- if (parentFqn.equals(oldParent.getFqn()))
- {
- log.warn("Attempting to move a node in same place. Not taking any action, treating this as a no-op.");
- return;
- }
- // retrieve parent
- WorkspaceNode parent = fetchWorkspaceNode(ctx, parentFqn, ws, false, true);
- if (parent == null) throw new NodeNotExistsException("Node " + parentFqn + " does not exist!");
-
- Object nodeName = nodeFqn.getLastElement();
-
- // now that we have the parent and target nodes:
- // first correct the pointers at the pruning point
- oldParent.removeChild(nodeName);
-
- // parent pointer is calculated on the fly using Fqns.
- // now adjust Fqns of node and all children.
- Fqn nodeNewFqn = Fqn.fromRelativeElements(parent.getFqn(), nodeFqn.getLastElement());
-
- // pre-notify
- notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, true, ctx);
- recursiveMoveNode(ctx, node, parent.getFqn(), ws);
-
- // remove old nodes. this may mark some nodes which have already been moved as deleted
- removeNode(ws, node, false, ctx);
-
- // post-notify
- notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, false, ctx);
- }
-
- /**
- * Moves a node to a new base.
- *
- * @param node node to move
- * @param newBase new base Fqn under which the given node will now exist
- * @param ws transaction workspace
- */
- private void recursiveMoveNode(InvocationContext ctx, WorkspaceNode node, Fqn newBase, TransactionWorkspace ws)
- {
- Fqn newFqn = Fqn.fromRelativeElements(newBase, node.getFqn().getLastElement());
- WorkspaceNode movedNode = fetchWorkspaceNode(ctx, newFqn, ws, true, true);
- movedNode.putAll(node.getData());
-
- // invoke children
- for (Object n : node.getChildrenNames())
- {
- WorkspaceNode child = fetchWorkspaceNode(ctx, Fqn.fromRelativeElements(node.getFqn(), n), ws, false, true);
- if (child != null) recursiveMoveNode(ctx, child, newFqn, ws);
- }
- }
-
- private void putDataMapAndNotify(Map<Object, Object> data, TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
- {
- if (workspaceNode == null)
- throw new NodeNotExistsException("optimisticCreateIfNotExistsInterceptor should have created this node!");
- // pre-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, PUT_MAP, workspaceNode.getData(), ctx);
- workspaceNode.putAll(data);
- workspace.addNode(workspaceNode);
- // post-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, PUT_MAP, workspaceNode.getData(), ctx);
- }
-
- private Object putDataKeyValueAndNotify(Object key, Object value, TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
- {
- if (workspaceNode == null)
- throw new NodeNotExistsException("optimisticCreateIfNotExistsInterceptor should have created this node!");
-
- if (notifier.shouldNotifyOnNodeModified())// pre-notify
- {
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, PUT_DATA, workspaceNode.getData(), ctx);
- }
-
- Object old = workspaceNode.put(key, value);
- workspace.addNode(workspaceNode);
-
- if (notifier.shouldNotifyOnNodeModified())// post-notify
- {
- Map addedData = Collections.singletonMap(key, value);
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, PUT_DATA, addedData, ctx);
- }
-
- return old;
- }
-
- private boolean removeNode(TransactionWorkspace workspace, WorkspaceNode workspaceNode, boolean notify, InvocationContext ctx) throws CacheException
- {
- // it is already removed - we can ignore it
- if (workspaceNode == null) return false;
-
- Fqn parentFqn = workspaceNode.getFqn().getParent();
- WorkspaceNode parentNode = fetchWorkspaceNode(ctx, parentFqn, workspace, false, true);
- if (parentNode == null) throw new NodeNotExistsException("Unable to find parent node with fqn " + parentFqn);
-
- // pre-notify
- if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), true, workspaceNode.getData(), ctx);
-
- Fqn nodeFqn = workspaceNode.getFqn();
- parentNode.removeChild(nodeFqn.getLastElement());
-
- SortedMap<Fqn, WorkspaceNode> tailMap = workspace.getNodesAfter(workspaceNode.getFqn());
-
- for (WorkspaceNode toDelete : tailMap.values())
- {
- if (toDelete.getFqn().isChildOrEquals(nodeFqn))
- {
- if (trace) log.trace("marking node " + toDelete.getFqn() + " as deleted");
- toDelete.setRemoved(true);
- }
- else
- {
- break;// no more children, we came to the end
- }
- }
-
- // post-notify
- if (notify) notifier.notifyNodeRemoved(workspaceNode.getFqn(), false, null, ctx);
- return workspaceNode.getNode().isValid();
- }
-
- private Object removeKeyAndNotify(Object removeKey, TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
- {
- if (workspaceNode == null) return null;
-
- if (notifier.shouldNotifyOnNodeModified())// pre-notify
- {
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, REMOVE_DATA, workspaceNode.getData(), ctx);
- }
-
- Object old = workspaceNode.remove(removeKey);
- workspace.addNode(workspaceNode);
-
- if (notifier.shouldNotifyOnNodeModified())
- {
- Map removedData = Collections.singletonMap(removeKey, old);
- // post-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, REMOVE_DATA, removedData, ctx);
- }
-
- return old;
- }
-
- private void removeDataAndNotify(TransactionWorkspace workspace, WorkspaceNode workspaceNode, InvocationContext ctx)
- {
- if (workspaceNode == null) return;
-
- Map data = new HashMap(workspaceNode.getData());
-
- // pre-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), true, REMOVE_DATA, data, ctx);
-
- workspaceNode.clearData();
- workspace.addNode(workspaceNode);
-
- // post-notify
- notifier.notifyNodeModified(workspaceNode.getFqn(), false, REMOVE_DATA, data, ctx);
- }
-
- // -----------------------------------------------------------------
-
- // Methods to help retrieval of nodes from the transaction workspace.
-
- // -----------------------------------------------------------------
-
- /**
- * Retrieves a node for a given Fqn from the workspace. If the node does not exist in the workspace it is retrieved
- * from the cache's data structure. Note that at no point is a NEW node created in the underlying data structure.
- * That is up to the {@link org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor}.
- * <p/>
- * If the node requested is in the workspace but marked as deleted, this method will NOT retrieve it, unless undeleteIfNecessary
- * is true, in which case the node's <tt>deleted</tt> property is set to false first before being retrieved.
- *
- * @param fqn Fqn of the node to retrieve
- * @param workspace transaction workspace to look in
- * @param undeleteIfNecessary if the node is in the workspace but marked as deleted, this meth
- * @param includeInvalidNodes
- * @return a node, if found, or null if not.
- */
- private WorkspaceNode fetchWorkspaceNode(InvocationContext ctx, Fqn fqn, TransactionWorkspace workspace, boolean undeleteIfNecessary, boolean includeInvalidNodes)
- {
- WorkspaceNode workspaceNode = workspace.getNode(fqn);
- // if we do not have the node then we need to add it to the workspace
- if (workspaceNode == null)
- {
- NodeSPI node = dataContainer.peek(fqn, true, includeInvalidNodes);
- if (node == null) return null;
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- workspaceNode = lockAndCreateWorkspaceNode(nodeFactory, node, workspace, gtx, lockAcquisitionTimeout);
-
- // and add the node to the workspace.
- workspace.addNode(workspaceNode);
- }
-
- // Check that the workspace node has been marked as deleted.
- if (workspaceNode.isRemoved())
- {
- if (trace) log.trace("Node " + fqn + " has been deleted in the workspace.");
- if (undeleteIfNecessary)
- {
- undeleteWorkspaceNode(workspaceNode, fetchWorkspaceNode(ctx, fqn.getParent(), workspace, undeleteIfNecessary, includeInvalidNodes));
- }
- else if (!includeInvalidNodes)
- {
- // don't return deleted nodes if undeleteIfNecessary is false!
- workspaceNode = null;
- }
- }
-
- // set implicit node versioning flag.
- if (workspaceNode != null && !(workspaceNode.getVersion() instanceof DefaultDataVersion))
- {
- workspaceNode.setVersioningImplicit(false);
- }
-
- // now make sure all parents are in the wsp as well
- if (workspaceNode != null && !fqn.isRoot())
- fetchWorkspaceNode(ctx, fqn.getParent(), workspace, false, includeInvalidNodes);
-
- return workspaceNode;
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,407 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.AbstractVisitor;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.commands.VersionedDataCommand;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionContext;
-import org.jboss.cache.transaction.TransactionContext;
-import org.jboss.cache.util.concurrent.ConcurrentHashSet;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Replication interceptor for the optimistically locked interceptor chain. Responsible for replicating
- * state to remote nodes. Unlike its cousin, the {@link org.jboss.cache.interceptors.ReplicationInterceptor}, this interceptor
- * only deals with transactional calls. Just like all things to do with Optimistic Locking, it is a requirement that
- * everything is done in a transaction and the transaction context is available via {@link org.jboss.cache.InvocationContext#getTransaction()}
- * and {@link org.jboss.cache.InvocationContext#getGlobalTransaction()}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class OptimisticReplicationInterceptor extends BaseRpcInterceptor
-{
- /**
- * record of local broacasts - so we do not broadcast rollbacks/commits that resuted from local prepare failures we
- * really just need a set here, but concurrent CopyOnWriteArraySet has poor performance when writing.
- */
- private final Set<GlobalTransaction> broadcastTxs = new ConcurrentHashSet<GlobalTransaction>();
-
- private CommandsFactory commandsFactory;
-
- @Inject
- public void initialize(CommandsFactory commandsFactory)
- {
- this.commandsFactory = commandsFactory;
- }
-
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- // pass up the chain.
- Object retval = invokeNextInterceptor(ctx, command);
- if (!skipReplicationOfTransactionMethod(ctx))
- {
- GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionContext transactionContext = ctx.getTransactionContext();
- if (transactionContext.hasLocalModifications())
- {
- OptimisticPrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
- replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
- command = replicablePrepareCommand;
- }
-
- // replicate the prepare call.
- broadcastPrepare(command, gtx, ctx);
- }
- return retval;
- }
-
- @Override
- public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- //lets broadcast the commit first
- Throwable remoteCommitException = null;
- GlobalTransaction gtx = getGlobalTransaction(ctx);
- if (!gtx.isRemote() && ctx.isOriginLocal() && broadcastTxs.contains(gtx))
- {
- try
- {
- if (!skipReplicationOfTransactionMethod(ctx)) broadcastCommit(gtx, ctx);
- }
- catch (Throwable t)
- {
- log.error("A problem occurred with remote commit", t);
- remoteCommitException = t;
- }
- }
-
- Object retval = invokeNextInterceptor(ctx, command);
- if (remoteCommitException != null)
- {
- throw remoteCommitException;
- }
- return retval;
- }
-
- @Override
- public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- // lets broadcast the rollback first
- GlobalTransaction gtx = getGlobalTransaction(ctx);
- Throwable remoteRollbackException = null;
- if (!gtx.isRemote() && ctx.isOriginLocal() && broadcastTxs.contains(gtx))
- {
- //we dont do anything
- try
- {
- if (!skipReplicationOfTransactionMethod(ctx)) broadcastRollback(gtx, ctx);
- }
- catch (Throwable t)
- {
- log.error(" a problem occurred with remote rollback", t);
- remoteRollbackException = t;
- }
-
- }
- Object retval = invokeNextInterceptor(ctx, command);
- if (remoteRollbackException != null)
- {
- throw remoteRollbackException;
- }
- return retval;
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- ctx.getTransactionContext().setForceAsyncReplication(true);
- return handleDefault(ctx, command);
- }
-
- public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
- {
- if (isLocalModeForced(ctx) && command instanceof WriteCommand)
- ctx.getTransactionContext().addLocalModification((WriteCommand) command);
- return invokeNextInterceptor(ctx, command);
- }
-
-
- private GlobalTransaction getGlobalTransaction(InvocationContext ctx)
- {
- // get the current globalTransaction
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- if (gtx == null)
- {
- throw new CacheException("failed to get global transaction");
- }
- return gtx;
- }
-
- protected void broadcastPrepare(OptimisticPrepareCommand command, GlobalTransaction gtx, InvocationContext ctx) throws Throwable
- {
- // this method will return immediately if we're the only member
- if (rpcManager.getMembers() != null && rpcManager.getMembers().size() > 1)
- {
- // Map method calls to data versioned equivalents.
- // See JBCACHE-843 and docs/design/DataVersioning.txt
- DataVersionPopulator populator = new DataVersionPopulator(getTransactionWorkspace(ctx), command.getModifications().size());
-
- // visit all elements in the collection and apply the DataVersionPopulator to ensure all commands have data versions set.
- populator.visitCollection(null, command.getModifications());
-
- ReplicableCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, populator.versionedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
-
- //record the things we have possibly sent
- broadcastTxs.add(gtx);
- if (log.isDebugEnabled())
- {
- log.debug("(" + rpcManager.getLocalAddress() + "): broadcasting prepare for " + gtx + " (" + command.getModificationsCount() + " modifications");
- }
- replicateCall(ctx, toBroadcast, defaultSynchronous, ctx.getOptionOverrides());
- }
- else
- {
- //no members, ignoring
- if (log.isDebugEnabled())
- {
- log.debug("(" + rpcManager.getLocalAddress() + "):not broadcasting prepare as members are " + rpcManager.getMembers());
- }
- }
- }
-
-
- protected void broadcastCommit(GlobalTransaction gtx, InvocationContext ctx) throws Throwable
- {
- boolean remoteCallSync = configuration.isSyncCommitPhase();
-
- // Broadcast commit() to all members (exclude myself though)
- if (rpcManager.getMembers() != null && rpcManager.getMembers().size() > 1)
- {
- try
- {
- broadcastTxs.remove(gtx);
- CommitCommand commitCommand = commandsFactory.buildCommitCommand(gtx);
-
- if (log.isDebugEnabled())
- log.debug("running remote commit for " + gtx + " and coord=" + rpcManager.getLocalAddress());
-
- // for an optimistic commit we don't need to force an OOB message since O/L means we have non-blocking reads.
- replicateCall(ctx, commitCommand, remoteCallSync, ctx.getOptionOverrides(), false);
- }
- catch (Exception e)
- {
- log.error("Commit failed", e);
- throw e;
- }
- }
- }
-
- protected void broadcastRollback(GlobalTransaction gtx, InvocationContext ctx) throws Throwable
- {
- boolean remoteCallSync = configuration.isSyncRollbackPhase();
-
- if (rpcManager.getMembers() != null && rpcManager.getMembers().size() > 1)
- {
- // Broadcast rollback() to all other members (excluding myself)
- try
- {
- broadcastTxs.remove(gtx);
- RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(null);
-
- if (log.isDebugEnabled())
- log.debug("running remote rollback for " + gtx + " and coord=" + rpcManager.getLocalAddress());
- replicateCall(ctx, rollbackCommand, remoteCallSync, ctx.getOptionOverrides());
- }
- catch (Exception e)
- {
- log.error("Rollback failed", e);
- throw e;
- }
- }
- }
-
- public class DataVersionPopulator extends AbstractVisitor
- {
- final TransactionWorkspace workspace;
- final List<WriteCommand> versionedCommands;
-
- public DataVersionPopulator(TransactionWorkspace workspace, int numCommands)
- {
- this.workspace = workspace;
- versionedCommands = new ArrayList<WriteCommand>(numCommands);
- }
-
- private void setDataVersion(VersionedDataCommand clone, Fqn fqn)
- {
- DataVersion versionToBroadcast = getVersionToBroadcast(workspace, fqn);
- clone.setDataVersion(versionToBroadcast);
- versionedCommands.add(clone);
- }
-
- @Override
- public Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
- {
- return command;
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- VersionedDataCommand clone = commandsFactory.buildPutDataMapCommand(null, command.getFqn(), command.getData());
- setDataVersion(clone, command.getFqn());
- return null;
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- VersionedDataCommand clone = commandsFactory.buildPutKeyValueCommand(null, command.getFqn(), command.getKey(), command.getValue());
- setDataVersion(clone, command.getFqn());
- return null;
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- VersionedDataCommand clone = commandsFactory.buildPutForExternalReadCommand(null, command.getFqn(), command.getKey(), command.getValue());
- setDataVersion(clone, command.getFqn());
- return null;
- }
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- VersionedDataCommand clone = commandsFactory.buildRemoveNodeCommand(command.getGlobalTransaction(), command.getFqn());
- setDataVersion(clone, command.getFqn());
- return null;
- }
-
- @Override
- public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- VersionedDataCommand clone = commandsFactory.buildRemoveKeyCommand(null, command.getFqn(), command.getKey());
- setDataVersion(clone, command.getFqn());
- return null;
- }
-
- @Override
- public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- VersionedDataCommand clone = commandsFactory.buildClearDataCommand(command.getGlobalTransaction(), command.getFqn()
- );
- setDataVersion(clone, command.getFqn());
- return null;
- }
-
- @Override
- public Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- versionedCommands.add(command);
- return command;
- }
-
- @Override
- public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- versionedCommands.add(command);
- return command;
- }
-
- @Override
- public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
- {
- throw new CacheException("Not handling " + command + "!");
- }
-
- /**
- * Digs out the DataVersion for a given Fqn. If the versioning is explicit, it is passed as-is. If implicit, it is
- * cloned and then incremented, and the clone is returned.
- */
- private DataVersion getVersionToBroadcast(TransactionWorkspace w, Fqn f)
- {
- WorkspaceNode n = w.getNode(f);
- if (n == null)
- {
- if (trace) log.trace("Fqn " + f + " not found in workspace; not using a data version.");
- return null;
- }
- if (n.isVersioningImplicit())
- {
- DefaultDataVersion v = (DefaultDataVersion) n.getVersion();
- if (trace)
- log.trace("Fqn " + f + " has implicit versioning. Broadcasting an incremented version.");
-
- // potential bug here - need to check if we *need* to increment at all, because of Configuration.isLockParentForChildInsertRemove()
- return v.increment();
- }
- else
- {
- if (trace) log.trace("Fqn " + f + " has explicit versioning. Broadcasting the version as-is.");
- return n.getVersion();
- }
- }
-
- }
-
- protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws CacheException
- {
- OptimisticTransactionContext transactionContext = (OptimisticTransactionContext) ctx.getTransactionContext();
- if (transactionContext == null)
- {
- throw new CacheException("unable to map global transaction " + ctx + " to transaction entry");
- }
- // try and get the workspace from the transaction
- return transactionContext.getTransactionWorkSpace();
- }
-
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,244 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.AbstractVisitor;
-import org.jboss.cache.commands.VersionedDataCommand;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionContext;
-import org.jboss.cache.transaction.TransactionContext;
-
-import javax.transaction.Transaction;
-import java.util.List;
-
-/**
- * A new interceptor to simplify functionality in the {@link org.jboss.cache.interceptors.TxInterceptor}.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 2.2.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class OptimisticTxInterceptor extends TxInterceptor
-{
- protected final ModificationsReplayVisitor replayVisitor = new ModificationsReplayVisitor();
-
- public OptimisticTxInterceptor()
- {
- optimistic = true;
- }
-
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- // nothing really different from a pessimistic prepare command.
- return visitPrepareCommand(ctx, command);
- }
-
- @Override
- public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
- {
- try
- {
- Transaction tx = ctx.getTransaction();
- boolean implicitTransaction = tx == null;
- if (implicitTransaction)
- {
- tx = createLocalTx();
- // we need to attach this tx to the InvocationContext.
- ctx.setTransaction(tx);
- }
-
- try
- {
- Object retval = attachGtxAndPassUpChain(ctx, command);
- if (implicitTransaction)
- {
- copyInvocationScopeOptionsToTxScope(ctx);
- copyForcedCacheModeToTxScope(ctx);
- txManager.commit();
- }
- return retval;
- }
- catch (Throwable t)
- {
- if (implicitTransaction)
- {
- log.warn("Rolling back, exception encountered", t);
- try
- {
- copyInvocationScopeOptionsToTxScope(ctx);
- copyForcedCacheModeToTxScope(ctx);
- txManager.rollback();
- }
- catch (Throwable th)
- {
- log.warn("Roll back failed encountered", th);
- }
- throw t;
- }
- }
- }
- catch (Throwable th)
- {
- ctx.throwIfNeeded(th);
- }
-
- return null;
- }
-
- private void copyForcedCacheModeToTxScope(InvocationContext ctx)
- {
- Option optionOverride = ctx.getOptionOverrides();
- if (optionOverride != null
- && (optionOverride.isForceAsynchronous() || optionOverride.isForceSynchronous()))
- {
- TransactionContext transactionContext = ctx.getTransactionContext();
- if (transactionContext != null)
- {
- if (optionOverride.isForceAsynchronous())
- transactionContext.setForceAsyncReplication(true);
- else
- transactionContext.setForceSyncReplication(true);
- }
- }
- }
-
- @Override
- protected PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, boolean onePhaseCommit)
- {
- // optimistic locking NEVER does one-phase prepares.
- return commandsFactory.buildOptimisticPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(), false);
- }
-
- /**
- * Replays modifications by passing them up the interceptor chain.
- *
- * @throws Throwable
- */
- @Override
- protected void replayModifications(InvocationContext ctx, Transaction ltx, PrepareCommand command) throws Throwable
- {
- if (log.isDebugEnabled()) log.debug("Handling optimistic remote prepare " + ctx.getGlobalTransaction());
-
- // invoke all modifications by passing them up the chain, setting data versions first.
- try
- {
- replayVisitor.visitCollection(ctx, command.getModifications());
- }
- catch (Throwable t)
- {
- log.error("Prepare failed!", t);
- throw t;
- }
- }
-
- @Override
- protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
- {
- super.cleanupStaleLocks(ctx);
- TransactionContext transactionContext = ctx.getTransactionContext();
- if (transactionContext != null)
- {
- ((OptimisticTransactionContext) transactionContext).getTransactionWorkSpace().clearNodes();
- }
- }
-
- private class ModificationsReplayVisitor extends AbstractVisitor
- {
- @Override
- public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
- {
- Object result = invokeNextInterceptor(ctx, command);
- assertTxIsStillValid(ctx.getTransaction());
- return result;
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- return handleDataVersionCommand(ctx, command);
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- return handleDataVersionCommand(ctx, command);
- }
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- return handleDataVersionCommand(ctx, command);
- }
-
- @Override
- public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- return handleDataVersionCommand(ctx, command);
- }
-
- @Override
- public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- return handleDataVersionCommand(ctx, command);
- }
-
- private Object handleDataVersionCommand(InvocationContext ctx, VersionedDataCommand command) throws Throwable
- {
- Option originalOption = ctx.getOptionOverrides();
- if (command.isVersioned())
- {
- Option option = new Option();
- option.setDataVersion(command.getDataVersion());
- ctx.setOptionOverrides(option);
- }
- Object retval;
- try
- {
- retval = invokeNextInterceptor(ctx, command);
- assertTxIsStillValid(ctx.getTransaction());
- }
- catch (Throwable t)
- {
- log.error("method invocation failed", t);
- throw t;
- }
- finally
- {
- ctx.setOptionOverrides(originalOption);
- }
- return retval;
- }
- }
-
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,305 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import static org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.optimistic.DataVersioningException;
-import org.jboss.cache.optimistic.DefaultDataVersion;
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.GlobalTransaction;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Validates the data in the {@link TransactionWorkspace} against data in the underlying data structure
- * (versions only) and then applies changes to the underlying data structure. This is only triggered when commit,
- * rollback or prepare method calls are encountered. Other method calls are directly passed up the interceptor chain,
- * untouched. Note that prepare/commit/rollbacks are <b>not</b> passed up the interceptor chain after being processed.
- * <p/>
- * When preparting, this interceptor does nothing more than validate versions.
- * The validation scheme used is based on the {@link org.jboss.cache.optimistic.DataVersion} implementation used.
- * {@link org.jboss.cache.optimistic.DataVersion#newerThan(org.jboss.cache.optimistic.DataVersion)} is used to determine
- * whether the version of one instance is newer than the version of another. It is up to the {@link org.jboss.cache.optimistic.DataVersion}
- * implementation to deal with attempting to compare incompatible version types (and potentially throwing {@link org.jboss.cache.optimistic.DataVersioningException}s.
- * <p/>
- * Upon successful commit, changes in the workspace are applied to the underlying data structure in the cache.
- * <p/>
- * On rollback clears the nodes in the workspace and leaves the underlying data structure untouched.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @author Steve Woodcock (<a href="mailto:stevew@jofti.com">stevew(a)jofti.com</a>)
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class OptimisticValidatorInterceptor extends OptimisticInterceptor
-{
- private boolean useTombstones;
-
- private DataContainer dataContainer;
-
- @Inject
- public void initialize(DataContainer dataContainer)
- {
- this.dataContainer = dataContainer;
- }
-
- @Inject
- private void init()
- {
- CacheMode mode = configuration.getCacheMode();
- useTombstones = (mode == CacheMode.INVALIDATION_ASYNC) || (mode == CacheMode.INVALIDATION_SYNC);
- }
-
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- TransactionWorkspace workspace = getTransactionWorkspace(ctx);
-
- // There is no guarantee that this collection is in any order!
- Collection<WorkspaceNode> nodes = workspace.getNodes().values();
-
- //we ought to have all necessary locks here so lets try and validate
- if (log.isDebugEnabled()) log.debug("Validating " + nodes.size() + " nodes.");
- for (WorkspaceNode workspaceNode : nodes)
- {
- if (workspaceNode.isDirty())
- {
- Fqn fqn = workspaceNode.getFqn();
- if (trace) log.trace("Validating version for node [" + fqn + "]");
-
- NodeSPI underlyingNode;
- underlyingNode = dataContainer.peek(fqn, true, true);
-
- // if this is a newly created node then we expect the underlying node to be null.
- // also, if the node has been deleted in the WS and the underlying node is null, this *may* be ok ... will test again later when comparing versions
- // if not, we have a problem...
- if (underlyingNode == null && !workspaceNode.isCreated() && !workspaceNode.isRemoved())
- {
- throw new DataVersioningException("Underlying node for " + fqn + " is null, and this node wasn't newly created in this transaction! We have a concurrent deletion event.");
- }
-
- // needs to have been created AND modified - we allow concurrent creation if no data is put into the node
- if (underlyingNode != null && underlyingNode.isValid() && workspaceNode.isCreated() && workspaceNode.isModified())
- {
- throw new DataVersioningException("Transaction attempted to create " + fqn + " anew. It has already been created since this transaction started, by another (possibly remote) transaction. We have a concurrent creation event.");
- }
-
- if (underlyingNode != null && !underlyingNode.isValid())
- {
- // we havea tombstone
- if (!workspaceNode.isCreated() && !workspaceNode.isRemoved())
- throw new DataVersioningException("Underlying node doesn't exist but a tombstone does; workspace node should be marked as created!");
- if (underlyingNode.getVersion().newerThan(workspaceNode.getVersion()))
- {
- // we have an out of date node here
- throw new DataVersioningException("Version mismatch for node " + fqn + ": underlying node with version " + workspaceNode.getNode().getVersion() + " is newer than workspace node, with version " + workspaceNode.getVersion());
- }
- }
-
- if (!workspaceNode.isCreated() && (workspaceNode.isRemoved() || workspaceNode.isModified()))
- {
- // if the real node is null, throw a DVE
- if (underlyingNode == null)
- {
- // but not if the WSN has also been deleted
- if (!workspaceNode.isRemoved())
- throw new DataVersioningException("Unable to compare versions since the underlying node has been deleted by a concurrent transaction!");
- else if (trace)
- log.trace("The data node [" + fqn + "] is null, but this is ok since the workspace node is marked as deleted as well");
- }
- // if there is a DataVersion type mismatch here, leave it up to the DataVersion impl to barf if necessary. - JBCACHE-962
- else if (underlyingNode.getVersion().newerThan(workspaceNode.getVersion()))
- {
- // we have an out of date node here
- throw new DataVersioningException("Version mismatch for node " + fqn + ": underlying node with version " + workspaceNode.getNode().getVersion() + " is newer than workspace node, with version " + workspaceNode.getVersion());
- }
- }
- }
- else
- {
- if (trace) log.trace("Node [" + workspaceNode.getFqn() + "] doesn't need validating as it isn't dirty");
- }
- }
- log.debug("Successfully validated nodes");
- return invokeNextInterceptor(ctx, command);
- }
-
- @SuppressWarnings("unchecked")
- private void commitTransaction(InvocationContext ctx)
- {
- GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionWorkspace workspace;
- workspace = getTransactionWorkspace(ctx);
-
- if (log.isDebugEnabled()) log.debug("Commiting successfully validated changes for GlobalTransaction " + gtx);
- Collection<WorkspaceNode> workspaceNodes = workspace.getNodes().values();
- for (WorkspaceNode workspaceNode : workspaceNodes)
- {
- NodeSPI underlyingNode = workspaceNode.getNode();
- // short circuit if this node is deleted?
- if (workspaceNode.isRemoved())
- {
- if (trace) log.trace("Workspace node " + workspaceNode.getFqn() + " deleted; removing");
-
- if (underlyingNode.getFqn().isRoot())
- {
- throw new CacheException("An illegal attempt to delete the root node!");
- }
- else
- {
- // mark it as invalid so any direct references are marked as such
- underlyingNode.setValid(false, true);
- // we need to update versions here, too
- performVersionUpdate(underlyingNode, workspaceNode);
-
- if (!useTombstones)
- {
- // don't retain the tombstone
- NodeSPI parent = underlyingNode.getParentDirect();
- if (parent == null)
- {
- throw new CacheException("Underlying node " + underlyingNode + " has no parent");
- }
-
- parent.removeChildDirect(underlyingNode.getFqn().getLastElement());
- }
- }
- }
- else
- {
- boolean updateVersion = false;
- if (workspaceNode.isChildrenModified() || workspaceNode.isResurrected()) // if it is newly created make sure we remove all underlying children that may exist, to solve a remove-and-create-in-tx condition
- {
- if (trace) log.trace("Updating children since node has modified children");
- // merge children.
- List<Set<Fqn>> deltas = workspaceNode.getMergedChildren();
-
- if (trace) log.trace("Applying children deltas to parent node " + underlyingNode.getFqn());
-
- if (workspaceNode.isResurrected())
- {
- // mark it as invalid so any direct references are marked as such
- Map childNode = underlyingNode.getChildrenMapDirect();
- for (Object o : childNode.values())
- {
- NodeSPI cn = (NodeSPI) o;
- cn.setValid(false, true);
- if (!useTombstones) underlyingNode.removeChildDirect(cn.getFqn().getLastElement());
- }
- }
-
- for (Fqn child : deltas.get(0))
- {
- NodeSPI childNode = workspace.getNode(child).getNode();
- underlyingNode.addChildDirect(childNode);
- childNode.setValid(true, false);
- }
-
- for (Fqn child : deltas.get(1))
- {
- // mark it as invalid so any direct references are marked as such
- NodeSPI childNode = underlyingNode.getChildDirect(child.getLastElement());
- if (childNode != null) childNode.setValid(false, true);
-
- if (!useTombstones) underlyingNode.removeChildDirect(child.getLastElement());
- }
-
- updateVersion = underlyingNode.isLockForChildInsertRemove();
-
- // do we need to notify listeners of a modification?? If all we've done is added children then don't
- // notify.
- }
-
- if (workspaceNode.isModified())
- {
- if (trace) log.trace("Merging data since node is dirty");
- Map mergedData = workspaceNode.getMergedData();
- underlyingNode.clearDataDirect();
- underlyingNode.putAllDirect(mergedData);
-
- // mark node and any parents as valid- if available. Versioning parents are tough though - leave as old versions?
- validateNodeAndParents(underlyingNode);
- updateVersion = true;
- }
-
- if (updateVersion)
- {
- performVersionUpdate(underlyingNode, workspaceNode);
- }
- }
- }
- }
-
- @Override
- public Object visitCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- commitTransaction(ctx);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- TransactionWorkspace workspace;
- workspace = getTransactionWorkspace(ctx);
- workspace.clearNodes();
- return invokeNextInterceptor(ctx, command);
- }
-
-
- private void validateNodeAndParents(NodeSPI node)
- {
- node.setValid(true, false);
- if (!node.getFqn().isRoot()) validateNodeAndParents(node.getParentDirect());
- }
-
- private void performVersionUpdate(NodeSPI underlyingNode, WorkspaceNode workspaceNode)
- {
- if (workspaceNode.isVersioningImplicit())
- {
- if (trace) log.trace("Versioning is implicit; incrementing.");
- underlyingNode.setVersion(((DefaultDataVersion) workspaceNode.getVersion()).increment());
- }
- else
- {
- if (trace) log.trace("Versioning is explicit; not attempting an increment.");
- underlyingNode.setVersion(workspaceNode.getVersion());
- }
-
- if (trace)
- log.trace("Setting version of node " + underlyingNode.getFqn() + " from " + workspaceNode.getVersion() + " to " + underlyingNode.getVersion());
- }
-
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,13 +25,13 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.notifications.Notifier;
+import org.jboss.starobrno.factories.annotations.Inject;
import java.util.Collections;
import java.util.HashMap;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,402 +0,0 @@
-/*
- * 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.cache.interceptors;
-
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.DataCommand;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.commands.legacy.ReversibleCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.lock.LockManager;
-import static org.jboss.cache.lock.LockType.READ;
-import static org.jboss.cache.lock.LockType.WRITE;
-import org.jboss.cache.lock.LockUtil;
-import org.jboss.cache.lock.PessimisticNodeBasedLockManager;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.PessimisticTransactionContext;
-import org.jboss.cache.transaction.TransactionContext;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * An interceptor that handles locking. When a TX is associated, we register
- * for TX completion and unlock the locks acquired within the scope of the TX.
- * When no TX is present, we keep track of the locks acquired during the
- * current method and unlock when the method returns.
- *
- * @author Bela Ban
- * @version $Id$
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class PessimisticLockInterceptor extends PrePostProcessingCommandInterceptor
-{
- private DataContainer dataContainer;
- private PessimisticNodeBasedLockManager lockManager;
- private CommandsFactory commandsFactory;
-
- @Inject
- public void injectDependencies(DataContainer dataContainer, LockManager lockManager, CommandsFactory commandsFactory)
- {
- this.dataContainer = dataContainer;
- this.lockManager = (PessimisticNodeBasedLockManager) lockManager;
- this.commandsFactory = commandsFactory;
- }
-
- @Override
- protected Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- return handlePutCommand(ctx, command, false);
- }
-
- @Override
- protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- return handlePutCommand(ctx, command, false);
- }
-
- @Override
- protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- return handlePutCommand(ctx, command, true);
- }
-
- private Object handlePutCommand(InvocationContext ctx, DataCommand command, boolean zeroAcquisitionTimeout)
- throws Throwable
- {
- if ((ctx.isLockingSuppressed()) || configuration.getIsolationLevel() == IsolationLevel.NONE)
- {
- if (trace) log.trace("Suppressing locking, creating nodes if necessary");
- int treeNodeSize = command.getFqn().size();
- NodeSPI n = dataContainer.getRoot();
- for (int i = 0; i < treeNodeSize; i++)
- {
- Object childName = command.getFqn().get(i);
- Fqn childFqn = Fqn.fromElements(childName);
- NodeSPI childNode = n.getChildDirect(childFqn);
- if (childNode == null) childNode = n.addChildDirect(childFqn);
- LockUtil.manageReverseRemove(ctx, childNode, true, null, commandsFactory);
- n = childNode;
- }
- }
- else
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, true,
- zeroAcquisitionTimeout, false, true, null, false);
- }
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- protected Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
- {
- // 2-phase commit prepares are no-ops here.
- if (!command.isOnePhaseCommit()) return invokeNextInterceptor(ctx, command);
-
- // commit propagated up from the tx interceptor
- commit(ctx.getTransactionContext(), ctx.getGlobalTransaction());
- Object retVal = invokeNextInterceptor(ctx, command);
- lockManager.unlock(ctx);
- return retVal;
- }
-
- @Override
- protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
- {
- commit(ctx.getTransactionContext(), command.getGlobalTransaction());
- if (trace) log.trace("bypassed locking as method commit() doesn't require locking");
- Object retVal = invokeNextInterceptor(ctx, command);
- lockManager.unlock(ctx);
- return retVal;
- }
-
- @Override
- protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- TransactionContext transactionContext = ctx.getTransactionContext();
- if (trace)
- {
- log.trace("called to rollback cache with GlobalTransaction=" + command.getGlobalTransaction());
- }
- if (transactionContext == null)
- {
- log.error("transactionContext for transaction " + command.getGlobalTransaction() + " not found (transaction has possibly already been rolled back)");
- }
- else
- {
- for (Fqn fqn : transactionContext.getRemovedNodes())
- {
- dataContainer.removeFromDataStructure(fqn, false);
- }
- // 1. Revert the modifications by running the undo-op list in reverse. This *cannot* throw any exceptions !
-
- undoOperations((PessimisticTransactionContext) transactionContext);
- }
- if (trace)
- {
- log.trace("bypassed locking as method rollback() doesn't require locking");
- }
- Object retVal = invokeNextInterceptor(ctx, command);
- lockManager.unlock(ctx);
- return retVal;
- }
-
- private void undoOperations(PessimisticTransactionContext transactionContext)
- {
- List<WriteCommand> modificationList = transactionContext.getAllModifications();
-
- if (modificationList.isEmpty())
- {
- if (trace) log.trace("Modification list is null, no modifications in this transaction!");
- return;
- }
-
- if (trace) log.trace("undoOperations " + modificationList);
-
- ArrayList<WriteCommand> copy;
- copy = new ArrayList<WriteCommand>(modificationList);
- RuntimeException exc = null;
- for (ListIterator<WriteCommand> i = copy.listIterator(copy.size()); i.hasPrevious();)
- {
- WriteCommand undoOp = i.previous();
- // since we are using pessimistic locking, all pessimistic WriteCommands implement ReversibleCommand.
- ReversibleCommand txCommand = (ReversibleCommand) undoOp;
- if (log.isDebugEnabled()) log.debug("Calling rollback() on command " + undoOp);
- try
- {
- txCommand.rollback();
- }
- catch (RuntimeException re)
- {
- exc = re;
- }
- }
- if (exc != null) throw exc;
- }
-
- @Override
- protected Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
-
- // this call will ensure the node gets a WL and its current parent gets RL.
- if (trace) log.trace("Attempting to get WL on node to be moved [" + command.getFqn() + "]");
- if (command.getFqn() != null && !(configuration.getIsolationLevel() == IsolationLevel.NONE))
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, false, false, true, false, null, false);
- if (ctx.getGlobalTransaction() != null)
- {
- ctx.getTransactionContext().addRemovedNode(command.getFqn());
- }
- lockManager.lockAllAndRecord(dataContainer.peek(command.getFqn(), true, false), WRITE, ctx);
- }
- if (command.getTo() != null && !(configuration.getIsolationLevel() == IsolationLevel.NONE))
- {
- //now for an RL for the new parent.
- if (trace) log.trace("Attempting to get RL on new parent [" + command.getTo() + "]");
- lockManager.lockPessimistically(ctx, command.getTo(), READ, false, false, false, false, null, false);
- lockManager.lockAllAndRecord(dataContainer.peek(command.getTo(), true, false), READ, ctx);
- }
- Object retValue = invokeNextInterceptor(ctx, command);
-
- if (ctx.getTransaction() == null) // not transactional
- {
- // do a REAL remove here.
- NodeSPI n = dataContainer.peek(command.getFqn(), true, false);
- if (n != null) lockManager.unlockAll(n, Thread.currentThread());
- }
-
- return retValue;
- }
-
- @Override
- protected Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- if (ctx.isLockingSuppressed()) return invokeNextInterceptor(ctx, command);
- // need to make a note of ALL nodes created here!!
- List<NodeSPI> createdNodes = new LinkedList<NodeSPI>();
- // we need to mark new nodes created as deleted since they are only created to form a path to the node being removed, to
- // create a lock.
- boolean created = lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, true, false, true, true, createdNodes, true);
- TransactionContext transactionContext = null;
- if (ctx.getGlobalTransaction() != null)
- {
- transactionContext = ctx.getTransactionContext();
- transactionContext.addRemovedNode(command.getFqn());
- for (NodeSPI nodeSPI : createdNodes)
- {
- transactionContext.addRemovedNode(nodeSPI.getFqn());
- nodeSPI.markAsDeleted(true);
- }
- }
-
- lockAllForRemoval(dataContainer.peek(command.getFqn(), false, false), ctx, transactionContext);
-
- if (!createdNodes.isEmpty())
- {
- if (trace) log.trace("There were new nodes created, skipping notification on delete");
- if (trace)
- log.trace("Changing 'skipNotification' for command 'remove' from " + command.isSkipSendingNodeEvents() + " to true");
- command.setSkipSendingNodeEvents(true);
- }
-
- Object retVal = invokeNextInterceptor(ctx, command);
- // and make sure we remove all nodes we've created for the sake of later removal.
- if (ctx.getGlobalTransaction() == null)
- {
- for (NodeSPI nodeSPI : createdNodes) dataContainer.removeFromDataStructure(nodeSPI.getFqn(), true);
- dataContainer.removeFromDataStructure(command.getFqn(), true);
-
- NodeSPI n = dataContainer.peek(command.getFqn(), true, false);
- if (n != null) lockManager.unlockAll(n, Thread.currentThread());
- }
- // if this is a delete op and we had to create the node, return a FALSE as nothing *really* was deleted!
- return created ? false : retVal;
- }
-
- /**
- * Acquires write locks on the node and all child nodes, adding children to the list of removed nodes in the context.
- *
- * @param node node to inspect
- * @param ctx invocation context
- * @param transactionContext transaction entry
- * @throws InterruptedException in the event of interruption
- */
- @SuppressWarnings("unchecked")
- public void lockAllForRemoval(NodeSPI node, InvocationContext ctx, TransactionContext transactionContext) throws InterruptedException
- {
- if (node == null) return;
- // lock node
- lockManager.lockAndRecord(node, WRITE, ctx);
-
- // add to deleted list
- if (transactionContext != null) transactionContext.addRemovedNode(node.getFqn());
-
- // now children.
- Map<Object, NodeSPI> children = node.getChildrenMapDirect();
- for (NodeSPI child : children.values())
- {
- // lock child.
- lockAllForRemoval(child, ctx, transactionContext);
- }
- }
-
- @Override
- protected Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, false, false, false, false, null, false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- protected Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, false, false, false, false, null, false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- protected Object handleEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, false, true, false, false, null, false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- protected Object handleGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), READ, false, false, false, false, null, false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- protected Object handleGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), READ, false, false, false, false, null, false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- protected Object handleGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), READ, false, false, false, false, null, false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- protected Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- lockManager.lockPessimistically(ctx, command.getFqn(), READ, false, false, false, false, null, false);
- return invokeNextInterceptor(ctx, command);
- }
-
- @Override
- public void doAfterCall(InvocationContext ctx, VisitableCommand command)
- {
- if (!ctx.isValidTransaction()) lockManager.unlock(ctx);
- }
-
- /**
- * Remove all locks held by <tt>tx</tt>, remove the transaction from the transaction table
- */
- private void commit(TransactionContext transactionContext, GlobalTransaction gtx)
- {
- if (trace) log.trace("committing cache with gtx " + gtx);
- if (transactionContext == null)
- {
- log.error("transactionContext for transaction " + gtx + " not found (maybe already committed)");
- return;
- }
- // first remove nodes that should be deleted.
- for (Fqn fqn : transactionContext.getRemovedNodes())
- {
- dataContainer.removeFromDataStructure(fqn, false);
- }
- }
-
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -34,9 +34,9 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.starobrno.config.Configuration;
/**
* Takes care of replicating modifications to other nodes in a cluster. Also
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.CacheException;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.ReplicationException;
@@ -31,7 +30,6 @@
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -40,9 +38,7 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Option;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.context.ContextFactory;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
@@ -53,6 +49,9 @@
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.annotations.Inject;
import javax.transaction.InvalidTransactionException;
import javax.transaction.Status;
@@ -793,12 +792,6 @@
return null;
}
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- command.setGlobalTransaction(gtx);
- return null;
- }
});
return command;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -26,8 +26,8 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
/**
* This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/JmxStatsCommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/JmxStatsCommandInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/JmxStatsCommandInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,9 +21,9 @@
*/
package org.jboss.cache.interceptors.base;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.jmx.JmxStatisticsExposer;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
+import org.jboss.starobrno.factories.annotations.Start;
import java.util.Collections;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,29 +1,28 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.interceptors.base;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -32,7 +31,6 @@
import org.jboss.cache.commands.read.GetNodeCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -136,29 +134,7 @@
return handleDefault(ctx, command);
}
- @Override
- public final Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- try
- {
- return doBeforeCall(ctx, command) ? handleCreateNodeCommand(ctx, command) : null;
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
- /**
- * @deprecated in 3.0. Will be removed when Optimistic and Pessimistic locking is removed.
- */
- @Deprecated
- protected Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
-
@Override
public final Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
{
@@ -429,24 +405,7 @@
return handleDefault(ctx, command);
}
- @Override
- public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- try
- {
- return doBeforeCall(ctx, command) ? handleOptimisticPrepareCommand(ctx, command) : null;
- }
- finally
- {
- doAfterCall(ctx, command);
- }
- }
- protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- return handleDefault(ctx, command);
- }
-
/**
* Callback that is invoked after every handleXXX() method defined above.
*
Modified: core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.interceptors.base;
import org.jboss.cache.InvocationContext;
@@ -31,7 +31,6 @@
import org.jboss.cache.commands.read.GetNodeCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
@@ -346,21 +345,6 @@
}
@Override
- public final Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- if (skipInterception(ctx, command))
- {
- return invokeNextInterceptor(ctx, command);
- }
- return handleOptimisticPrepareCommand(ctx, command);
- }
-
- protected Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- return handleAll(ctx, command);
- }
-
- @Override
public final Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
{
if (skipInterception(ctx, command))
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,10 +22,10 @@
package org.jboss.cache.invocation;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.InterceptorChain;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
/**
* The JBoss Cache hand-wired interceptor stack. A "minimal" AOP framework which uses delegation through an
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.DataContainer;
@@ -53,14 +52,7 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.Option;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
@@ -70,6 +62,14 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.Configuration.NodeLockingScheme;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.Option;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
import org.jgroups.Address;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,9 +22,9 @@
package org.jboss.cache.invocation;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.context.ContextFactory;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
/**
* Container and factory for thread locals
Deleted: core/branches/flat/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,81 +0,0 @@
-/*
- * 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.cache.invocation;
-
-import org.jboss.cache.DataContainer;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeSPI;
-
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * This is to provide backward compatibility with legacy locking schemes.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class LegacyInvocationContext extends InvocationContext
-{
- DataContainer container;
-
- public LegacyInvocationContext(DataContainer container)
- {
- this.container = container;
- }
-
- public NodeSPI lookUpNode(Fqn fqn)
- {
- return container.peek(fqn);
- }
-
- public void putLookedUpNode(Fqn f, NodeSPI n)
- {
- // a no-op by default.
- }
-
- public void putLookedUpNodes(Map<Fqn, NodeSPI> lookedUpNodes)
- {
- // a no-op by default.
- }
-
- public void clearLookedUpNodes()
- {
- // no-op
- }
-
- public Map<Fqn, NodeSPI> getLookedUpNodes()
- {
- // a no-op by default.
- return Collections.emptyMap();
- }
-
- public InvocationContext copy()
- {
- LegacyInvocationContext copy = new LegacyInvocationContext(container);
- doCopy(copy);
- return copy;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
@@ -32,10 +31,10 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeNotValidException;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.config.Option;
import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Option;
import java.util.Collections;
import java.util.HashSet;
@@ -148,16 +147,6 @@
throw new CacheException("This method is deprecated!");
}
- public void setVersion(DataVersion version)
- {
- node.setVersion(version);
- }
-
- public DataVersion getVersion()
- {
- return node.getVersion();
- }
-
public Set<NodeSPI<K, V>> getChildrenDirect()
{
return node.getChildrenDirect();
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapper.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,22 +24,22 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.RuntimeConfig;
-import org.jboss.cache.config.parsing.JGroupsStackParser;
-import org.jboss.cache.config.parsing.element.BuddyElementParser;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
-import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.util.CachePrinter;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.EvictionConfig;
+import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.config.parsing.JGroupsStackParser;
+import org.jboss.starobrno.config.parsing.element.BuddyElementParser;
+import org.jboss.starobrno.config.parsing.element.EvictionElementParser;
+import org.jboss.starobrno.config.parsing.element.LoadersElementParser;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.ChannelFactory;
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/CacheJmxWrapperMBean.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,9 +22,9 @@
package org.jboss.cache.jmx;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheStatus;
-import org.jboss.cache.config.Configuration;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
import org.jgroups.Address;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxRegistrationManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,10 +24,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,8 +21,9 @@
*/
package org.jboss.cache.jmx;
-import org.jboss.cache.config.Configuration;
+import org.jboss.starobrno.config.Configuration;
+
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
Modified: core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/jmx/PlatformMBeanServerRegistration.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,11 +24,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
/**
* If {@link org.jboss.cache.config.Configuration#getExposeManagementStatistics()} is true, then class will register
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
@@ -36,6 +35,7 @@
import org.jboss.cache.marshall.NodeDataExceptionMarker;
import org.jboss.cache.marshall.NodeDataMarker;
import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.CacheException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AbstractDelegatingCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,7 +25,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,10 +25,10 @@
import org.apache.commons.logging.Log;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.lock.StripedLock;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.CacheLoaderConfig;
import java.io.IOException;
import java.io.InputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.IOException;
import java.util.ArrayList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/AsyncCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -26,7 +26,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,20 +23,20 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import java.util.ArrayList;
import java.util.Iterator;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/ChainingCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,10 +24,10 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.factories.annotations.Inject;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -37,9 +37,9 @@
import org.jboss.cache.commands.read.GetDataMapCommand;
import org.jboss.cache.commands.read.GetKeyValueCommand;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.lock.StripedLock;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.factories.annotations.Inject;
import org.jgroups.Address;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RspFilter;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/ClusteredCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,9 +21,10 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.config.Dynamic;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.Dynamic;
+
import java.util.Properties;
public class ClusteredCacheLoaderConfig extends IndividualCacheLoaderConfig
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,8 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.lock.StripedLock;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.util.stream.MarshalledValueInputStream;
import java.io.File;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/FileCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,9 +21,9 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
-import org.jboss.cache.config.Dynamic;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.Dynamic;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,9 +25,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.marshall.NodeData;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.InputStream;
import java.io.ObjectInputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOld.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,7 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.sql.Connection;
import java.sql.PreparedStatement;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/JDBCCacheLoaderOldConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig;
/**
* Cache loader configuration for JDBCCacheLoaderOld implementation.
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,7 +25,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/LocalDelegatingCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,7 +22,7 @@
package org.jboss.cache.loader;
import org.jboss.cache.Cache;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -27,14 +27,14 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.CacheStarted;
import org.jboss.cache.notifications.annotation.CacheStopped;
import org.jboss.cache.notifications.annotation.ViewChanged;
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.notifications.event.ViewChangedEvent;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.jgroups.Address;
import org.jgroups.View;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreDefaultConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreDefaultConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/SingletonStoreDefaultConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,9 +21,10 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
-import org.jboss.cache.config.Dynamic;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
+import org.jboss.starobrno.config.Dynamic;
+
import java.util.Properties;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.tcp.TcpCacheOperations;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/TcpDelegatingCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -43,9 +43,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.AbstractCacheLoader;
import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.File;
import java.io.IOException;
@@ -553,8 +553,9 @@
throws Exception
{
// JBCACHE-769 -- make a defensive copy
- if (values != null && !(values instanceof HashMap)) {
- values = new HashMap(values);
+ if (values != null && !(values instanceof HashMap))
+ {
+ values = new HashMap(values);
}
/* To update-or-insert, try putNoOverwrite first, then a RMW cycle. */
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.loader.bdbje;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -33,8 +33,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.FqnComparator;
import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.File;
import java.io.IOException;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,8 +21,8 @@
*/
package org.jboss.cache.loader.jdbm;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -32,8 +32,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.io.BufferedInputStream;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3Exception.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3Exception.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3Exception.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.loader.s3;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
/**
* Basic exception class.
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3LoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3LoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/s3/S3LoaderConfig.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,8 +24,8 @@
import net.noderunner.amazon.s3.Bucket;
import net.noderunner.amazon.s3.CallingFormat;
import net.noderunner.amazon.s3.Connection;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import java.lang.reflect.Field;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/loader/tcp/TcpCacheServer.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
@@ -32,6 +31,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.jmx.CacheJmxWrapperMBean;
+import org.jboss.starobrno.CacheException;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -483,7 +483,8 @@
return sb.toString();
}
- protected void handleModifications(List<Modification> modifications) throws CacheException
+ protected void handleModifications(List<Modification> modifications) throws
+ CacheException
{
for (Modification m : modifications)
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/AbstractLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/AbstractLockManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/AbstractLockManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,9 +22,9 @@
package org.jboss.cache.lock;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
/**
* Common lock manager functionality
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/LockStrategyFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,11 +21,10 @@
*/
package org.jboss.cache.lock;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
/**
@@ -52,7 +51,7 @@
@Start(priority = 1)
public void start()
{
- lockingLevel = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC ? IsolationLevel.REPEATABLE_READ : configuration.getIsolationLevel();
+ lockingLevel = configuration.getIsolationLevel();
}
public LockStrategy getLockStrategy()
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/LockingException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/LockingException.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/LockingException.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.lock;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -30,14 +30,14 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.invocation.InvocationContextContainer;
import static org.jboss.cache.lock.LockType.READ;
import org.jboss.cache.util.concurrent.locks.LockContainer;
import org.jboss.cache.util.concurrent.locks.OwnableReentrantLock;
import org.jboss.cache.util.concurrent.locks.OwnableReentrantLockContainer;
import org.jboss.cache.util.concurrent.locks.ReentrantLockContainer;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import javax.transaction.TransactionManager;
import java.util.Collection;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,24 +1,24 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.lock;
import org.apache.commons.logging.Log;
@@ -27,8 +27,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import java.util.ArrayList;
import java.util.Collection;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -27,10 +27,10 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.factories.annotations.Inject;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.factories.annotations.Inject;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/lock/TimeoutException.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.lock;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
/**
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -42,16 +42,15 @@
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.tx.AbstractTransactionCommand;
import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import org.jgroups.util.Buffer;
import java.io.InputStream;
@@ -150,7 +149,6 @@
//Object[] args = cmd.getParameters();
switch (cmd.getCommandId())
{
- case OptimisticPrepareCommand.METHOD_ID:
case PrepareCommand.METHOD_ID:
// Prepare method has a list of modifications. We will just take the first one and extract.
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,18 +21,17 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.Region.Status;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.util.FastCopyHashMap;
import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.factories.annotations.Inject;
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
@@ -342,11 +341,6 @@
out.writeByte(MAGICNUMBER_IPADDRESS);
marshallIpAddress((IpAddress) o, out);
}
- else if (o instanceof DefaultDataVersion)
- {
- out.writeByte(MAGICNUMBER_DEFAULT_DATA_VERSION);
- marshallDefaultDataVersion((DefaultDataVersion) o, out);
- }
else if (o.getClass().equals(ArrayList.class))
{
out.writeByte(MAGICNUMBER_ARRAY_LIST);
@@ -602,9 +596,6 @@
case MAGICNUMBER_IPADDRESS:
retVal = unmarshallIpAddress(in);
return retVal;
- case MAGICNUMBER_DEFAULT_DATA_VERSION:
- retVal = unmarshallDefaultDataVersion(in);
- return retVal;
case MAGICNUMBER_ARRAY:
return unmarshallArray(in, refMap);
case MAGICNUMBER_ARRAY_LIST:
@@ -813,18 +804,6 @@
for (int i = 0; i < listSize; i++) listToPopulate.add(unmarshallObject(in, refMap));
}
- @SuppressWarnings("deprecation")
- protected void marshallDefaultDataVersion(DefaultDataVersion ddv, ObjectOutputStream out) throws Exception
- {
- writeUnsignedLong(out, ddv.getRawVersion());
- }
-
- @SuppressWarnings("deprecation")
- protected DefaultDataVersion unmarshallDefaultDataVersion(ObjectInputStream in) throws Exception
- {
- return new DefaultDataVersion(readUnsignedLong(in));
- }
-
/**
* Reads a reference from a given stream.
*
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller300.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller300.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/CacheMarshaller300.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
import java.io.ObjectOutputStream;
import java.lang.reflect.Array;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -27,11 +27,11 @@
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.util.concurrent.WithinThreadExecutor;
+import org.jboss.starobrno.config.Configuration;
import org.jgroups.Address;
import org.jgroups.Channel;
import org.jgroups.MembershipListener;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionException.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/InactiveRegionException.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
/**
* Thrown by a {@link org.jboss.cache.marshall.AbstractMarshaller} instance when attempting to perform an operation on an inactive region.
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValue.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValue.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
import org.jboss.util.stream.MarshalledValueInputStream;
import java.io.ByteArrayInputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValueMap.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValueMap.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/MarshalledValueMap.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,7 +22,7 @@
package org.jboss.cache.marshall;
import net.jcip.annotations.Immutable;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
import java.io.Externalizable;
import java.io.IOException;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/MethodCall.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/MethodCall.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/MethodCall.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,6 @@
*/
package org.jboss.cache.marshall;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import java.lang.reflect.Method;
@@ -66,8 +65,6 @@
{
case PrepareCommand.METHOD_ID:
return (Boolean) this.getArgs()[3];
- case OptimisticPrepareCommand.METHOD_ID:
- return (Boolean) this.getArgs()[4];
default:
return false;
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/UnmarshalledReferences.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,27 +1,27 @@
-/*
- * 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.
- */
+/*
+ * 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.cache.marshall;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
import java.util.ArrayList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -25,11 +25,11 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.util.stream.MarshalledValueInputStream;
import java.io.ByteArrayInputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -29,8 +29,8 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.UnversionedNode;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.starobrno.factories.annotations.Start;
import java.util.Map;
Modified: core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
@@ -31,13 +30,14 @@
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.lock.TimeoutException;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
import java.util.Collection;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -28,7 +28,6 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.Map;
@@ -237,16 +236,6 @@
delegate.removeChildren();
}
- public final void setVersion(DataVersion version)
- {
- delegate.setVersion(version);
- }
-
- public final DataVersion getVersion()
- {
- return delegate.getVersion();
- }
-
public final Fqn getFqn()
{
return delegate.getFqn();
Modified: core/branches/flat/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -29,7 +29,7 @@
import org.jboss.cache.InvocationContext;
import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.CHANGED;
import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.DELETED;
-import org.jboss.cache.optimistic.DataVersioningException;
+import org.jboss.starobrno.CacheException;
/**
* A node delegate that encapsulates repeatable read semantics when writes are initiated, committed or rolled back.
@@ -65,7 +65,7 @@
{
String errormsg = new StringBuilder().append("Detected write skew on Fqn [").append(fqn).append("]. Another process has changed the node since we last read it!").toString();
if (log.isWarnEnabled()) log.warn(errormsg + ". Unable to copy node for update.");
- throw new DataVersioningException(errormsg);
+ throw new CacheException(errormsg);
}
}
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/IncorrectCacheListenerException.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.notifications;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
/**
* Thrown when an incorrectly annotated class is added as a cache listener using the {@link org.jboss.cache.Cache#addCacheListener(Object)} API.
Modified: core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,23 +24,23 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Destroy;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.marshall.MarshalledValueMap;
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.*;
import static org.jboss.cache.notifications.event.Event.Type.*;
import org.jboss.cache.util.Immutables;
import org.jboss.cache.util.concurrent.WithinThreadExecutor;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Destroy;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
import org.jgroups.View;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/remoting/jgroups/ChannelMessageListener.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,14 +23,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.io.ExposedByteArrayOutputStream;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import org.jgroups.ExtendedMessageListener;
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferGenerator.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -28,11 +28,11 @@
import org.jboss.cache.InternalNode;
import org.jboss.cache.Node;
import org.jboss.cache.Version;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.marshall.NodeDataExceptionMarker;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import java.io.IOException;
import java.io.ObjectOutputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
@@ -31,15 +30,16 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.marshall.NodeDataExceptionMarker;
import org.jboss.cache.marshall.NodeDataMarker;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import java.io.IOException;
import java.io.ObjectInputStream;
Modified: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,21 +23,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.RegionEmptyException;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.InactiveRegionException;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.marshall.NodeDataMarker;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferGenerator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferGenerator.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferGenerator.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,200 +0,0 @@
-/*
- * 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.cache.statetransfer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InternalNode;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.Version;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.marshall.NodeDataExceptionMarker;
-
-import java.io.ObjectOutputStream;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-@Deprecated
-public class LegacyStateTransferGenerator implements StateTransferGenerator
-{
-
- public static final short STATE_TRANSFER_VERSION = Version.getVersionShort("2.0.0.GA");
-
- private Log log = LogFactory.getLog(getClass().getName());
-
- private CacheSPI cache;
-
- private Set<Fqn> internalFqns;
-
- @Inject
- public void inject(CacheSPI cache)
- {
- this.cache = cache;
- }
-
- @Start(priority = 18)
- private void start()
- {
- this.internalFqns = cache.getInternalFqns();
- }
-
- public void generateState(ObjectOutputStream out, Object rootNode, boolean generateTransient,
- boolean generatePersistent, boolean suppressErrors) throws Exception
- {
- Fqn fqn = getFqn(rootNode);
- try
- {
- cache.getMarshaller().objectToObjectStream(STATE_TRANSFER_VERSION, out);
- if (generateTransient)
- {
- //transient + marker
- if (log.isTraceEnabled())
- {
- log.trace("writing transient state for " + fqn);
- }
- marshallTransientState((NodeSPI) rootNode, out);
- delimitStream(out);
-
- if (log.isTraceEnabled())
- {
- log.trace("transient state succesfully written");
- }
-
- //associated + marker
- if (log.isTraceEnabled())
- {
- log.trace("writing associated state");
- }
-
- delimitStream(out);
-
- if (log.isTraceEnabled())
- {
- log.trace("associated state succesfully written");
- }
-
- }
- else
- {
- //we have to write two markers for transient and associated
- delimitStream(out);
- delimitStream(out);
- }
-
- CacheLoader cacheLoader = cache.getCacheLoaderManager() == null ? null : cache.getCacheLoaderManager().getCacheLoader();
- if (cacheLoader != null && generatePersistent)
- {
- if (log.isTraceEnabled())
- {
- log.trace("writing persistent state for " + fqn + ",using " + cache.getCacheLoaderManager().getCacheLoader().getClass());
- }
-
- if (fqn.isRoot())
- {
- cacheLoader.loadEntireState(out);
- }
- else
- {
- cacheLoader.loadState(fqn, out);
- }
-
- if (log.isTraceEnabled())
- {
- log.trace("persistent state succesfully written");
- }
- }
- delimitStream(out);
- }
- catch (Exception e)
- {
- cache.getMarshaller().objectToObjectStream(new NodeDataExceptionMarker(e, cache.getLocalAddress()), out);
- throw e;
- }
- }
-
- private Fqn getFqn(Object o)
- {
- if (o instanceof Node) return ((Node) o).getFqn();
- if (o instanceof InternalNode) return ((InternalNode) o).getFqn();
- throw new IllegalArgumentException();
- }
-
- /**
- * Places a delimiter marker on the stream
- *
- * @param out stream
- * @throws java.io.IOException if there are errs
- */
- protected void delimitStream(ObjectOutputStream out) throws Exception
- {
- cache.getMarshaller().objectToObjectStream(DefaultStateTransferManager.STREAMING_DELIMITER_NODE, out);
- }
-
- /**
- * Do a preorder traversal: visit the node first, then the node's children
- *
- * @param out
- * @throws Exception
- */
- protected void marshallTransientState(NodeSPI node, ObjectOutputStream out) throws Exception
- {
- List<NodeData> nodeData = new LinkedList<NodeData>();
- generateNodeDataList(node, nodeData);
- cache.getMarshaller().objectToObjectStream(nodeData, out, node.getFqn());
- }
-
- protected void generateNodeDataList(NodeSPI<?, ?> node, List<NodeData> list) throws Exception
- {
- if (internalFqns.contains(node.getFqn()))
- {
- return;
- }
-
- Map attrs;
- NodeData nd;
-
- // first handle the current node
- attrs = node.getInternalState(false);
-
- if (attrs.size() == 0)
- {
- nd = new NodeData(node.getFqn());
- }
- else
- {
- nd = new NodeData(node.getFqn(), attrs, true);
- }
-
- list.add(nd);
-
- // then visit the children
- for (NodeSPI child : node.getChildrenDirect()) generateNodeDataList(child, list);
- }
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,423 +0,0 @@
-/*
- * 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.cache.statetransfer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeFactory;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.Region;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.eviction.EvictionEvent;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.loader.CacheLoader;
-import org.jboss.cache.loader.CacheLoaderManager;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.marshall.NodeDataExceptionMarker;
-import org.jboss.cache.marshall.NodeDataMarker;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-@Deprecated
-public class LegacyStateTransferIntegrator implements StateTransferIntegrator
-{
-
- private static final Log log = LogFactory.getLog(LegacyStateTransferIntegrator.class);
- private static final boolean trace = log.isTraceEnabled();
- private CacheSPI cache;
- private NodeFactory factory;
- private Set<Fqn> internalFqns;
- private Configuration cfg;
- private boolean usePut; // for JBCACHE-131
-
- @Inject
- public void inject(CacheSPI<?, ?> cache, NodeFactory nodefactory, Configuration cfg)
- {
- this.cache = cache;
- this.factory = nodefactory;
- this.cfg = cfg;
- }
-
- @Start(priority = 14)
- public void start()
- {
- this.internalFqns = cache.getInternalFqns();
- usePut = cfg.getCacheLoaderConfig() != null && !cfg.getCacheLoaderConfig().isFetchPersistentState() &&
- !cfg.getCacheLoaderConfig().isShared();
- }
-
- public void integrateState(ObjectInputStream ois, Object target, Fqn targetFqn, boolean integratePersistentState) throws Exception
- {
- // pop version from the stream first!
- short version = (Short) cache.getMarshaller().objectFromObjectStream(ois);
- log.info("Using version " + version);
- integrateTransientState(ois, (NodeSPI) target);
- // read another marker for the dummy associated state
- if (trace) log.trace("Reading marker for nonexistent associated state");
- cache.getMarshaller().objectFromObjectStream(ois);
- if (integratePersistentState) integratePersistentState(ois, targetFqn);
- }
-
- protected void integrateTransientState(ObjectInputStream in, NodeSPI target) throws Exception
- {
- boolean transientSet = false;
- try
- {
- if (log.isTraceEnabled())
- {
- log.trace("integrating transient state for " + target);
- }
-
- integrateTransientState(target, in);
-
- transientSet = true;
-
- if (log.isTraceEnabled())
- {
- log.trace("transient state successfully integrated");
- }
-
- notifyAllNodesCreated(cache.getInvocationContext(), target);
- }
- catch (Exception e)
- {
- throw new CacheException(e);
- }
- finally
- {
- if (!transientSet)
- {
- target.clearDataDirect();
- target.removeChildrenDirect();
- }
- }
- }
-
- protected void integratePersistentState(ObjectInputStream in, Fqn targetFqn) throws Exception
- {
- if (trace) log.trace("Reading persistent state from stream");
- CacheLoaderManager loaderManager = cache.getCacheLoaderManager();
- CacheLoader loader = loaderManager == null ? null : loaderManager.getCacheLoader();
- if (loader == null)
- {
- if (log.isTraceEnabled())
- {
- log.trace("cache loader is null, will not attempt to integrate persistent state");
- }
- }
- else
- {
-
- if (log.isTraceEnabled())
- {
- log.trace("integrating persistent state using " + loader.getClass().getName());
- }
-
- boolean persistentSet = false;
- try
- {
- if (targetFqn.isRoot())
- {
- loader.storeEntireState(in);
- }
- else
- {
- loader.storeState(targetFqn, in);
- }
- persistentSet = true;
- }
- catch (ClassCastException cce)
- {
- log.error("Failed integrating persistent state. One of cacheloaders is not"
- + " adhering to state stream format. See JBCACHE-738.");
- throw cce;
- }
- finally
- {
- if (!persistentSet)
- {
- log.warn("persistent state integration failed, removing all nodes from loader");
- loader.remove(targetFqn);
- }
- else
- {
- if (log.isTraceEnabled())
- {
- log.trace("persistent state integrated successfully");
- }
- }
- }
- }
- }
-
- /**
- * Generates NodeAdded notifications for all nodes of the tree. This is
- * called whenever the tree is initially retrieved (state transfer)
- */
- private void notifyAllNodesCreated(InvocationContext ctx, NodeSPI curr)
- {
- if (curr == null) return;
- ctx.setOriginLocal(false);
- cache.getNotifier().notifyNodeCreated(curr.getFqn(), true, ctx);
- cache.getNotifier().notifyNodeCreated(curr.getFqn(), false, ctx);
- // AND notify that they have been modified!!
- if (!curr.getKeysDirect().isEmpty())
- {
- cache.getNotifier().notifyNodeModified(curr.getFqn(), true, NodeModifiedEvent.ModificationType.PUT_MAP, Collections.emptyMap(), ctx);
- cache.getNotifier().notifyNodeModified(curr.getFqn(), false, NodeModifiedEvent.ModificationType.PUT_MAP, curr.getDataDirect(), ctx);
- }
- ctx.setOriginLocal(true);
-
- Set<NodeSPI> children = curr.getChildrenDirect();
- for (NodeSPI n : children)
- {
- notifyAllNodesCreated(ctx, n);
- }
- }
-
- private void integrateTransientState(NodeSPI target, ObjectInputStream in) throws Exception
- {
- if (trace) log.trace("Reading transient state from stream");
- target.removeChildrenDirect();
-
- List<NodeData> list = readNodesAsList(in);
- if (list != null)
- {
- // if the list was null we read an EOF marker!! So don't bother popping it off the stack later.
- Iterator<NodeData> nodeDataIterator = list.iterator();
-
- // Read the first NodeData and integrate into our target
- if (nodeDataIterator.hasNext())
- {
- NodeData nd = nodeDataIterator.next();
-
- //are there any transient nodes at all?
- if (nd != null && !nd.isMarker())
- {
- Map attributes = nd.getAttributes();
- if (usePut)
- {
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- target.clearData();
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- target.putAll(attributes);
- }
- else
- {
- target.setInternalState(attributes);
- }
-
- // Check whether this is an integration into the buddy backup
- // subtree
- Fqn tferFqn = nd.getFqn();
- Fqn tgtFqn = target.getFqn();
- boolean move = tgtFqn.isChildOrEquals(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)
- && !tferFqn.isChildOrEquals(tgtFqn);
- // If it is an integration, calculate how many levels of offset
- int offset = move ? tgtFqn.size() - tferFqn.size() : 0;
-
- integrateStateTransferChildren(target, offset, nodeDataIterator);
-
- integrateRetainedNodes(target);
- }
- }
-
- // read marker off stack
- if (trace) log.trace("Reading marker from stream");
- cache.getMarshaller().objectFromObjectStream(in);
- }
- }
-
- @SuppressWarnings("unchecked")
- private List<NodeData> readNodesAsList(ObjectInputStream in) throws Exception
- {
- Object obj = cache.getMarshaller().objectFromObjectStream(in);
- if (obj instanceof NodeDataMarker) return null;
-
- return (List<NodeData>) obj;
- }
-
- private NodeData integrateStateTransferChildren(NodeSPI parent, int offset, Iterator<NodeData> nodeDataIterator)
- throws IOException, ClassNotFoundException
- {
- int parent_level = parent.getFqn().size();
- int target_level = parent_level + 1;
- Fqn fqn;
- int size;
- NodeData nd = nodeDataIterator.hasNext() ? nodeDataIterator.next() : null;
- while (nd != null && !nd.isMarker())
- {
- fqn = nd.getFqn();
- // If we need to integrate into the buddy backup subtree,
- // change the Fqn to fit under it
- if (offset > 0)
- {
- fqn = Fqn.fromRelativeFqn(parent.getFqn().getAncestor(offset), fqn);
- }
- size = fqn.size();
- if (size <= parent_level)
- {
- return nd;
- }
- else if (size > target_level)
- {
- throw new IllegalStateException("NodeData " + fqn + " is not a direct child of " + parent.getFqn());
- }
-
- Map attrs = nd.getAttributes();
-
- // We handle this NodeData. Create a TreeNode and
- // integrate its data
- NodeSPI target;
- if (usePut)
- {
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- cache.clearData(fqn);
- cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- cache.put(fqn, attrs);
- target = cache.getNode(fqn);
- }
- else
- {
- target = factory.createNode(fqn, parent, attrs);
- parent.addChild(fqn.getLastElement(), target);
- // JBCACHE-913
- Region region = cache.getRegion(fqn, false);
- if (region != null && region.getEvictionRegionConfig() != null)
- {
- region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT, attrs == null ? 0 : attrs.size());
- }
- }
-
- // Recursively call, which will walk down the tree
- // and return the next NodeData that's a child of our parent
- nd = integrateStateTransferChildren(target, offset, nodeDataIterator);
- }
- if (nd != null && nd.isExceptionMarker())
- {
- NodeDataExceptionMarker ndem = (NodeDataExceptionMarker) nd;
- throw new CacheException("State provider node " + ndem.getCacheNodeIdentity()
- + " threw exception during loadState", ndem.getCause());
- }
- return null;
- }
-
- private Set<Node> retainInternalNodes(Node target)
- {
- Set<Node> result = new HashSet<Node>();
- Fqn targetFqn = target.getFqn();
- for (Fqn internalFqn : internalFqns)
- {
- if (internalFqn.isChildOf(targetFqn))
- {
- Node internalNode = getInternalNode(target, internalFqn);
- if (internalNode != null)
- {
- result.add(internalNode);
- }
- }
- }
-
- return result;
- }
-
- private Node getInternalNode(Node parent, Fqn internalFqn)
- {
- Object name = internalFqn.get(parent.getFqn().size());
- cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- Node result = parent.getChild(name);
- if (result != null)
- {
- if (internalFqn.size() < result.getFqn().size())
- {
- // need to recursively walk down the tree
- result = getInternalNode(result, internalFqn);
- }
- }
- return result;
- }
-
- private void integrateRetainedNodes(NodeSPI target)
- {
- Set<Node> retainedNodes = retainInternalNodes(target);
- Fqn rootFqn = target.getFqn();
- for (Node retained : retainedNodes)
- {
- if (retained.getFqn().isChildOf(rootFqn))
- {
- integrateRetainedNode(target, retained);
- }
- }
- }
-
- private void integrateRetainedNode(NodeSPI ancestor, Node descendant)
- {
- Fqn descFqn = descendant.getFqn();
- Fqn ancFqn = ancestor.getFqn();
- Object name = descFqn.get(ancFqn.size());
- NodeSPI child = (NodeSPI) ancestor.getChild(name);
- if (ancFqn.size() == descFqn.size() + 1)
- {
- if (child == null)
- {
- ancestor.addChild(name, descendant);
- }
- else
- {
- log.warn("Received unexpected internal node " + descFqn + " in transferred state");
- }
- }
- else
- {
- if (child == null)
- {
- // Missing level -- have to create empty node
- // This shouldn't really happen -- internal fqns should
- // be immediately under the root
- child = factory.createNode(name, ancestor);
- ancestor.addChild(name, child);
- }
-
- // Keep walking down the tree
- integrateRetainedNode(child, descendant);
- }
- }
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferManager.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferManager.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,208 +0,0 @@
-/*
- * 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.cache.statetransfer;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RegionEmptyException;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.lock.LockManager;
-import static org.jboss.cache.lock.LockType.READ;
-import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.marshall.InactiveRegionException;
-
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-/**
- * This is to support legacy locking schemes such as Pessimistic and Optimistic locking.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- */
-@Deprecated
-public class LegacyStateTransferManager extends DefaultStateTransferManager
-{
- protected LockManager lockManager;
- private boolean usePut; // for JBCACHE-131
-
- @Inject
- public void injectLockManager(LockManager lockManager)
- {
- this.lockManager = lockManager;
- }
-
- @Start(priority = 14)
- public void checkLoaders()
- {
- usePut = configuration.getCacheLoaderConfig() != null && !configuration.getCacheLoaderConfig().isFetchPersistentState() &&
- !configuration.getCacheLoaderConfig().isShared();
- }
-
- @Override
- public void getState(ObjectOutputStream out, Fqn fqn, long timeout, boolean force, boolean suppressErrors) throws Exception
- {
- // can't give state for regions currently being activated/inactivated
- boolean canProvideState = (!regionManager.isInactive(fqn) && cache.peek(fqn, false) != null);
-
- if (canProvideState && (fetchPersistentState || fetchTransientState))
- {
- marshaller.objectToObjectStream(true, out);
- long startTime = System.currentTimeMillis();
- NodeSPI rootNode = cache.peek(fqn, false, false);
-
- try
- {
- if (log.isDebugEnabled())
- {
- log.debug("locking the " + fqn + " subtree to return the in-memory (transient) state");
- }
- acquireLocksForStateTransfer(rootNode, timeout, force);
- generator.generateState(out, rootNode, fetchTransientState, fetchPersistentState, suppressErrors);
- if (log.isDebugEnabled())
- {
- log.debug("Successfully generated state in " + (System.currentTimeMillis() - startTime) + " msec");
- }
- }
- finally
- {
- releaseStateTransferLocks(rootNode);
- }
- }
- else
- {
- marshaller.objectToObjectStream(false, out);
- Exception e = null;
- if (!canProvideState)
- {
- String exceptionMessage = "Cache instance at " + cache.getLocalAddress() + " cannot provide state for fqn " + fqn + ".";
-
- if (regionManager.isInactive(fqn))
- {
- exceptionMessage += " Region for fqn " + fqn + " is inactive.";
- e = new InactiveRegionException(exceptionMessage);
- }
- // this is not really an exception. Just provide empty state. The exception is just a signal. Yes, lousy. - JBCACHE-1349
- if (cache.peek(fqn, false, false) == null)
- {
- e = new RegionEmptyException();
- }
- }
- if (!fetchPersistentState && !fetchTransientState)
- {
- e = new CacheException("Cache instance at " + cache.getLocalAddress() + " is not configured to provide state");
- }
- marshaller.objectToObjectStream(e, out);
- if (e != null) throw e;
- }
- }
-
- /**
- * Set the portion of the cache rooted in <code>targetRoot</code>
- * to match the given state. Updates the contents of <code>targetRoot</code>
- * to reflect those in <code>new_state</code>.
- * <p/>
- * <strong>NOTE:</strong> This method performs no locking of nodes; it
- * is up to the caller to lock <code>targetRoot</code> before calling
- * this method.
- *
- * @param state a serialized byte[][] array where element 0 is the
- * transient state (or null) , and element 1 is the
- * persistent state (or null)
- * @param targetRoot node into which the state should be integrated
- */
- protected void setState(ObjectInputStream state, NodeSPI targetRoot) throws Exception
- {
- long startTime = System.currentTimeMillis();
-
- acquireLocksForStateTransfer(targetRoot, stateRetrievalTimeout, true);
- /*
- * Vladimir/Manik/Brian (Dec 7,2006)
- *
- * integrator.integrateState(in,targetRoot, cl) will call cache.put for each
- * node read from stream. Having option override below allows nodes read
- * to be directly stored into a tree since we bypass interceptor chain.
- *
- */
- try
- {
- if (log.isDebugEnabled())
- {
- log.debug("starting state integration at node " + targetRoot);
- }
- integrator.integrateState(state, targetRoot, targetRoot.getFqn(), fetchPersistentState);
- if (log.isDebugEnabled())
- {
- log.debug("successfully integrated state in " + (System.currentTimeMillis() - startTime) + " msec");
- }
- }
- finally
- {
- releaseStateTransferLocks(targetRoot);
- }
- }
-
-
- protected void acquireLocksForStateTransfer(NodeSPI root, long timeout, boolean force) throws InterruptedException
- {
- if (usePut) return;
- try
- {
- lockManager.lockAll(root, READ, getLockOwner(), timeout, true);
- }
- catch (TimeoutException te)
- {
- log.error("Caught TimeoutException acquiring locks on region " +
- root.getFqn(), te);
- if (force)
- {
- throw te;
- }
- else
- {
- throw te;
- }
- }
- }
-
- protected void releaseStateTransferLocks(NodeSPI root)
- {
- if (usePut) return;
- try
- {
- lockManager.unlockAll(root, getLockOwner());
- }
- catch (Throwable t)
- {
- log.error("failed releasing locks", t);
- }
- }
-
- private Object getLockOwner()
- {
- Object owner = cache.getCurrentTransaction();
- if (owner == null) owner = Thread.currentThread();
- return owner;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/AbstractTransactionContext.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -24,9 +24,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.config.Option;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.util.Immutables;
+import org.jboss.starobrno.config.Option;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManagerLookup.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManagerLookup.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/BatchModeTransactionManagerLookup.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,48 +0,0 @@
-/*
- * 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.cache.transaction;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.transaction.TransactionManager;
-
-
-/**
- * Returns an instance of {@link BatchModeTransactionManager}.
- *
- * @author Bela Ban Sept 5 2003
- * @version $Id$
- * @deprecated Use batching API on Cache instead.
- */
-@Deprecated
-public class BatchModeTransactionManagerLookup implements TransactionManagerLookup
-{
- private Log log = LogFactory.getLog(BatchModeTransactionManagerLookup.class);
-
- public TransactionManager getTransactionManager() throws Exception
- {
- log.warn("Using a deprecated/unsupported transaction manager!");
- return BatchModeTransactionManager.getInstance();
- }
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,73 +0,0 @@
-/*
- * 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.cache.transaction;
-
-import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.TransactionWorkspaceImpl;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-
-/**
- * Subclasses the {@link PessimisticTransactionContext} class to add a {@link TransactionWorkspace}. Used with optimistic locking
- * where each call is assigned a trasnaction and a transaction workspace.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class OptimisticTransactionContext extends PessimisticTransactionContext
-{
- private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
-
- public OptimisticTransactionContext(Transaction tx) throws SystemException, RollbackException
- {
- super(tx);
- }
-
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder(super.toString());
- sb.append("\nworkspace: ").append(transactionWorkSpace);
- return sb.toString();
- }
-
- /**
- * @return Returns the transactionWorkSpace.
- */
- public TransactionWorkspace getTransactionWorkSpace()
- {
- return transactionWorkSpace;
- }
-
- /**
- * @param transactionWorkSpace The transactionWorkSpace to set.
- */
- public void setTransactionWorkSpace(TransactionWorkspace transactionWorkSpace)
- {
- this.transactionWorkSpace = transactionWorkSpace;
- }
-
-}
Deleted: core/branches/flat/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/PessimisticTransactionContext.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -1,90 +0,0 @@
-/*
- * 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.cache.transaction;
-
-
-import org.jboss.cache.commands.WriteCommand;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Information associated with a {@link GlobalTransaction} about the transaction state.
- * <p/>
- * A TransactionContext maintains:
- * <ul>
- * <li>Handle to the local Transaction</li>
- * <li>List of {@link org.jboss.cache.commands.WriteCommand}s that make up this transaction</li>
- * <li>List of locks acquired</li>
- * <li>Any transaction-scope options</li>
- * </ul>
- *
- * @author <a href="mailto:bela@jboss.org">Bela Ban</a>
- * @author Manik Surtani
- * @version $Revision$
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class PessimisticTransactionContext extends AbstractTransactionContext
-{
- private List<WriteCommand> allModifications;
-
- public PessimisticTransactionContext(Transaction tx) throws SystemException, RollbackException
- {
- super(tx);
- }
-
- @Override
- public void addLocalModification(WriteCommand command)
- {
- if (command == null) return;
- super.addLocalModification(command);
- if (allModifications == null) allModifications = new LinkedList<WriteCommand>();
- allModifications.add(command);
- }
-
- @Override
- public void addModification(WriteCommand command)
- {
- if (command == null) return;
- super.addModification(command);
- if (allModifications == null) allModifications = new LinkedList<WriteCommand>();
- allModifications.add(command);
- }
-
- public List<WriteCommand> getAllModifications()
- {
- if (allModifications == null) return Collections.emptyList();
- return allModifications;
- }
-
- @Override
- public void reset()
- {
- super.reset();
- allModifications = null;
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,8 +23,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.config.Option;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
+import org.jboss.starobrno.config.Option;
import javax.transaction.Transaction;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionManagerLookup.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -22,7 +22,6 @@
package org.jboss.cache.transaction;
import org.jboss.cache.Cache;
-import org.jboss.cache.config.Configuration;
import javax.transaction.TransactionManager;
Modified: core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,12 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.context.ContextFactory;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jgroups.Address;
import javax.transaction.Status;
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/concurrent/WithinThreadExecutor.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -21,7 +21,7 @@
*/
package org.jboss.cache.util.concurrent;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
import java.util.Collection;
import java.util.Collections;
Modified: core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-10-08 16:24:08 UTC (rev 6884)
+++ core/branches/flat/src/main/java/org/jboss/cache/util/reflect/ReflectionUtil.java 2008-10-08 16:28:04 UTC (rev 6885)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
+import org.jboss.starobrno.CacheException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
17 years, 2 months
JBoss Cache SVN: r6884 - in core/branches/flat/src/main/java/org/jboss: cache/config/parsing/element and 11 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 12:24:08 -0400 (Wed, 08 Oct 2008)
New Revision: 6884
Added:
core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/CloneableConfigurationComponent.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationException.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationRegistry.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/CustomInterceptorConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/Dynamic.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/MissingPolicyException.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/OldFileFormatException.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/Option.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/PluggableConfigurationComponent.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/UnsupportedEvictionImplException.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/XmlParsingConfigurationRegistry.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithmConfigBase.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionException.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RegionNameConflictException.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/BuddyManagerFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/ReplicationQueueFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferManagerFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/TransactionManagerFactory.java
Removed:
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java
Modified:
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java
core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java
core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java
core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java
core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
Log:
Moved stuff
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/CacheConfigsXmlParser.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,31 +1,31 @@
-/*
- * 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.cache.config.parsing;
+/*
+ * 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.parsing;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.util.FileLookup;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -118,18 +118,11 @@
throw new ConfigurationException("Element " + element + " has no name attribute");
XmlConfigurationParser parser = new XmlConfigurationParser();
- Configuration c;
+ Configuration c = null;
if (parser.isValidElementRoot(element))
{
- // FIXME - This should be using a valid schema!!!
c = parser.parseElementIgnoringRoot(element);
}
- else
- {
- log.warn("Detected legacy configuration file format when parsing configuration file. Migrating to the new (3.x) file format is recommended. See FAQs for details.");
- XmlConfigurationParser2x oldParser = new XmlConfigurationParser2x();
- c = oldParser.parseConfiguration(element);
- }
// Prove that we can successfully clone it
c = c.clone();
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ConfigFilesConvertor.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -19,7 +19,7 @@
* 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.cache.config.parsing;
+package org.jboss.starobrno.config.parsing;
import org.jboss.cache.util.FileLookup;
import org.w3c.dom.Document;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/JGroupsStackParser.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,25 +1,25 @@
-/*
- * 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.cache.config.parsing;
+/*
+ * 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.parsing;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/ParsedAttributes.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -19,7 +19,7 @@
* 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.cache.config.parsing;
+package org.jboss.starobrno.config.parsing;
import org.w3c.dom.Element;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/RootElementBuilder.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,29 +1,29 @@
-/*
- * 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.cache.config.parsing;
+/*
+ * 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.parsing;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.ConfigurationException;
+import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.util.xml.JBossEntityResolver;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigHelper.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -19,12 +19,12 @@
* 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.cache.config.parsing;
+package org.jboss.starobrno.config.parsing;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.util.BeanUtils;
+import org.jboss.starobrno.config.ConfigurationException;
import org.jboss.util.StringPropertyReplacer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -19,21 +19,21 @@
* 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.cache.config.parsing;
+package org.jboss.starobrno.config.parsing;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.CustomInterceptorConfig;
-import org.jboss.cache.config.parsing.element.BuddyElementParser;
-import org.jboss.cache.config.parsing.element.CustomInterceptorsElementParser;
-import org.jboss.cache.config.parsing.element.EvictionElementParser;
-import org.jboss.cache.config.parsing.element.LoadersElementParser;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.util.FileLookup;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.CustomInterceptorConfig;
+import org.jboss.starobrno.config.parsing.element.BuddyElementParser;
+import org.jboss.starobrno.config.parsing.element.CustomInterceptorsElementParser;
+import org.jboss.starobrno.config.parsing.element.EvictionElementParser;
+import org.jboss.starobrno.config.parsing.element.LoadersElementParser;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.ErrorHandler;
Deleted: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlConfigurationParser2x.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,597 +0,0 @@
-/*
- * 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.cache.config.parsing;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.RegionManagerImpl;
-import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionAlgorithmConfig;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.MissingPolicyException;
-import org.jboss.cache.eviction.EvictionAlgorithm;
-import org.jboss.cache.eviction.EvictionPolicy;
-import org.jboss.cache.eviction.ModernizablePolicy;
-import org.jboss.cache.util.FileLookup;
-import org.jboss.cache.util.Util;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-/**
- * Reads in XMLconfiguration files and spits out a {@link org.jboss.cache.config.Configuration} object. When deployed as a
- * JBoss MBean, this role is performed by the JBoss Microcontainer. This class is only used internally in unit tests
- * or within {@link org.jboss.cache.CacheFactory} implementations for standalone JBoss Cache usage.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
- * @since 2.00.
- * @deprecated
- */
-public class XmlConfigurationParser2x
-{
- private static final Log log = LogFactory.getLog(XmlConfigurationParser2x.class);
-
- public static final String ATTR = "attribute";
- public static final String NAME = "name";
-
- /**
- * Parses an XML file and returns a new configuration. This method attempts to look for the file name passed in on
- * the classpath. If not found, it will search for the file on the file system instead, treating the name as an
- * absolute path.
- *
- * @param filename the name of the XML file to parse.
- * @return a configured Configuration object representing the configuration in the file
- */
- public Configuration parseFile(String filename)
- {
- InputStream is = new FileLookup().lookupFile(filename);
- if (is == null)
- {
- throw new ConfigurationException("Unable to find config file " + filename + " either in classpath or on the filesystem!");
- }
-
- return parseStream(is);
- }
-
- /**
- * Parses an input stream containing XML text and returns a new configuration.
- *
- * @param stream input stream to parse. SHould not be null.
- * @return a configured Configuration object representing the configuration in the stream
- * @since 2.1.0
- */
- public Configuration parseStream(InputStream stream)
- {
- // loop through all elements in XML.
- Element root = XmlConfigHelper.getDocumentRoot(stream);
- Element mbeanElement = getMBeanElement(root);
-
- return parseConfiguration(mbeanElement);
- }
-
- public Configuration parseConfiguration(Element configurationRoot)
- {
- ParsedAttributes attributes = XmlConfigHelper.extractAttributes(configurationRoot);
-
- // Deal with legacy attributes we no longer support
- handleRemovedAttributes(attributes);
-
- // Deal with legacy attributes that we renamed or otherwise altered
- handleRenamedAttributes(attributes);
-
- Configuration c = new Configuration();
- XmlConfigHelper.setValues(c, attributes.stringAttribs, false, false);
- // Special handling for XML elements -- we hard code the parsing
- setXmlValues(c, attributes.xmlAttribs);
-
- return c;
- }
-
- /**
- * Check for and remove any attributes that were supported in the
- * 1.x releases and no longer are. Log a WARN or throw a
- * {@link ConfigurationException} if any are found. Which is done depends
- * on the attribute:
- * <p/>
- * <ul>
- * <li><i>MultiplexerService</i> -- throws an Exception</li>
- * <li><i>ServiceName</i> -- logs a WARN</li>
- * </ul>
- *
- * @param attributes
- */
- protected void handleRemovedAttributes(ParsedAttributes attributes)
- {
- String evictionPolicy = attributes.stringAttribs.remove("EvictionPolicyClass");
- if (evictionPolicy != null)
- {
- throw new ConfigurationException("XmlConfigurationParser does not " +
- "support the JBC 1.x attribute EvictionPolicyClass. Set the default " +
- "eviction policy via the policyClass element in the EvictionConfig section");
- }
- String multiplexerService = attributes.stringAttribs.remove("MultiplexerService");
- if (multiplexerService != null)
- {
- throw new ConfigurationException("XmlConfigurationParser does not " +
- "support the JBC 1.x attribute MultiplexerService. Inject the " +
- "multiplexer directly using Configuration.getRuntimeConfig().setMuxChannelFactory()");
- }
- String serviceName = attributes.stringAttribs.remove("ServiceName");
- if (serviceName != null)
- {
- log.warn("XmlConfigurationParser does not support the deprecated " +
- "attribute ServiceName. If JMX registration is needed, " +
- "register a CacheJmxWrapper or PojoCacheJmxWrapper in " +
- "JMX with the desired name");
- }
- }
-
- /**
- * Check for any attributes that were supported in the
- * 1.x releases but whose name has changed. Log a WARN if any are found, but
- * convert the attribute to the new name.
- * <p/>
- * <ul>
- * <li><i>UseMbean</i> becomes <i>ExposeManagementStatistics</i></li>
- * </ul>
- *
- * @param attributes
- */
- private void handleRenamedAttributes(ParsedAttributes attributes)
- {
- String keepStats = attributes.stringAttribs.remove("UseInterceptorMbeans");
- if (keepStats != null && attributes.stringAttribs.get("ExposeManagementStatistics") == null)
- {
- log.warn("Found non-existent JBC 1.x attribute 'UseInterceptorMbeans' and replaced " +
- "with 'ExposeManagementStatistics'. Please update your config " +
- "to use the new attribute name");
- attributes.stringAttribs.put("ExposeManagementStatistics", keepStats);
- }
- Element clc = attributes.xmlAttribs.remove("CacheLoaderConfiguration");
- if (clc != null && attributes.xmlAttribs.get("CacheLoaderConfig") == null)
- {
- log.warn("Found non-existent JBC 1.x attribute 'CacheLoaderConfiguration' and replaced " +
- "with 'CacheLoaderConfig'. Please update your config " +
- "to use the new attribute name");
- attributes.xmlAttribs.put("CacheLoaderConfig", clc);
- }
- }
-
- protected Element getMBeanElement(Element root)
- {
- // This is following JBoss convention.
- NodeList list = root.getElementsByTagName(XmlConfigHelper.ROOT);
- if (list == null) throw new ConfigurationException("Can't find " + XmlConfigHelper.ROOT + " tag");
-
- if (list.getLength() > 1) throw new ConfigurationException("Has multiple " + XmlConfigHelper.ROOT + " tag");
-
- Node node = list.item(0);
- Element element;
- if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
- {
- element = (Element) node;
- }
- else
- {
- throw new ConfigurationException("Can't find " + XmlConfigHelper.ROOT + " element");
- }
- return element;
- }
-
- protected void setXmlValues(Configuration conf, Map<String, Element> attribs)
- {
- for (Entry<String, Element> entry : attribs.entrySet())
- {
- String propname = entry.getKey();
- if ("BuddyReplicationConfiguration".equals(propname)
- || "BuddyReplicationConfig".equals(propname))
- {
- BuddyReplicationConfig brc = parseBuddyReplicationConfig(entry.getValue());
- conf.setBuddyReplicationConfig(brc);
- }
- else if ("CacheLoaderConfiguration".equals(propname)
- || "CacheLoaderConfig".equals(propname))
- {
- CacheLoaderConfig clc = parseCacheLoaderConfig(entry.getValue());
- conf.setCacheLoaderConfig(clc);
- }
- else if ("EvictionPolicyConfiguration".equals(propname)
- || "EvictionPolicyConfig".equals(propname))
- {
- EvictionConfig ec = parseEvictionConfig(entry.getValue());
- conf.setEvictionConfig(ec);
- }
- else if ("ClusterConfig".equals(propname))
- {
- String jgc = parseClusterConfigXml(entry.getValue());
- conf.setClusterConfig(jgc);
- }
- else
- {
- throw new ConfigurationException("Unknown configuration element " + propname);
- }
- }
- }
-
- private static BuddyReplicationConfig parseBuddyReplicationConfig(Element element)
- {
- BuddyReplicationConfig brc = new BuddyReplicationConfig();
- brc.setEnabled(XmlConfigHelper.readBooleanContents(element, "buddyReplicationEnabled"));
- brc.setDataGravitationRemoveOnFind(XmlConfigHelper.readBooleanContents(element, "dataGravitationRemoveOnFind", true));
- brc.setDataGravitationSearchBackupTrees(XmlConfigHelper.readBooleanContents(element, "dataGravitationSearchBackupTrees", true));
- brc.setAutoDataGravitation(brc.isEnabled() && XmlConfigHelper.readBooleanContents(element, "autoDataGravitation", false));
-
- String strBuddyCommunicationTimeout = XmlConfigHelper.readStringContents(element, "buddyCommunicationTimeout");
- try
- {
- brc.setBuddyCommunicationTimeout(Integer.parseInt(strBuddyCommunicationTimeout));
- }
- catch (Exception e)
- {
- if (log.isTraceEnabled()) log.trace(e.getMessage());
- }
- finally
- {
- if (log.isDebugEnabled())
- {
- log.debug("Using buddy communication timeout of " + brc.getBuddyCommunicationTimeout() + " millis");
- }
- }
- String buddyPoolName = XmlConfigHelper.readStringContents(element, "buddyPoolName");
- if ("".equals(buddyPoolName))
- {
- buddyPoolName = null;
- }
-
- brc.setBuddyPoolName(buddyPoolName);
-
- // now read the buddy locator details
-
- String buddyLocatorClass = XmlConfigHelper.readStringContents(element, "buddyLocatorClass");
- if (buddyLocatorClass == null || buddyLocatorClass.length() == 0)
- {
- buddyLocatorClass = NextMemberBuddyLocator.class.getName();
- }
- Properties props = null;
- props = XmlConfigHelper.readPropertiesContents(element, "buddyLocatorProperties");
- BuddyLocatorConfig blc = new BuddyLocatorConfig();
- blc.setBuddyLocatorClass(buddyLocatorClass);
- blc.setBuddyLocatorProperties(props);
- brc.setBuddyLocatorConfig(blc);
-
- return brc;
- }
-
- private static CacheLoaderConfig parseCacheLoaderConfig(Element element)
- {
- CacheLoaderConfig clc = new CacheLoaderConfig();
- clc.setPassivation(XmlConfigHelper.readBooleanContents(element, "passivation"));
- String s = XmlConfigHelper.readStringContents(element, "preload");
- if (s != null && s.length() > 0) clc.setPreload(s);
- clc.setShared(XmlConfigHelper.readBooleanContents(element, "shared"));
-
- NodeList cacheLoaderNodes = element.getElementsByTagName("cacheloader");
- for (int i = 0; i < cacheLoaderNodes.getLength(); i++)
- {
- Node node = cacheLoaderNodes.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE)
- {
- Element indivElement = (Element) node;
- CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
- iclc.setAsync(XmlConfigHelper.readBooleanContents(indivElement, "async", false));
- iclc.setIgnoreModifications(XmlConfigHelper.readBooleanContents(indivElement, "ignoreModifications", false));
- iclc.setFetchPersistentState(XmlConfigHelper.readBooleanContents(indivElement, "fetchPersistentState", false));
- iclc.setPurgeOnStartup(XmlConfigHelper.readBooleanContents(indivElement, "purgeOnStartup", false));
- iclc.setClassName(XmlConfigHelper.readStringContents(indivElement, "class"));
- iclc.setProperties(XmlConfigHelper.readPropertiesContents(indivElement, "properties"));
-
- SingletonStoreConfig ssc = parseSingletonStoreConfig(indivElement);
- if (ssc != null)
- {
- iclc.setSingletonStoreConfig(ssc);
- }
-
- clc.addIndividualCacheLoaderConfig(iclc);
- }
- }
- return clc;
- }
-
- private static CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig parseSingletonStoreConfig(Element cacheLoaderelement)
- {
- /* singletonStore element can only appear once in a cacheloader, so we just take the first one ignoring any
- subsequent definitions in cacheloader element*/
- Node singletonStoreNode = cacheLoaderelement.getElementsByTagName("singletonStore").item(0);
- if (singletonStoreNode != null && singletonStoreNode.getNodeType() == Node.ELEMENT_NODE)
- {
- Element singletonStoreElement = (Element) singletonStoreNode;
- boolean singletonStoreEnabled = XmlConfigHelper.readBooleanContents(singletonStoreElement, "enabled");
- String singletonStoreClass = XmlConfigHelper.readStringContents(singletonStoreElement, "class");
- Properties singletonStoreproperties;
- singletonStoreproperties = XmlConfigHelper.readPropertiesContents(singletonStoreElement, "properties");
- CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig ssc = new CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig();
- ssc.setSingletonStoreEnabled(singletonStoreEnabled);
- ssc.setSingletonStoreClass(singletonStoreClass);
- ssc.setSingletonStoreproperties(singletonStoreproperties);
-
- return ssc;
- }
-
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public static EvictionConfig parseEvictionConfig(Element element)
- {
- EvictionConfig evictionConfig = new EvictionConfig();
-
- if (element != null)
- {
- // If they set the default eviction policy in the element, use that
- // in preference to the external attribute
- String temp = XmlConfigHelper.getTagContents(element, "policyClass", ATTR, NAME);
- String defaultEvPolicyClassName = null;
- if (temp != null && temp.length() > 0)
- {
- defaultEvPolicyClassName = temp;
- EvictionAlgorithmConfig eac = getEvictionAlgorithmConfig(temp);
- evictionConfig.getDefaultEvictionRegionConfig().setEvictionAlgorithmConfig(eac);
- }
-
- temp = XmlConfigHelper.getTagContents(element, "wakeUpIntervalSeconds", ATTR, NAME);
-
- int wakeupIntervalSeconds = 0;
- if (temp != null)
- {
- wakeupIntervalSeconds = Integer.parseInt(temp);
- }
-
- if (wakeupIntervalSeconds <= 0)
- {
- wakeupIntervalSeconds = EvictionConfig.WAKEUP_DEFAULT;
- }
-
- evictionConfig.setWakeupInterval(wakeupIntervalSeconds * 1000);
-
- int eventQueueSize = 0;
- temp = XmlConfigHelper.getTagContents(element, "eventQueueSize", ATTR, NAME);
-
- if (temp != null)
- {
- eventQueueSize = Integer.parseInt(temp);
- }
-
- if (eventQueueSize <= 0)
- {
- eventQueueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
- }
-
- evictionConfig.getDefaultEvictionRegionConfig().setEventQueueSize(eventQueueSize);
-
- NodeList list = element.getElementsByTagName(EvictionRegionConfig.REGION);
- if (list != null && list.getLength() > 0)
- {
- List regionConfigs = new ArrayList(list.getLength());
- for (int i = 0; i < list.getLength(); i++)
- {
- org.w3c.dom.Node node = list.item(i);
- if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
- {
- continue;
- }
- try
- {
- EvictionRegionConfig evictionRegionConfig = parseEvictionRegionConfig((Element) node, defaultEvPolicyClassName, eventQueueSize);
- if (!evictionRegionConfig.getRegionFqn().equals(RegionManagerImpl.DEFAULT_REGION))
- {
- regionConfigs.add(evictionRegionConfig);
- }
- else
- {
- evictionConfig.getDefaultEvictionRegionConfig().setEventQueueSize(evictionRegionConfig.getEventQueueSize());
- evictionConfig.getDefaultEvictionRegionConfig().setEvictionAlgorithmConfig(evictionRegionConfig.getEvictionAlgorithmConfig());
- }
- }
- catch (MissingPolicyException missingPolicy)
- {
- LogFactory.getLog(EvictionConfig.class).warn(missingPolicy.getLocalizedMessage());
- throw missingPolicy;
- }
- }
-
- evictionConfig.setEvictionRegionConfigs(regionConfigs);
- }
- }
-
- return evictionConfig;
-
- }
-
- private static EvictionRegionConfig parseEvictionRegionConfig(Element element, String defaultEvPolicyClassName, int defaultQueueCapacity)
- {
- EvictionRegionConfig erc = new EvictionRegionConfig();
-
- erc.setRegionName(element.getAttribute(EvictionRegionConfig.NAME));
-
- String temp = element.getAttribute("eventQueueSize");
- if (temp != null && temp.length() > 0)
- {
- erc.setEventQueueSize(Integer.parseInt(temp));
- }
- else
- {
- erc.setEventQueueSize(defaultQueueCapacity);
- }
- String evictionClass = element.getAttribute("policyClass");
-
- if (evictionClass == null || evictionClass.length() == 0)
- {
- evictionClass = defaultEvPolicyClassName;
- // if it's still null... what do we setCache?
- if (evictionClass == null || evictionClass.length() == 0)
- {
- throw new MissingPolicyException(
- "There is no Eviction Policy Class specified on the region or for the entire cache!");
- }
- }
-
- EvictionAlgorithmConfig algorithmConfig = getEvictionAlgorithmConfig(evictionClass);
-
- parseEvictionPolicyConfig(element, algorithmConfig);
-
- erc.setEvictionAlgorithmConfig(algorithmConfig);
- return erc;
- }
-
- private static EvictionAlgorithmConfig getEvictionAlgorithmConfig(String evictionClass)
- {
- EvictionConfig.assertIsTransformable(evictionClass);
-
- EvictionAlgorithm algorithm;
-
- try
- {
- EvictionPolicy ep = (EvictionPolicy) Util.getInstance(evictionClass);
- Class<? extends EvictionAlgorithm> algoClass = ((ModernizablePolicy) ep).modernizePolicy();
- if (log.isTraceEnabled()) log.trace("Using algo class " + algoClass);
- algorithm = Util.getInstance(algoClass);
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Eviction class is not properly loaded in classloader", e);
- }
-
- EvictionAlgorithmConfig algorithmConfig;
- try
- {
- algorithmConfig = algorithm.getConfigurationClass().newInstance();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Failed to instantiate eviction configuration of class " +
- algorithm.getConfigurationClass(), e);
- }
- return algorithmConfig;
- }
-
- @SuppressWarnings("unchecked")
- private static void parseEvictionPolicyConfig(Element element, EvictionAlgorithmConfig target)
- {
- target.reset();
- ParsedAttributes attributes = XmlConfigHelper.extractAttributes(element);
- Map updatedElements = new HashMap();
- for (Map.Entry entry : attributes.stringAttribs.entrySet())
- {
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
- if (key.indexOf("Seconds") > 0)
- {
- key = key.substring(0, key.length() - "Seconds".length());
- value = value.trim() + "000";
- }
- updatedElements.put(key, value);
- }
- attributes.stringAttribs.clear();
- attributes.stringAttribs.putAll(updatedElements);
- XmlConfigHelper.setValues(target, attributes.stringAttribs, false, true);
- XmlConfigHelper.setValues(target, attributes.xmlAttribs, true, true);
- }
-
-
- /**
- * Parses the cluster config which is used to start a JGroups channel
- *
- * @param config an old-style JGroups protocol config String
- */
- public static String parseClusterConfigXml(Element config)
- {
- StringBuilder buffer = new StringBuilder();
- NodeList stack = config.getChildNodes();
- int length = stack.getLength();
-
- for (int s = 0; s < length; s++)
- {
- org.w3c.dom.Node node = stack.item(s);
- if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE)
- {
- continue;
- }
-
- Element tag = (Element) node;
- String protocol = tag.getTagName();
- buffer.append(protocol);
- NamedNodeMap attrs = tag.getAttributes();
- int attrLength = attrs.getLength();
- if (attrLength > 0)
- {
- buffer.append('(');
- }
- for (int a = 0; a < attrLength; a++)
- {
- Attr attr = (Attr) attrs.item(a);
- String name = attr.getName();
- String value = attr.getValue();
- buffer.append(name);
- buffer.append('=');
- buffer.append(value);
- if (a < attrLength - 1)
- {
- buffer.append(';');
- }
- }
- if (attrLength > 0)
- {
- buffer.append(')');
- }
- buffer.append(':');
- }
- // Remove the trailing ':'
- buffer.setLength(buffer.length() - 1);
- return buffer.toString();
- }
-}
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/XmlParserBase.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,25 +1,25 @@
-/*
- * 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.cache.config.parsing;
+/*
+ * 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.parsing;
import org.jboss.util.StringPropertyReplacer;
import org.w3c.dom.Element;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/BuddyElementParser.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,30 +1,30 @@
-/*
- * 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.cache.config.parsing.element;
+/*
+ * 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.parsing.element;
import org.jboss.cache.buddyreplication.NextMemberBuddyLocator;
-import org.jboss.cache.config.BuddyReplicationConfig;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.starobrno.config.BuddyReplicationConfig;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
import org.w3c.dom.Element;
import java.util.Properties;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/CustomInterceptorsElementParser.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,33 +1,34 @@
-/*
- * 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.cache.config.parsing.element;
+/*
+ * 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.parsing.element;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.CustomInterceptorConfig;
-import org.jboss.cache.config.parsing.ParsedAttributes;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.XmlParserBase;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
+
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.CustomInterceptorConfig;
+import org.jboss.starobrno.config.parsing.ParsedAttributes;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/EvictionElementParser.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,36 +1,36 @@
-/*
- * 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.cache.config.parsing.element;
+/*
+ * 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.parsing.element;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionAlgorithmConfig;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.MissingPolicyException;
-import org.jboss.cache.config.parsing.ParsedAttributes;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.XmlParserBase;
-import org.jboss.cache.eviction.EvictionAlgorithm;
import org.jboss.cache.util.Util;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.config.EvictionConfig;
+import org.jboss.starobrno.config.EvictionRegionConfig;
+import org.jboss.starobrno.config.MissingPolicyException;
+import org.jboss.starobrno.config.parsing.ParsedAttributes;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
+import org.jboss.starobrno.eviction.EvictionAlgorithm;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Modified: core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/cache/config/parsing/element/LoadersElementParser.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,30 +1,30 @@
-/*
- * 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.cache.config.parsing.element;
+/*
+ * 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.parsing.element;
-import org.jboss.cache.config.CacheLoaderConfig;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
-import org.jboss.cache.config.parsing.XmlParserBase;
+import org.jboss.starobrno.config.CacheLoaderConfig;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.parsing.XmlConfigHelper;
+import org.jboss.starobrno.config.parsing.XmlParserBase;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheDelegate.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,16 +21,20 @@
*/
package org.jboss.starobrno;
-import org.jboss.starobrno.context.InvocationContext;
-import org.jboss.starobrno.invocation.InvocationContextContainer;
import org.jboss.starobrno.commands.CommandsFactory;
+import org.jboss.starobrno.commands.read.GetKeyValueCommand;
import org.jboss.starobrno.commands.read.SizeCommand;
-import org.jboss.starobrno.commands.read.GetKeyValueCommand;
-import org.jboss.starobrno.commands.write.*;
+import org.jboss.starobrno.commands.write.ClearCommand;
+import org.jboss.starobrno.commands.write.EvictCommand;
+import org.jboss.starobrno.commands.write.PutKeyValueCommand;
+import org.jboss.starobrno.commands.write.PutMapCommand;
+import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.commands.write.ReplaceCommand;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.interceptors.InterceptorChain;
-import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
import org.jboss.starobrno.notifier.Notifier;
-import org.jboss.util.NotImplementedException;
import java.util.Collection;
import java.util.Map;
@@ -57,13 +61,13 @@
public boolean remove(Object key, Object value)
{
RemoveCommand command = commandsFactory.buildRemoveCommand(key, value);
- return (Boolean)invoker.invoke(buildCtx(), command);
+ return (Boolean) invoker.invoke(buildCtx(), command);
}
public boolean replace(Object key, Object oldValue, Object newValue)
{
ReplaceCommand command = commandsFactory.buildReplaceCommand(key, oldValue, newValue);
- return (Boolean)invoker.invoke(buildCtx(), command);
+ return (Boolean) invoker.invoke(buildCtx(), command);
}
public Object replace(Object key, Object value)
@@ -178,6 +182,16 @@
else invocationContextContainer.set(ctx);
}
+ public AtomicGroup putAtomicGroup(Object key, AtomicGroup group)
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
+ public AtomicGroup getAtomicGroup(Object key)
+ {
+ return null; //TODO: Autogenerated. Implement me properly
+ }
+
public void start()
{
//TODO: Autogenerated. Implement me properly
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,7 +21,6 @@
*/
package org.jboss.starobrno;
-import org.jboss.starobrno.config.CacheConfig;
import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.util.NotImplementedException;
@@ -38,14 +37,13 @@
{
private ConcurrentHashMap data = new ConcurrentHashMap();
private Map<String, AtomicGroup> atomicGroups = new ConcurrentHashMap<String, AtomicGroup>();
- private CacheConfig cacheConfig;
+// private CacheConfig cacheConfig;
+// public CacheImpl(CacheConfig cacheConfig)
+// {
+// this.cacheConfig = cacheConfig;
+// }
- public CacheImpl(CacheConfig cacheConfig)
- {
- this.cacheConfig = cacheConfig;
- }
-
public Object putIfAbsent(Object key, Object value)
{
return data.putIfAbsent(key, value);
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/CacheManager.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -22,10 +22,9 @@
package org.jboss.starobrno;
import org.jboss.starobrno.config.Configuration;
-import org.jboss.starobrno.config.CacheConfig;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
/**
* @author Mircea.Markus(a)jboss.com
@@ -42,11 +41,15 @@
public CacheImpl getCache(String confName)
{
+ return null; // TODO
+
+ /*
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);
CacheImpl result = new CacheImpl(config);
caches.put(confName, result);
- return result;
+ return result;*/
}
}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/BuddyReplicationConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,208 @@
+/*
+ * 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.buddyreplication.NextMemberBuddyLocator;
+import org.jboss.cache.util.Util;
+
+import java.util.Properties;
+
+
+public class BuddyReplicationConfig extends ConfigurationComponent
+{
+ private static final long serialVersionUID = -4826380823985089339L;
+
+ /**
+ * Test whether buddy replication is enabled.
+ */
+ private boolean enabled;
+
+ /**
+ * Name of the buddy pool for current instance. May be null if buddy pooling is not used.
+ */
+ private String buddyPoolName;
+
+ private boolean autoDataGravitation = true;
+ private boolean dataGravitationRemoveOnFind = true;
+ private boolean dataGravitationSearchBackupTrees = true;
+ @Dynamic
+ private int buddyCommunicationTimeout = 10000;
+ private BuddyLocatorConfig buddyLocatorConfig;
+
+ public boolean isAutoDataGravitation()
+ {
+ return autoDataGravitation;
+ }
+
+ public void setAutoDataGravitation(boolean autoDataGravitation)
+ {
+ testImmutability("autoDataGravitation");
+ this.autoDataGravitation = autoDataGravitation;
+ }
+
+ public int getBuddyCommunicationTimeout()
+ {
+ return buddyCommunicationTimeout;
+ }
+
+ public void setBuddyCommunicationTimeout(int buddyCommunicationTimeout)
+ {
+ testImmutability("buddyCommunicationTimeout");
+ this.buddyCommunicationTimeout = buddyCommunicationTimeout;
+ }
+
+ public String getBuddyPoolName()
+ {
+ return buddyPoolName;
+ }
+
+ public void setBuddyPoolName(String buddyPoolName)
+ {
+ testImmutability("buddyPoolName");
+ this.buddyPoolName = buddyPoolName;
+ }
+
+ public boolean isDataGravitationRemoveOnFind()
+ {
+ return dataGravitationRemoveOnFind;
+ }
+
+ public void setDataGravitationRemoveOnFind(boolean dataGravitationRemoveOnFind)
+ {
+ testImmutability("dataGravitationRemoveOnFind");
+ this.dataGravitationRemoveOnFind = dataGravitationRemoveOnFind;
+ }
+
+ public boolean isDataGravitationSearchBackupTrees()
+ {
+ return dataGravitationSearchBackupTrees;
+ }
+
+ public void setDataGravitationSearchBackupTrees(boolean dataGravitationSearchBackupTrees)
+ {
+ testImmutability("dataGravitationSearchBackupTrees");
+ this.dataGravitationSearchBackupTrees = dataGravitationSearchBackupTrees;
+ }
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ testImmutability("enabled");
+ this.enabled = enabled;
+ }
+
+ public BuddyLocatorConfig getBuddyLocatorConfig()
+ {
+ return buddyLocatorConfig;
+ }
+
+ public void setBuddyLocatorConfig(BuddyLocatorConfig buddyLocatorConfig)
+ {
+ testImmutability("buddyLocatorConfig");
+ replaceChildConfig(this.buddyLocatorConfig, buddyLocatorConfig);
+ this.buddyLocatorConfig = buddyLocatorConfig;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj instanceof BuddyReplicationConfig)
+ {
+ BuddyReplicationConfig other = (BuddyReplicationConfig) obj;
+ return (this.autoDataGravitation == other.autoDataGravitation)
+ && (this.dataGravitationRemoveOnFind == other.dataGravitationRemoveOnFind)
+ && (this.dataGravitationSearchBackupTrees == other.dataGravitationSearchBackupTrees)
+ && (this.enabled == other.enabled)
+ && (this.buddyCommunicationTimeout == other.buddyCommunicationTimeout)
+ && Util.safeEquals(this.buddyPoolName, other.buddyPoolName)
+ && Util.safeEquals(this.buddyLocatorConfig, other.buddyLocatorConfig);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 11;
+ result = 29 * result + (autoDataGravitation ? 0 : 1);
+ result = 29 * result + (dataGravitationRemoveOnFind ? 0 : 1);
+ result = 29 * result + (dataGravitationSearchBackupTrees ? 0 : 1);
+ result = 29 * result + (enabled ? 0 : 1);
+ result = 29 * result + buddyCommunicationTimeout;
+ result = 29 * result + (buddyPoolName == null ? 0 : buddyPoolName.hashCode());
+ result = 29 * result + (buddyLocatorConfig == null ? 0 : buddyLocatorConfig.hashCode());
+ return result;
+ }
+
+ @Override
+ public BuddyReplicationConfig clone() throws CloneNotSupportedException
+ {
+ BuddyReplicationConfig clone = (BuddyReplicationConfig) super.clone();
+ if (buddyLocatorConfig != null)
+ clone.setBuddyLocatorConfig(buddyLocatorConfig.clone());
+ return clone;
+ }
+
+ public static class BuddyLocatorConfig extends PluggableConfigurationComponent
+ {
+ private static final long serialVersionUID = -8003634097931826091L;
+
+ public BuddyLocatorConfig()
+ {
+ // default
+ className = NextMemberBuddyLocator.class.getName();
+ }
+
+ public String getBuddyLocatorClass()
+ {
+ return className;
+ }
+
+ public void setBuddyLocatorClass(String buddyLocatorClass)
+ {
+ setClassName(buddyLocatorClass);
+ }
+
+ public Properties getBuddyLocatorProperties()
+ {
+ return properties;
+ }
+
+ public void setBuddyLocatorProperties(Properties buddyLocatorProperties)
+ {
+ setProperties(buddyLocatorProperties);
+ }
+
+ public BuddyLocatorConfig clone() throws CloneNotSupportedException
+ {
+ return (BuddyLocatorConfig) super.clone();
+ }
+ }
+}
Deleted: core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,1074 +0,0 @@
-/*
- * 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
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/CacheLoaderConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,444 @@
+/*
+ * 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.loader.CacheLoader;
+import org.jboss.cache.loader.SingletonStoreCacheLoader;
+import org.jboss.cache.util.Util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Holds the configuration of the cache loader chain. ALL cache loaders should be defined using this class, adding
+ * individual cache loaders to the chain by calling {@link CacheLoaderConfig#addIndividualCacheLoaderConfig}
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @author Brian Stansberry
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
+ */
+public class CacheLoaderConfig extends ConfigurationComponent
+{
+ private static final long serialVersionUID = 2210349340378984424L;
+
+ private boolean passivation;
+ private String preload;
+ private List<IndividualCacheLoaderConfig> cacheLoaderConfigs = new ArrayList<IndividualCacheLoaderConfig>();
+
+ private boolean shared;
+
+ public String getPreload()
+ {
+ return preload;
+ }
+
+ public void setPreload(String preload)
+ {
+ testImmutability("preload");
+ this.preload = preload;
+ }
+
+ public void setPassivation(boolean passivation)
+ {
+ testImmutability("passivation");
+ this.passivation = passivation;
+ }
+
+ public boolean isPassivation()
+ {
+ return passivation;
+ }
+
+ public void addIndividualCacheLoaderConfig(IndividualCacheLoaderConfig clc)
+ {
+ testImmutability("cacheLoaderConfigs");
+ cacheLoaderConfigs.add(clc);
+ // Ensure this config gets our back ref to the cache
+ addChildConfig(clc);
+ }
+
+ public List<IndividualCacheLoaderConfig> getIndividualCacheLoaderConfigs()
+ {
+ return cacheLoaderConfigs;
+ }
+
+ public void setIndividualCacheLoaderConfigs(List<IndividualCacheLoaderConfig> configs)
+ {
+ testImmutability("cacheLoaderConfigs");
+ // Ensure these configs get our back ref to the cache
+ replaceChildConfigs(this.cacheLoaderConfigs, configs);
+ this.cacheLoaderConfigs = configs == null ? new ArrayList<IndividualCacheLoaderConfig>() : configs;
+ }
+
+ public IndividualCacheLoaderConfig getFirstCacheLoaderConfig()
+ {
+ if (cacheLoaderConfigs.size() == 0) return null;
+ return cacheLoaderConfigs.get(0);
+ }
+
+ public boolean useChainingCacheLoader()
+ {
+ return !isPassivation() && cacheLoaderConfigs.size() > 1;
+ }
+
+ @Override
+ public String toString()
+ {
+ return new StringBuilder().append("CacheLoaderConfig{").append("shared=").append(shared).append(", passivation=").append(passivation).append(", preload='").append(preload).append('\'').append(", cacheLoaderConfigs.size()=").append(cacheLoaderConfigs.size()).append('}').toString();
+ }
+
+ public void setShared(boolean shared)
+ {
+ testImmutability("shared");
+ this.shared = shared;
+ }
+
+ public boolean isShared()
+ {
+ return shared;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj instanceof CacheLoaderConfig)
+ {
+ CacheLoaderConfig other = (CacheLoaderConfig) obj;
+ return (this.passivation == other.passivation)
+ && (this.shared == other.shared)
+ && Util.safeEquals(this.preload, other.preload)
+ && Util.safeEquals(this.cacheLoaderConfigs, other.cacheLoaderConfigs);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 19;
+ result = 51 * result + (passivation ? 0 : 1);
+ result = 51 * result + (shared ? 0 : 1);
+ result = 51 * result + (preload == null ? 0 : preload.hashCode());
+ result = 51 * result + (cacheLoaderConfigs == null ? 0 : cacheLoaderConfigs.hashCode());
+ return result;
+ }
+
+
+ @Override
+ public CacheLoaderConfig clone() throws CloneNotSupportedException
+ {
+ CacheLoaderConfig clone = (CacheLoaderConfig) super.clone();
+ if (cacheLoaderConfigs != null)
+ {
+ List<IndividualCacheLoaderConfig> clcs = new ArrayList<IndividualCacheLoaderConfig>(cacheLoaderConfigs.size());
+ for (IndividualCacheLoaderConfig clc : cacheLoaderConfigs)
+ {
+ clcs.add(clc.clone());
+ }
+ clone.setIndividualCacheLoaderConfigs(clcs);
+ }
+ return clone;
+ }
+
+ /**
+ * Loops through all individual cache loader configs and checks if fetchPersistentState is set on any of them
+ */
+ public boolean isFetchPersistentState()
+ {
+ for (IndividualCacheLoaderConfig iclc : cacheLoaderConfigs)
+ {
+ if (iclc.isFetchPersistentState()) return true;
+ }
+ return false;
+ }
+
+
+ /**
+ * Configuration object that holds the confguration of an individual cache loader.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
+ */
+ public static class IndividualCacheLoaderConfig extends PluggableConfigurationComponent
+ {
+ private static final long serialVersionUID = -2282396799100828593L;
+
+ private boolean async;
+ private boolean ignoreModifications;
+ private boolean fetchPersistentState;
+
+ private boolean purgeOnStartup;
+
+ private SingletonStoreConfig singletonStoreConfig;
+ private transient CacheLoader cacheLoader;
+
+ protected void populateFromBaseConfig(IndividualCacheLoaderConfig base)
+ {
+ if (base != null)
+ {
+ setAsync(base.isAsync());
+ setIgnoreModifications(base.isIgnoreModifications());
+ setFetchPersistentState(base.isFetchPersistentState());
+ setSingletonStoreConfig(base.getSingletonStoreConfig());
+ setPurgeOnStartup(base.isPurgeOnStartup());
+ setProperties(base.getProperties());
+ }
+ }
+
+ public boolean isPurgeOnStartup()
+ {
+ return purgeOnStartup;
+ }
+
+ public boolean isFetchPersistentState()
+ {
+ return fetchPersistentState;
+ }
+
+ public void setFetchPersistentState(boolean fetchPersistentState)
+ {
+ testImmutability("fetchPersistentState");
+ this.fetchPersistentState = fetchPersistentState;
+ }
+
+ public void setAsync(boolean async)
+ {
+ testImmutability("async");
+ this.async = async;
+ }
+
+ public boolean isAsync()
+ {
+ return async;
+ }
+
+ public void setIgnoreModifications(boolean ignoreModifications)
+ {
+ testImmutability("ignoreModifications");
+ this.ignoreModifications = ignoreModifications;
+ }
+
+ public boolean isIgnoreModifications()
+ {
+ return ignoreModifications;
+ }
+
+ public void setPurgeOnStartup(boolean purgeOnStartup)
+ {
+ testImmutability("purgeOnStartup");
+ this.purgeOnStartup = purgeOnStartup;
+ }
+
+ public SingletonStoreConfig getSingletonStoreConfig()
+ {
+ return singletonStoreConfig;
+ }
+
+ public void setSingletonStoreConfig(SingletonStoreConfig singletonStoreConfig)
+ {
+ testImmutability("singletonStoreConfig");
+ replaceChildConfig(this.singletonStoreConfig, singletonStoreConfig);
+ this.singletonStoreConfig = singletonStoreConfig;
+ }
+
+ /**
+ * Provides the ability to get and set a running cache loader, which, if exists, will be used rather than
+ * constructing a new one. Primarily to facilitate testing with mock objects.
+ *
+ * @return cache loader, if one exists
+ * @since 2.1.0
+ */
+ public CacheLoader getCacheLoader()
+ {
+ return cacheLoader;
+ }
+
+ /**
+ * Provides the ability to get and set a running cache loader, which, if exists, will be used rather than
+ * constructing a new one. Primarily to facilitate testing with mock objects.
+ *
+ * @param cacheLoader cacheLoader to set
+ * @since 2.1.0
+ */
+ public void setCacheLoader(CacheLoader cacheLoader)
+ {
+ this.cacheLoader = cacheLoader;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (super.equals(obj))
+ {
+ IndividualCacheLoaderConfig i = (IndividualCacheLoaderConfig) obj;
+ return equalsExcludingProperties(i);
+ }
+ return false;
+ }
+
+ protected boolean equalsExcludingProperties(Object obj)
+ {
+ if (!(obj instanceof IndividualCacheLoaderConfig))
+ return false;
+ IndividualCacheLoaderConfig other = (IndividualCacheLoaderConfig) obj;
+
+ return Util.safeEquals(this.className, other.className)
+ && (this.async == other.async)
+ && (this.ignoreModifications == other.ignoreModifications)
+ && (this.fetchPersistentState == other.fetchPersistentState)
+ && Util.safeEquals(this.singletonStoreConfig, other.singletonStoreConfig);
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return 31 * hashCodeExcludingProperties() + (properties == null ? 0 : properties.hashCode());
+ }
+
+ protected int hashCodeExcludingProperties()
+ {
+ int result = 17;
+ result = 31 * result + (className == null ? 0 : className.hashCode());
+ result = 31 * result + (async ? 0 : 1);
+ result = 31 * result + (ignoreModifications ? 0 : 1);
+ result = 31 * result + (fetchPersistentState ? 0 : 1);
+ result = 31 * result + (singletonStoreConfig == null ? 0 : singletonStoreConfig.hashCode());
+ result = 31 * result + (purgeOnStartup ? 0 : 1);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return new StringBuilder().append("IndividualCacheLoaderConfig{").append("className='").append(className).append('\'')
+ .append(", async=").append(async)
+ .append(", ignoreModifications=").append(ignoreModifications)
+ .append(", fetchPersistentState=").append(fetchPersistentState)
+ .append(", properties=").append(properties)
+ .append(", purgeOnStartup=").append(purgeOnStartup).append("},")
+ .append("SingletonStoreConfig{").append(singletonStoreConfig).append('}')
+ .toString();
+ }
+
+ @Override
+ public IndividualCacheLoaderConfig clone() throws CloneNotSupportedException
+ {
+ IndividualCacheLoaderConfig clone = (IndividualCacheLoaderConfig) super.clone();
+ if (singletonStoreConfig != null)
+ clone.setSingletonStoreConfig(singletonStoreConfig.clone());
+ clone.cacheLoader = cacheLoader;
+ return clone;
+ }
+
+ /**
+ * Configuration for a SingletonStoreCacheLoader
+ */
+ public static class SingletonStoreConfig extends PluggableConfigurationComponent
+ {
+ private static final long serialVersionUID = 824251894176131850L;
+
+ /**
+ * Indicates whether the singleton store functionality is enabled or not.
+ */
+ private boolean singletonStoreEnabled;
+
+ public SingletonStoreConfig()
+ {
+ // default value
+ className = SingletonStoreCacheLoader.class.getName();
+ }
+
+ public boolean isSingletonStoreEnabled()
+ {
+ return singletonStoreEnabled;
+ }
+
+ public void setSingletonStoreEnabled(boolean singletonStoreEnabled)
+ {
+ testImmutability("singletonStoreEnabled");
+ this.singletonStoreEnabled = singletonStoreEnabled;
+ }
+
+ public String getSingletonStoreClass()
+ {
+ return className;
+ }
+
+ public void setSingletonStoreClass(String className)
+ {
+ setClassName(className);
+ }
+
+ public Properties getSingletonStoreproperties()
+ {
+ return properties;
+ }
+
+ public void setSingletonStoreproperties(Properties properties)
+ {
+ setProperties(properties);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (super.equals(obj))
+ {
+ SingletonStoreConfig other = (SingletonStoreConfig) obj;
+ return this.singletonStoreEnabled == other.singletonStoreEnabled;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 19;
+ result = 41 * result + super.hashCode();
+ result = 41 * result + (singletonStoreEnabled ? 0 : 1);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + " enabled=" + singletonStoreEnabled +
+ " class=" + className +
+ " properties=" + properties;
+ }
+
+ @Override
+ public SingletonStoreConfig clone() throws CloneNotSupportedException
+ {
+ return (SingletonStoreConfig) super.clone();
+ }
+ }
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/CloneableConfigurationComponent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/CloneableConfigurationComponent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/CloneableConfigurationComponent.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,35 @@
+/*
+ * 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 java.io.Serializable;
+
+/**
+ * Interface for all configurable components
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface CloneableConfigurationComponent extends Serializable, Cloneable
+{
+ CloneableConfigurationComponent clone() throws CloneNotSupportedException;
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Configuration.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -1,55 +1,1024 @@
-/*
- * 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);
- }
-}
+/*
+ * 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.lock.IsolationLevel;
+import org.jboss.cache.marshall.Marshaller;
+import org.jboss.starobrno.config.parsing.JGroupsStackParser;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+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 Configuration 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
+ }
+
+ /**
+ * Default replication version, from {@link 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;
+ }
+
+ 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));
+ }
+
+ 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;
+ }
+
+ 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;
+
+ Configuration that = (Configuration) 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 Configuration clone() throws CloneNotSupportedException
+ {
+ Configuration c = (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() != Configuration.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;
+ }
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationComponent.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,168 @@
+/*
+ * 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.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheStatus;
+import org.jboss.starobrno.factories.ComponentRegistry;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Base superclass of Cache configuration classes that expose some properties
+ * that can be changed after the cache is started.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 6776 $
+ * @see #testImmutability(String)
+ */
+public abstract class ConfigurationComponent implements CloneableConfigurationComponent
+{
+ private static final long serialVersionUID = 4879873994727821938L;
+
+ protected transient Log log = LogFactory.getLog(getClass());
+ private transient CacheSPI cache; // back-reference to test whether the cache is running.
+ private final Set<ConfigurationComponent> children = Collections.synchronizedSet(new HashSet<ConfigurationComponent>());
+ private transient ComponentRegistry cr;
+ // a workaround to get over immutability checks
+ private boolean accessible;
+
+ protected ConfigurationComponent()
+ {
+ }
+
+ public void passCacheToChildConfig(ConfigurationComponent child)
+ {
+ if (child != null)
+ {
+ child.setCache(cache);
+ }
+ }
+
+ protected void addChildConfig(ConfigurationComponent child)
+ {
+ if (child != null && children.add(child))
+ child.setCache(cache);
+ }
+
+ protected void addChildConfigs(Collection<? extends ConfigurationComponent> toAdd)
+ {
+ if (toAdd != null)
+ {
+ for (ConfigurationComponent child : toAdd)
+ addChildConfig(child);
+ }
+ }
+
+ protected void removeChildConfig(ConfigurationComponent child)
+ {
+ children.remove(child);
+ }
+
+ protected void removeChildConfigs(Collection<? extends ConfigurationComponent> toRemove)
+ {
+ if (toRemove != null)
+ {
+ for (ConfigurationComponent child : toRemove)
+ removeChildConfig(child);
+ }
+ }
+
+ protected void replaceChildConfig(ConfigurationComponent oldConfig, ConfigurationComponent newConfig)
+ {
+ removeChildConfig(oldConfig);
+ addChildConfig(newConfig);
+ }
+
+ protected void replaceChildConfigs(Collection<? extends ConfigurationComponent> oldConfigs,
+ Collection<? extends ConfigurationComponent> newConfigs)
+ {
+ synchronized (children)
+ {
+ removeChildConfigs(oldConfigs);
+ addChildConfigs(newConfigs);
+ }
+ }
+
+ /**
+ * Checks field modifications via setters
+ *
+ * @param fieldName
+ */
+ protected void testImmutability(String fieldName)
+ {
+ try
+ {
+ if (!accessible && cache != null && cache.getCacheStatus() != null && cache.getCacheStatus() == CacheStatus.STARTED && !getClass().getDeclaredField(fieldName).isAnnotationPresent(Dynamic.class))
+ {
+ throw new ConfigurationException("Attempted to modify a non-Dynamic configuration element [" + fieldName + "] after the cache has started!");
+ }
+ }
+ catch (NoSuchFieldException e)
+ {
+ log.warn("Field " + fieldName + " not found!!");
+ }
+ finally
+ {
+ accessible = false;
+ }
+ }
+
+ public void setCache(CacheSPI cache)
+ {
+ this.cache = cache;
+ synchronized (children)
+ {
+ for (ConfigurationComponent child : children)
+ {
+ child.setCache(cache);
+ }
+ }
+ }
+
+ @Inject
+ private void injectDependencies(ComponentRegistry cr)
+ {
+ this.cr = cr;
+ }
+
+ @Start
+ private void start()
+ {
+ setCache(cr.getComponent(CacheSPI.class));
+ }
+
+ @Override
+ public CloneableConfigurationComponent clone() throws CloneNotSupportedException
+ {
+ ConfigurationComponent c = (ConfigurationComponent) super.clone();
+ c.setCache(null);
+ return c;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationException.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,74 @@
+/*
+ * 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.starobrno.CacheException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * An exception that represents an error in the configuration. This could be a parsing error or a logical error involving clashing
+ * configuration options or missing mandatory configuration elements.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @see org.jboss.cache.config.Configuration
+ * @see org.jboss.cache.CacheFactory
+ */
+public class ConfigurationException extends CacheException
+{
+
+ private static final long serialVersionUID = -5576382839360927955L;
+
+ private List<String> erroneousAttributes = new ArrayList<String>();
+
+ public ConfigurationException(Exception e)
+ {
+ super(e);
+ }
+
+ public ConfigurationException(String string)
+ {
+ super(string);
+ }
+
+ public ConfigurationException(String string, String erroneousAttribute)
+ {
+ super(string);
+ erroneousAttributes.add(erroneousAttribute);
+ }
+
+ public ConfigurationException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public List<String> getErroneousAttributes()
+ {
+ return erroneousAttributes;
+ }
+
+ public void addErroneousAttribute(String s)
+ {
+ erroneousAttributes.add(s);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationRegistry.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationRegistry.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,80 @@
+/*
+ * 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 java.util.Set;
+
+
+/**
+ * A registry for {@link Configuration}s.
+ *
+ * @author Brian Stansberry
+ * @version $Revision$
+ */
+public interface ConfigurationRegistry
+{
+ /**
+ * Gets a {@link Configuration#clone() clone} of the {@link Configuration}
+ * registered under the given name.
+ * <p/>
+ * The returned object is a clone of the internally held configuration,
+ * so any changes made to it by the caller will not affect the internal
+ * state of this registry.
+ *
+ * @param configName the name of the configuration
+ * @return a <code>Configuration</code>. Will not be <code>null</code>.
+ * @throws IllegalArgumentException if no configuration is registered
+ * under <code>configName</code>
+ */
+ Configuration getConfiguration(String configName) throws Exception;
+
+ /**
+ * Register the given configuration under the given name.
+ * <p/>
+ * The configuration will be cloned before being stored internally,
+ * so the copy under the control of the registry will not be affected
+ * by any external changes.
+ *
+ * @param configName the name of the configuration
+ * @param config the configuration
+ * @throws CloneNotSupportedException
+ * @throws IllegalStateException if a configuration is already registered
+ * under <code>configName</code>
+ */
+ void registerConfiguration(String configName, Configuration config) throws CloneNotSupportedException;
+
+ /**
+ * Unregisters the named configuration.
+ *
+ * @param configName the name of the configuration
+ * @throws IllegalStateException if no configuration is registered
+ * under <code>configName</code>
+ */
+ void unregisterConfiguration(String configName);
+
+ /**
+ * Gets the names of all registered configurations.
+ *
+ * @return a set of configuration names
+ */
+ Set<String> getConfigurationNames();
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/config/ConfigurationRegistry.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/CustomInterceptorConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/CustomInterceptorConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/CustomInterceptorConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,223 @@
+/*
+ * 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 net.jcip.annotations.Immutable;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+
+/**
+ * Holds information about the custom interceptors defined in the configuration file.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+@Immutable
+public class CustomInterceptorConfig extends ConfigurationComponent
+{
+ private CommandInterceptor interceptor;
+ private boolean isFirst;
+ private boolean isLast;
+ private int index = -1;
+ private String afterClass;
+ private String beforeClass;
+
+ /**
+ * Builds a custom interceptor.
+ *
+ * @param interceptor interceptor instance, already initialized with all attributes specified in the configuration
+ * @param first true if you wan this to be the first interceptor in the chain
+ * @param last true if you wan this to be the last interceptor in the chain
+ * @param index an absolute position within the interceptor chain
+ * @param afterClass if you want this interceptor immediately after the specified class in the chain
+ * @param beforeClass immediately before the specified class in the chain
+ */
+ public CustomInterceptorConfig(CommandInterceptor interceptor, boolean first, boolean last, int index,
+ String afterClass, String beforeClass)
+ {
+ this.interceptor = interceptor;
+ isFirst = first;
+ isLast = last;
+ this.index = index;
+ this.afterClass = afterClass;
+ this.beforeClass = beforeClass;
+ }
+
+ /**
+ * Constructs an interceptor config based on the supplied interceptor instance.
+ *
+ * @param interceptor
+ */
+ public CustomInterceptorConfig(CommandInterceptor interceptor)
+ {
+ this.interceptor = interceptor;
+ }
+
+ /**
+ * Shall this interceptor be the first one in the chain?
+ */
+ public void setFirst(boolean first)
+ {
+ testImmutability("first");
+ isFirst = first;
+ }
+
+ /**
+ * Shall this intercepto be the last one in the chain?
+ */
+ public void setLast(boolean last)
+ {
+ testImmutability("last");
+ isLast = last;
+ }
+
+ /**
+ * Put this interceptor at the specified index, after the default chain is built.
+ * If the index is not valid (negative or grater than the size of the chain)
+ * an {@link org.jboss.cache.config.ConfigurationException} is thrown at construction time.
+ */
+ public void setIndex(int index)
+ {
+ testImmutability("index");
+ this.index = index;
+ }
+
+ /**
+ * Adds the interceptor immediately after the first occurance of an interceptor having the given class.
+ * If the chain does not contain such an interceptor then this interceptor definition is ignored.
+ */
+ public void setAfterClass(String afterClass)
+ {
+ testImmutability("afterClass");
+ this.afterClass = afterClass;
+ }
+
+ /**
+ * Adds the interceptor immediately before the first occurance of an interceptor having the given class.
+ * If the chain does not contain such an interceptor then this interceptor definition is ignored.
+ */
+ public void setBeforeClass(String beforeClass)
+ {
+ testImmutability("beforeClass");
+ this.beforeClass = beforeClass;
+ }
+
+ /**
+ * Returns a the interceptor that we want to add to the chain.
+ */
+ public CommandInterceptor getInterceptor()
+ {
+ return interceptor;
+ }
+
+ /**
+ * @see #setFirst(boolean)
+ */
+ public boolean isFirst()
+ {
+ return isFirst;
+ }
+
+ /**
+ * @see #setLast(boolean)
+ */
+ public boolean isLast()
+ {
+ return isLast;
+ }
+
+ /**
+ * @see #getIndex()
+ */
+ public int getIndex()
+ {
+ return index;
+ }
+
+ /**
+ * @see #getAfterClass()
+ */
+ public String getAfterClass()
+ {
+ return afterClass;
+ }
+
+ /**
+ * @see #getBeforeClass()
+ */
+ public String getBeforeClass()
+ {
+ return beforeClass;
+ }
+
+ public String toString()
+ {
+ return "CustomInterceptorConfig{" +
+ "interceptor='" + interceptor + '\'' +
+ ", isFirst=" + isFirst +
+ ", isLast=" + isLast +
+ ", index=" + index +
+ ", afterClass='" + afterClass + '\'' +
+ ", beforeClass='" + beforeClass + '\'' +
+ '}';
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof CustomInterceptorConfig)) return false;
+
+ CustomInterceptorConfig that = (CustomInterceptorConfig) o;
+
+ if (index != that.index) return false;
+ if (isFirst != that.isFirst) return false;
+ if (isLast != that.isLast) return false;
+ if (afterClass != null ? !afterClass.equals(that.afterClass) : that.afterClass != null) return false;
+ if (beforeClass != null ? !beforeClass.equals(that.beforeClass) : that.beforeClass != null) return false;
+ if (interceptor != null ? !interceptor.equals(that.interceptor) : that.interceptor != null)
+ return false;
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (interceptor != null ? interceptor.hashCode() : 0);
+ result = 31 * result + (isFirst ? 1 : 0);
+ result = 31 * result + (isLast ? 1 : 0);
+ result = 31 * result + index;
+ result = 31 * result + (afterClass != null ? afterClass.hashCode() : 0);
+ result = 31 * result + (beforeClass != null ? beforeClass.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public CustomInterceptorConfig clone() throws CloneNotSupportedException
+ {
+ CustomInterceptorConfig dolly = (CustomInterceptorConfig) super.clone();
+ dolly.interceptor = interceptor;
+ dolly.isFirst = isFirst;
+ dolly.isLast = isLast;
+ dolly.afterClass = afterClass;
+ dolly.beforeClass = beforeClass;
+ return dolly;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/Dynamic.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Dynamic.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Dynamic.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,48 @@
+/*
+ * 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 java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation that marks fields in {@link Configuration} as being modifiable even after the cache has started.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+
+// ensure that this annotation is documented on fields in Configuration
+@Documented
+
+// only applies to fields.
+(a)Target(ElementType.FIELD)
+
+public @interface Dynamic
+{
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+/**
+ * An interface used to configure an eviction algorithm. Replaces the deprecated {@link org.jboss.cache.config.EvictionPolicyConfig}.
+ * <p/>
+ * In its most basic form, it is implemented by {@link org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase}, but
+ * more specific eviction policies may subclass {@link org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase} or re-implement
+ * this interface to provide access to more config variables.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface EvictionAlgorithmConfig extends CloneableConfigurationComponent
+{
+ /**
+ * Gets the class name of the {@link org.jboss.starobrno.eviction.EvictionAlgorithm} implementation
+ * this object will configure.
+ *
+ * @return fully qualified class name
+ */
+ String getEvictionAlgorithmClassName();
+
+ /**
+ * Validate the configuration. Will be called after any configuration
+ * properties are set.
+ *
+ * @throws ConfigurationException if any values for the configuration
+ * properties are invalid
+ */
+ void validate() throws ConfigurationException;
+
+ /**
+ * Resets the values to their defaults.
+ */
+ void reset();
+
+ /**
+ * @return a clone of the EvictionAlgorithmConfig.
+ */
+ EvictionAlgorithmConfig clone() throws CloneNotSupportedException;
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,307 @@
+/*
+ * 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.Fqn;
+import org.jboss.cache.RegionManagerImpl;
+import org.jboss.starobrno.eviction.DefaultEvictionActionPolicy;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+public class EvictionConfig extends ConfigurationComponent
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -7979639000026975201L;
+
+ public static final int WAKEUP_DEFAULT = 5000;
+ public static final int EVENT_QUEUE_SIZE_DEFAULT = 200000;
+ public static final String EVICTION_ACTION_POLICY_CLASS_DEFAULT = DefaultEvictionActionPolicy.class.getName();
+
+ /**
+ * value expressed in millis
+ */
+ @Dynamic
+ private long wakeupInterval = WAKEUP_DEFAULT;
+
+ private int defaultEventQueueSize = EVENT_QUEUE_SIZE_DEFAULT;
+
+ // Dynamic to support runtime adds/removes of regions
+ @Dynamic
+ private List<EvictionRegionConfig> evictionRegionConfigs;
+ private EvictionRegionConfig defaultEvictionRegionConfig;
+ @Deprecated
+ private String defaultEvictionPolicyClass;
+
+ public EvictionConfig()
+ {
+ evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+ defaultEvictionRegionConfig = new EvictionRegionConfig(Fqn.ROOT);
+ defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
+ defaultEvictionRegionConfig.setEvictionActionPolicyClassName(DefaultEvictionActionPolicy.class.getName());
+ }
+
+ public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig)
+ {
+ evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+ try
+ {
+ this.defaultEvictionRegionConfig = defaultEvictionRegionConfig.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new ConfigurationException(e);
+ }
+ this.defaultEvictionRegionConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
+ if (this.defaultEvictionRegionConfig.getEvictionActionPolicyClassName() == null)
+ this.defaultEvictionRegionConfig.setEvictionActionPolicyClassName(DefaultEvictionActionPolicy.class.getName());
+ }
+
+ public EvictionConfig(EvictionRegionConfig defaultEvictionRegionConfig, int wakeupInterval)
+ {
+ this(defaultEvictionRegionConfig);
+ this.wakeupInterval = wakeupInterval;
+ }
+
+ public boolean isValidConfig()
+ {
+ return (defaultEvictionRegionConfig != null && defaultEvictionRegionConfig.getEvictionActionPolicyClassName() != null && defaultEvictionRegionConfig.getEvictionAlgorithmConfig() != null)
+ || (evictionRegionConfigs != null && evictionRegionConfigs.size() > 0);
+ }
+
+ public EvictionRegionConfig getDefaultEvictionRegionConfig()
+ {
+ return defaultEvictionRegionConfig;
+ }
+
+ public void setDefaultEvictionRegionConfig(EvictionRegionConfig defaultEvictionRegionConfig)
+ {
+ this.defaultEvictionRegionConfig = defaultEvictionRegionConfig;
+ this.defaultEvictionRegionConfig.setEventQueueSizeIfUnset(EVENT_QUEUE_SIZE_DEFAULT);
+ }
+
+ /**
+ * @deprecated use {@link #getDefaultEvictionRegionConfig()} instead.
+ */
+ @Deprecated
+ public String getDefaultEvictionPolicyClass()
+ {
+ return defaultEvictionPolicyClass;
+ }
+
+ /**
+ * Creates an EvictionRegionConfig for the
+ * {@link org.jboss.cache.RegionManagerImpl#DEFAULT_REGION "_default_"} region using the
+ * {@link #getDefaultEvictionPolicyClass()} default eviction policy class}. Throws a
+ * {@link ConfigurationException} if
+ * {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class}
+ * has not been set.
+ *
+ * @return an EvictionRegionConfig whose FQN is {@link org.jboss.cache.RegionManagerImpl#DEFAULT_REGION}
+ * and whose EvictionPolicyConfig is the default config for the
+ * default eviction policy class.
+ * @throws ConfigurationException if a
+ * {@link #setDefaultEvictionPolicyClass(String) a default eviction policy class}
+ * has not been set or there is a problem instantiating the configuration.
+ * @deprecated the default region is now created when this instance is constructed. Use {@link #getDefaultEvictionRegionConfig()} instead.
+ */
+ @Deprecated
+ public EvictionRegionConfig createDefaultEvictionRegionConfig()
+ {
+ return getDefaultEvictionRegionConfig();
+ }
+
+ public List<EvictionRegionConfig> getEvictionRegionConfigs()
+ {
+ return evictionRegionConfigs;
+ }
+
+ public void setEvictionRegionConfigs(List<EvictionRegionConfig> evictionRegionConfigs)
+ {
+ testImmutability("evictionRegionConfigs");
+ EvictionRegionConfig toRemove = null;
+ for (EvictionRegionConfig erc : evictionRegionConfigs)
+ {
+ if (erc.getRegionFqn().isRoot() || erc.getRegionFqn().equals(RegionManagerImpl.DEFAULT_REGION))
+ {
+ mergeWithDefault(erc);
+ toRemove = erc;
+ break;
+ }
+ }
+
+ if (toRemove != null) evictionRegionConfigs.remove(toRemove);
+
+ this.evictionRegionConfigs = evictionRegionConfigs;
+ }
+
+ private void mergeWithDefault(EvictionRegionConfig erc)
+ {
+ erc.setEventQueueSizeIfUnset(defaultEvictionRegionConfig.getEventQueueSize());
+ if (erc.getEvictionAlgorithmConfig() == null)
+ erc.setEvictionAlgorithmConfig(defaultEvictionRegionConfig.getEvictionAlgorithmConfig());
+ defaultEvictionRegionConfig = erc;
+ }
+
+ public void addEvictionRegionConfig(EvictionRegionConfig evictionRegionConfig)
+ {
+ testImmutability("evictionRegionConfigs");
+ if (evictionRegionConfig.getRegionFqn().isRoot() || evictionRegionConfig.getRegionFqn().equals(RegionManagerImpl.DEFAULT_REGION))
+ {
+ mergeWithDefault(evictionRegionConfig);
+ }
+ else
+ {
+ evictionRegionConfigs.add(evictionRegionConfig);
+ }
+ }
+
+ /**
+ * @return the wake up interval of the eviction thread, in milliseconds.
+ */
+ public long getWakeupInterval()
+ {
+ return wakeupInterval;
+ }
+
+ /**
+ * Set the wake up interval for the eviction thread. 0 or a negative number disables the eviction thread.
+ *
+ * @param wakeupInterval interval, in milliseconds.
+ */
+ public void setWakeupInterval(long wakeupInterval)
+ {
+ testImmutability("wakeupInterval");
+ this.wakeupInterval = wakeupInterval;
+ }
+
+ /**
+ * Set the wake up interval for the eviction thread. 0 or a negative number disables the eviction thread.
+ *
+ * @param wakeupInterval interval
+ * @param timeUnit for the interval provided
+ */
+ public void setWakeupInterval(long wakeupInterval, TimeUnit timeUnit)
+ {
+ testImmutability("wakeupInterval");
+ this.wakeupInterval = timeUnit.toMillis(wakeupInterval);
+ }
+
+ /**
+ * @deprecated Use {@link #getWakeupIntervalSeconds()}.
+ */
+ @Deprecated
+ public int getWakeupIntervalSeconds()
+ {
+ return (int) TimeUnit.MILLISECONDS.toSeconds(wakeupInterval);
+ }
+
+ /**
+ * @deprecated Use {@link #setWakeupInterval(long)}.
+ */
+ @Deprecated
+ public void setWakeupIntervalSeconds(int wakeupIntervalSeconds)
+ {
+ setWakeupInterval(wakeupIntervalSeconds, TimeUnit.SECONDS);
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof EvictionConfig)) return false;
+
+ EvictionConfig that = (EvictionConfig) o;
+
+ if (defaultEventQueueSize != that.defaultEventQueueSize) return false;
+ if (wakeupInterval != that.wakeupInterval) return false;
+ if (defaultEvictionRegionConfig != null ? !defaultEvictionRegionConfig.equals(that.defaultEvictionRegionConfig) : that.defaultEvictionRegionConfig != null)
+ return false;
+ if (evictionRegionConfigs != null ? !evictionRegionConfigs.equals(that.evictionRegionConfigs) : that.evictionRegionConfigs != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = 31 + (int) (wakeupInterval ^ (wakeupInterval >>> 32));
+ result = 31 * result + defaultEventQueueSize;
+ result = 31 * result + (evictionRegionConfigs != null ? evictionRegionConfigs.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public EvictionConfig clone() throws CloneNotSupportedException
+ {
+ EvictionConfig clone = (EvictionConfig) super.clone();
+ if (evictionRegionConfigs != null)
+ {
+ // needs to be a deep copy
+ clone.evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
+ for (EvictionRegionConfig erc : evictionRegionConfigs)
+ clone.addEvictionRegionConfig(erc.clone());
+ }
+ return clone;
+ }
+
+
+ /**
+ * Returns the <code>EvictionRegionConfig</code> coresponding to given region fqn, or <code>null</code> if no
+ * match is found.
+ */
+ public EvictionRegionConfig getEvictionRegionConfig(String region)
+ {
+ Fqn fqn = Fqn.fromString(region);
+ for (EvictionRegionConfig evConfig : getEvictionRegionConfigs())
+ {
+ if (evConfig.getRegionFqn().equals(fqn))
+ {
+ return evConfig;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Applies defaults to a config passed in
+ *
+ * @param config config to apply defaults to
+ */
+ public void applyDefaults(EvictionRegionConfig config)
+ {
+ if (config == null) return; // no op
+ config.setDefaults(defaultEvictionRegionConfig);
+ }
+
+ /**
+ * @deprecated set these attributes on the default eviction region config.
+ */
+ @Deprecated
+ public void setDefaultEventQueueSize(int queueSize)
+ {
+ defaultEvictionRegionConfig.setEventQueueSize(queueSize);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/EvictionRegionConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,218 @@
+/*
+ * 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.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.util.Util;
+
+import java.lang.reflect.Method;
+
+public class EvictionRegionConfig extends ConfigurationComponent
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -5482474634995601400L;
+
+ public static final String NAME = "name";
+ public static final String REGION = "region";
+
+ private Fqn regionFqn;
+ @Dynamic
+ private Integer eventQueueSize;
+ private EvictionAlgorithmConfig evictionAlgorithmConfig;
+ private String evictionActionPolicyClassName;
+
+ public EvictionRegionConfig()
+ {
+ }
+
+ public EvictionRegionConfig(Fqn regionFqn, EvictionAlgorithmConfig evictionAlgorithmConfig)
+ {
+ this.regionFqn = regionFqn;
+ this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+ }
+
+ public EvictionRegionConfig(Fqn regionFqn, EvictionAlgorithmConfig evictionAlgorithmConfig, int queueSize)
+ {
+ this.regionFqn = regionFqn;
+ this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+ this.eventQueueSize = queueSize;
+ }
+
+ public EvictionRegionConfig(Fqn fqn)
+ {
+ this.regionFqn = fqn;
+ }
+
+ public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
+ {
+ return evictionAlgorithmConfig;
+ }
+
+ public void setEvictionAlgorithmConfig(EvictionAlgorithmConfig config)
+ {
+ testImmutability("evictionAlgorithmConfig");
+ this.evictionAlgorithmConfig = config;
+ }
+
+ public Fqn getRegionFqn()
+ {
+ return regionFqn;
+ }
+
+ public void setRegionFqn(Fqn regionFqn)
+ {
+ testImmutability("regionFqn");
+ this.regionFqn = regionFqn;
+ }
+
+ public String getRegionName()
+ {
+ return regionFqn == null ? null : regionFqn.toString();
+ }
+
+ public void setRegionName(String name)
+ {
+ setRegionFqn(name == null ? null : Fqn.fromString(name));
+ }
+
+ public int getEventQueueSize()
+ {
+ return eventQueueSize == null ? EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT : eventQueueSize;
+ }
+
+ public void setEventQueueSize(int queueSize)
+ {
+ testImmutability("eventQueueSize");
+ if (queueSize <= 0)
+ {
+ LogFactory.getLog(EvictionRegionConfig.class).warn("Ignoring invalid queue capacity " +
+ queueSize + " -- using " +
+ EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT);
+ queueSize = EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT;
+ }
+ this.eventQueueSize = queueSize;
+ }
+
+ public void setDefaults(EvictionRegionConfig defaults)
+ {
+ // go thru each element that is unset here and copy from "defaults"
+ if (eventQueueSize == null) eventQueueSize = defaults.getEventQueueSize();
+ if (evictionAlgorithmConfig == null) evictionAlgorithmConfig = defaults.getEvictionAlgorithmConfig();
+ if (evictionActionPolicyClassName == null)
+ evictionActionPolicyClassName = defaults.getEvictionActionPolicyClassName();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+
+ if (obj instanceof EvictionRegionConfig)
+ {
+ EvictionRegionConfig other = (EvictionRegionConfig) obj;
+ boolean equalRegions = Util.safeEquals(this.regionFqn, other.regionFqn);
+ boolean equalConfigurations = Util.safeEquals(this.evictionAlgorithmConfig, other.evictionAlgorithmConfig);
+ boolean equalEventQueuSizes = this.getEventQueueSize() == other.getEventQueueSize();
+ return equalRegions && equalConfigurations && equalConfigurations && equalEventQueuSizes;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 17;
+ result = 31 * result + (regionFqn == null ? 0 : regionFqn.hashCode());
+
+ return result;
+ }
+
+ @Override
+ public EvictionRegionConfig clone() throws CloneNotSupportedException
+ {
+ EvictionRegionConfig clone = (EvictionRegionConfig) super.clone();
+ if (evictionAlgorithmConfig != null)
+ {
+ if (evictionAlgorithmConfig instanceof ConfigurationComponent)
+ {
+ clone.setEvictionAlgorithmConfig((EvictionAlgorithmConfig) ((ConfigurationComponent) evictionAlgorithmConfig).clone());
+ }
+ else
+ {
+ try
+ {
+ Method cloneMethod = this.evictionAlgorithmConfig.getClass().getDeclaredMethod("clone");
+ EvictionAlgorithmConfig evictionAlgorithmConfig = (EvictionAlgorithmConfig) cloneMethod.invoke(this.evictionAlgorithmConfig);
+ clone.setEvictionAlgorithmConfig(evictionAlgorithmConfig);
+ }
+ catch (Exception e)
+ {
+ CloneNotSupportedException cnse = new CloneNotSupportedException("Cannot invoke clone() on " + evictionAlgorithmConfig);
+ cnse.initCause(e);
+ throw cnse;
+ }
+ }
+ }
+
+ clone.evictionActionPolicyClassName = evictionActionPolicyClassName;
+
+ return clone;
+ }
+
+ public boolean isDefaultRegion()
+ {
+ return regionFqn.isRoot();
+ }
+
+ public String getEvictionActionPolicyClassName()
+ {
+ return evictionActionPolicyClassName == null ? EvictionConfig.EVICTION_ACTION_POLICY_CLASS_DEFAULT : evictionActionPolicyClassName;
+ }
+
+ public void setEvictionActionPolicyClassName(String evictionActionPolicyClassName)
+ {
+ this.evictionActionPolicyClassName = evictionActionPolicyClassName;
+ }
+
+ public void setEventQueueSizeIfUnset(int eventQueueSize)
+ {
+ if (this.eventQueueSize == null) this.eventQueueSize = eventQueueSize;
+ }
+
+ /**
+ * Ensure this is a valid eviction region configuration.
+ */
+ public void validate()
+ {
+ if (eventQueueSize < 1)
+ throw new ConfigurationException("Eviction event queue size cannot be less than 1!");
+
+ if (evictionAlgorithmConfig == null)
+ throw new MissingPolicyException("Eviction algorithm configuration cannot be null!");
+
+ evictionAlgorithmConfig.validate();
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/MissingPolicyException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/MissingPolicyException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/MissingPolicyException.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+public class MissingPolicyException extends ConfigurationException
+{
+
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = 6107098975617303157L;
+
+ public MissingPolicyException(String message)
+ {
+ super(message);
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/OldFileFormatException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/OldFileFormatException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/OldFileFormatException.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+/**
+ * This exception indicates that an old configuration file is passed to a parser that only knows how to handle newer
+ * configuration file.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 3.0
+ */
+public class OldFileFormatException extends ConfigurationException
+{
+ public OldFileFormatException(String string)
+ {
+ super(string);
+ }
+
+ public OldFileFormatException()
+ {
+ this("The configuration file has an old format.");
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/Option.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/Option.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/Option.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,440 @@
+/*
+ * 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;
+
+
+/**
+ * Used to override characteristics of specific calls to the cache. The javadocs of each of the setters below detail functionality and behaviour.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @since 1.3.0
+ */
+public class Option implements Cloneable
+{
+ private boolean failSilently;
+ private boolean cacheModeLocal;
+ private boolean suppressLocking;
+ private boolean forceDataGravitation;
+ private boolean skipDataGravitation;
+
+ private boolean forceWriteLock;
+ private boolean skipCacheStatusCheck;
+
+ private boolean forceAsynchronous;
+ private boolean forceSynchronous;
+
+ private long syncReplTimeout = -1;
+ private int groupRequestMode = -1;
+
+ private int lockAcquisitionTimeout = -1;
+ private boolean suppressPersistence;
+
+ /**
+ * @since 1.4.0
+ */
+ public boolean isSuppressLocking()
+ {
+ return suppressLocking;
+ }
+
+ /**
+ * Suppresses acquiring locks for the given invocation. Used with pessimistic locking only. Use with extreme care, may lead to a breach in data integrity!
+ *
+ * @since 1.4.0
+ */
+ public void setSuppressLocking(boolean suppressLocking)
+ {
+ this.suppressLocking = suppressLocking;
+ }
+
+
+ /**
+ * @since 1.3.0
+ */
+ public boolean isFailSilently()
+ {
+ return failSilently;
+ }
+
+ /**
+ * suppress any failures in your cache operation, including version mismatches with optimistic locking, timeouts obtaining locks, transaction rollbacks. If this is option is set, the method invocation will __never fail or throw an exception__, although it may not succeed. With this option enabled the call will <b>not</b> participate in any ongoing transactions even if a transaction is running.
+ *
+ * @since 1.3.0
+ */
+ public void setFailSilently(boolean failSilently)
+ {
+ this.failSilently = failSilently;
+ }
+
+ /**
+ * only applies to put() and remove() methods on the cache.
+ *
+ * @since 1.3.0
+ */
+ public boolean isCacheModeLocal()
+ {
+ return cacheModeLocal;
+ }
+
+ /**
+ * overriding CacheMode from REPL_SYNC, REPL_ASYNC, INVALIDATION_SYNC, INVALIDATION_ASYNC to LOCAL. Only applies to put() and remove() methods on the cache.
+ *
+ * @param cacheModeLocal
+ * @since 1.3.0
+ */
+ public void setCacheModeLocal(boolean cacheModeLocal)
+ {
+ this.cacheModeLocal = cacheModeLocal;
+ }
+
+ /**
+ * @since 1.4.0
+ */
+ public boolean getForceDataGravitation()
+ {
+ return forceDataGravitation;
+ }
+
+ /**
+ * Enables data gravitation calls if a cache miss is detected when using <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheBuddyReplicationDesign">Buddy Replication</a>.
+ * Enabled only for a given invocation, and only useful if <code>autoDataGravitation</code> is set to <code>false</code>.
+ * See <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheBuddyReplicationDesign">Buddy Replication</a> documentation for more details.
+ *
+ * @since 1.4.0
+ */
+ public void setForceDataGravitation(boolean enableDataGravitation)
+ {
+ this.forceDataGravitation = enableDataGravitation;
+ }
+
+ /**
+ * @return true if skipDataGravitation is set to true.
+ * @since 1.4.1.SP6
+ */
+ public boolean isSkipDataGravitation()
+ {
+ return skipDataGravitation;
+ }
+
+ /**
+ * Suppresses data gravitation when buddy replication is used. If true, overrides {@link #setForceDataGravitation(boolean)}
+ * being set to true. Typically used to suppress gravitation calls when {@link org.jboss.cache.config.BuddyReplicationConfig#setAutoDataGravitation(boolean)}
+ * is set to true.
+ *
+ * @param skipDataGravitation
+ * @since 1.4.1.SP6
+ */
+ public void setSkipDataGravitation(boolean skipDataGravitation)
+ {
+ this.skipDataGravitation = skipDataGravitation;
+ }
+
+ /**
+ * Gets whether replication or invalidation should be done asynchronously,
+ * even if the cache is configured in a synchronous mode. Has no
+ * effect if the call is occuring within a transactional context.
+ *
+ * @return <code>true</code> if replication/invalidation should be done
+ * asynchronously; <code>false</code> if the default mode
+ * configured for the cache should be used.
+ */
+ public boolean isForceAsynchronous()
+ {
+ return forceAsynchronous;
+ }
+
+ /**
+ * Sets whether replication or invalidation should be done asynchronously,
+ * even if the cache is configured in a synchronous mode. Has no
+ * effect if the call is occuring within a transactional context.
+ *
+ * @param forceAsynchronous <code>true</code> if replication/invalidation
+ * should be done asynchronously; <code>false</code>
+ * if the default mode configured for the cache
+ * should be used.
+ */
+ public void setForceAsynchronous(boolean forceAsynchronous)
+ {
+ this.forceAsynchronous = forceAsynchronous;
+ }
+
+ /**
+ * Gets whether replication or invalidation should be done synchronously,
+ * even if the cache is configured in an asynchronous mode. Has no
+ * effect if the call is occuring within a transactional context.
+ *
+ * @return <code>true</code> if replication/invalidation should be done
+ * synchronously; <code>false</code> if the default mode
+ * configured for the cache should be used.
+ */
+ public boolean isForceSynchronous()
+ {
+ return forceSynchronous;
+ }
+
+ /**
+ * Sets whether replication or invalidation should be done synchronously,
+ * even if the cache is configured in an asynchronous mode. Has no
+ * effect if the call is occuring within a transactional context.
+ *
+ * @param forceSynchronous <code>true</code> if replication/invalidation
+ * should be done synchronously; <code>false</code>
+ * if the default mode configured for the cache
+ * should be used.
+ */
+ public void setForceSynchronous(boolean forceSynchronous)
+ {
+ this.forceSynchronous = forceSynchronous;
+ }
+
+ /**
+ * Gets any lock acquisition timeout configured for the call.
+ *
+ * @return the time in ms that lock acquisition attempts should block
+ * before failing with a TimeoutException. A value < 0 indicates
+ * that the cache's default timeout should be used.
+ */
+ public int getLockAcquisitionTimeout()
+ {
+ return lockAcquisitionTimeout;
+ }
+
+ /**
+ * Sets any lock acquisition timeout configured for the call.
+ *
+ * @param lockAcquisitionTimeout the time in ms that lock acquisition
+ * attempts should block before failing with a
+ * TimeoutException. A value < 0 indicates
+ * that the cache's default timeout should be used.
+ */
+ public void setLockAcquisitionTimeout(int lockAcquisitionTimeout)
+ {
+ this.lockAcquisitionTimeout = lockAcquisitionTimeout;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Option{" +
+ "failSilently=" + failSilently +
+ ", cacheModeLocal=" + cacheModeLocal +
+ ", suppressLocking=" + suppressLocking +
+ ", lockAcquisitionTimeout=" + lockAcquisitionTimeout +
+ ", forceDataGravitation=" + forceDataGravitation +
+ ", skipDataGravitation=" + skipDataGravitation +
+ ", forceAsynchronous=" + forceAsynchronous +
+ ", forceSynchronous=" + forceSynchronous +
+ '}';
+ }
+
+ /**
+ * @see #copy()
+ * @deprecated this method may disappear in future, please use copy() instead.
+ */
+ @Override
+ @Deprecated
+ public Option clone() throws CloneNotSupportedException
+ {
+ return (Option) super.clone();
+ }
+
+ /**
+ * @return a new Option instance with all fields shallow-copied.
+ */
+ public Option copy()
+ {
+ try
+ {
+ return (Option) super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // should never happen
+ return null;
+ }
+ }
+
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final Option option = (Option) o;
+
+ if (skipDataGravitation != option.skipDataGravitation) return false;
+ if (cacheModeLocal != option.cacheModeLocal) return false;
+ if (failSilently != option.failSilently) return false;
+ if (forceDataGravitation != option.forceDataGravitation) return false;
+ if (suppressLocking != option.suppressLocking) return false;
+ if (forceWriteLock != option.forceWriteLock) return false;
+ if (forceAsynchronous != option.forceAsynchronous) return false;
+ if (forceSynchronous != option.forceSynchronous) return false;
+ if (lockAcquisitionTimeout != option.lockAcquisitionTimeout) return false;
+ if (suppressPersistence != option.suppressPersistence) return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result;
+ result = (failSilently ? 1 : 0);
+ result = 29 * result + (cacheModeLocal ? 1 : 0);
+ result = 29 * result + (suppressLocking ? 1 : 0);
+ result = 29 * result + (forceDataGravitation ? 1 : 0);
+ result = 29 * result + (skipDataGravitation ? 1 : 0);
+ result = 29 * result + (forceWriteLock ? 0 : 1);
+ result = 29 * result + (forceAsynchronous ? 0 : 1);
+ result = 29 * result + (forceSynchronous ? 0 : 1);
+ result = 29 * result + (lockAcquisitionTimeout);
+ result = 29 * result + (suppressPersistence ? 0 : 1);
+ return result;
+ }
+
+ /**
+ * Resets this option to defaults.
+ */
+ public void reset()
+ {
+ this.skipDataGravitation = false;
+ this.cacheModeLocal = false;
+ this.failSilently = false;
+ this.forceDataGravitation = false;
+ this.suppressLocking = false;
+ this.forceWriteLock = false;
+ this.forceAsynchronous = false;
+ this.forceSynchronous = false;
+ this.lockAcquisitionTimeout = -1;
+ this.suppressPersistence = false;
+ }
+
+ /**
+ * Forces a write lock to be acquired on the call, regardless of whether it is a read or write. Only applies to the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}
+ *
+ * @param forceWriteLock
+ * @since 2.0.0
+ */
+ public void setForceWriteLock(boolean forceWriteLock)
+ {
+ this.forceWriteLock = forceWriteLock;
+ }
+
+
+ /**
+ * Tests whether a write lock has been forced on the call, regardless of whether it is a read or write. Only applies to the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}
+ *
+ * @since 2.0.0
+ */
+ public boolean isForceWriteLock()
+ {
+ return forceWriteLock;
+ }
+
+ /**
+ * If set to true, cache lifecycle checks will be skipped. DO NOT USE unless you really know what you're doing.
+ *
+ * @since 2.0.0
+ */
+ public void setSkipCacheStatusCheck(boolean skipCacheStatusCheck)
+ {
+ this.skipCacheStatusCheck = skipCacheStatusCheck;
+ }
+
+ /**
+ * @return true if skipCacheStatusCheck is true
+ * @since 2.0.0
+ */
+ public boolean isSkipCacheStatusCheck()
+ {
+ return skipCacheStatusCheck;
+ }
+
+ /**
+ * @return the value of the sync replication timeout (used when cache mode is either {@link org.jboss.cache.config.Configuration.CacheMode#REPL_SYNC}
+ * or {@link org.jboss.cache.config.Configuration.CacheMode#INVALIDATION_SYNC}) to be used for this specific call, or -1 (default) if the
+ * default value in {@link Configuration#getSyncReplTimeout()} is to be used instead.
+ * @since 2.1.0
+ */
+ public long getSyncReplTimeout()
+ {
+ return syncReplTimeout;
+ }
+
+ /**
+ * Used to override the value in {@link Configuration#getSyncReplTimeout()} (used when cache mode is either {@link org.jboss.cache.config.Configuration.CacheMode#REPL_SYNC}
+ * or {@link org.jboss.cache.config.Configuration.CacheMode#INVALIDATION_SYNC}) for this specific invocation. Defaults to -1,
+ * which means use the default in the configuration.
+ *
+ * @param syncReplTimeout new timeout value for this invocation.
+ * @since 2.1.0
+ */
+ public void setSyncReplTimeout(long syncReplTimeout)
+ {
+ this.syncReplTimeout = syncReplTimeout;
+ }
+
+ /**
+ * @return overridden JGroups {@link org.jgroups.blocks.GroupRequest} mode to use, or -1 if the {@link org.jboss.cache.RPCManager}'s
+ * own logic is to be used to select a group request mode (this is the default).
+ * @since 2.1.0
+ */
+ public int getGroupRequestMode()
+ {
+ return groupRequestMode;
+ }
+
+ /**
+ * By default, the {@link org.jboss.cache.RPCManager} has inbuilt logic when it comes to selecting a group request mode.
+ * This can be overridden by setting the group request mode here, using this method, for a specific invocation.
+ *
+ * @param groupRequestMode a group request mode, found in the {@link org.jgroups.blocks.GroupRequest} class.
+ * @since 2.1.0
+ */
+ public void setGroupRequestMode(int groupRequestMode)
+ {
+ this.groupRequestMode = groupRequestMode;
+ }
+
+ /**
+ * If set to true, any persistence to a cache loader will be suppressed for the current invocation only. Does not apply to transactional calls.
+ *
+ * @return true if persistence is suppressed.
+ * @since 3.0
+ */
+ public boolean isSuppressPersistence()
+ {
+ return suppressPersistence;
+ }
+
+ /**
+ * If set to true, any persistence to a cache loader will be suppressed for the current invocation only. Does not apply to transactional calls.
+ *
+ * @param suppressPersistence if true, will suppress persistence.
+ * @since 3.0
+ */
+ public void setSuppressPersistence(boolean suppressPersistence)
+ {
+ this.suppressPersistence = suppressPersistence;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/PluggableConfigurationComponent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/PluggableConfigurationComponent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/PluggableConfigurationComponent.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,113 @@
+/*
+ * 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.starobrno.config.parsing.XmlConfigHelper;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+/**
+ * A configuration component where the implementation class can be specified, and comes with its own set of properties.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.2.0
+ */
+public abstract class PluggableConfigurationComponent extends ConfigurationComponent
+{
+ protected String className;
+ protected Properties properties;
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ public void setClassName(String className)
+ {
+ if (className == null || className.length() == 0) return;
+ testImmutability("className");
+ this.className = className;
+ }
+
+ public Properties getProperties()
+ {
+ return properties;
+ }
+
+ public void setProperties(Properties properties)
+ {
+ testImmutability("properties");
+ this.properties = properties;
+ }
+
+ public void setProperties(String properties) throws IOException
+ {
+ if (properties == null) return;
+
+ testImmutability("properties");
+ // JBCACHE-531: escape all backslash characters
+ // replace any "\" that is not preceded by a backslash with "\\"
+ properties = XmlConfigHelper.escapeBackslashes(properties);
+ ByteArrayInputStream is = new ByteArrayInputStream(properties.trim().getBytes("ISO8859_1"));
+ this.properties = new Properties();
+ this.properties.load(is);
+ is.close();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ PluggableConfigurationComponent that = (PluggableConfigurationComponent) o;
+
+ if (className != null ? !className.equals(that.className) : that.className != null) return false;
+ if (properties != null ? !properties.equals(that.properties) : that.properties != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (className != null ? className.hashCode() : 0);
+ result = 31 * result + (properties != null ? properties.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName() + " {className = " + className +
+ ", properties=" + properties + "}";
+ }
+
+ @Override
+ public PluggableConfigurationComponent clone() throws CloneNotSupportedException
+ {
+ PluggableConfigurationComponent clone = (PluggableConfigurationComponent) super.clone();
+ if (properties != null) clone.properties = (Properties) properties.clone();
+ return clone;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/RuntimeConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,288 @@
+/*
+ * 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.RPCManager;
+import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.util.Util;
+import org.jgroups.Channel;
+import org.jgroups.ChannelFactory;
+import org.jgroups.util.ThreadFactory;
+
+import javax.transaction.TransactionManager;
+import java.util.concurrent.ExecutorService;
+
+public class RuntimeConfig extends ConfigurationComponent
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = 5626847485703341794L;
+
+ private transient TransactionManager transactionManager;
+ private transient Channel channel;
+ private transient ChannelFactory muxChannelFactory;
+ private transient BuddyGroup buddyGroup;
+ private RPCManager rpcManager;
+ private transient ThreadFactory evictionTimerThreadFactory;
+ private transient ExecutorService asyncSerializationExecutor;
+ private transient ExecutorService asyncCacheListenerExecutor;
+
+ /**
+ * Resets the runtime to default values.
+ */
+ public void reset()
+ {
+ channel = null;
+ rpcManager = null;
+ }
+
+
+ /**
+ * Gets the factory the cache will use to create a multiplexed channel.
+ *
+ * @return the channel, or <code>null</code> if not set
+ */
+ public ChannelFactory getMuxChannelFactory()
+ {
+ return muxChannelFactory;
+ }
+
+ /**
+ * Sets the factory the cache should use to create a multiplexed channel.
+ * Ignored if a Channel is directly configured via
+ * {@link #setChannel(Channel)}. If the channel factory is set,
+ * {@link Configuration#setMultiplexerStack(String)} must also be set, or
+ * a <code>CacheException</code> will be thrown during cache startup.
+ *
+ * @param multiplexerChannelFactory channel factory
+ */
+ public void setMuxChannelFactory(ChannelFactory multiplexerChannelFactory)
+ {
+ testImmutability("muxChannelFactory");
+ this.muxChannelFactory = multiplexerChannelFactory;
+ }
+
+ /**
+ * Gets the channel the cache is using.
+ * <p/>
+ * External callers should use extreme care if they access the channel.
+ * The cache expects it has exclusive access to the channel; external code
+ * trying to send or receive messages via the channel will almost certainly
+ * disrupt the operation of the cache.
+ * </p>
+ *
+ * @return the channel. May return <code>null</code> if the channel was
+ * not externally set via {@link #setChannel(Channel)} and the
+ * cache has not yet been started.
+ * @see #setChannel(Channel)
+ */
+ public Channel getChannel()
+ {
+ return channel;
+ }
+
+ /**
+ * Sets the channel the cache will use. The channel should not be
+ * connected or closed.
+ * <p/>
+ * External callers should use extreme care if they access the channel.
+ * The cache expects it has exclusive access to the channel; external code
+ * trying to send or receive messages via the channel will almost certainly
+ * disrupt the operation of the cache.
+ * </p>
+ * <p/>
+ * If an application wishes to send and receive messages using the same
+ * underlying channel as the <ocde>Cache</code>, a multiplexed channel should
+ * be used. Two separate mux channels should be created from the same
+ * <code>ChannelFactory</code> using the same <i>stack name</i> but different
+ * <code>id</code>s.
+ * See {@link ChannelFactory#createMultiplexerChannel(String,String,boolean,String)}.
+ * These two mux channels will share the same underlying channel. One of the
+ * two mux channels can be injected into the cache; the other can be used by
+ * the application. The cache will not see the application messages and vice versa.
+ * </p>
+ * <p/>
+ * Configuring the cache to use a mux channel can also be done by configuring
+ * {@link #setMuxChannelFactory(ChannelFactory) the channel factory} and the
+ * {@link Configuration#setMultiplexerStack(String) stack name}, in which case
+ * the cache will create and use a mux channel.
+ * </p>
+ *
+ * @param channel channel to set
+ */
+ public void setChannel(Channel channel)
+ {
+ this.channel = channel;
+ }
+
+ public TransactionManager getTransactionManager()
+ {
+ return transactionManager;
+ }
+
+ public void setTransactionManager(TransactionManager transactionManager)
+ {
+ testImmutability("transactionManager");
+ this.transactionManager = transactionManager;
+ }
+
+ /**
+ * This is only relevant if an eviction timer thread factory has been set using {@link #setEvictionTimerThreadFactory(org.jgroups.util.ThreadFactory)}.
+ * Will return a null if the eviction timer thread factory needs to be created internally.
+ * <p/>
+ *
+ * @return the thread factory used by the eviction timer's scheduled executor.
+ * @since 3.0
+ */
+ public ThreadFactory getEvictionTimerThreadFactory()
+ {
+ return evictionTimerThreadFactory;
+ }
+
+ /**
+ * Sets the eviction timer thread factory to use when creating a scheduled executor. If this is not set, the eviction
+ * timer task will use a default thread factory.
+ *
+ * @param evictionTimerThreadFactory factory to use
+ * @since 3.0
+ */
+ public void setEvictionTimerThreadFactory(ThreadFactory evictionTimerThreadFactory)
+ {
+ this.evictionTimerThreadFactory = evictionTimerThreadFactory;
+ }
+
+ /**
+ * This is only relevant if the async cache replication executor has been set using {@link #setAsyncSerializationExecutor(java.util.concurrent.ExecutorService)}.
+ * If the executor is created internally, this method will return null.
+ * <p/>
+ *
+ * @return the executor used for async replication.
+ * @since 3.0
+ */
+ public ExecutorService getAsyncSerializationExecutor()
+ {
+ return asyncSerializationExecutor;
+ }
+
+ /**
+ * This is used to set the executor to use for async cache replucation, and effectively overrides {@link org.jboss.cache.config.Configuration#setSerializationExecutorPoolSize(int)}
+ * <p/>
+ *
+ * @param asyncSerializationExecutor executor to set
+ * @since 3.0
+ */
+ public void setAsyncSerializationExecutor(ExecutorService asyncSerializationExecutor)
+ {
+ this.asyncSerializationExecutor = asyncSerializationExecutor;
+ }
+
+ /**
+ * This is only relevant if the async cache listener executor has been set using {@link #setAsyncCacheListenerExecutor(java.util.concurrent.ExecutorService)}.
+ * If the executor is created internally, this method will return null.
+ * <p/>
+ *
+ * @return the executor to use for async cache listeners
+ * @since 3.0
+ */
+ public ExecutorService getAsyncCacheListenerExecutor()
+ {
+ return asyncCacheListenerExecutor;
+ }
+
+ /**
+ * This is used to set the executor to use for async cache listeners, and effectively overrides {@link org.jboss.cache.config.Configuration#setListenerAsyncPoolSize(int)}
+ * <p/>
+ *
+ * @param asyncCacheListenerExecutor the executor to use for async cache listeners
+ * @since 3.0
+ */
+ public void setAsyncCacheListenerExecutor(ExecutorService asyncCacheListenerExecutor)
+ {
+ this.asyncCacheListenerExecutor = asyncCacheListenerExecutor;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+
+ if (obj instanceof RuntimeConfig)
+ {
+ RuntimeConfig other = (RuntimeConfig) obj;
+ return Util.safeEquals(transactionManager, other.transactionManager)
+ && Util.safeEquals(muxChannelFactory, other.muxChannelFactory)
+ && Util.safeEquals(rpcManager, other.rpcManager)
+ && Util.safeEquals(channel, other.channel)
+ && Util.safeEquals(evictionTimerThreadFactory, other.evictionTimerThreadFactory)
+ && Util.safeEquals(asyncCacheListenerExecutor, other.asyncCacheListenerExecutor)
+ && Util.safeEquals(asyncSerializationExecutor, other.asyncSerializationExecutor);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = 17;
+ result = result * 29 + (transactionManager == null ? 0 : transactionManager.hashCode());
+ result = result * 29 + (muxChannelFactory == null ? 0 : muxChannelFactory.hashCode());
+ result = result * 29 + (rpcManager == null ? 0 : rpcManager.hashCode());
+ result = result * 29 + (channel == null ? 0 : channel.hashCode());
+ result = result * 29 + (evictionTimerThreadFactory == null ? 0 : evictionTimerThreadFactory.hashCode());
+ result = result * 29 + (asyncCacheListenerExecutor == null ? 0 : asyncCacheListenerExecutor.hashCode());
+ result = result * 29 + (asyncSerializationExecutor == null ? 0 : asyncSerializationExecutor.hashCode());
+ return result;
+ }
+
+ public void setBuddyGroup(BuddyGroup buddyGroup)
+ {
+ this.buddyGroup = buddyGroup;
+ }
+
+ public BuddyGroup getBuddyGroup()
+ {
+ return buddyGroup;
+ }
+
+ public void setRPCManager(RPCManager rpcManager)
+ {
+ this.rpcManager = rpcManager;
+ }
+
+ public RPCManager getRPCManager()
+ {
+ return rpcManager;
+ }
+
+ @Override
+ public RuntimeConfig clone() throws CloneNotSupportedException
+ {
+ return (RuntimeConfig) super.clone();
+ }
+
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/UnsupportedEvictionImplException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/UnsupportedEvictionImplException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/UnsupportedEvictionImplException.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,51 @@
+/*
+ * 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;
+
+/**
+ * Thrown if an eviction configuration that cannot be translated to the new 3.x eviction interfaces is used.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class UnsupportedEvictionImplException extends ConfigurationException
+{
+ public UnsupportedEvictionImplException(Exception e)
+ {
+ super(e);
+ }
+
+ public UnsupportedEvictionImplException(String string)
+ {
+ super(string);
+ }
+
+ public UnsupportedEvictionImplException(String string, String erroneousAttribute)
+ {
+ super(string, erroneousAttribute);
+ }
+
+ public UnsupportedEvictionImplException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/config/XmlParsingConfigurationRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/config/XmlParsingConfigurationRegistry.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/config/XmlParsingConfigurationRegistry.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,125 @@
+/*
+ * 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.starobrno.config.parsing.CacheConfigsXmlParser;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * {@link ConfigurationRegistry} that obtains its initial set of configurations
+ * by parsing an XML document.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1 $
+ */
+public class XmlParsingConfigurationRegistry implements ConfigurationRegistry
+{
+ private final CacheConfigsXmlParser parser;
+ private final String configResource;
+ private final Map<String, Configuration> configs = new Hashtable<String, Configuration>();
+ private boolean started;
+
+ public XmlParsingConfigurationRegistry(String configResource)
+ {
+ parser = new CacheConfigsXmlParser();
+ this.configResource = configResource;
+ }
+
+ public void start() throws Exception
+ {
+ if (!started)
+ {
+ if (configResource != null)
+ configs.putAll(parser.parseConfigs(configResource));
+ started = true;
+ }
+ }
+
+ public void stop()
+ {
+ if (started)
+ {
+ synchronized (configs)
+ {
+ configs.clear();
+ }
+ started = false;
+ }
+ }
+
+ public String getConfigResource()
+ {
+ return configResource;
+ }
+
+ public Set<String> getConfigurationNames()
+ {
+ return new HashSet<String>(configs.keySet());
+ }
+
+ public void registerConfiguration(String configName, Configuration config)
+ throws CloneNotSupportedException
+ {
+ synchronized (configs)
+ {
+ if (configs.containsKey(configName))
+ throw new IllegalStateException(configName + " already registered");
+ configs.put(configName, config.clone());
+ }
+ }
+
+ public void unregisterConfiguration(String configName)
+ {
+ synchronized (configs)
+ {
+ if (configs.remove(configName) == null)
+ throw new IllegalStateException(configName + " not registered");
+ }
+ }
+
+ public Configuration getConfiguration(String configName)
+ {
+ Configuration config;
+ synchronized (configs)
+ {
+ config = configs.get(configName);
+ }
+
+ if (config == null)
+ throw new IllegalArgumentException("unknown config " + configName);
+
+ // Don't hand out a ref to our master copy
+ try
+ {
+ return config.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // This should not happen, as we already cloned the config
+ throw new RuntimeException("Could not clone configuration " + configName, e);
+ }
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/config/XmlParsingConfigurationRegistry.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContext.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,8 +21,8 @@
*/
package org.jboss.starobrno.context;
-import org.jboss.cache.config.Option;
import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.transaction.GlobalTransaction;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/InvocationContextImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -23,9 +23,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.Option;
import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.mvcc.MVCCEntry;
import org.jboss.starobrno.transaction.GlobalTransaction;
import org.jboss.starobrno.transaction.TransactionTable;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContext.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,9 +21,9 @@
*/
package org.jboss.starobrno.context;
-import org.jboss.cache.config.Option;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.config.Option;
import javax.transaction.Transaction;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/context/TransactionContextImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,16 +21,23 @@
*/
package org.jboss.starobrno.context;
-import org.jboss.cache.config.Option;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.util.Immutables;
import org.jboss.starobrno.commands.VisitableCommand;
+import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.mvcc.MVCCEntry;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* A transaction context specially geared to dealing with MVCC.
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseEvictionAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,614 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.lock.TimeoutException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.EvictionEvent.Type;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Abstract Event Processing Eviction Algorithm.
+ * This class is used to implement basic event processing for Eviction Algorithms.
+ * To extend this abstract class to make an Eviction Algorithm, implement the
+ * abstract methods and a policy.
+ *
+ * @author Daniel Huang - dhuang(a)jboss.org 10/2005
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
+ * @version $Revision: 6776 $
+ */
+public abstract class BaseEvictionAlgorithm implements EvictionAlgorithm
+{
+ private static final Log log = LogFactory.getLog(BaseEvictionAlgorithm.class);
+ private static final boolean trace = log.isTraceEnabled();
+ protected org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy;
+ protected EvictionAlgorithmConfig evictionAlgorithmConfig;
+ /**
+ * Contains Fqn instances.
+ */
+ protected BlockingQueue<Fqn> recycleQueue;
+ /**
+ * Contains NodeEntry instances.
+ */
+ protected org.jboss.starobrno.eviction.EvictionQueue evictionQueue;
+ protected boolean allowTombstones = false;
+ protected Configuration configuration;
+ protected Fqn regionFqn;
+ protected CacheSPI<?, ?> cache;
+
+ /**
+ * This method will create an EvictionQueue implementation and prepare it for use.
+ *
+ * @return The created EvictionQueue to be used as the eviction queue for this algorithm.
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ * if there are problems
+ * @see org.jboss.starobrno.eviction.EvictionQueue
+ */
+ protected abstract org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException;
+
+ /**
+ * This method will check whether the given node should be evicted or not.
+ *
+ * @param ne NodeEntry to test eviction for.
+ * @return True if the given node should be evicted. False if the given node should not be evicted.
+ */
+ protected abstract boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne);
+
+ protected BaseEvictionAlgorithm()
+ {
+ recycleQueue = new LinkedBlockingQueue<Fqn>(500000);
+ }
+
+ public synchronized void initialize()
+ {
+ if (evictionQueue == null)
+ {
+ evictionQueue = setupEvictionQueue();
+ allowTombstones = false;
+ }
+ }
+
+ public org.jboss.starobrno.eviction.EvictionActionPolicy getEvictionActionPolicy()
+ {
+ return evictionActionPolicy;
+ }
+
+ public void setEvictionActionPolicy(org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy)
+ {
+ this.evictionActionPolicy = evictionActionPolicy;
+ }
+
+ public EvictionAlgorithmConfig getEvictionAlgorithmConfig()
+ {
+ return evictionAlgorithmConfig;
+ }
+
+ public void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
+ {
+ this.regionFqn = fqn;
+ this.cache = cache;
+ this.evictionAlgorithmConfig = evictionAlgorithmConfig;
+ this.configuration = configuration;
+ }
+
+ public boolean canIgnoreEvent(Type eventType)
+ {
+ return false; // don't ignore anything!
+ }
+
+ /**
+ * Process the given eviction event queue. Eviction Processing encompasses the following:
+ * <p/>
+ * - Add/Remove/Visit Nodes
+ * - Prune according to Eviction Algorithm
+ * - Empty/Retry the recycle queue of previously evicted but locked (during actual cache eviction) nodes.
+ *
+ * @param eventQueue queue containing eviction events
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ *
+ */
+ public void process(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> eventQueue) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ if (trace) log.trace("process(): region: " + regionFqn);
+ initialize();
+ this.processQueues(eventQueue);
+ this.emptyRecycleQueue();
+ this.prune();
+ }
+
+ public void resetEvictionQueue()
+ {
+ // a no-op
+ }
+
+ /**
+ * Get the underlying EvictionQueue implementation.
+ *
+ * @return the EvictionQueue used by this algorithm
+ * @see org.jboss.starobrno.eviction.EvictionQueue
+ */
+ public org.jboss.starobrno.eviction.EvictionQueue getEvictionQueue()
+ {
+ return this.evictionQueue;
+ }
+
+ protected org.jboss.starobrno.eviction.EvictionEvent getNextInQueue(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue)
+ {
+ try
+ {
+ return queue.poll(0, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ return null;
+ }
+
+ /**
+ * Event processing for Evict/Add/Visiting of nodes.
+ * <p/>
+ * - On AddEvents a new element is added into the eviction queue
+ * - On RemoveEvents, the removed element is removed from the eviction queue.
+ * - On VisitEvents, the visited node has its eviction statistics updated (idleTime, numberOfNodeVisists, etc..)
+ *
+ * @param queue queue to inspect
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ * in the event of problems
+ */
+ protected void processQueues(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ org.jboss.starobrno.eviction.EvictionEvent node;
+ int count = 0;
+ while ((node = getNextInQueue(queue)) != null)
+ {
+ count++;
+ switch (node.getEventType())
+ {
+ case ADD_NODE_EVENT:
+ this.processAddedNodes(node);
+ break;
+ case REMOVE_NODE_EVENT:
+ this.processRemovedNodes(node);
+ break;
+ case VISIT_NODE_EVENT:
+ this.processVisitedNodes(node);
+ break;
+ case ADD_ELEMENT_EVENT:
+ this.processAddedElement(node);
+ break;
+ case REMOVE_ELEMENT_EVENT:
+ this.processRemovedElement(node);
+ break;
+ case MARK_IN_USE_EVENT:
+ this.processMarkInUseNodes(node.getFqn(), node.getInUseTimeout());
+ break;
+ case UNMARK_USE_EVENT:
+ this.processUnmarkInUseNodes(node.getFqn());
+ break;
+ default:
+ throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
+ }
+ }
+
+ if (trace) log.trace("processed " + count + " node events");
+ }
+
+ protected void evict(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+// NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+ if (ne != null)
+ {
+ evictionQueue.removeNodeEntry(ne);
+ if (!this.evictCacheNode(ne.getFqn()))
+ {
+ try
+ {
+ boolean result = recycleQueue.offer(ne.getFqn(), 5, TimeUnit.SECONDS);
+ if (!result)
+ {
+ log.warn("Unable to add Fqn[" + ne.getFqn() + "] to recycle " +
+ "queue because it's full. This is often sign that " +
+ "evictions are not occurring and nodes that should be " +
+ "evicted are piling up waiting to be evicted.");
+ }
+ }
+ catch (InterruptedException e)
+ {
+ log.debug("InterruptedException", e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Evict a node from cache.
+ *
+ * @param fqn node corresponds to this fqn
+ * @return True if successful
+ */
+ protected boolean evictCacheNode(Fqn fqn)
+ {
+ if (trace) log.trace("Attempting to evict cache node with fqn of " + fqn);
+
+ try
+ {
+ evictionActionPolicy.evict(fqn);
+ }
+ catch (TimeoutException e)
+ {
+ log.warn("Eviction of " + fqn + " timed out, retrying later");
+ log.debug(e, e);
+ return false;
+ }
+ catch (Exception e)
+ {
+ log.error("Eviction of " + fqn + " failed", e);
+ return false;
+ }
+
+ if (trace)
+ {
+ log.trace("Eviction of cache node with fqn of " + fqn + " successful");
+ }
+
+ return true;
+ }
+
+ protected void processMarkInUseNodes(Fqn fqn, long inUseTimeout) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ if (trace)
+ {
+ log.trace("Marking node " + fqn + " as in use with a usage timeout of " + inUseTimeout);
+ }
+
+ org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+ if (ne != null)
+ {
+ ne.setCurrentlyInUse(true, inUseTimeout);
+ }
+ }
+
+ protected void processUnmarkInUseNodes(Fqn fqn) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ if (trace)
+ {
+ log.trace("Unmarking node " + fqn + " as in use");
+ }
+
+ org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+ if (ne != null)
+ {
+ ne.setCurrentlyInUse(false, 0);
+ }
+ }
+
+ /**
+ * Convenience method, which calls {@link #processAddedNodes(org.jboss.starobrno.eviction.EvictionEvent , int)} using values in the
+ * evictedEventNode for number of added elements and the resetElementCount flag.
+ *
+ * @param evictedEventNode an evictedEventNode to process
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ * on problems
+ */
+ protected void processAddedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ processAddedNodes(evictedEventNode, evictedEventNode.getElementDifference());
+ }
+
+ protected void processAddedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode, int numAddedElements) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ Fqn fqn = evictedEventNode.getFqn();
+
+ if (trace)
+ {
+ log.trace("Adding node " + fqn + " with " + numAddedElements + " elements to eviction queue");
+ }
+
+ org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+ if (ne != null)
+ {
+ ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+ ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
+ ne.setNumberOfElements(ne.getNumberOfElements() + numAddedElements);
+ if (trace)
+ {
+ log.trace("Queue already contains " + ne.getFqn() + " processing it as visited");
+ }
+ processVisitedNodes(evictedEventNode);
+ return;
+ }
+
+ ne = new org.jboss.starobrno.eviction.NodeEntry(fqn);
+ ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+ ne.setNumberOfNodeVisits(1);
+ ne.setNumberOfElements(numAddedElements);
+
+ evictionQueue.addNodeEntry(ne);
+
+ if (trace)
+ {
+ log.trace(ne.getFqn() + " added successfully to eviction queue");
+ }
+ }
+
+ /**
+ * Remove a node from cache.
+ * <p/>
+ * This method will remove the node from the eviction queue as well as
+ * evict the node from cache.
+ * <p/>
+ * If a node cannot be removed from cache, this method will remove it from the eviction queue
+ * and place the element into the recycleQueue. Each node in the recycle queue will get retried until
+ * proper cache eviction has taken place.
+ * <p/>
+ * Because EvictionQueues are collections, when iterating them from an iterator, use iterator.remove()
+ * to avoid ConcurrentModificationExceptions. Use the boolean parameter to indicate the calling context.
+ *
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ *
+ */
+ protected void processRemovedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ Fqn fqn = evictedEventNode.getFqn();
+
+ if (trace)
+ {
+ log.trace("Removing node " + fqn + " from eviction queue and attempting eviction");
+ }
+
+ org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+ if (ne != null)
+ {
+ if (allowTombstones)
+ {
+ // don't remove from the queue - deleting a node results in a tombstone which means the nodes
+ // still need to be considered for eviction!
+ return;
+ }
+ else
+ {
+ // a removeNode operation will simply remove the node. Nothing to worry about.
+ evictionQueue.removeNodeEntry(ne);
+ }
+ }
+ else
+ {
+ if (trace)
+ {
+ log.trace("processRemoveNodes(): Can't find node associated with fqn: " + fqn
+ + "Could have been evicted earlier. Will just continue.");
+ }
+ return;
+ }
+
+ if (trace)
+ {
+ log.trace(fqn + " removed from eviction queue");
+ }
+ }
+
+ /**
+ * Visit a node in cache.
+ * <p/>
+ * This method will update the numVisits and modifiedTimestamp properties of the Node.
+ * These properties are used as statistics to determine eviction (LRU, LFU, MRU, etc..)
+ * <p/>
+ * *Note* that this method updates Node Entries by reference and does not put them back
+ * into the queue. For some sorted collections, a remove, and a re-add is required to
+ * maintain the sorted order of the elements.
+ *
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ *
+ */
+ protected void processVisitedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ Fqn fqn = evictedEventNode.getFqn();
+ org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+ if (ne == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Visiting node that was not added to eviction queues. Assuming that it has 1 element.");
+ }
+ this.processAddedNodes(evictedEventNode, 1);
+ return;
+ }
+ // note this method will visit and modify the node statistics by reference!
+ // if a collection is only guaranteed sort order by adding to the collection,
+ // this implementation will not guarantee sort order.
+ ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
+ ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+ }
+
+ protected void processRemovedElement(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ Fqn fqn = evictedEventNode.getFqn();
+ org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+
+ if (ne == null)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Removing element from " + fqn + " but eviction queue does not contain this node. " +
+ "Ignoring removeElement event.");
+ }
+ return;
+ }
+
+ ne.setNumberOfElements(ne.getNumberOfElements() - 1);
+ // also treat it as a node visit.
+ ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
+ ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+ }
+
+ protected void processAddedElement(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ Fqn fqn = evictedEventNode.getFqn();
+ org.jboss.starobrno.eviction.NodeEntry ne = evictionQueue.getNodeEntry(fqn);
+ if (ne == null)
+ {
+ if (trace)
+ {
+ log.trace("Adding element " + fqn + " for a node that doesn't exist yet. Process as an add.");
+ }
+ this.processAddedNodes(evictedEventNode, 1);
+ return;
+ }
+
+ ne.setNumberOfElements(ne.getNumberOfElements() + 1);
+
+ // also treat it as a node visit.
+ ne.setNumberOfNodeVisits(ne.getNumberOfNodeVisits() + 1);
+ ne.setModifiedTimeStamp(evictedEventNode.getCreationTimestamp());
+// log.error ("*** Processing nodeAdded for fqn " + fqn + " NodeEntry's hashcode is " + ne.hashCode());
+ }
+
+
+ /**
+ * Empty the Recycle Queue.
+ * <p/>
+ * This method will go through the recycle queue and retry to evict the nodes from cache.
+ *
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ *
+ */
+ protected void emptyRecycleQueue() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ while (true)
+ {
+ Fqn fqn;
+
+ try
+ {
+ //fqn = (Fqn) recycleQueue.take();
+ fqn = recycleQueue.poll(0, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ log.debug(e, e);
+ break;
+ }
+
+ if (fqn == null)
+ {
+ if (trace)
+ {
+ log.trace("Recycle queue is empty");
+ }
+ break;
+ }
+
+ if (trace)
+ {
+ log.trace("emptying recycle bin. Evict node " + fqn);
+ }
+
+ // Still doesn't work
+ if (!evictCacheNode(fqn))
+ {
+ try
+ {
+ recycleQueue.put(fqn);
+ }
+ catch (InterruptedException e)
+ {
+ log.debug(e, e);
+ }
+ break;
+ }
+ }
+ }
+
+ protected boolean isNodeInUseAndNotTimedOut(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+ if (ne.isCurrentlyInUse())
+ {
+ if (ne.getInUseTimeoutTimestamp() == 0)
+ {
+ return true;
+ }
+
+ if (System.currentTimeMillis() < ne.getInUseTimeoutTimestamp())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void prune() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ org.jboss.starobrno.eviction.NodeEntry entry;
+ while ((entry = evictionQueue.getFirstNodeEntry()) != null)
+ {
+ if (this.shouldEvictNode(entry))
+ {
+ this.evict(entry);
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ /**
+ * Returns debug information.
+ */
+ @Override
+ public String toString()
+ {
+ return super.toString() +
+ " recycle=" + recycleQueue.size() +
+ " evict=" + evictionQueue.getNumberOfNodes();
+ }
+
+ /**
+ * Tests whether a node entry is younger than the minimum time to live - if one is configured.
+ *
+ * @param entry the node entry being examined
+ * @return true if the node is younger than - or exactly equal to - the minimum time to live, if one is configured for the given region. False otherwise.
+ */
+ protected boolean isYoungerThanMinimumTimeToLive(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ if (evictionAlgorithmConfig instanceof org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase)
+ {
+ org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase cfg = (org.jboss.starobrno.eviction.EvictionAlgorithmConfigBase) evictionAlgorithmConfig;
+ long minTTL = cfg.getMinTimeToLive();
+ return minTTL >= 1 && (entry.getModifiedTimeStamp() + minTTL > System.currentTimeMillis());
+ }
+ else
+ {
+ log.trace("Eviction policy implementation does not support minimum TTL!");
+ return false;
+ }
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/BaseSortedEvictionAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,126 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.concurrent.BlockingQueue;
+
+
+/**
+ * An abstract SortedEvictionAlgorithm.
+ * <p/>
+ * This class supports early termination of the eviction queue processing. Because the eviction
+ * queue is sorted by first to evict to last to evict, when iterating the eviction queue, the first time
+ * a node is encountered that does not require eviction will terminate the loop early. This way we don't incur
+ * the full breadth of the O(n) = n operation everytime we need to check for eviction (defined by eviction poll time
+ * interval).
+ *
+ * @author Daniel Huang - dhuang(a)jboss.org - 10/2005
+ */
+public abstract class BaseSortedEvictionAlgorithm extends BaseEvictionAlgorithm
+{
+ private static final Log log = LogFactory.getLog(BaseSortedEvictionAlgorithm.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ @Override
+ protected void processQueues(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ boolean evictionNodesModified = false;
+
+ org.jboss.starobrno.eviction.EvictionEvent node;
+ int count = 0;
+ while ((node = getNextInQueue(queue)) != null)
+ {
+ count++;
+ switch (node.getEventType())
+ {
+ case ADD_NODE_EVENT:
+ this.processAddedNodes(node);
+ evictionNodesModified = true;
+ break;
+ case REMOVE_NODE_EVENT:
+ this.processRemovedNodes(node);
+ break;
+ case VISIT_NODE_EVENT:
+ this.processVisitedNodes(node);
+ evictionNodesModified = true;
+ break;
+ case ADD_ELEMENT_EVENT:
+ this.processAddedElement(node);
+ evictionNodesModified = true;
+ break;
+ case REMOVE_ELEMENT_EVENT:
+ this.processRemovedElement(node);
+ evictionNodesModified = true;
+ break;
+ default:
+ throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
+ }
+ }
+
+ if (trace)
+ {
+ log.trace("Eviction nodes visited or added requires resort of queue " + evictionNodesModified);
+ }
+
+ this.resortEvictionQueue(evictionNodesModified);
+
+
+ if (trace)
+ {
+ log.trace("processed " + count + " node events");
+ }
+
+ }
+
+ /**
+ * This method is called to resort the queue after add or visit events have occurred.
+ * <p/>
+ * If the parameter is true, the queue needs to be resorted. If it is false, the queue does not
+ * need resorting.
+ *
+ * @param evictionQueueModified True if the queue was added to or visisted during event processing.
+ */
+ protected void resortEvictionQueue(boolean evictionQueueModified)
+ {
+ if (!evictionQueueModified)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Eviction queue not modified. Resort unnecessary.");
+ }
+ return;
+ }
+ long begin = System.currentTimeMillis();
+ ((org.jboss.starobrno.eviction.SortedEvictionQueue) evictionQueue).resortEvictionQueue();
+ long end = System.currentTimeMillis();
+
+ if (trace)
+ {
+ long diff = end - begin;
+ log.trace("Took " + diff + "ms to sort queue with " + getEvictionQueue().getNumberOfNodes() + " elements");
+ }
+ }
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/DefaultEvictionActionPolicy.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,59 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+
+/**
+ * Default eviction action policy that calls {@link org.jboss.cache.Cache#evict(org.jboss.cache.Fqn)} to evict a node.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class DefaultEvictionActionPolicy implements EvictionActionPolicy
+{
+ Cache<?, ?> cache;
+ private static final Log log = LogFactory.getLog(DefaultEvictionActionPolicy.class);
+
+ public void setCache(Cache<?, ?> cache)
+ {
+ this.cache = cache;
+ }
+
+ public boolean evict(Fqn fqn)
+ {
+ try
+ {
+ if (log.isTraceEnabled()) log.trace("Evicting Fqn " + fqn);
+ cache.evict(fqn);
+ return true;
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e);
+ return false;
+ }
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,62 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+/**
+ * @author Daniel Huang
+ * @version $Revision: 6776 $
+ */
+public class ElementSizeAlgorithm extends BaseSortedEvictionAlgorithm
+{
+ @Override
+ protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ return new org.jboss.starobrno.eviction.ElementSizeQueue();
+ }
+
+ @Override
+ protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+ // check the minimum time to live and see if we should not evict the node. This check will
+ // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+ if (isYoungerThanMinimumTimeToLive(ne)) return false;
+ int size = this.getEvictionQueue().getNumberOfNodes();
+ org.jboss.starobrno.eviction.ElementSizeAlgorithmConfig config = (org.jboss.starobrno.eviction.ElementSizeAlgorithmConfig) evictionAlgorithmConfig;
+ return config.getMaxNodes() > -1 && size > config.getMaxNodes() || ne.getNumberOfElements() > config.getMaxElementsPerNode();
+ }
+
+ @Override
+ protected void prune() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ super.prune();
+
+ // clean up the Queue's eviction removals
+ ((org.jboss.starobrno.eviction.ElementSizeQueue) this.evictionQueue).prune();
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return ElementSizeAlgorithmConfig.class;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,127 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.Dynamic;
+
+/**
+ * Configuration for {@link org.jboss.starobrno.eviction.ElementSizeAlgorithm}.
+ * <p/>
+ * Requires a positive "maxElementsPerNode" value otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class ElementSizeAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = 2510593544656833758L;
+
+ @Dynamic
+ private int maxElementsPerNode;
+
+ public ElementSizeAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.ElementSizeAlgorithm.class.getName();
+ // Force configuration of maxElementsPerNode
+ setMaxElementsPerNode(-1);
+ }
+
+ public ElementSizeAlgorithmConfig(int maxNodes, int maxElementsPerNode)
+ {
+ this();
+ setMaxNodes(maxNodes);
+ setMaxElementsPerNode(maxElementsPerNode);
+ }
+
+ public int getMaxElementsPerNode()
+ {
+ return maxElementsPerNode;
+ }
+
+ public void setMaxElementsPerNode(int maxElementsPerNode)
+ {
+ testImmutability("maxElementsPerNode");
+ this.maxElementsPerNode = maxElementsPerNode;
+ }
+
+ /**
+ * Requires a positive maxElementsPerNode value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ super.validate();
+ if (maxElementsPerNode < 0)
+ {
+ throw new ConfigurationException("maxElementsPerNode must be must be " +
+ "configured to a value greater than or equal to 0");
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder str = new StringBuilder();
+ str.append("ElementSizeConfiguration: maxElementsPerNode =");
+ str.append(getMaxElementsPerNode()).append(" maxNodes =").append(getMaxNodes());
+ return str.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj instanceof ElementSizeAlgorithmConfig && super.equals(obj))
+ {
+ return this.maxElementsPerNode == ((ElementSizeAlgorithmConfig) obj).maxElementsPerNode;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + maxElementsPerNode;
+ return result;
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ setMaxElementsPerNode(-1);
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.ElementSizeAlgorithm.class.getName();
+ }
+
+ @Override
+ public ElementSizeAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (ElementSizeAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ElementSizeQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,230 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * @author Daniel Huang
+ * @version $Revision: 6776 $
+ */
+public class ElementSizeQueue implements SortedEvictionQueue
+{
+ private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> nodeMap;
+ private LinkedList<org.jboss.starobrno.eviction.NodeEntry> evictionList;
+ private Comparator<org.jboss.starobrno.eviction.NodeEntry> comparator;
+
+ private Set<org.jboss.starobrno.eviction.NodeEntry> removalQueue;
+ private int numElements = 0;
+
+ protected ElementSizeQueue()
+ {
+ nodeMap = new HashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
+ evictionList = new LinkedList<org.jboss.starobrno.eviction.NodeEntry>();
+ comparator = new MaxElementComparator();
+ removalQueue = new HashSet<org.jboss.starobrno.eviction.NodeEntry>();
+ }
+
+ public void resortEvictionQueue()
+ {
+ Collections.sort(evictionList, comparator);
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+ {
+ try
+ {
+ org.jboss.starobrno.eviction.NodeEntry ne;
+ while ((ne = evictionList.getFirst()) != null)
+ {
+ if (removalQueue.contains(ne))
+ {
+ evictionList.removeFirst();
+ removalQueue.remove(ne);
+ }
+ else
+ {
+ break;
+ }
+ }
+ return ne;
+ }
+ catch (NoSuchElementException e)
+ {
+ //
+ }
+
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+ {
+ return nodeMap.get(fqn);
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+ {
+ return this.getNodeEntry(Fqn.fromString(fqn));
+ }
+
+ public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ Fqn fqn = entry.getFqn();
+ return this.getNodeEntry(fqn) != null;
+ }
+
+ public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ org.jboss.starobrno.eviction.NodeEntry ne = nodeMap.remove(entry.getFqn());
+ if (ne != null)
+ {
+ // don't remove directly from the LinkedList otherwise we will incur a O(n) = n
+ // performance penalty for every removal! In the prune method for LFU, we will iterate the LinkedList through ONCE
+ // doing a single O(n) = n operation and removal. This is much preferred over running O(n) = n every single time
+ // remove is called. There is also special logic in the getFirstNodeEntry that will know to check
+ // the removalQueue before returning.
+ this.removalQueue.add(ne);
+/* if(!evictionList.remove(ne)) {
+ throw new RuntimeException("");
+ } */
+ this.numElements -= ne.getNumberOfElements();
+ }
+ }
+
+ public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ if (!this.containsNodeEntry(entry))
+ {
+ Fqn fqn = entry.getFqn();
+ entry.queue = this;
+ nodeMap.put(fqn, entry);
+ evictionList.add(entry);
+ this.numElements += entry.getNumberOfElements();
+ }
+ }
+
+ public int getNumberOfNodes()
+ {
+ return nodeMap.size();
+ }
+
+ public int getNumberOfElements()
+ {
+ return this.numElements;
+ }
+
+ public void modifyElementCount(int difference)
+ {
+ this.numElements += difference;
+ }
+
+ public void clear()
+ {
+ nodeMap.clear();
+ evictionList.clear();
+ removalQueue.clear();
+ this.numElements = 0;
+ }
+
+ protected final List<org.jboss.starobrno.eviction.NodeEntry> getEvictionList()
+ {
+ return evictionList;
+ }
+
+ protected final Set<org.jboss.starobrno.eviction.NodeEntry> getRemovalQueue()
+ {
+ return removalQueue;
+ }
+
+ protected final void prune()
+ {
+ Iterator<org.jboss.starobrno.eviction.NodeEntry> it = evictionList.iterator();
+ while (it.hasNext() && removalQueue.size() > 0)
+ {
+ if (removalQueue.remove(it.next()))
+ {
+ it.remove();
+ }
+ }
+ }
+
+ public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+ {
+ return evictionList.iterator();
+ }
+
+ /**
+ * Comparator class for Max Elements.
+ * <p/>
+ * This class will sort the eviction queue in the correct eviction order.
+ * The top of the list should evict before the bottom of the list.
+ * <p/>
+ * The sort is based on descending order of numElements.
+ * <p/>
+ * Note: this class has a natural ordering that is inconsistent with equals as defined by the java.lang.Comparator
+ * contract.
+ */
+ protected static class MaxElementComparator implements Comparator<org.jboss.starobrno.eviction.NodeEntry>
+ {
+
+ public int compare(org.jboss.starobrno.eviction.NodeEntry ne1, org.jboss.starobrno.eviction.NodeEntry ne2)
+ {
+ if (ne1.equals(ne2))
+ {
+ return 0;
+ }
+
+ int neNumElements = ne1.getNumberOfElements();
+ int neNumElements2 = ne2.getNumberOfElements();
+
+ if (neNumElements > neNumElements2)
+ {
+ return -1;
+ }
+ else if (neNumElements < neNumElements2)
+ {
+ return 1;
+ }
+ else if (neNumElements == neNumElements2)
+ {
+ return 0;
+ }
+
+ throw new RuntimeException("Should never reach this condition");
+ }
+
+ }
+
+}
+
+
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionActionPolicy.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,49 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+
+/**
+ * Performs an eviction on a given Fqn.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface EvictionActionPolicy
+{
+ /**
+ * Sets a reference to the cache.
+ *
+ * @param cache cache
+ */
+ void setCache(Cache<?, ?> cache);
+
+ /**
+ * Performs an eviction on a given node.
+ *
+ * @param fqn fqn to evict
+ * @return true if the eviction was successful, false if not.
+ */
+ boolean evict(Fqn fqn);
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,101 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.EvictionEvent.Type;
+
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * Interface for all eviction algorithms.
+ * <p/>
+ * Note: None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/
+ * EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.
+ *
+ * @author Ben Wang 2-2004
+ * @author Daniel Huang - dhuang(a)jboss.org - 10/2005
+ * @version $Revision: 6776 $
+ */
+public interface EvictionAlgorithm
+{
+ /**
+ * Entry point for eviction algorithm. Invoking this will cause the algorithm to process the queue of {@link EvictionEvent}
+ * passed in.
+ *
+ * @param queue to process
+ */
+ void process(BlockingQueue<EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException;
+
+ /**
+ * Reset the whole eviction queue. The queue may need to be reset due to corrupted state, for example.
+ */
+ void resetEvictionQueue();
+
+ /**
+ * Get the EvictionQueue implementation used by this algorithm.
+ *
+ * @return the EvictionQueue implementation.
+ */
+ org.jboss.starobrno.eviction.EvictionQueue getEvictionQueue();
+
+ /**
+ * Sets the eviction action policy, so the algorithm knows what to do when a node is to be evicted.
+ *
+ * @param evictionActionPolicy to set
+ */
+ void setEvictionActionPolicy(org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy);
+
+ /**
+ * Assigns the algorithm instance to a specific region.
+ *
+ * @param fqn of the region to be assigned to
+ * @param cache cache reference
+ * @param evictionAlgorithmConfig configuration for the current algorithm instance.
+ * @param configuration for the entire cache.
+ */
+ void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration);
+
+ /**
+ * Tests whether the algorithm would ignore certain event types on certain Fqns.
+ *
+ * @param eventType event type to test for
+ * @return true if the event representing the parameters would be ignored by this algorithm or not.
+ */
+ boolean canIgnoreEvent(Type eventType);
+
+ /**
+ * Invoked by the region manager when the enclosing region is initialized.
+ */
+ void initialize();
+
+ /**
+ * This is a helper so that the XML parser will be able to select and use the correct {@link org.jboss.cache.config.EvictionAlgorithmConfig} implementation
+ * class corresponding to this EvictionAlgorithm. E.g., the {@link FIFOAlgorithm} would return {@link FIFOAlgorithmConfig}.class.
+ *
+ * @return a class that is used to configure this EvictionAlgorithm.
+ */
+ Class<? extends EvictionAlgorithmConfig> getConfigurationClass();
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithm.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithmConfigBase.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithmConfigBase.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionAlgorithmConfigBase.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,142 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.annotations.Compat;
+import org.jboss.starobrno.config.ConfigurationComponent;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.Dynamic;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A base class used for configuring eviction algorithms.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public abstract class EvictionAlgorithmConfigBase extends ConfigurationComponent implements EvictionAlgorithmConfig
+{
+ private static final long serialVersionUID = 4591691674370188932L;
+
+ protected String evictionAlgorithmClassName;
+ @Dynamic
+ protected int maxNodes = 0;
+ @Dynamic
+ protected long minTimeToLive;
+
+ /**
+ * Can only be instantiated by a subclass.
+ */
+ protected EvictionAlgorithmConfigBase()
+ {
+ }
+
+ public String getEvictionAlgorithmClassName()
+ {
+ return evictionAlgorithmClassName;
+ }
+
+ public int getMaxNodes()
+ {
+ return maxNodes;
+ }
+
+ public void setMaxNodes(int maxNodes)
+ {
+ testImmutability("maxNodes");
+ this.maxNodes = maxNodes;
+ }
+
+ /**
+ * @return The minimum time to live, in milliseconds.
+ */
+ public long getMinTimeToLive()
+ {
+ return minTimeToLive;
+ }
+
+ /**
+ * @param minTimeToLive time to live, in milliseconds
+ */
+ public void setMinTimeToLive(long minTimeToLive)
+ {
+ testImmutability("minTimeToLive");
+ this.minTimeToLive = minTimeToLive;
+ }
+
+ public void setMinTimeToLive(long time, TimeUnit timeUnit)
+ {
+ testImmutability("minTimeToLive");
+ minTimeToLive = timeUnit.toMillis(time);
+ }
+
+ @Deprecated
+ @Compat
+ public void setMinTimeToLiveSeconds(long time)
+ {
+ setMinTimeToLive(time, TimeUnit.SECONDS);
+ }
+
+ public void validate() throws ConfigurationException
+ {
+ if (evictionAlgorithmClassName == null)
+ throw new ConfigurationException("Eviction algorithm class name cannot be null!");
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof EvictionAlgorithmConfigBase)) return false;
+
+ EvictionAlgorithmConfigBase that = (EvictionAlgorithmConfigBase) o;
+
+ if (maxNodes != that.maxNodes) return false;
+ if (minTimeToLive != that.minTimeToLive) return false;
+ if (evictionAlgorithmClassName != null ? !evictionAlgorithmClassName.equals(that.evictionAlgorithmClassName) : that.evictionAlgorithmClassName != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (evictionAlgorithmClassName != null ? evictionAlgorithmClassName.hashCode() : 0);
+ result = 31 * result + maxNodes;
+ result = (int) (31 * result + minTimeToLive);
+ result = 31 * result + (int) (minTimeToLive ^ (minTimeToLive >>> 32));
+ return result;
+ }
+
+ public void reset()
+ {
+ maxNodes = 0;
+ minTimeToLive = 0;
+ }
+
+ public EvictionAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (EvictionAlgorithmConfig) super.clone();
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,127 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+/**
+ * An eviction event records activity on nodes in the cache. These are recorded on a {@link org.jboss.cache.Region} for processing
+ * later by calls to {@link org.jboss.cache.Region#processEvictionQueues()}.
+ * <p/>
+ *
+ * @see org.jboss.cache.Region
+ */
+public class EvictionEvent
+{
+ private Fqn fqn;
+ private Type type;
+ private int elementDifference;
+
+ private long inUseTimeout;
+ private long creationTimestamp;
+
+ public EvictionEvent()
+ {
+ }
+
+ public static enum Type
+ {
+ ADD_NODE_EVENT,
+ REMOVE_NODE_EVENT,
+ VISIT_NODE_EVENT,
+ ADD_ELEMENT_EVENT,
+ REMOVE_ELEMENT_EVENT,
+ MARK_IN_USE_EVENT,
+ UNMARK_USE_EVENT
+ }
+
+ public EvictionEvent(Fqn fqn, Type type, int elementDifference)
+ {
+ this.fqn = fqn;
+ this.type = type;
+ this.elementDifference = elementDifference;
+ this.creationTimestamp = System.currentTimeMillis();
+ }
+
+ public long getCreationTimestamp()
+ {
+ return creationTimestamp;
+ }
+
+ public long getInUseTimeout()
+ {
+ return inUseTimeout;
+ }
+
+ public void setInUseTimeout(long inUseTimeout)
+ {
+ this.inUseTimeout = inUseTimeout;
+ }
+
+ public int getElementDifference()
+ {
+ return elementDifference;
+ }
+
+ public void setElementDifference(int elementDifference)
+ {
+ this.elementDifference = elementDifference;
+ }
+
+ public Fqn getFqn()
+ {
+ return fqn;
+ }
+
+ public void setFqn(Fqn fqn)
+ {
+ this.fqn = fqn;
+ }
+
+ public void setEventType(Type event)
+ {
+ type = event;
+ }
+
+ public Type getEventType()
+ {
+ return type;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "EvictedEventNode[fqn=" + fqn + " event=" + type + " diff=" + elementDifference + "]";
+ }
+
+ /**
+ * Copies this evicted event node to create a new one with the same values, except with a new Fqn root.
+ *
+ * @param newRoot new Fqn root to use
+ * @return a new EvictedEventNode instance
+ * @see org.jboss.cache.Region#copy(org.jboss.cache.Fqn)
+ */
+ public EvictionEvent copy(Fqn newRoot)
+ {
+ return new EvictionEvent(Fqn.fromRelativeFqn(newRoot, fqn), type, elementDifference);
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionEvent.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionException.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,49 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.CacheException;
+
+/**
+ * @author Ben Wang, Feb 11, 2004
+ */
+public class EvictionException extends CacheException
+{
+
+ private static final long serialVersionUID = 4006783737166646935L;
+
+ public EvictionException()
+ {
+ super();
+ }
+
+ public EvictionException(String msg)
+ {
+ super(msg);
+ }
+
+ public EvictionException(String msg, Throwable cause)
+ {
+ super(msg, cause);
+ }
+
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionException.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionListEntry.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,67 @@
+/*
+ * 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.eviction;
+
+/**
+ * // TODO: MANIK: Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+class EvictionListEntry
+{
+ EvictionListEntry next;
+ EvictionListEntry previous;
+
+ NodeEntry node;
+
+ EvictionListEntry()
+ {
+ }
+
+ EvictionListEntry(NodeEntry node)
+ {
+ this.node = node;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof EvictionListEntry))
+ return false;
+ EvictionListEntry entry = (EvictionListEntry) o;
+ return this.node.getFqn().equals(entry.node.getFqn());
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return this.node.getFqn().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "EntryLE=" + node;
+ }
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,106 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+
+/**
+ * Eviction Queue interface defines a contract for the Eviction Queue implementations used by EvictionPolicies.
+ * <p/>
+ * Note: None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/
+ * EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public interface EvictionQueue extends Iterable<org.jboss.starobrno.eviction.NodeEntry>
+{
+ /**
+ * Get the first entry in the queue.
+ * <p/>
+ * If there are no entries in queue, this method will return null.
+ * <p/>
+ * The first node returned is expected to be the first node to evict.
+ *
+ * @return first NodeEntry in queue.
+ */
+ org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry();
+
+ /**
+ * Retrieve a node entry by Fqn.
+ * <p/>
+ * This will return null if the entry is not found.
+ *
+ * @param fqn Fqn of the node entry to retrieve.
+ * @return Node Entry object associated with given Fqn param.
+ */
+ org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn);
+
+ org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn);
+
+ /**
+ * Check if queue contains the given NodeEntry.
+ *
+ * @param entry NodeEntry to check for existence in queue.
+ * @return true/false if NodeEntry exists in queue.
+ */
+ boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry);
+
+ /**
+ * Remove a NodeEntry from queue.
+ * <p/>
+ * If the NodeEntry does not exist in the queue, this method will return normally.
+ *
+ * @param entry The NodeEntry to remove from queue.
+ */
+ void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry);
+
+ /**
+ * Add a NodeEntry to the queue.
+ *
+ * @param entry The NodeEntry to add to queue.
+ */
+ void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry);
+
+ /**
+ * Get the number of nodes in the queue.
+ *
+ * @return The number of nodes in the queue.
+ */
+ int getNumberOfNodes();
+
+ /**
+ * Get the number of elements in the queue.
+ *
+ * @return The number of elements in the queue.
+ */
+ int getNumberOfElements();
+
+ void modifyElementCount(int difference);
+
+ /**
+ * Clear the queue.
+ */
+ void clear();
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionQueueList.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,349 @@
+/*
+ * 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.eviction;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.ConcurrentModificationException;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+
+/**
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class EvictionQueueList
+{
+ EvictionListEntry head;
+ EvictionListEntry tail;
+ int modCount;
+ private int size;
+
+ EvictionQueueList()
+ {
+ head = null;
+ tail = null;
+ size = 0;
+ modCount = 0;
+ }
+
+ void addToTop(EvictionListEntry entry)
+ {
+ EvictionListEntry formerHead = head;
+ head = entry;
+ // if there was no previous head then this list was empty.
+ if (formerHead != null)
+ {
+ formerHead.previous = head;
+ head.next = formerHead;
+ head.previous = null;
+ }
+ else
+ {
+ tail = entry;
+ }
+ size++;
+ modCount++;
+ }
+
+ void addToBottom(EvictionListEntry entry)
+ {
+ EvictionListEntry formerTail = tail;
+ tail = entry;
+ // if there was no previous head then this list was empty.
+ if (formerTail != null)
+ {
+ tail.previous = formerTail;
+ formerTail.next = tail;
+ tail.next = null;
+ }
+ else
+ {
+ head = entry;
+ }
+ size++;
+ modCount++;
+ }
+
+ void remove(EvictionListEntry entry)
+ {
+ if (this.isEmpty())
+ {
+ return;
+ }
+
+ if (isSingleNode(entry))
+ {
+ head = null;
+ tail = null;
+ }
+ else if (isTail(entry))
+ {
+ tail = entry.previous;
+ // unlink the last node.
+ entry.previous.next = null;
+ }
+ else if (isHead(entry))
+ {
+ head = entry.next;
+ head.previous = null;
+ }
+ else
+ {
+ // node is in between two other nodes.
+ entry.next.previous = entry.previous;
+ entry.previous.next = entry.next;
+ }
+ size--;
+ modCount++;
+ }
+
+ int size()
+ {
+ return this.size;
+ }
+
+ void clear()
+ {
+ head = null;
+ tail = null;
+ size = 0;
+ modCount++;
+ }
+
+ EvictionListEntry getFirst()
+ {
+ if (head == null)
+ {
+ throw new NoSuchElementException("List is empty");
+ }
+ return head;
+ }
+
+ EvictionListEntry getLast()
+ {
+ if (tail == null)
+ {
+ throw new NoSuchElementException("List is empty");
+ }
+ return tail;
+ }
+
+ Iterator<NodeEntry> iterator()
+ {
+ return new EvictionListIterator();
+ }
+
+ NodeEntry[] toNodeEntryArray()
+ {
+ if (isEmpty())
+ {
+ return null;
+ }
+ NodeEntry[] ret = new NodeEntry[size];
+ int i = 0;
+ EvictionListEntry temp = head;
+
+ do
+ {
+ ret[i] = temp.node;
+ temp = temp.next;
+ i++;
+ }
+ while (temp != null);
+
+ return ret;
+ }
+
+ EvictionListEntry[] toArray()
+ {
+ if (isEmpty())
+ {
+ return null;
+ }
+ EvictionListEntry[] ret = new EvictionListEntry[size];
+ int i = 0;
+ EvictionListEntry temp = head;
+
+ do
+ {
+ ret[i] = temp;
+ temp = temp.next;
+ i++;
+ }
+ while (temp != null);
+
+ return ret;
+ }
+
+ void fromArray(EvictionListEntry[] evictionListEntries)
+ {
+
+ for (EvictionListEntry evictionListEntry : evictionListEntries)
+ {
+ this.addToBottom(evictionListEntry);
+ }
+ }
+
+ private boolean isEmpty()
+ {
+ return head == null && tail == null;
+ }
+
+ private boolean isSingleNode(EvictionListEntry entry)
+ {
+ return isTail(entry) && isHead(entry);
+ }
+
+ private boolean isTail(EvictionListEntry entry)
+ {
+ return entry.next == null;
+ }
+
+ private boolean isHead(EvictionListEntry entry)
+ {
+ return entry.previous == null;
+ }
+
+ @Override
+ public String toString()
+ {
+ return Arrays.asList(toArray()).toString();
+ }
+
+ static class EvictionListComparator implements Comparator<EvictionListEntry>
+ {
+ Comparator<NodeEntry> nodeEntryComparator;
+
+ EvictionListComparator(Comparator<NodeEntry> nodeEntryComparator)
+ {
+ this.nodeEntryComparator = nodeEntryComparator;
+ }
+
+ public int compare(EvictionListEntry e1, EvictionListEntry e2)
+ {
+ return nodeEntryComparator.compare(e1.node, e2.node);
+ }
+ }
+
+ class EvictionListIterator implements ListIterator<NodeEntry>
+ {
+ EvictionListEntry next = head;
+ EvictionListEntry previous;
+ EvictionListEntry cursor;
+
+ int initialModCount = EvictionQueueList.this.modCount;
+
+ public boolean hasNext()
+ {
+ this.doConcurrentModCheck();
+ return next != null;
+ }
+
+ public NodeEntry next()
+ {
+ this.doConcurrentModCheck();
+ this.forwardCursor();
+ return cursor.node;
+ }
+
+ public boolean hasPrevious()
+ {
+ this.doConcurrentModCheck();
+ return previous != null;
+ }
+
+ public NodeEntry previous()
+ {
+ this.doConcurrentModCheck();
+ this.rewindCursor();
+ return cursor.node;
+ }
+
+ public int nextIndex()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public int previousIndex()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void remove()
+ {
+ this.doConcurrentModCheck();
+ if (cursor == null)
+ {
+ throw new IllegalStateException("Cannot remove from iterator when there is nothing at the current iteration point");
+ }
+ EvictionQueueList.this.remove(cursor);
+ cursor = null;
+ initialModCount++;
+ }
+
+ public void set(NodeEntry o)
+ {
+ this.doConcurrentModCheck();
+ cursor.node = (NodeEntry) o;
+ }
+
+ public void add(NodeEntry o)
+ {
+ this.doConcurrentModCheck();
+ initialModCount++;
+ }
+
+ private void doConcurrentModCheck()
+ {
+ if (EvictionQueueList.this.modCount != initialModCount)
+ {
+ throw new ConcurrentModificationException();
+ }
+ }
+
+ private void forwardCursor()
+ {
+ if (next == null)
+ {
+ throw new NoSuchElementException("No more objects to iterate.");
+ }
+ previous = cursor;
+ cursor = next;
+ next = cursor.next;
+ }
+
+ private void rewindCursor()
+ {
+ if (previous == null)
+ {
+ throw new NoSuchElementException();
+ }
+ next = cursor;
+ cursor = previous;
+ previous = cursor.previous;
+ }
+ }
+
+}
+
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,174 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Region;
+import org.jboss.cache.util.concurrent.ConcurrentHashSet;
+
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Timer threads to do periodic node clean up by running the eviction policy.
+ *
+ * @author Ben Wang 2-2004
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6840 $
+ */
+public class EvictionTimerTask
+{
+ private Log log = LogFactory.getLog(EvictionTimerTask.class);
+
+ private final Set<Region> processedRegions;
+ private static AtomicInteger tcount = new AtomicInteger();
+ private long wakeupInterval;
+ ScheduledExecutorService scheduledExecutor;
+ private Task task;
+
+ public EvictionTimerTask()
+ {
+ // synchronized set because we need to maintain thread safety
+ // for dynamic configuration purposes.
+ processedRegions = new ConcurrentHashSet<Region>();
+ task = new Task();
+ }
+
+ public void init(long wakeupInterval, ThreadFactory evictionThreadFactory)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Creating a new eviction listener with wakeupInterval millis set at " + wakeupInterval);
+ this.wakeupInterval = wakeupInterval;
+ start(evictionThreadFactory);
+ }
+
+ /**
+ * Add a MarshRegion to process by the Eviction Thread.
+ *
+ * @param region MarshRegion to process.
+ */
+ public void addRegionToProcess(Region region)
+ {
+ processedRegions.add(region);
+ }
+
+ /**
+ * Remove a MarshRegion to process from the Eviction thread.
+ *
+ * @param region
+ */
+ public void removeRegionToProcess(Region region)
+ {
+ processedRegions.remove(region);
+ }
+
+ public boolean isRegionRegisteredForProcessing(Region region)
+ {
+ return processedRegions.contains(region);
+ }
+
+ public Set<Region> getProcessedRegions()
+ {
+ return processedRegions;
+ }
+
+ public void stop()
+ {
+ if (log.isDebugEnabled()) log.debug("Stopping eviction timer");
+
+ if (scheduledExecutor != null)
+ {
+ scheduledExecutor.shutdownNow();
+ }
+ scheduledExecutor = null;
+ }
+
+ private void start(ThreadFactory tf)
+ {
+ if (wakeupInterval < 1)
+ {
+ if (log.isInfoEnabled())
+ log.info("Wakeup Interval set to " + wakeupInterval + ". Not starting an eviction thread!");
+ return;
+ }
+
+ if (tf == null) tf = new ThreadFactory()
+ {
+ public Thread newThread(Runnable r)
+ {
+ Thread t = new Thread(r, "EvictionTimer-" + tcount.getAndIncrement());
+ t.setDaemon(true);
+ return t;
+ }
+ };
+
+ scheduledExecutor = Executors.newSingleThreadScheduledExecutor(tf);
+ scheduledExecutor.scheduleWithFixedDelay(task, wakeupInterval, wakeupInterval, TimeUnit.MILLISECONDS);
+ }
+
+ private void processRegions()
+ {
+ synchronized (processedRegions)
+ {
+ for (Region region : processedRegions)
+ {
+ handleRegion(region);
+ }
+ }
+ }
+
+ private void handleRegion(Region region)
+ {
+ synchronized (region)
+ {
+ try
+ {
+ region.processEvictionQueues();
+ }
+ catch (EvictionException e)
+ {
+ log.error("run(): error processing eviction with exception: " + e.toString()
+ + " will reset the eviction queue list.");
+ region.resetEvictionQueues();
+ log.debug("trace", e);
+ }
+ }
+ }
+
+ public class Task implements Runnable
+ {
+ public void run()
+ {
+ // Run the eviction thread.
+ // This thread will synchronize the set of regions and iterate through every MarshRegion registered w/ the
+ // Eviction thread. It also synchronizes on each individual region as it is being processed.
+ processRegions();
+ }
+ }
+}
+
+
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/EvictionTimerTask.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,377 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.EvictionEvent.Type;
+
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * Eviction algorithm that uses a key in the Node data that indicates the time
+ * the node should be evicted. The key must be a java.lang.Long object, with
+ * the time to expire as milliseconds past midnight January 1st, 1970 UTC (the
+ * same relative time as provided by {@link
+ * java.lang.System#currentTimeMillis()}).
+ * <p/>
+ * This algorithm also obeys the configuration key {@link
+ * org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#getMaxNodes()}, and will evict the soonest to
+ * expire entires first to reduce the region size. If there are not enough
+ * nodes with expiration keys set, a warning is logged.
+ * <p/>
+ * If a node in the eviction region does not have an expiration value, then
+ * {@link org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#getTimeToLive()} (if set) will be used.
+ * The expiration is updated when a node is added or updated.
+ * <p/>
+ * If there is no time-to-live set, and a node in the eviction region does not
+ * have an expiration value, then that node will never be evicted. As
+ * forgetting to indicate an expiration value is likely a mistake, a warning
+ * message is logged by this class. This warning, however, can be disabled
+ * through {@link org.jboss.starobrno.eviction.ExpirationAlgorithmConfig#setWarnNoExpirationKey(boolean)}.
+ * <p/>
+ * A node's expiration time can be changed by setting a new value in the node.
+ * <p/>
+ * Example usage:
+ * <pre>
+ * Cache cache;
+ * Fqn fqn1 = Fqn.fromString("/node/1");
+ * Long future = new Long(System.currentTimeMillis() + 2000);
+ * cache.put(fqn1, ExpirationConfiguration.EXPIRATION_KEY, future);
+ * cache.put(fqn1, "foo");
+ * assertTrue(cache.get(fqn1) != null);
+ * <p/>
+ * Thread.sleep(5000); // 5 seconds
+ * assertTrue(cache.get(fqn1) == null);
+ * <p/>
+ * </pre>
+ */
+public class ExpirationAlgorithm extends BaseEvictionAlgorithm
+{
+
+ private static final Log log = LogFactory.getLog(ExpirationAlgorithm.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ private org.jboss.starobrno.eviction.ExpirationAlgorithmConfig config;
+
+ private SortedSet<ExpirationEntry> set;
+
+ /**
+ * Constructs a new algorithm with a policy.
+ */
+ public ExpirationAlgorithm()
+ {
+ this.set = new TreeSet<ExpirationEntry>();
+ }
+
+ private void addEvictionEntry(org.jboss.starobrno.eviction.EvictionEvent node)
+ {
+ Fqn fqn = node.getFqn();
+ addEvictionEntry(fqn);
+ }
+
+ private void addEvictionEntry(Fqn fqn)
+ {
+ Long l = getExpiration(fqn);
+ if (l == null)
+ {
+ if (config.isWarnNoExpirationKey() && log.isWarnEnabled())
+ log.warn("No expiration key '" + config.getExpirationKeyName() + "' for Node: " + fqn);
+ else if (log.isDebugEnabled())
+ log.debug("No expiration key for Node: " + fqn);
+ }
+ else
+ {
+ setExpiration(fqn, l);
+ }
+ }
+
+ private void setExpiration(Fqn fqn, Long l)
+ {
+ ExpirationEntry ee = new ExpirationEntry(fqn, l);
+ if (trace)
+ log.trace("adding eviction entry: " + ee);
+ set.add(ee);
+ }
+
+ @SuppressWarnings("unchecked")
+ private Long getExpiration(Fqn fqn)
+ {
+ NodeSPI n = cache.peek(fqn, false);
+ if (n == null)
+ return null;
+ return (Long) n.getDirect(config.getExpirationKeyName());
+ }
+
+ @Override
+ protected void processQueues(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ org.jboss.starobrno.eviction.EvictionEvent node;
+ int count = 0;
+ while ((node = getNextInQueue(queue)) != null)
+ {
+ count++;
+ switch (node.getEventType())
+ {
+ case ADD_NODE_EVENT:
+ case ADD_ELEMENT_EVENT:
+ addEvictionEntry(node);
+ break;
+ case REMOVE_ELEMENT_EVENT:
+ case REMOVE_NODE_EVENT:
+ case UNMARK_USE_EVENT:
+ // Removals will be noticed when double-checking expiry time
+ // removeEvictionEntry(node);
+ break;
+ case VISIT_NODE_EVENT:
+ // unused
+ break;
+ case MARK_IN_USE_EVENT:
+ markInUse(node);
+ break;
+ default:
+ throw new RuntimeException("Illegal Eviction Event type " + node.getEventType());
+ }
+ }
+
+ if (trace) log.trace("processed " + count + " node events in region: " + regionFqn);
+ }
+
+ private void markInUse(org.jboss.starobrno.eviction.EvictionEvent node)
+ {
+ long expiration = node.getInUseTimeout() + System.currentTimeMillis();
+ setExpiration(node.getFqn(), expiration);
+ }
+
+ @Override
+ protected void prune() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ if (set.isEmpty())
+ return;
+ long now = System.currentTimeMillis();
+ int max = config.getMaxNodes();
+ for (Iterator<ExpirationEntry> i = set.iterator(); i.hasNext();)
+ {
+ ExpirationEntry ee = i.next();
+ Long ce = getExpiration(ee.getFqn());
+ if (ce == null || ce > ee.getExpiration())
+ {
+ // Expiration now older
+ i.remove();
+ continue;
+ }
+ if (ee.getExpiration() < now || (max != 0 && set.size() > max))
+ {
+ i.remove();
+ evictCacheNode(ee.getFqn());
+ }
+ else
+ {
+ break;
+ }
+ }
+ if (max != 0 && max > set.size())
+ log.warn("Unable to remove nodes to reduce region size below " +
+ config.getMaxNodes() + ". " +
+ "Set expiration for nodes in this region");
+ }
+
+ @Override
+ public void resetEvictionQueue()
+ {
+ for (ExpirationEntry ee : set)
+ {
+ addEvictionEntry(ee.getFqn());
+ }
+ }
+
+ @Override
+ protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ this.config = (org.jboss.starobrno.eviction.ExpirationAlgorithmConfig) evictionAlgorithmConfig;
+ return new DummyEvictionQueue();
+ }
+
+ @Override
+ protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean canIgnoreEvent(Type eventType)
+ {
+ return (eventType == org.jboss.starobrno.eviction.EvictionEvent.Type.VISIT_NODE_EVENT);
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return org.jboss.starobrno.eviction.ExpirationAlgorithmConfig.class;
+ }
+
+ /**
+ * Ordered list of FQN, with the expiration taken from the Map at the time
+ * of processing.
+ */
+ static class ExpirationEntry implements Comparable<ExpirationEntry>
+ {
+
+ private long expiration;
+
+ private Fqn fqn;
+
+ public ExpirationEntry(Fqn fqn)
+ {
+ this.fqn = fqn;
+ }
+
+ public ExpirationEntry(Fqn fqn, long expiration)
+ {
+ this.fqn = fqn;
+ this.expiration = expiration;
+ }
+
+ /**
+ * Compares expiration, then FQN order.
+ */
+ public int compareTo(ExpirationEntry ee)
+ {
+ long n = expiration - ee.expiration;
+ if (n < 0)
+ return -1;
+ if (n > 0)
+ return 1;
+ return fqn.compareTo(ee.fqn);
+ }
+
+ /**
+ * @return the expiration
+ */
+ public long getExpiration()
+ {
+ return expiration;
+ }
+
+ /**
+ * @return the fqn
+ */
+ public Fqn getFqn()
+ {
+ return fqn;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof ExpirationEntry))
+ return false;
+ ExpirationEntry ee = (ExpirationEntry) o;
+ return expiration == ee.expiration && fqn.equals(ee.fqn);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return (int) expiration ^ fqn.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ long now = System.currentTimeMillis();
+ long ttl = expiration - now;
+ String sttl;
+ if (ttl > 1000 * 60)
+ sttl = (ttl / (1000 * 60)) + "min";
+ else if (ttl > 1000)
+ sttl = (ttl / 1000) + "s";
+ else
+ sttl = ttl + "ms";
+ return "EE fqn=" + fqn + " ttl=" + sttl;
+ }
+ }
+
+ class DummyEvictionQueue implements org.jboss.starobrno.eviction.EvictionQueue
+ {
+
+ public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void clear()
+ {
+ set.clear();
+ }
+
+ public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ return false;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+ {
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+ {
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+ {
+ return null;
+ }
+
+ public int getNumberOfElements()
+ {
+ return set.size();
+ }
+
+ public int getNumberOfNodes()
+ {
+ return set.size();
+ }
+
+ public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+ {
+ return null;
+ }
+
+ public void modifyElementCount(int difference)
+ {
+ }
+
+ public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithm.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,161 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.annotations.Compat;
+import org.jboss.starobrno.config.Dynamic;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Configuration for indicating the Node key for setting a specific eviction time.
+ */
+public class ExpirationAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+
+ private static final long serialVersionUID = 47338798734219507L;
+
+ /**
+ * Default key name for indicating expiration time.
+ */
+ public static final String EXPIRATION_KEY = "expiration";
+
+ /**
+ * Node key name used to indicate the expiration of a node.
+ */
+ @Dynamic
+ private String expirationKeyName = EXPIRATION_KEY;
+
+ @Dynamic
+ private boolean warnNoExpirationKey = true;
+
+ @Dynamic
+ private long timeToLive = 0;
+
+ public ExpirationAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.ExpirationAlgorithm.class.getName();
+ }
+
+ /**
+ * Returns the expirationKeyName.
+ * This key should point to a java.lang.Long value in the Node data.
+ */
+ public String getExpirationKeyName()
+ {
+ return expirationKeyName;
+ }
+
+ /**
+ * Sets the expirationKeyName.
+ */
+ public void setExpirationKeyName(String expirationKeyName)
+ {
+ this.expirationKeyName = expirationKeyName;
+ }
+
+ /**
+ * Returns true if the algorithm should warn if a expiration key is missing for a node.
+ */
+ public boolean isWarnNoExpirationKey()
+ {
+ return warnNoExpirationKey;
+ }
+
+ /**
+ * Sets if the algorithm should warn if a expiration key is missing for a node.
+ */
+ public void setWarnNoExpirationKey(boolean warnNoExpirationKey)
+ {
+ this.warnNoExpirationKey = warnNoExpirationKey;
+ }
+
+ /**
+ * @return time to live, in milliseconds
+ */
+ public long getTimeToLive()
+ {
+ return timeToLive;
+ }
+
+ /**
+ * Sets the time to live
+ *
+ * @param timeToLive value in milliseconds
+ */
+ public void setTimeToLive(long timeToLive)
+ {
+ this.timeToLive = timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive, TimeUnit timeUnit)
+ {
+ this.timeToLive = timeUnit.toMillis(timeToLive);
+ }
+
+ @Deprecated
+ @Compat
+ public void setTimeToLiveSeconds(long time)
+ {
+ setTimeToLive(time, TimeUnit.SECONDS);
+ }
+
+ @Override
+ public ExpirationAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (ExpirationAlgorithmConfig) super.clone();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ if (!super.equals(o)) return false;
+
+ ExpirationAlgorithmConfig that = (ExpirationAlgorithmConfig) o;
+
+ if (timeToLive != that.timeToLive) return false;
+ if (warnNoExpirationKey != that.warnNoExpirationKey) return false;
+ if (expirationKeyName != null ? !expirationKeyName.equals(that.expirationKeyName) : that.expirationKeyName != null)
+ return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (expirationKeyName != null ? expirationKeyName.hashCode() : 0);
+ result = 31 * result + (warnNoExpirationKey ? 1 : 0);
+ result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
+ return result;
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.ExpirationAlgorithm.class.getName();
+ warnNoExpirationKey = true;
+ timeToLive = 0;
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/ExpirationAlgorithmConfig.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,72 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+/**
+ * First-in-first-out algorithm used to evict nodes.
+ *
+ * @author Daniel Huang - dhuang(a)jboss.org
+ * @author Morten Kvistgaard
+ * @version $Revision: 6776 $
+ */
+public class FIFOAlgorithm extends BaseEvictionAlgorithm
+{
+ private static final Log log = LogFactory.getLog(FIFOAlgorithm.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+
+ @Override
+ protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ return new org.jboss.starobrno.eviction.FIFOQueue();
+ }
+
+ /**
+ * For FIFO, a node should be evicted if the queue size is >= to the configured maxNodes size.
+ */
+ @Override
+ protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+ // check the minimum time to live and see if we should not evict the node. This check will
+ // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+ if (isYoungerThanMinimumTimeToLive(ne)) return false;
+
+ org.jboss.starobrno.eviction.FIFOAlgorithmConfig config = (org.jboss.starobrno.eviction.FIFOAlgorithmConfig) evictionAlgorithmConfig;
+ if (trace)
+ {
+ log.trace("Deciding whether node in queue " + ne.getFqn() + " requires eviction.");
+ }
+
+ int size = this.getEvictionQueue().getNumberOfNodes();
+ return config.getMaxNodes() != 0 && size > config.getMaxNodes();
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return org.jboss.starobrno.eviction.FIFOAlgorithmConfig.class;
+ }
+}
+
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithm.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,97 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.config.ConfigurationException;
+
+/**
+ * Configuration for {@link org.jboss.starobrno.eviction.FIFOAlgorithm}.
+ * <p/>
+ * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class FIFOAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -7229715009546277313L;
+
+ public FIFOAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.FIFOAlgorithm.class.getName();
+ // We require that maxNodes is set
+ setMaxNodes(-1);
+ }
+
+ public FIFOAlgorithmConfig(int maxNodes)
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.FIFOAlgorithm.class.getName();
+ // We require that maxNodes is set
+ setMaxNodes(maxNodes);
+ }
+
+ /**
+ * Requires a positive maxNodes value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ super.validate();
+ if (getMaxNodes() < 0)
+ {
+ throw new ConfigurationException("maxNodes must be must be " +
+ "configured to a value greater than or equal to 0");
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder ret = new StringBuilder();
+ ret.append("FIFOAlgorithmConfig: maxNodes = ").append(getMaxNodes());
+ return ret.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return (obj instanceof FIFOAlgorithmConfig && super.equals(obj));
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ setMaxNodes(-1);
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.FIFOAlgorithm.class.getName();
+ }
+
+ @Override
+ public FIFOAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (FIFOAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/FIFOQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,123 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * FIFO Eviction Queue implementation for FIFO Policy.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class FIFOQueue implements EvictionQueue
+{
+ private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> nodeMap;
+ private int numElements = 0;
+
+ protected FIFOQueue()
+ {
+ nodeMap = new LinkedHashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
+ // We use a LinkedHashMap here because we want to maintain FIFO ordering and still get the benefits of
+ // O(n) = 1 for add/remove/search.
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+ {
+/* Iterator it = nodeMap.keySet().iterator();
+ if(it.hasNext()) {
+ return (NodeEntry) nodeMap.get(it.next());
+ }
+
+ return null; */
+
+ // this code path is *slightly* faster when profiling. 20ms faster iterating over 200000 entries in queue.
+ if (nodeMap.size() > 0)
+ {
+ return nodeMap.values().iterator().next();
+ }
+
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+ {
+ return nodeMap.get(fqn);
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+ {
+ return this.getNodeEntry(Fqn.fromString(fqn));
+ }
+
+ public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ Fqn fqn = entry.getFqn();
+ return this.getNodeEntry(fqn) != null;
+ }
+
+ public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ org.jboss.starobrno.eviction.NodeEntry e = nodeMap.remove(entry.getFqn());
+ this.numElements -= e.getNumberOfElements();
+ }
+
+ public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ if (!this.containsNodeEntry(entry))
+ {
+ entry.queue = this;
+ nodeMap.put(entry.getFqn(), entry);
+ this.numElements += entry.getNumberOfElements();
+ }
+ }
+
+ public int getNumberOfNodes()
+ {
+ return nodeMap.size();
+ }
+
+ public int getNumberOfElements()
+ {
+ return this.numElements;
+ }
+
+ public void modifyElementCount(int difference)
+ {
+ this.numElements += difference;
+ }
+
+ public void clear()
+ {
+ nodeMap.clear();
+ this.numElements = 0;
+ }
+
+ public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+ {
+ return nodeMap.values().iterator();
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,107 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+/**
+ * Least Frequently Used algorithm for cache eviction.
+ * Note that this algorithm is not thread-safe.
+ * <p/>
+ * This algorithm relies on maxNodes and minNodes to operate correctly.
+ * Eviction takes place using Least Frequently Used algorithm. A node A
+ * that is used less than a node B is evicted sooner.
+ * <p/>
+ * The minNodes property defines a threshold for eviction. If minNodes = 100,
+ * the LFUAlgorithm will not evict the cache to anything less than 100 elements
+ * still left in cache. The maxNodes property defines the maximum number of nodes
+ * the cache will accept before eviction. maxNodes = 0 means that this region is
+ * unbounded. minNodes = 0 means that the eviction queue will attempt to bring
+ * the cache of this region to 0 elements (evict all elements) whenever it is run.
+ * <p/>
+ * This algorithm uses a sorted eviction queue. The eviction queue is sorted in
+ * ascending order based on the number of times a node is visited. The more frequently
+ * a node is visited, the less likely it will be evicted.
+ *
+ * @author Daniel Huang - dhuang(a)jboss.org 10/2005
+ * @version $Revision: 6776 $
+ */
+public class LFUAlgorithm extends BaseSortedEvictionAlgorithm
+{
+ private static final Log log = LogFactory.getLog(LFUAlgorithm.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ @Override
+ protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+ if (trace)
+ {
+ log.trace("Deciding whether node in queue " + ne.getFqn() + " requires eviction.");
+ }
+
+ // check the minimum time to live and see if we should not evict the node. This check will
+ // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+ if (isYoungerThanMinimumTimeToLive(ne)) return false;
+
+ org.jboss.starobrno.eviction.LFUAlgorithmConfig config = (org.jboss.starobrno.eviction.LFUAlgorithmConfig) evictionAlgorithmConfig;
+ int size = this.getEvictionQueue().getNumberOfNodes();
+ if (config.getMaxNodes() > -1 && size > config.getMaxNodes())
+ {
+ return true;
+ }
+ else if (size > config.getMinNodes())
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Will create a LFUQueue to be used as the underlying eviction queue.
+ *
+ * @return The created LFUQueue.
+ * @throws org.jboss.starobrno.eviction.EvictionException
+ *
+ */
+ @Override
+ protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ return new org.jboss.starobrno.eviction.LFUQueue();
+ }
+
+ @Override
+ protected void prune() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ super.prune();
+
+ // clean up the Queue's eviction removals
+ ((org.jboss.starobrno.eviction.LFUQueue) this.evictionQueue).prune();
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return org.jboss.starobrno.eviction.LFUAlgorithmConfig.class;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,104 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.config.Dynamic;
+
+/**
+ * Configuration implementation for {@link org.jboss.starobrno.eviction.LFUAlgorithm}.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class LFUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = 1865801530398969179L;
+
+ @Dynamic
+ private int minNodes;
+
+ public LFUAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.LFUAlgorithm.class.getName();
+ }
+
+ public LFUAlgorithmConfig(int maxNodes, int minNodes)
+ {
+ this();
+ setMaxNodes(maxNodes);
+ setMinNodes(minNodes);
+ }
+
+ public int getMinNodes()
+ {
+ return minNodes;
+ }
+
+ public void setMinNodes(int minNodes)
+ {
+ testImmutability("minNodes");
+ this.minNodes = minNodes;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder ret = new StringBuilder();
+ ret.append("LFUAlgorithmConfig: maxNodes = ").append(getMaxNodes()).append(" minNodes = ").append(getMinNodes());
+ return ret.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof LFUAlgorithmConfig && super.equals(obj))
+ {
+ return (this.minNodes == ((LFUAlgorithmConfig) obj).minNodes);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + minNodes;
+ return result;
+ }
+
+ @Override
+ public LFUAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (LFUAlgorithmConfig) super.clone();
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ minNodes = -1;
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.LFUAlgorithm.class.getName();
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LFUQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,237 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+/**
+ * LFUQueue EvictionQueue implementation for LFU Policy.
+ * <p/>
+ * The queue is sorted in least frequently used order.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class LFUQueue implements SortedEvictionQueue
+{
+ private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> nodeMap;
+ private LinkedList<org.jboss.starobrno.eviction.NodeEntry> evictionList;
+ private Comparator<org.jboss.starobrno.eviction.NodeEntry> comparator;
+
+ private Set<org.jboss.starobrno.eviction.NodeEntry> removalQueue;
+ private int numElements = 0;
+
+ protected LFUQueue()
+ {
+ nodeMap = new HashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
+ comparator = new LFUComparator();
+ evictionList = new LinkedList<org.jboss.starobrno.eviction.NodeEntry>();
+ removalQueue = new HashSet<org.jboss.starobrno.eviction.NodeEntry>();
+ }
+
+ /**
+ * Return the first node to evict.
+ * <p/>
+ * This method will return the least frequently used entry in the queue.
+ */
+ public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+ {
+ try
+ {
+ org.jboss.starobrno.eviction.NodeEntry ne;
+ while ((ne = evictionList.getFirst()) != null)
+ {
+ if (removalQueue.contains(ne))
+ {
+ evictionList.removeFirst();
+ removalQueue.remove(ne);
+ }
+ else
+ {
+ break;
+ }
+ }
+ return ne;
+ }
+ catch (NoSuchElementException e)
+ {
+ //
+ }
+
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+ {
+ return nodeMap.get(fqn);
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+ {
+ return this.getNodeEntry(Fqn.fromString(fqn));
+ }
+
+ public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ Fqn fqn = entry.getFqn();
+ return this.getNodeEntry(fqn) != null;
+ }
+
+ public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ org.jboss.starobrno.eviction.NodeEntry ne = nodeMap.remove(entry.getFqn());
+ if (ne != null)
+ {
+ // don't remove directly from the LinkedList otherwise we will incur a O(n) = n
+ // performance penalty for every removal! In the prune method for LFU, we will iterate the LinkedList through ONCE
+ // doing a single O(n) = n operation and removal. This is much preferred over running O(n) = n every single time
+ // remove is called. There is also special logic in the getFirstNodeEntry that will know to check
+ // the removalQueue before returning.
+ this.removalQueue.add(ne);
+/* if(!evictionList.remove(ne)) {
+ throw new RuntimeException("");
+ } */
+ this.numElements -= ne.getNumberOfElements();
+ }
+ }
+
+ public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ if (!this.containsNodeEntry(entry))
+ {
+ Fqn fqn = entry.getFqn();
+ entry.queue = this;
+ nodeMap.put(fqn, entry);
+ evictionList.add(entry);
+ this.numElements += entry.getNumberOfElements();
+ }
+ }
+
+ public int getNumberOfNodes()
+ {
+ return nodeMap.size();
+ }
+
+ public int getNumberOfElements()
+ {
+ return this.numElements;
+ }
+
+ public void clear()
+ {
+ nodeMap.clear();
+ evictionList.clear();
+ removalQueue.clear();
+ this.numElements = 0;
+ }
+
+ public void resortEvictionQueue()
+ {
+ Collections.sort(evictionList, comparator);
+ }
+
+ public void modifyElementCount(int difference)
+ {
+ this.numElements += difference;
+ }
+
+ protected void prune()
+ {
+ Iterator<org.jboss.starobrno.eviction.NodeEntry> it = this.iterator();
+ while (it.hasNext() && removalQueue.size() > 0)
+ {
+ if (removalQueue.remove(it.next()))
+ {
+ it.remove();
+ }
+ }
+ }
+
+ protected final List<org.jboss.starobrno.eviction.NodeEntry> getEvictionList()
+ {
+ return this.evictionList;
+ }
+
+ protected final Set<org.jboss.starobrno.eviction.NodeEntry> getRemovalQueue()
+ {
+ return this.removalQueue;
+ }
+
+ public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+ {
+ return evictionList.iterator();
+ }
+
+ /**
+ * Comparator class for LFU.
+ * <p/>
+ * This class will sort the eviction queue in the correct eviction order.
+ * The top of the list should evict before the bottom of the list.
+ * <p/>
+ * The sort is based on ascending order of nodeVisits.
+ * <p/>
+ * Note: this class has a natural ordering that is inconsistent with equals as defined by the java.lang.Comparator
+ * contract.
+ */
+ protected static class LFUComparator implements Comparator<org.jboss.starobrno.eviction.NodeEntry>
+ {
+
+ public int compare(org.jboss.starobrno.eviction.NodeEntry ne1, org.jboss.starobrno.eviction.NodeEntry ne2)
+ {
+ if (ne1.equals(ne2))
+ {
+ return 0;
+ }
+
+ int neNodeHits = ne1.getNumberOfNodeVisits();
+ int ne2NodeHits = ne2.getNumberOfNodeVisits();
+
+ if (neNodeHits > ne2NodeHits)
+ {
+ return 1;
+ }
+ else if (neNodeHits < ne2NodeHits)
+ {
+ return -1;
+ }
+ else if (neNodeHits == ne2NodeHits)
+ {
+ return 0;
+ }
+
+ throw new RuntimeException("Should never reach this condition");
+ }
+ }
+
+}
+
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,198 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+import java.util.Iterator;
+
+/**
+ * Least recently Used algorithm to purge old data.
+ * Note that this algorithm is not thread-safe.
+ *
+ * @author Ben Wang 02-2004
+ * @author Daniel Huang - dhuang(a)jboss.org
+ */
+public class LRUAlgorithm extends BaseEvictionAlgorithm
+{
+ private static final Log log = LogFactory.getLog(LRUAlgorithm.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ @Override
+ protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ return new org.jboss.starobrno.eviction.LRUQueue();
+ }
+
+ @Override
+ protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ // check the minimum time to live and see if we should not evict the node. This check will
+ // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+ if (isYoungerThanMinimumTimeToLive(entry)) return false;
+
+ org.jboss.starobrno.eviction.LRUAlgorithmConfig config = (org.jboss.starobrno.eviction.LRUAlgorithmConfig) evictionAlgorithmConfig;
+ // no idle or max time limit
+ if (config.getTimeToLive() < 0 && config.getMaxAge() < 0) return false;
+
+ long currentTime = System.currentTimeMillis();
+ if (config.getTimeToLive() > -1)
+ {
+ long idleTime = currentTime - entry.getModifiedTimeStamp();
+ if (trace)
+ {
+ log.trace("Node " + entry.getFqn() + " has been idle for " + idleTime + "ms");
+ }
+ if ((idleTime >= (config.getTimeToLive())))
+ {
+ if (trace)
+ {
+ log.trace("Node " + entry.getFqn() + " should be evicted because of idle time");
+ log.trace("Time to live in millies is: " + (config.getTimeToLive()));
+ log.trace("Config instance is: " + System.identityHashCode(config));
+ }
+ return true;
+ }
+ }
+
+ if (config.getMaxAge() > -1)
+ {
+ long objectLifeTime = currentTime - entry.getCreationTimeStamp();
+ if (trace)
+ {
+ log.trace("Node " + entry.getFqn() + " has been alive for " + objectLifeTime + "ms");
+ }
+ if ((objectLifeTime >= config.getMaxAge()))
+ {
+ if (trace)
+ {
+ log.trace("Node " + entry.getFqn() + " should be evicted because of max age");
+ }
+ return true;
+ }
+ }
+
+ if (trace)
+ {
+ log.trace("Node " + entry.getFqn() + " should not be evicted");
+ }
+ return false;
+ }
+
+ @Override
+ protected void evict(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+ if (ne != null)
+ {
+ if (!this.evictCacheNode(ne.getFqn()))
+ {
+ try
+ {
+ recycleQueue.put(ne.getFqn());
+ }
+ catch (InterruptedException e)
+ {
+ log.debug("InterruptedException", e);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void prune() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ org.jboss.starobrno.eviction.LRUQueue lruQueue = (org.jboss.starobrno.eviction.LRUQueue) evictionQueue;
+ org.jboss.starobrno.eviction.NodeEntry ne;
+ Iterator it = lruQueue.iterateLRUQueue();
+ while (it.hasNext())
+ {
+ ne = (org.jboss.starobrno.eviction.NodeEntry) it.next();
+ if (isNodeInUseAndNotTimedOut(ne))
+ {
+ continue;
+ }
+
+ if (this.shouldEvictNode(ne))
+ {
+ it.remove();
+ lruQueue.removeNodeEntryFromMaxAge(ne);
+ this.evict(ne);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ it = lruQueue.iterateMaxAgeQueue();
+ while (it.hasNext())
+ {
+ ne = (org.jboss.starobrno.eviction.NodeEntry) it.next();
+ if (isNodeInUseAndNotTimedOut(ne))
+ {
+ continue;
+ }
+
+ if (this.shouldEvictNode(ne))
+ {
+ it.remove();
+ lruQueue.removeNodeEntryFromLRU(ne);
+ this.evict(ne);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ int maxNodes = ((org.jboss.starobrno.eviction.LRUAlgorithmConfig) evictionAlgorithmConfig).getMaxNodes();
+ if (maxNodes <= 0)
+ {
+ return;
+ }
+
+ it = lruQueue.iterateLRUQueue();
+ while (evictionQueue.getNumberOfNodes() > maxNodes)
+ {
+ ne = (org.jboss.starobrno.eviction.NodeEntry) it.next();
+ if (trace)
+ {
+ log.trace("Node " + ne.getFqn() + " will be evicted because of exceeding the maxNode limit." +
+ " maxNode: " + maxNodes + " but current queue size is: " + evictionQueue.getNumberOfNodes());
+ }
+
+ if (!this.isNodeInUseAndNotTimedOut(ne))
+ {
+ it.remove();
+ lruQueue.removeNodeEntryFromMaxAge(ne);
+ this.evict(ne);
+ }
+ }
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return org.jboss.starobrno.eviction.LRUAlgorithmConfig.class;
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithm.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,194 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.annotations.Compat;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.Dynamic;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Configuration implementation for {@link org.jboss.starobrno.eviction.LRUAlgorithm}.
+ * <p/>
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class LRUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -3426716488271559729L;
+
+ /**
+ * value expressed in millis
+ */
+ @Dynamic
+ private long timeToLive;
+
+ /**
+ * value expressed in millis
+ */
+ @Dynamic
+ private long maxAge;
+
+ public LRUAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.LRUAlgorithm.class.getName();
+ // Force config of ttls
+ setTimeToLive(-1);
+ setMaxAge(-1);
+ }
+
+ public LRUAlgorithmConfig(long timeToLive, long maxAge)
+ {
+ this();
+ this.timeToLive = timeToLive;
+ this.maxAge = maxAge;
+ }
+
+ public LRUAlgorithmConfig(long timeToLive, int maxAge, int maxNodes)
+ {
+ this(timeToLive, maxAge);
+ this.maxNodes = maxNodes;
+ }
+
+ /**
+ * @return the time to live, in milliseconds
+ */
+ public long getTimeToLive()
+ {
+ return timeToLive;
+ }
+
+ /**
+ * Sets the time to live
+ *
+ * @param timeToLive the time to live, in milliseconds
+ */
+ public void setTimeToLive(long timeToLive)
+ {
+ testImmutability("timeToLive");
+ this.timeToLive = timeToLive;
+ }
+
+ public void setTimeToLive(long timeToLive, TimeUnit timeUnit)
+ {
+ testImmutability("timeToLive");
+ this.timeToLive = timeUnit.toMillis(timeToLive);
+ }
+
+ @Deprecated
+ @Compat
+ public void setTimeToLiveSeconds(long time)
+ {
+ setTimeToLive(time, TimeUnit.SECONDS);
+ }
+
+ /**
+ * @return the max age per element, in milliseconds
+ */
+ public long getMaxAge()
+ {
+ return maxAge;
+ }
+
+ /**
+ * Sets the max age per element
+ *
+ * @param maxAge value in milliseconds
+ */
+ public void setMaxAge(long maxAge)
+ {
+ testImmutability("maxAge");
+ this.maxAge = maxAge;
+ }
+
+ public void setMaxAge(long maxAge, TimeUnit timeUnit)
+ {
+ testImmutability("maxAge");
+ this.maxAge = timeUnit.toMillis(maxAge);
+ }
+
+ /**
+ * Requires a positive timeToLive value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ super.validate();
+ if (timeToLive < -1)
+ {
+ throw new ConfigurationException("timeToLive must be " +
+ "configured to a value greater than or equal to 0 (or -1 for unlimited time to live) for " + getEvictionAlgorithmClassName());
+ }
+ }
+
+ public String toString()
+ {
+ return "LRUAlgorithmConfig {" +
+ "algorithmClassName=" + evictionAlgorithmClassName +
+ ", timeToLive=" + timeToLive +
+ ", maxAge=" + maxAge +
+ '}';
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (!(o instanceof LRUAlgorithmConfig)) return false;
+ if (!super.equals(o)) return false;
+
+ LRUAlgorithmConfig that = (LRUAlgorithmConfig) o;
+
+ if (maxAge != that.maxAge) return false;
+ if (timeToLive != that.timeToLive) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result = super.hashCode();
+ result = 31 * result + (int) (timeToLive ^ (timeToLive >>> 32));
+ result = 31 * result + (int) (maxAge ^ (maxAge >>> 32));
+ return result;
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ setTimeToLive(-1);
+ setMaxAge(-1);
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.LRUAlgorithm.class.getName();
+ }
+
+ @Override
+ public LRUAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (LRUAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/LRUQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,203 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * LRU Eviction Queue implementation.
+ * <p/>
+ * This eviction queue will iterate properly through two sorted lists.
+ * One sorted by maxAge and the other sorted by idleTime.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class LRUQueue implements EvictionQueue
+{
+ private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> maxAgeQueue;
+ private Map<Fqn, org.jboss.starobrno.eviction.NodeEntry> lruQueue;
+ private long alternatingCount = 0;
+ private int numElements = 0;
+
+ protected LRUQueue()
+ {
+ maxAgeQueue = new LinkedHashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>();
+ lruQueue = new LinkedHashMap<Fqn, org.jboss.starobrno.eviction.NodeEntry>(16, 0.75f, true);
+ }
+
+ protected void reorderByLRU(Fqn fqn)
+ {
+ // leave the max age queue alone - it is like a fifo.
+
+ // the lru queue is access ordered. meaning the most recently read item is moved to the bottom of the queue.
+ // simply calling get against it visits it and will cause LinkedHashMap to move it to the bottom of the queue.
+ lruQueue.get(fqn);
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+ {
+ // because the underlying queue is in two differently sorted queues, we alternate between them when calling
+ // a generic getFirstNodeEntry.
+ // we must alternate to keep things balanced when evicting nodes based on the maxNodes attribute. We don't
+ // want to just prune from one queue but rather we want to be able to prune from both.
+ org.jboss.starobrno.eviction.NodeEntry ne;
+ if (alternatingCount % 2 == 0)
+ {
+ ne = this.getFirstLRUNodeEntry();
+ if (ne == null)
+ {
+ ne = this.getFirstMaxAgeNodeEntry();
+ }
+ }
+ else
+ {
+ ne = this.getFirstMaxAgeNodeEntry();
+ if (ne == null)
+ {
+ ne = this.getFirstLRUNodeEntry();
+ }
+ }
+ alternatingCount++;
+ return ne;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getFirstLRUNodeEntry()
+ {
+ if (lruQueue.size() > 0)
+ {
+ return lruQueue.values().iterator().next();
+ }
+
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getFirstMaxAgeNodeEntry()
+ {
+ if (maxAgeQueue.size() > 0)
+ {
+ return maxAgeQueue.values().iterator().next();
+ }
+
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+ {
+ return lruQueue.get(fqn);
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+ {
+ return this.getNodeEntry(Fqn.fromString(fqn));
+ }
+
+ public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ return this.maxAgeQueue.containsKey(entry.getFqn());
+ }
+
+ protected void removeNodeEntryFromLRU(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ Fqn fqn = entry.getFqn();
+ lruQueue.remove(fqn);
+ }
+
+ protected void removeNodeEntryFromMaxAge(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ Fqn fqn = entry.getFqn();
+ maxAgeQueue.remove(fqn);
+ }
+
+ public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ if (!this.containsNodeEntry(entry))
+ {
+ return;
+ }
+ Fqn fqn = entry.getFqn();
+ org.jboss.starobrno.eviction.NodeEntry ne1 = lruQueue.remove(fqn);
+ org.jboss.starobrno.eviction.NodeEntry ne2 = maxAgeQueue.remove(fqn);
+
+ if (ne1 == null || ne2 == null)
+ {
+ throw new RuntimeException("The queues are out of sync.");
+ }
+
+ this.numElements -= ne1.getNumberOfElements();
+
+ }
+
+ public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ if (!this.containsNodeEntry(entry))
+ {
+ Fqn fqn = entry.getFqn();
+ entry.queue = this;
+ maxAgeQueue.put(fqn, entry);
+ lruQueue.put(fqn, entry);
+ this.numElements += entry.getNumberOfElements();
+ }
+ }
+
+ public int getNumberOfNodes()
+ {
+ return maxAgeQueue.size();
+ }
+
+ public int getNumberOfElements()
+ {
+ return this.numElements;
+ }
+
+ public void clear()
+ {
+ maxAgeQueue.clear();
+ lruQueue.clear();
+ this.numElements = 0;
+ }
+
+ public void modifyElementCount(int difference)
+ {
+ this.numElements += difference;
+ }
+
+ public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+ {
+ return lruQueue.values().iterator();
+ }
+
+ protected final Iterator<org.jboss.starobrno.eviction.NodeEntry> iterateMaxAgeQueue()
+ {
+ return maxAgeQueue.values().iterator();
+ }
+
+ protected final Iterator<org.jboss.starobrno.eviction.NodeEntry> iterateLRUQueue()
+ {
+ return lruQueue.values().iterator();
+ }
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,67 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+/**
+ * Most Recently Used Algorithm.
+ * <p/>
+ * This algorithm will evict the most recently used cache entries from cache.
+ * <p/>
+ * Note: None of the Eviction classes are thread safe. It is assumed that an individual instance of an EvictionPolicy/
+ * EvictionAlgorithm/EvictionQueue/EvictionConfiguration are only operated on by one thread at any given time.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class MRUAlgorithm extends BaseEvictionAlgorithm
+{
+ @Override
+ protected org.jboss.starobrno.eviction.EvictionQueue setupEvictionQueue() throws org.jboss.starobrno.eviction.EvictionException
+ {
+ return new org.jboss.starobrno.eviction.MRUQueue();
+ }
+
+ @Override
+ protected boolean shouldEvictNode(org.jboss.starobrno.eviction.NodeEntry ne)
+ {
+ // check the minimum time to live and see if we should not evict the node. This check will
+ // ensure that, if configured, nodes are kept alive for at least a minimum period of time.
+ if (isYoungerThanMinimumTimeToLive(ne)) return false;
+
+ org.jboss.starobrno.eviction.MRUAlgorithmConfig config = (org.jboss.starobrno.eviction.MRUAlgorithmConfig) evictionAlgorithmConfig;
+ return evictionQueue.getNumberOfNodes() > config.getMaxNodes();
+ }
+
+ @Override
+ protected void processVisitedNodes(org.jboss.starobrno.eviction.EvictionEvent evictedEventNode) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ super.processVisitedNodes(evictedEventNode);
+ ((org.jboss.starobrno.eviction.MRUQueue) evictionQueue).moveToTopOfStack(evictedEventNode.getFqn());
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return org.jboss.starobrno.eviction.MRUAlgorithmConfig.class;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,95 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.config.ConfigurationException;
+
+/**
+ * Configuration for {@link org.jboss.starobrno.eviction.MRUAlgorithm}.
+ * <p/>
+ * Requires a "maxNodes" attribute otherwise a ConfigurationException is thrown.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class MRUAlgorithmConfig extends EvictionAlgorithmConfigBase
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -8734577898966155218L;
+
+ public MRUAlgorithmConfig()
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.MRUAlgorithm.class.getName();
+ // We require that maxNodes is set
+ setMaxNodes(-1);
+ }
+
+ public MRUAlgorithmConfig(int maxNodes)
+ {
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.MRUAlgorithm.class.getName();
+ setMaxNodes(maxNodes);
+ }
+
+ /**
+ * Requires a positive maxNodes value or ConfigurationException
+ * is thrown.
+ */
+ @Override
+ public void validate() throws ConfigurationException
+ {
+ super.validate();
+ if (getMaxNodes() < 0)
+ throw new ConfigurationException("maxNodes not configured");
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder str = new StringBuilder();
+ str.append("MRUAlgorithmConfig: ").
+ append(" maxNodes =").append(getMaxNodes());
+ return str.toString();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return (obj instanceof MRUAlgorithmConfig && super.equals(obj));
+ }
+
+ @Override
+ public void reset()
+ {
+ super.reset();
+ setMaxNodes(-1);
+ evictionAlgorithmClassName = org.jboss.starobrno.eviction.MRUAlgorithm.class.getName();
+ }
+
+ @Override
+ public MRUAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (MRUAlgorithmConfig) super.clone();
+ }
+
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/MRUQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,169 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+/**
+ * MRU Eviction Queue implementation.
+ * <p/>
+ * This nodeMap is sorted by MRU. The first entry in the nodeMap
+ * will also be the most recently used entry. The sort is implicit
+ * based on a Stack that we can implicitly sort to the top by moving
+ * a node that is used to the top of the eviction stack.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public class MRUQueue implements EvictionQueue
+{
+ // we use our own Stack/Linked List implementation here because it guarantees O(n) = 1 for add, remove, get and
+ // we can sort it in order of MRU implicitly while still getting O(n) = 1 access time
+ // throughout.
+ Map<Fqn, EvictionListEntry> nodeMap;
+ org.jboss.starobrno.eviction.EvictionQueueList list;
+ private int numElements = 0;
+
+ protected MRUQueue()
+ {
+ nodeMap = new HashMap<Fqn, EvictionListEntry>();
+ list = new org.jboss.starobrno.eviction.EvictionQueueList();
+ }
+
+ /**
+ * This call moves a NodeEntry to the top of the stack.
+ * <p/>
+ * When a node is visited this method should be called to guarantee MRU ordering.
+ *
+ * @param fqn Fqn of the nodeEntry to move to the top of the stack.
+ */
+ protected void moveToTopOfStack(Fqn fqn)
+ {
+ EvictionListEntry le = nodeMap.remove(fqn);
+ if (le != null)
+ {
+ list.remove(le);
+ list.addToTop(le);
+ nodeMap.put(le.node.getFqn(), le);
+ }
+ }
+
+ /**
+ * Will return the first entry in the nodeMap.
+ * <p/>
+ * The first entry in this nodeMap will also be the most recently used entry.
+ *
+ * @return The first node entry in nodeMap.
+ */
+ public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+ {
+ try
+ {
+ return list.getFirst().node;
+ }
+ catch (NoSuchElementException e)
+ {
+ //
+ }
+
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+ {
+ EvictionListEntry le = nodeMap.get(fqn);
+ if (le != null)
+ return le.node;
+
+ return null;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+ {
+ return this.getNodeEntry(Fqn.fromString(fqn));
+ }
+
+ public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ return nodeMap.containsKey(entry.getFqn());
+ }
+
+ public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ EvictionListEntry le = nodeMap.remove(entry.getFqn());
+ if (le != null)
+ {
+ list.remove(le);
+ this.numElements -= le.node.getNumberOfElements();
+ }
+ }
+
+ public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ if (!this.containsNodeEntry(entry))
+ {
+ entry.queue = this;
+ EvictionListEntry le = new EvictionListEntry(entry);
+ list.addToBottom(le);
+ nodeMap.put(entry.getFqn(), le);
+ this.numElements += entry.getNumberOfElements();
+ }
+ }
+
+ public int getNumberOfNodes()
+ {
+ return list.size();
+ }
+
+ public int getNumberOfElements()
+ {
+ return this.numElements;
+ }
+
+ public void modifyElementCount(int difference)
+ {
+ this.numElements += difference;
+ }
+
+ public void clear()
+ {
+ nodeMap.clear();
+ list.clear();
+ this.numElements = 0;
+ }
+
+ public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+ {
+ return list.iterator();
+ }
+
+ @Override
+ public String toString()
+ {
+ return list.toString();
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,193 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+/**
+ * Value object used in queue
+ *
+ * @author Ben Wang 2-2004
+ * @author Daniel Huang - dhuang(a)jboss.org
+ */
+public class NodeEntry
+{
+ private long modifiedTimeStamp;
+ private long creationTimeStamp;
+ private int numberOfNodeVisits;
+ private int numberOfElements;
+ private Fqn fqn;
+
+ private long inUseTimeoutTimestamp;
+ private boolean currentlyInUse = false;
+
+ EvictionQueue queue;
+
+ /**
+ * Private constructor that automatically sets the creation time stamp of the node entry.
+ */
+ private NodeEntry()
+ {
+ this.creationTimeStamp = System.currentTimeMillis();
+ }
+
+ public NodeEntry(Fqn fqn)
+ {
+ this();
+ setFqn(fqn);
+ }
+
+ public NodeEntry(String fqn)
+ {
+ this();
+ setFqn(Fqn.fromString(fqn));
+ }
+
+ /**
+ * Is the node currently in use.
+ *
+ * @return True/false if the node is currently marked as in use.
+ */
+ public boolean isCurrentlyInUse()
+ {
+ return currentlyInUse;
+ }
+
+ public void setCurrentlyInUse(boolean currentlyInUse, long inUseTimeout)
+ {
+ this.currentlyInUse = currentlyInUse;
+ if (inUseTimeout > 0)
+ {
+ this.inUseTimeoutTimestamp = System.currentTimeMillis() + inUseTimeout;
+ }
+ }
+
+ public long getInUseTimeoutTimestamp()
+ {
+ return this.inUseTimeoutTimestamp;
+ }
+
+ /**
+ * Get modified time stamp. This stamp is created during the node is
+ * processed so it has some fuzy tolerance in there.
+ *
+ * @return The last modified time stamp
+ */
+ public long getModifiedTimeStamp()
+ {
+ return modifiedTimeStamp;
+ }
+
+ public void setModifiedTimeStamp(long modifiedTimeStamp)
+ {
+// log.error("Being modified to " + modifiedTimeStamp, new Throwable());
+ this.modifiedTimeStamp = modifiedTimeStamp;
+ }
+
+ /**
+ * Get the time stamp for when the node entry was created.
+ *
+ * @return The node entry creation time stamp
+ */
+ public long getCreationTimeStamp()
+ {
+ return creationTimeStamp;
+ }
+
+ public void setCreationTimeStamp(long creationTimeStamp)
+ {
+ this.creationTimeStamp = creationTimeStamp;
+ }
+
+ public int getNumberOfNodeVisits()
+ {
+ return numberOfNodeVisits;
+ }
+
+ public void setNumberOfNodeVisits(int numberOfNodeVisits)
+ {
+ this.numberOfNodeVisits = numberOfNodeVisits;
+ }
+
+ public int getNumberOfElements()
+ {
+ return numberOfElements;
+ }
+
+ public void setNumberOfElements(int numberOfElements)
+ {
+ if (queue != null)
+ {
+ int difference = numberOfElements - this.numberOfElements;
+ queue.modifyElementCount(difference);
+ }
+ this.numberOfElements = numberOfElements;
+ }
+
+ public Fqn getFqn()
+ {
+ return fqn;
+ }
+
+ void setFqn(Fqn fqn)
+ {
+ this.fqn = fqn;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return fqn.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof NodeEntry))
+ return false;
+ NodeEntry ne = (NodeEntry) o;
+ return fqn.equals(ne.getFqn());
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder output = new StringBuilder();
+ output.append("Fqn: ");
+ if (fqn != null)
+ {
+ output.append(fqn);
+ }
+ else
+ {
+ output.append(" null");
+ }
+
+ output.append(" CreateTime: ").append(this.getCreationTimeStamp());
+ output.append(" NodeVisits: ").append(this.getNumberOfNodeVisits());
+ output.append(" ModifiedTime: ").append(this.getModifiedTimeStamp());
+ output.append(" NumberOfElements: ").append(this.getNumberOfElements());
+ output.append(" CurrentlyInUse: ").append(this.isCurrentlyInUse());
+ return output.toString();
+ }
+
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NodeEntry.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,98 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+import org.jboss.starobrno.eviction.EvictionEvent.Type;
+
+import java.util.concurrent.BlockingQueue;
+
+/**
+ * An eviction algorithm that does nothing - a no-op for everything.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionAlgorithm implements EvictionAlgorithm
+{
+ /**
+ * Singleton instance of this class.
+ */
+ private static final NullEvictionAlgorithm INSTANCE = new NullEvictionAlgorithm();
+
+ /**
+ * Constructs a new NullEvictionAlgorithm.
+ */
+ private NullEvictionAlgorithm()
+ {
+ }
+
+ public static NullEvictionAlgorithm getInstance()
+ {
+ return INSTANCE;
+ }
+
+ /**
+ * Returns {@link org.jboss.starobrno.eviction.NullEvictionQueue#INSTANCE}.
+ */
+ public org.jboss.starobrno.eviction.EvictionQueue getEvictionQueue()
+ {
+ return org.jboss.starobrno.eviction.NullEvictionQueue.INSTANCE;
+ }
+
+ public void setEvictionActionPolicy(org.jboss.starobrno.eviction.EvictionActionPolicy evictionActionPolicy)
+ {
+ // no-op
+ }
+
+ public void assignToRegion(Fqn fqn, CacheSPI<?, ?> cache, EvictionAlgorithmConfig evictionAlgorithmConfig, Configuration configuration)
+ {
+ // no-op
+ }
+
+ public void process(BlockingQueue<org.jboss.starobrno.eviction.EvictionEvent> queue) throws org.jboss.starobrno.eviction.EvictionException
+ {
+ // no-op
+ }
+
+ public void resetEvictionQueue()
+ {
+ // no-op
+ }
+
+ public boolean canIgnoreEvent(Type eventType)
+ {
+ return true; // always ignore everything!
+ }
+
+ public void initialize()
+ {
+ // no-op
+ }
+
+ public Class<? extends EvictionAlgorithmConfig> getConfigurationClass()
+ {
+ return org.jboss.starobrno.eviction.NullEvictionAlgorithmConfig.class;
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithm.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,63 @@
+/*
+ * 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.eviction;
+
+import org.jboss.starobrno.config.ConfigurationComponent;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.EvictionAlgorithmConfig;
+
+/**
+ * Configuration class for {@link NullEvictionAlgorithm}.
+ *
+ * @author Manik Surtani
+ * @since 3.0
+ */
+public class NullEvictionAlgorithmConfig extends ConfigurationComponent implements EvictionAlgorithmConfig
+{
+ private static final long serialVersionUID = -6591180473728241737L;
+
+ /**
+ * No-op
+ */
+ public void reset()
+ {
+ // no-op
+ }
+
+ public String getEvictionAlgorithmClassName()
+ {
+ return NullEvictionAlgorithm.class.getName();
+ }
+
+ /**
+ * No-op
+ */
+ public void validate() throws ConfigurationException
+ {
+ // no-op
+ }
+
+ public NullEvictionAlgorithmConfig clone() throws CloneNotSupportedException
+ {
+ return (NullEvictionAlgorithmConfig) super.clone();
+ }
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionAlgorithmConfig.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,161 @@
+/*
+ * 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.eviction;
+
+import org.jboss.cache.Fqn;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A queue that does nothing.
+ *
+ * @author Brian Stansberry
+ */
+public class NullEvictionQueue implements EvictionQueue
+{
+ /**
+ * Singleton instance of this class.
+ */
+ public static final NullEvictionQueue INSTANCE = new NullEvictionQueue();
+
+ /**
+ * Constructs a new NullEvictionQueue.
+ */
+ private NullEvictionQueue()
+ {
+ }
+
+ /**
+ * No-op
+ */
+ public void addNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ // no-op
+ }
+
+ /**
+ * No-op
+ */
+ public void clear()
+ {
+ // no-op
+ }
+
+ /**
+ * Returns <code>false</code>
+ */
+ public boolean containsNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ return false;
+ }
+
+ /**
+ * Returns <code>null</code>
+ */
+ public org.jboss.starobrno.eviction.NodeEntry getFirstNodeEntry()
+ {
+ return null;
+ }
+
+ /**
+ * Returns <code>null</code>
+ */
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(Fqn fqn)
+ {
+ return null;
+ }
+
+ /**
+ * Returns <code>null</code>
+ */
+ public org.jboss.starobrno.eviction.NodeEntry getNodeEntry(String fqn)
+ {
+ return null;
+ }
+
+ /**
+ * Returns <code>0</code>
+ */
+ public int getNumberOfElements()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns <code>0</code>
+ */
+ public int getNumberOfNodes()
+ {
+ return 0;
+ }
+
+ /**
+ * Returns an <code>Iterator</code> whose
+ * <code>hasNext()</code> returns <code>false</code>.
+ */
+ public Iterator<org.jboss.starobrno.eviction.NodeEntry> iterator()
+ {
+ return NullQueueIterator.INSTANCE;
+ }
+
+ /**
+ * No-op
+ */
+ public void modifyElementCount(int difference)
+ {
+ // no-op
+ }
+
+ /**
+ * No-op
+ */
+ public void removeNodeEntry(org.jboss.starobrno.eviction.NodeEntry entry)
+ {
+ // no-op
+ }
+
+ static class NullQueueIterator implements Iterator<org.jboss.starobrno.eviction.NodeEntry>
+ {
+ private static final NullQueueIterator INSTANCE = new NullQueueIterator();
+
+ private NullQueueIterator()
+ {
+ }
+
+ public boolean hasNext()
+ {
+ return false;
+ }
+
+ public org.jboss.starobrno.eviction.NodeEntry next()
+ {
+ throw new NoSuchElementException("No more elements");
+ }
+
+ public void remove()
+ {
+ throw new IllegalStateException("Must call next() before remove()");
+ }
+ }
+
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/NullEvictionQueue.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RegionNameConflictException.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RegionNameConflictException.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RegionNameConflictException.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,48 @@
+/*
+ * 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.eviction;
+
+/**
+ * MarshRegion name conflicts with pre-existing regions.
+ *
+ * @author Ben Wang 2-2004
+ */
+public class RegionNameConflictException extends Exception
+{
+
+ private static final long serialVersionUID = -6796150029431162837L;
+
+ public RegionNameConflictException()
+ {
+ super();
+ }
+
+ public RegionNameConflictException(String msg)
+ {
+ super(msg);
+ }
+
+ public RegionNameConflictException(String msg, Throwable cause)
+ {
+ super(msg, cause);
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RegionNameConflictException.java
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/RemoveOnEvictActionPolicy.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,57 @@
+/*
+ * 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.eviction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+
+/**
+ * An eviction action policy that calls {@link org.jboss.cache.Cache#removeNode(org.jboss.cache.Fqn)} to evict a node.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class RemoveOnEvictActionPolicy implements EvictionActionPolicy
+{
+ Cache<?, ?> cache;
+ private static final Log log = LogFactory.getLog(org.jboss.starobrno.eviction.DefaultEvictionActionPolicy.class);
+
+ public void setCache(Cache<?, ?> cache)
+ {
+ this.cache = cache;
+ }
+
+ public boolean evict(Fqn fqn)
+ {
+ try
+ {
+ return cache.removeNode(fqn);
+ }
+ catch (Exception e)
+ {
+ if (log.isDebugEnabled()) log.debug("Unable to evict " + fqn, e);
+ return false;
+ }
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/eviction/SortedEvictionQueue.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,36 @@
+/*
+ * 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.eviction;
+
+/**
+ * Sorted Eviction Queue implementation.
+ *
+ * @author Daniel Huang (dhuang(a)jboss.org)
+ * @version $Revision: 6776 $
+ */
+public interface SortedEvictionQueue extends EvictionQueue
+{
+ /**
+ * Provide contract to resort a sorted queue.
+ */
+ void resortEvictionQueue();
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/BootstrapFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,60 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+
+/**
+ * Factory for setting up bootstrap components
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.2.0
+ */
+@DefaultFactoryFor(classes = {CacheSPI.class, Configuration.class, ComponentRegistry.class})
+@NonVolatile
+public class BootstrapFactory extends ComponentFactory
+{
+ CacheSPI cacheSPI;
+
+ public BootstrapFactory(CacheSPI cacheSPI, Configuration configuration, ComponentRegistry componentRegistry)
+ {
+ super(componentRegistry, configuration);
+ this.cacheSPI = cacheSPI;
+ }
+
+ @Override
+ protected <T> T construct(Class<T> componentType)
+ {
+ if (componentType.isAssignableFrom(CacheSPI.class) ||
+ componentType.isAssignableFrom(Configuration.class) ||
+ componentType.isAssignableFrom(ComponentRegistry.class))
+ {
+ return componentType.cast(cacheSPI);
+ }
+
+ throw new CacheException("Don't know how to handle type " + componentType);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/BuddyManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/BuddyManagerFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/BuddyManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,49 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+/**
+ * Buddy manager factory
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@DefaultFactoryFor(classes = {BuddyManager.class})
+public class BuddyManagerFactory extends EmptyConstructorFactory
+{
+ @Override
+ public <T> T construct(Class<T> componentType)
+ {
+ if (configuration.getBuddyReplicationConfig() != null && configuration.getBuddyReplicationConfig().isEnabled() && configuration.getCacheMode() != Configuration.CacheMode.LOCAL)
+ {
+ return super.construct(componentType);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,90 @@
+/*
+ * 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.factories;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.annotations.Inject;
+
+/**
+ * Factory that creates components used internally within JBoss Cache, and also wires dependencies into the components.
+ * <p/>
+ * The {@link org.jboss.cache.DefaultCacheFactory} is a special subclass of this, which bootstraps the construction of
+ * other components. When this class is loaded, it maintains a static list of known default factories for known
+ * components, which it then delegates to, when actually performing the construction.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @see Inject
+ * @see ComponentRegistry
+ * @since 2.1.0
+ */
+public abstract class ComponentFactory
+{
+ protected final Log log = LogFactory.getLog(getClass());
+ protected ComponentRegistry componentRegistry;
+ protected Configuration configuration;
+
+ /**
+ * Constructs a new ComponentFactory.
+ */
+ public ComponentFactory(ComponentRegistry componentRegistry, Configuration configuration)
+ {
+ this.componentRegistry = componentRegistry;
+ this.configuration = configuration;
+ }
+
+ /**
+ * Constructs a new ComponentFactory.
+ */
+ public ComponentFactory()
+ {
+ }
+
+ @Inject
+ private void injectDependencies(Configuration configuration, ComponentRegistry componentRegistry)
+ {
+ this.configuration = configuration;
+ this.componentRegistry = componentRegistry;
+ }
+
+ /**
+ * Constructs a component.
+ *
+ * @param componentType type of component
+ * @return a component
+ */
+ protected abstract <T> T construct(Class<T> componentType);
+
+ protected void assertTypeConstructable(Class requestedType, Class... ableToConstruct)
+ {
+ boolean canConstruct = false;
+ for (Class c : ableToConstruct)
+ {
+ canConstruct = canConstruct || requestedType.isAssignableFrom(c);
+ }
+ if (!canConstruct) throw new ConfigurationException("Don't know how to construct " + requestedType);
+ }
+
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ComponentRegistry.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,988 @@
+/*
+ * 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.factories;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Version;
+import org.jboss.cache.util.BeanUtils;
+import org.jboss.cache.util.reflect.ReflectionUtil;
+import org.jboss.starobrno.CacheException;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.annotations.Destroy;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
+import org.jboss.starobrno.factories.annotations.Start;
+import org.jboss.starobrno.factories.annotations.Stop;
+
+import javax.management.MBeanServerFactory;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A registry where components which have been created are stored. Components are stored as singletons, registered under
+ * a specific name.
+ * <p/>
+ * Components can be retrieved from the registry using {@link #getComponent(Class)}.
+ * <p/>
+ * Components can be registered using {@link #registerComponent(Object, Class)}, which will cause any dependencies to be
+ * wired in as well. Components that need to be created as a result of wiring will be done using {@link #getOrCreateComponent(Class)},
+ * which will look up the default factory for the component type (factories annotated with the appropriate {@link DefaultFactoryFor} annotation.
+ * <p/>
+ * Default factories are treated as components too and will need to be wired before being used.
+ * <p/>
+ * The registry can exist in one of several states, as defined by the {@link CacheStatus} enumeration. In terms of the cache,
+ * state changes in the following manner:
+ * <ul>
+ * <li>INSTANTIATED - when first constructed</li>
+ * <li>CONSTRUCTED - when created using the DefaultCacheFactory</li>
+ * <li>When {@link org.jboss.cache.Cache#create()} is called, the components are rewired.</li>
+ * <li>STARTED - when {@link org.jboss.cache.Cache#start()} is called</li>
+ * <li>STOPPED - when {@link org.jboss.cache.Cache#stop()} is called</li>
+ * <li>DESTROYED - when {@link org.jboss.cache.Cache#destroy()} is called.</li>
+ * </ul>
+ * <p/>
+ * Cache configuration can only be changed and will only be reinjected if the cache is not in the {@link org.jboss.cache.CacheStatus#STARTED} state.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@NonVolatile
+public class ComponentRegistry
+{
+ /**
+ * Contains class definitions of component factories that can be used to construct certain components
+ */
+ Map<Class, Class<? extends ComponentFactory>> defaultFactories = null;
+
+ private static final Log log = LogFactory.getLog(ComponentRegistry.class);
+ private static final boolean trace = log.isTraceEnabled();
+ protected static final Object NULL_COMPONENT = new Object();
+
+ // component and method containers
+ final Map<String, Component> componentLookup = new HashMap<String, Component>();
+
+ CacheStatus state = CacheStatus.INSTANTIATED;
+
+ /**
+ * Hook to shut down the cache when the JVM exits.
+ */
+ private Thread shutdownHook;
+ /**
+ * A flag that the shutdown hook sets before calling cache.stop(). Allows stop() to identify if it has been called
+ * from a shutdown hook.
+ */
+ private boolean invokedFromShutdownHook;
+
+ /**
+ * Creates an instance of the component registry. The configuration passed in is automatically registered.
+ *
+ * @param configuration configuration with which this is created
+ */
+ public ComponentRegistry(Configuration configuration, CacheSPI cache)
+ {
+ try
+ {
+ // bootstrap.
+ registerDefaultClassLoader(null);
+ registerComponent(this, ComponentRegistry.class);
+ registerComponent(configuration, Configuration.class);
+ registerComponent(new BootstrapFactory(cache, configuration, this), BootstrapFactory.class);
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Unable to construct ComponentRegistry", e);
+ }
+ }
+
+ /**
+ * Retrieves the state of the registry
+ *
+ * @return state of the registry
+ */
+ public CacheStatus getState()
+ {
+ return state;
+ }
+
+ /**
+ * Wires an object instance with dependencies annotated with the {@link org.jboss.cache.factories.annotations.Inject} annotation, creating more components
+ * as needed based on the Configuration passed in if these additional components don't exist in the
+ * {@link ComponentRegistry}. Strictly for components that don't otherwise live in the registry and have a lifecycle, such as Nodes.
+ *
+ * @param target object to wire
+ * @throws ConfigurationException if there is a problem wiring the instance
+ */
+ public void wireDependencies(Object target) throws ConfigurationException
+ {
+ try
+ {
+ // don't use the reflection cache for wireDependencies calls since these are not managed by the ComponentRegistry
+ // and may be invoked at any time, even after the cache starts.
+ List<Method> methods = ReflectionUtil.getAllMethods(target.getClass(), Inject.class);
+
+ // search for anything we need to inject
+ for (Method method : methods) invokeInjectionMethod(target, method);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to configure component (type: " + target.getClass() + ", instance " + target + ")", e);
+ }
+ }
+
+ /**
+ * Registers the default class loader. This method *must* be called before any other components are registered,
+ * typically called by bootstrap code. Defensively, it is called in the constructor of ComponentRegistry with a null
+ * parameter.
+ *
+ * @param loader a class loader to use by default. If this is null, the class loader used to load this instance of ComponentRegistry is used.
+ */
+ public void registerDefaultClassLoader(ClassLoader loader)
+ {
+ registerComponent(loader == null ? getClass().getClassLoader() : loader, ClassLoader.class);
+ // make sure the class loader is non-volatile, so it survives restarts.
+ componentLookup.get(ClassLoader.class.getName()).nonVolatile = true;
+ }
+
+ /**
+ * This is hard coded for now, since scanning the classpath for factories annotated with {@link org.jboss.cache.factories.annotations.DefaultFactoryFor}
+ * does not work with all class loaders. This is a temporary solution until a more elegant one can be designed.
+ * <p/>
+ * BE SURE TO ADD ANY NEW FACTORY TYPES ANNOTATED WITH DefaultFactoryFor TO THIS SET!!
+ * <p/>
+ *
+ * @return set of known factory types.
+ */
+ private Set<Class<? extends ComponentFactory>> getHardcodedFactories()
+ {
+ Set<Class<? extends ComponentFactory>> s = new HashSet<Class<? extends ComponentFactory>>();
+ s.add(BootstrapFactory.class);
+ s.add(BuddyManagerFactory.class);
+ s.add(EmptyConstructorFactory.class);
+ s.add(InterceptorChainFactory.class);
+ s.add(RuntimeConfigAwareFactory.class);
+ s.add(TransactionManagerFactory.class);
+ s.add(ReplicationQueueFactory.class);
+ s.add(StateTransferManagerFactory.class);
+ s.add(StateTransferFactory.class);
+ return s;
+ }
+
+ /**
+ * Registers a component in the registry under the given type, and injects any dependencies needed. If a component
+ * of this type already exists, it is overwritten.
+ *
+ * @param component component to register
+ * @param type type of component
+ */
+ public void registerComponent(Object component, Class type)
+ {
+
+ String name = type.getName();
+ Component old = componentLookup.get(name);
+
+ if (old != null)
+ {
+ // if they are equal don't bother
+ if (old.instance.equals(component))
+ {
+ if (trace)
+ log.trace("Attempting to register a component equal to one that already exists under the same name (" + name + "). Not doing anything.");
+ return;
+ }
+ }
+
+ Component c;
+ if (old != null)
+ {
+ if (trace) log.trace("Replacing old component " + old + " with new instance " + component);
+ old.instance = component;
+ old.methodsScanned = false;
+ c = old;
+
+ if (state == CacheStatus.STARTED) populateLifecycleMethods();
+ }
+ else
+ {
+ c = new Component();
+ c.name = name;
+ c.instance = component;
+ if (trace) log.trace("Registering component " + c + " under name " + name);
+ componentLookup.put(name, c);
+ }
+ c.nonVolatile = component.getClass().isAnnotationPresent(NonVolatile.class);
+ addComponentDependencies(c);
+ // inject dependencies for this component
+ c.injectDependencies();
+ }
+
+ /**
+ * Adds component dependencies for a given component, by populating {@link Component#injectionMethods}.
+ *
+ * @param c component to add dependencies to
+ */
+ protected void addComponentDependencies(Component c)
+ {
+ Class type = c.instance.getClass();
+ List<Method> methods = ReflectionUtil.getAllMethods(type, Inject.class);
+ c.injectionMethods.clear();
+ c.injectionMethods.addAll(methods);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void invokeInjectionMethod(Object o, Method m)
+ {
+ Class[] dependencies = m.getParameterTypes();
+ Object[] params = new Object[dependencies.length];
+
+ for (int i = 0; i < dependencies.length; i++)
+ {
+ params[i] = getOrCreateComponent(dependencies[i]);
+ }
+
+ ReflectionUtil.invokeAccessibly(o, m, params);
+ }
+
+ /**
+ * Retrieves a component if one exists, and if not, attempts to find a factory capable of constructing the component
+ * (factories annotated with the {@link DefaultFactoryFor} annotation that is capable of creating the component class).
+ * <p/>
+ * If an instance needs to be constructed, dependencies are then automatically wired into the instance, based on methods
+ * on the component type annotated with {@link Inject}.
+ * <p/>
+ * Summing it up, component retrieval happens in the following order:<br />
+ * 1. Look for a component that has already been created and registered.
+ * 2. Look for an appropriate component that exists in the {@link Configuration} that may be injected from an external system.
+ * 3. Look for a class definition passed in to the {@link org.jboss.cache.config.Configuration} - such as an EvictionPolicy implementation
+ * 4. Attempt to create it by looking for an appropriate factory (annotated with {@link DefaultFactoryFor})
+ * <p/>
+ *
+ * @param componentClass type of component to be retrieved. Should not be null.
+ * @return a fully wired component instance, or null if one cannot be found or constructed.
+ * @throws ConfigurationException if there is a problem with consructing or wiring the instance.
+ */
+ protected <T> T getOrCreateComponent(Class<T> componentClass)
+ {
+
+ T component = getComponent(componentClass);
+
+ if (component == null)
+ {
+ // first see if this has been injected externally.
+ component = getFromConfiguration(componentClass);
+ boolean attemptedFactoryConstruction = false;
+
+ if (component == null)
+ {
+ // create this component and add it to the registry
+ ComponentFactory factory = getFactory(componentClass);
+ component = factory.construct(componentClass);
+ attemptedFactoryConstruction = true;
+
+ }
+
+ if (component != null)
+ {
+ registerComponent(component, componentClass);
+ }
+ else if (attemptedFactoryConstruction)
+ {
+ if (trace) log.trace("Registering a null for component " + componentClass.getSimpleName());
+ registerNullComponent(componentClass);
+ }
+ }
+
+ return component;
+ }
+
+ /**
+ * Retrieves a component factory instance capable of constructing components of a specified type. If the factory doesn't
+ * exist in the registry, one is created.
+ *
+ * @param componentClass type of component to construct
+ * @return component factory capable of constructing such components
+ */
+ protected ComponentFactory getFactory(Class componentClass)
+ {
+ if (defaultFactories == null) scanDefaultFactories();
+ Class<? extends ComponentFactory> cfClass = defaultFactories.get(componentClass);
+ if (cfClass == null)
+ throw new ConfigurationException("No registered default factory for component " + componentClass + " found!");
+ // a component factory is a component too! See if one has been created and exists in the registry
+ ComponentFactory cf = getComponent(cfClass);
+ if (cf == null)
+ {
+ // hasn't yet been created. Create and put in registry
+ cf = instantiateFactory(cfClass);
+ if (cf == null)
+ throw new ConfigurationException("Unable to locate component factory for component " + componentClass);
+ // we simply register this factory. Registration will take care of constructing any dependencies.
+ registerComponent(cf, cfClass);
+ }
+
+ // ensure the component factory is in the STARTED state!
+ Component c = componentLookup.get(cfClass.getName());
+ if (c.instance != cf)
+ throw new ConfigurationException("Component factory " + cfClass + " incorrectly registered!");
+ return cf;
+ }
+
+ /**
+ * Scans the class path for classes annotated with {@link org.jboss.cache.factories.annotations.DefaultFactoryFor}, and
+ * analyses which components can be created by such factories.
+ */
+ void scanDefaultFactories()
+ {
+ defaultFactories = new HashMap<Class, Class<? extends ComponentFactory>>();
+
+ Set<Class<? extends ComponentFactory>> factories = getHardcodedFactories();
+
+ for (Class<? extends ComponentFactory> factory : factories)
+ {
+ DefaultFactoryFor dFFAnnotation = factory.getAnnotation(DefaultFactoryFor.class);
+ for (Class targetClass : dFFAnnotation.classes()) defaultFactories.put(targetClass, factory);
+ }
+ }
+
+ /**
+ * No such thing as a meta factory yet. Factories are created using this method which attempts to use an empty public
+ * constructor.
+ *
+ * @param factory class of factory to be created
+ * @return factory instance
+ */
+ ComponentFactory instantiateFactory(Class<? extends ComponentFactory> factory)
+ {
+ try
+ {
+ return factory.newInstance();
+ }
+ catch (Exception e)
+ {
+ // unable to get a hold of an instance!!
+ throw new ConfigurationException("Unable to instantiate factory " + factory, e);
+ }
+ }
+
+ /**
+ * registers a special "null" component that has no dependencies.
+ *
+ * @param type type of component to register as a null
+ */
+ void registerNullComponent(Class type)
+ {
+ registerComponent(NULL_COMPONENT, type);
+ }
+
+ /**
+ * Retrieves a component from the {@link Configuration} or {@link RuntimeConfig}.
+ *
+ * @param componentClass component type
+ * @return component, or null if it cannot be found
+ */
+ @SuppressWarnings("unchecked")
+ protected <T> T getFromConfiguration(Class<T> componentClass)
+ {
+ if (log.isDebugEnabled())
+ log.debug("Looking in configuration for an instance of " + componentClass + " that may have been injected from an external source.");
+ Method getter = BeanUtils.getterMethod(Configuration.class, componentClass);
+ T returnValue = null;
+
+ if (getter != null)
+ {
+ try
+ {
+ returnValue = (T) getter.invoke(getConfiguration());
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to invoke getter " + getter + " on Configuration.class!", e);
+ }
+ }
+
+ // now try the RuntimeConfig - a legacy "registry" of sorts.
+ if (returnValue == null)
+ {
+ getter = BeanUtils.getterMethod(RuntimeConfig.class, componentClass);
+ if (getter != null)
+ {
+ try
+ {
+ returnValue = (T) getter.invoke(getConfiguration().getRuntimeConfig());
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to invoke getter " + getter + " on RuntimeConfig.class!", e);
+ }
+ }
+ }
+ return returnValue;
+ }
+
+ /**
+ * Retrieves the configuration component.
+ *
+ * @return a Configuration object
+ */
+ protected Configuration getConfiguration()
+ {
+ // this is assumed to always be present as a part of the bootstrap/construction of a ComponentRegistry.
+ return getComponent(Configuration.class);
+ }
+
+ /**
+ * Retrieves a component of a specified type from the registry, or null if it cannot be found.
+ *
+ * @param type type to find
+ * @return component, or null
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T getComponent(Class<T> type)
+ {
+ Component wrapper = componentLookup.get(type.getName());
+ if (wrapper == null) return null;
+
+ return (T) (wrapper.instance == NULL_COMPONENT ? null : wrapper.instance);
+ }
+
+ /**
+ * Rewires components. Can only be called if the current state is WIRED or STARTED.
+ */
+ public void rewire()
+ {
+ // need to re-inject everything again.
+ for (Component c : new HashSet<Component>(componentLookup.values()))
+ {
+ // inject dependencies for this component
+ c.injectDependencies();
+ }
+ }
+
+ /**
+ * Scans each registered component for lifecycle methods, and adds them to the appropriate lists, and then sorts them
+ * by priority.
+ */
+ private void populateLifecycleMethods()
+ {
+ for (Component c : componentLookup.values())
+ {
+ if (!c.methodsScanned)
+ {
+ c.methodsScanned = true;
+ c.startMethods.clear();
+ c.stopMethods.clear();
+ c.destroyMethods.clear();
+
+ List<Method> methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Start.class);
+ for (Method m : methods)
+ {
+ PrioritizedMethod em = new PrioritizedMethod();
+ em.component = c;
+ em.method = m;
+ em.priority = m.getAnnotation(Start.class).priority();
+ c.startMethods.add(em);
+ }
+
+ methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Stop.class);
+ for (Method m : methods)
+ {
+ PrioritizedMethod em = new PrioritizedMethod();
+ em.component = c;
+ em.method = m;
+ em.priority = m.getAnnotation(Stop.class).priority();
+ c.stopMethods.add(em);
+ }
+
+ methods = ReflectionUtil.getAllMethods(c.instance.getClass(), Destroy.class);
+ for (Method m : methods)
+ {
+ PrioritizedMethod em = new PrioritizedMethod();
+ em.component = c;
+ em.method = m;
+ em.priority = m.getAnnotation(Destroy.class).priority();
+ c.destroyMethods.add(em);
+ }
+ }
+ }
+ }
+
+ /**
+ * Removes any components not annotated as @NonVolatile.
+ */
+ public void resetNonVolatile()
+ {
+ // destroy all components to clean up resources
+ for (Component c : new HashSet<Component>(componentLookup.values()))
+ {
+ // the component is volatile!!
+ if (!c.nonVolatile)
+ {
+ componentLookup.remove(c.name);
+ }
+ }
+
+ if (trace) log.trace("Reset volatile components. Registry now contains " + componentLookup.keySet());
+ }
+
+ // ------------------------------ START: Publicly available lifecycle methods -----------------------------
+ // These methods perform a check for appropriate transition and then delegate to similarly named internal methods.
+
+ /**
+ * Creates the components needed by a cache instance and sets the cache status to {@link org.jboss.cache.CacheStatus#CREATED}
+ * when it is done.
+ */
+ public void create()
+ {
+ if (!state.createAllowed())
+ {
+ if (state.needToDestroyFailedCache())
+ destroy();
+ else
+ return;
+ }
+
+ try
+ {
+ internalCreate();
+ }
+ catch (Throwable t)
+ {
+ handleLifecycleTransitionFailure(t);
+ }
+ }
+
+ /**
+ * This starts the components in the cache, connecting to channels, starting service threads, etc. If the cache is
+ * not in the {@link org.jboss.cache.CacheStatus#CREATED} state, {@link #create()} will be invoked first.
+ */
+ public void start()
+ {
+ boolean createdInStart = false;
+ if (!state.startAllowed())
+ {
+ if (state.needToDestroyFailedCache())
+ destroy(); // this will take us back to DESTROYED
+
+ if (state.needCreateBeforeStart())
+ {
+ create();
+ createdInStart = true;
+ }
+ else
+ return;
+ }
+
+ try
+ {
+ internalStart(createdInStart);
+ }
+ catch (Throwable t)
+ {
+ handleLifecycleTransitionFailure(t);
+ }
+ }
+
+ /**
+ * Stops the cache and sets the cache status to {@link org.jboss.cache.CacheStatus#STOPPED} once it is done. If the cache is not in
+ * the {@link org.jboss.cache.CacheStatus#STARTED} state, this is a no-op.
+ */
+ public void stop()
+ {
+ if (!state.stopAllowed())
+ {
+ return;
+ }
+
+ // Trying to stop() from FAILED is valid, but may not work
+ boolean failed = state == CacheStatus.FAILED;
+
+ try
+ {
+ internalStop();
+ }
+ catch (Throwable t)
+ {
+ if (failed)
+ {
+ log.warn("Attempted to stop() from FAILED state, but caught exception; try calling destroy()", t);
+ }
+ failed = true;
+ handleLifecycleTransitionFailure(t);
+ }
+ finally
+ {
+ if (!failed) state = CacheStatus.STOPPED;
+ }
+ }
+
+ /**
+ * Destroys the cache and frees up any resources. Sets the cache status to {@link CacheStatus#DESTROYED} when it is done.
+ * <p/>
+ * If the cache is in {@link org.jboss.cache.CacheStatus#STARTED} when this method is called, it will first call {@link #stop()}
+ * to stop the cache.
+ */
+ public void destroy()
+ {
+ if (!state.destroyAllowed())
+ {
+ if (state.needStopBeforeDestroy())
+ {
+ try
+ {
+ stop();
+ }
+ catch (CacheException e)
+ {
+ log.warn("Needed to call stop() before destroying but stop() threw exception. Proceeding to destroy", e);
+ }
+ }
+ else
+ return;
+ }
+
+ try
+ {
+ internalDestroy();
+ }
+ finally
+ {
+ // We always progress to destroyed
+ state = CacheStatus.DESTROYED;
+ }
+ }
+ // ------------------------------ END: Publicly available lifecycle methods -----------------------------
+
+ // ------------------------------ START: Actual internal lifecycle methods --------------------------------
+
+ /**
+ * Sets the cacheStatus to FAILED and rethrows the problem as one
+ * of the declared types. Converts any non-RuntimeException Exception
+ * to CacheException.
+ *
+ * @param t throwable thrown during failure
+ */
+ private void handleLifecycleTransitionFailure(Throwable t)
+ {
+ state = CacheStatus.FAILED;
+ if (t instanceof CacheException)
+ throw (CacheException) t;
+ else if (t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ else if (t instanceof Error)
+ throw (Error) t;
+ else
+ throw new CacheException(t);
+ }
+
+ /**
+ * The actual create implementation.
+ */
+ private void internalCreate()
+ {
+ state = CacheStatus.CREATING;
+ resetNonVolatile();
+ rewire();
+ state = CacheStatus.CREATED;
+ }
+
+ private void internalStart(boolean createdInStart) throws CacheException, IllegalArgumentException
+ {
+ if (!createdInStart)
+ {
+ // re-wire all dependencies in case stuff has changed since the cache was created
+ // remove any components whose construction may have depended upon a configuration that may have changed.
+ resetNonVolatile();
+ rewire();
+ }
+
+ state = CacheStatus.STARTING;
+
+ // start all internal components
+ // first cache all start, stop and destroy methods.
+ populateLifecycleMethods();
+
+ List<PrioritizedMethod> startMethods = new ArrayList<PrioritizedMethod>(componentLookup.size());
+ for (Component c : componentLookup.values()) startMethods.addAll(c.startMethods);
+
+ // sort the start methods by priority
+ Collections.sort(startMethods);
+
+ // fire all START methods according to priority
+
+
+ for (PrioritizedMethod em : startMethods) em.invoke();
+
+ addShutdownHook();
+
+ log.info("JBoss Cache version: " + Version.printVersion());
+ state = CacheStatus.STARTED;
+ }
+
+ private void addShutdownHook()
+ {
+ ArrayList al = MBeanServerFactory.findMBeanServer(null);
+ boolean registerShutdownHook = (getConfiguration().getShutdownHookBehavior() == Configuration.ShutdownHookBehavior.DEFAULT && al.size() == 0)
+ || getConfiguration().getShutdownHookBehavior() == Configuration.ShutdownHookBehavior.REGISTER;
+
+ if (registerShutdownHook)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Registering a shutdown hook. Configured behavior = " + getConfiguration().getShutdownHookBehavior());
+ shutdownHook = new Thread()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ invokedFromShutdownHook = true;
+ ComponentRegistry.this.stop();
+ }
+ finally
+ {
+ invokedFromShutdownHook = false;
+ }
+ }
+ };
+
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ }
+ else
+ {
+ if (log.isTraceEnabled())
+ log.trace("Not registering a shutdown hook. Configured behavior = " + getConfiguration().getShutdownHookBehavior());
+ }
+ }
+
+ /**
+ * Actual stop
+ */
+ private void internalStop()
+ {
+ state = CacheStatus.STOPPING;
+ // if this is called from a source other than the shutdown hook, deregister the shutdown hook.
+ if (!invokedFromShutdownHook && shutdownHook != null) Runtime.getRuntime().removeShutdownHook(shutdownHook);
+
+ List<PrioritizedMethod> stopMethods = new ArrayList<PrioritizedMethod>(componentLookup.size());
+ for (Component c : componentLookup.values()) stopMethods.addAll(c.stopMethods);
+
+ Collections.sort(stopMethods);
+
+ // fire all STOP methods according to priority
+ for (PrioritizedMethod em : stopMethods) em.invoke();
+
+ state = CacheStatus.STOPPED;
+ }
+
+ /**
+ * Actual destroy
+ */
+ private void internalDestroy()
+ {
+
+ state = CacheStatus.DESTROYING;
+
+ resetNonVolatile();
+
+ List<PrioritizedMethod> destroyMethods = new ArrayList<PrioritizedMethod>(componentLookup.size());
+ for (Component c : componentLookup.values()) destroyMethods.addAll(c.destroyMethods);
+
+ Collections.sort(destroyMethods);
+
+ // fire all DESTROY methods according to priority
+ for (PrioritizedMethod em : destroyMethods) em.invoke();
+
+ state = CacheStatus.DESTROYED;
+ }
+
+ // ------------------------------ END: Actual internal lifecycle methods --------------------------------
+
+ /**
+ * Asserts whether invocations are allowed on the cache or not. Returns <tt>true</tt> if invocations are to be allowed,
+ * <tt>false</tt> otherwise. If the origin of the call is remote and the cache status is {@link org.jboss.cache.CacheStatus#STARTING},
+ * this method will block for up to {@link org.jboss.cache.config.Configuration#getStateRetrievalTimeout()} millis, checking
+ * for a valid state.
+ *
+ * @param originLocal true if the call originates locally (i.e., from the {@link org.jboss.cache.invocation.CacheInvocationDelegate} or false if it originates remotely, i.e., from the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher}.
+ * @return true if invocations are allowed, false otherwise.
+ */
+ public boolean invocationsAllowed(boolean originLocal)
+ {
+ log.trace("Testing if invocations are allowed.");
+ if (state.allowInvocations()) return true;
+
+ // if this is a locally originating call and the cache is not in a valid state, return false.
+ if (originLocal) return false;
+
+ log.trace("Is remotely originating.");
+
+ // else if this is a remote call and the status is STARTING, wait until the cache starts.
+ if (state == CacheStatus.STARTING)
+ {
+ log.trace("Cache is starting; block.");
+ try
+ {
+ blockUntilCacheStarts();
+ return true;
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+ else
+ {
+ log.warn("Received a remote call but the cache is not in STARTED state - ignoring call.");
+ }
+ return false;
+ }
+
+ /**
+ * Blocks until the current cache instance is in its {@link org.jboss.cache.CacheStatus#STARTED started} phase. Blocks
+ * for up to {@link org.jboss.cache.config.Configuration#getStateRetrievalTimeout()} milliseconds, throwing an IllegalStateException
+ * if the cache doesn't reach this state even after this maximum wait time.
+ *
+ * @throws InterruptedException if interrupted while waiting
+ * @throws IllegalStateException if even after waiting the cache has not started.
+ */
+ private void blockUntilCacheStarts() throws InterruptedException, IllegalStateException
+ {
+ int pollFrequencyMS = 100;
+ long startupWaitTime = getConfiguration().getStateRetrievalTimeout();
+ long giveUpTime = System.currentTimeMillis() + startupWaitTime;
+
+ while (System.currentTimeMillis() < giveUpTime)
+ {
+ if (state.allowInvocations()) break;
+ Thread.sleep(pollFrequencyMS);
+ }
+
+ // check if we have started.
+ if (!state.allowInvocations())
+ throw new IllegalStateException("Cache not in STARTED state, even after waiting " + getConfiguration().getStateRetrievalTimeout() + " millis.");
+ }
+
+ /**
+ * A wrapper representing a component in the registry
+ */
+ public class Component
+ {
+ /**
+ * A reference to the object instance for this component.
+ */
+ Object instance;
+ /**
+ * The name of the component
+ */
+ String name;
+ boolean methodsScanned;
+ /**
+ * List of injection methods used to inject dependencies into the component
+ */
+ List<Method> injectionMethods = new ArrayList<Method>(2);
+ List<PrioritizedMethod> startMethods = new ArrayList<PrioritizedMethod>(2);
+ List<PrioritizedMethod> stopMethods = new ArrayList<PrioritizedMethod>(2);
+ List<PrioritizedMethod> destroyMethods = new ArrayList<PrioritizedMethod>(2);
+ /**
+ * If true, then this component is not flushed before starting the ComponentRegistry.
+ */
+ boolean nonVolatile;
+
+ @Override
+ public String toString()
+ {
+ return "Component{" +
+ "instance=" + instance +
+ ", name=" + name +
+ ", nonVolatile=" + nonVolatile +
+ '}';
+ }
+
+ /**
+ * Injects dependencies into this component.
+ */
+ public void injectDependencies()
+ {
+ for (Method m : injectionMethods) invokeInjectionMethod(instance, m);
+ }
+
+ public Object getInstance()
+ {
+ return instance;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+
+ /**
+ * Wrapper to encapsulate a method along with a priority
+ */
+ static class PrioritizedMethod implements Comparable<PrioritizedMethod>
+ {
+ Method method;
+ Component component;
+ int priority;
+
+ public int compareTo(PrioritizedMethod o)
+ {
+ return (priority < o.priority ? -1 : (priority == o.priority ? 0 : 1));
+ }
+
+ void invoke()
+ {
+ ReflectionUtil.invokeAccessibly(component.instance, method, null);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "PrioritizedMethod{" +
+ "method=" + method +
+ ", priority=" + priority +
+ '}';
+ }
+ }
+
+ /**
+ * Returns an immutable set contating all the components that exists in the reporsitory at this moment.
+ */
+ public Set<Component> getRegiteredComponents()
+ {
+ HashSet<Component> defensiveCopy = new HashSet<Component>(componentLookup.values());
+ return Collections.unmodifiableSet(defensiveCopy);
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EmptyConstructorFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,86 @@
+/*
+ * 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.factories;
+
+
+import org.jboss.cache.RegionRegistry;
+import org.jboss.cache.batch.BatchContainer;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
+import org.jboss.cache.loader.CacheLoaderManager;
+import org.jboss.cache.lock.LockStrategyFactory;
+import org.jboss.cache.marshall.Marshaller;
+import org.jboss.cache.marshall.VersionAwareMarshaller;
+import org.jboss.cache.mvcc.MVCCNodeHelper;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
+import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.factories.context.ContextFactory;
+import org.jboss.starobrno.invocation.InvocationContextContainer;
+import org.jboss.starobrno.transaction.TransactionTable;
+
+/**
+ * Simple factory that just uses reflection and an empty constructor of the component type.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@DefaultFactoryFor(classes = {Notifier.class, MVCCNodeHelper.class, RegionRegistry.class,
+ ChannelMessageListener.class, CacheLoaderManager.class, Marshaller.class, InvocationContextContainer.class,
+ CacheInvocationDelegate.class, TransactionTable.class, DataContainer.class,
+ LockStrategyFactory.class, BuddyFqnTransformer.class, BatchContainer.class,
+ ContextFactory.class, EntryFactory.class})
+public class EmptyConstructorFactory extends ComponentFactory
+{
+ @Override
+ protected <T> T construct(Class<T> componentType)
+ {
+ try
+ {
+ if (componentType.isInterface())
+ {
+ Class componentImpl;
+ if (componentType.equals(Marshaller.class))
+ {
+ componentImpl = VersionAwareMarshaller.class;
+ }
+ else
+ {
+ // add an "Impl" to the end of the class name and try again
+ componentImpl = getClass().getClassLoader().loadClass(componentType.getName() + "Impl");
+ }
+
+ return componentType.cast(componentImpl.newInstance());
+ }
+ else
+ {
+ return componentType.newInstance();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to create component " + componentType, e);
+ }
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/EntryFactoryImpl.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,11 +21,11 @@
*/
package org.jboss.starobrno.factories;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.mvcc.EntryImpl;
import org.jboss.starobrno.mvcc.MVCCEntry;
import org.jboss.starobrno.mvcc.NullMarkerEntry;
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/InterceptorChainFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,212 @@
+/*
+ * 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.factories;
+
+
+import org.jboss.cache.interceptors.*;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.CustomInterceptorConfig;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+import org.jboss.starobrno.interceptors.InterceptorChain;
+import org.jboss.starobrno.interceptors.base.CommandInterceptor;
+
+import java.util.List;
+
+/**
+ * Factory class that builds an interceptor chain based on cache configuration.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@DefaultFactoryFor(classes = InterceptorChain.class)
+public class InterceptorChainFactory extends ComponentFactory
+{
+ /**
+ * Note - this method used to return a singleton instance, and since 2.1.0 returns a new instance. The method is
+ * deprecated and you should use the no-arg constructor to create a new instance of this factory.
+ *
+ * @return a NEW instance of this class.
+ */
+ @Deprecated
+ public static InterceptorChainFactory getInstance()
+ {
+ return new InterceptorChainFactory();
+ }
+
+ private CommandInterceptor createInterceptor(Class clazz) throws IllegalAccessException, InstantiationException
+ {
+ return null; // todo - un-hack!
+// CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
+// if (chainedInterceptor == null)
+// {
+// chainedInterceptor = clazz.newInstance();
+// componentRegistry.registerComponent(chainedInterceptor, clazz);
+// }
+// else
+// {
+// // wipe next/last chaining!!
+// chainedInterceptor.setNext(null);
+// }
+// return chainedInterceptor;
+ }
+
+ public InterceptorChain buildInterceptorChain() throws IllegalAccessException, InstantiationException, ClassNotFoundException
+ {
+ boolean invocationBatching = configuration.isInvocationBatchingEnabled();
+ // load the icInterceptor first
+ CommandInterceptor first = invocationBatching ? createInterceptor(BatchingInterceptor.class) : createInterceptor(InvocationContextInterceptor.class);
+ InterceptorChain interceptorChain = new InterceptorChain(first);
+
+ // add the interceptor chain to the registry first, since some interceptors may ask for it.
+ componentRegistry.registerComponent(interceptorChain, InterceptorChain.class);
+
+ // NOW add the ICI if we are using batching!
+ if (invocationBatching)
+ interceptorChain.appendIntereceptor(createInterceptor(InvocationContextInterceptor.class));
+
+ // load the cache management interceptor next
+ if (configuration.getExposeManagementStatistics())
+ interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtInterceptor.class));
+
+ // load the tx interceptor
+ interceptorChain.appendIntereceptor(createInterceptor(TxInterceptor.class));
+
+ if (configuration.isUseLazyDeserialization())
+ interceptorChain.appendIntereceptor(createInterceptor(MarshalledValueInterceptor.class));
+ interceptorChain.appendIntereceptor(createInterceptor(NotificationInterceptor.class));
+
+ switch (configuration.getCacheMode())
+ {
+ case REPL_SYNC:
+ case REPL_ASYNC:
+ interceptorChain.appendIntereceptor(createInterceptor(ReplicationInterceptor.class));
+ break;
+ case INVALIDATION_SYNC:
+ case INVALIDATION_ASYNC:
+ interceptorChain.appendIntereceptor(createInterceptor(InvalidationInterceptor.class));
+ break;
+ case LOCAL:
+ //Nothing...
+ }
+
+ if (configuration.isUsingCacheLoaders())
+ {
+ if (configuration.getCacheLoaderConfig().isPassivation())
+ {
+ interceptorChain.appendIntereceptor(createInterceptor(ActivationInterceptor.class));
+ }
+ else
+ {
+ interceptorChain.appendIntereceptor(createInterceptor(CacheLoaderInterceptor.class));
+ }
+ }
+ interceptorChain.appendIntereceptor(createInterceptor(MVCCLockingInterceptor.class));
+
+ if (configuration.isUsingCacheLoaders())
+ {
+ if (configuration.getCacheLoaderConfig().isPassivation())
+ {
+
+ interceptorChain.appendIntereceptor(createInterceptor(PassivationInterceptor.class));
+
+ }
+ else
+ {
+
+ interceptorChain.appendIntereceptor(createInterceptor(CacheStoreInterceptor.class));
+
+ }
+ }
+
+ if (configuration.isUsingBuddyReplication())
+ {
+
+ interceptorChain.appendIntereceptor(createInterceptor(DataGravitatorInterceptor.class));
+
+ }
+
+ // eviction interceptor to come before the optimistic node interceptor
+ if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
+ interceptorChain.appendIntereceptor(createInterceptor(configuration.isUsingBuddyReplication() ? BuddyRegionAwareEvictionInterceptor.class : EvictionInterceptor.class));
+
+ CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
+ interceptorChain.appendIntereceptor(callInterceptor);
+ if (log.isTraceEnabled()) log.trace("Finished building default interceptor chain.");
+ buildCustomInterceptors(interceptorChain, configuration.getCustomInterceptors());
+ return interceptorChain;
+ }
+
+ private void buildCustomInterceptors(InterceptorChain interceptorChain, List<CustomInterceptorConfig> customInterceptors)
+ {
+ for (CustomInterceptorConfig config : customInterceptors)
+ {
+ if (interceptorChain.containsInstance(config.getInterceptor())) continue;
+ if (config.isFirst())
+ {
+ interceptorChain.addInterceptor(config.getInterceptor(), 0);
+ }
+ if (config.isLast()) interceptorChain.appendIntereceptor(config.getInterceptor());
+ if (config.getIndex() >= 0) interceptorChain.addInterceptor(config.getInterceptor(), config.getIndex());
+ if (config.getAfterClass() != null)
+ {
+ List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClassName(config.getAfterClass());
+ if (withClassName.isEmpty())
+ {
+ throw new ConfigurationException("Cannot add after class: " + config.getAfterClass()
+ + " as no such iterceptor exists in the default chain");
+ }
+ interceptorChain.addAfterInterceptor(config.getInterceptor(), withClassName.get(0).getClass());
+ }
+ if (config.getBeforeClass() != null)
+ {
+ List<CommandInterceptor> withClassName = interceptorChain.getInterceptorsWithClassName(config.getBeforeClass());
+ if (withClassName.isEmpty())
+ {
+ throw new ConfigurationException("Cannot add before class: " + config.getAfterClass()
+ + " as no such iterceptor exists in the default chain");
+ }
+ interceptorChain.addBeforeInterceptor(config.getInterceptor(), withClassName.get(0).getClass());
+ }
+ }
+ }
+
+ @Override
+ protected <T> T construct(Class<T> componentType)
+ {
+ try
+ {
+ return componentType.cast(buildInterceptorChain());
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to build interceptor chain", e);
+ }
+ }
+
+ public static InterceptorChainFactory getInstance(ComponentRegistry componentRegistry, Configuration configuration)
+ {
+ InterceptorChainFactory icf = new InterceptorChainFactory();
+ icf.componentRegistry = componentRegistry;
+ icf.configuration = configuration;
+ return icf;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/ReplicationQueueFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/ReplicationQueueFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/ReplicationQueueFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,50 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.cluster.ReplicationQueue;
+import org.jboss.starobrno.config.Configuration;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+/**
+ * RPCManager factory
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@DefaultFactoryFor(classes = ReplicationQueue.class)
+public class ReplicationQueueFactory extends EmptyConstructorFactory
+{
+ @Override
+ public <T> T construct(Class<T> componentType)
+ {
+ if ((configuration.getCacheMode() == Configuration.CacheMode.REPL_ASYNC || configuration.getCacheMode() == Configuration.CacheMode.INVALIDATION_ASYNC)
+ && configuration.isUseReplQueue())
+ {
+ return super.construct(componentType);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
\ No newline at end of file
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/RuntimeConfigAwareFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,60 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.util.BeanUtils;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.config.RuntimeConfig;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+import java.lang.reflect.Method;
+
+/**
+ * An extension of the EmptyConstructorFactory that places a component in the {@link RuntimeConfig} after creating it.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@DefaultFactoryFor(classes = RPCManager.class)
+public class RuntimeConfigAwareFactory extends EmptyConstructorFactory
+{
+ @Override
+ protected <T> T construct(Class<T> componentType)
+ {
+ T component = super.construct(componentType);
+
+ Method setter = BeanUtils.setterMethod(RuntimeConfig.class, componentType);
+ if (setter != null)
+ {
+ try
+ {
+ setter.invoke(configuration.getRuntimeConfig(), component);
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Unable to put newly constructed component of type " + componentType + " in the RuntimeConfig", e);
+ }
+ }
+ return component;
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,56 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.statetransfer.DefaultStateTransferGenerator;
+import org.jboss.cache.statetransfer.DefaultStateTransferIntegrator;
+import org.jboss.cache.statetransfer.StateTransferGenerator;
+import org.jboss.cache.statetransfer.StateTransferIntegrator;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+/**
+ * Factory class able to create {@link org.jboss.cache.statetransfer.StateTransferGenerator} and
+ * {@link org.jboss.cache.statetransfer.StateTransferIntegrator} instances.
+ * <p/>
+ * Updated in 3.0.0 to extend ComponentFactory, etc.
+ * <p/>
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @author Manik Surtani
+ * @version $Revision: 6776 $
+ */
+@DefaultFactoryFor(classes = {StateTransferGenerator.class, StateTransferIntegrator.class})
+public class StateTransferFactory extends ComponentFactory
+{
+ @SuppressWarnings("deprecation")
+ protected <T> T construct(Class<T> componentType)
+ {
+ if (componentType.equals(StateTransferIntegrator.class))
+ {
+ return componentType.cast(new DefaultStateTransferIntegrator());
+ }
+ else
+ {
+ return componentType.cast(new DefaultStateTransferGenerator());
+ }
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferManagerFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/StateTransferManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,42 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.statetransfer.DefaultStateTransferManager;
+import org.jboss.cache.statetransfer.StateTransferManager;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+/**
+ * Constructs {@link org.jboss.cache.statetransfer.StateTransferManager} instances.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+@DefaultFactoryFor(classes = StateTransferManager.class)
+public class StateTransferManagerFactory extends ComponentFactory
+{
+ @SuppressWarnings("deprecation")
+ protected <T> T construct(Class<T> componentType)
+ {
+ return componentType.cast(new DefaultStateTransferManager());
+ }
+}
Added: core/branches/flat/src/main/java/org/jboss/starobrno/factories/TransactionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/TransactionManagerFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/TransactionManagerFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -0,0 +1,85 @@
+/*
+ * 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.factories;
+
+import org.jboss.cache.transaction.BatchModeTransactionManager;
+import org.jboss.cache.transaction.TransactionManagerLookup;
+import org.jboss.starobrno.config.ConfigurationException;
+import org.jboss.starobrno.factories.annotations.DefaultFactoryFor;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * Uses a number of mechanisms to retrieve a transaction manager.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.1.0
+ */
+@DefaultFactoryFor(classes = {TransactionManager.class})
+public class TransactionManagerFactory extends ComponentFactory
+{
+ protected <T> T construct(Class<T> componentType)
+ {
+ // See if we had a TransactionManager injected into our config
+ TransactionManager transactionManager = configuration.getRuntimeConfig().getTransactionManager();
+ TransactionManagerLookup lookup = null;
+
+ if (transactionManager == null)
+ {
+ // Nope. See if we can look it up from JNDI
+ if (configuration.getTransactionManagerLookupClass() != null)
+ {
+ try
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) cl = getClass().getClassLoader();
+ Class clazz = cl.loadClass(configuration.getTransactionManagerLookupClass());
+ lookup = (TransactionManagerLookup) clazz.newInstance();
+ }
+ catch (Exception e)
+ {
+ throw new ConfigurationException("Problems looking up transaction manager", e);
+ }
+ }
+
+ try
+ {
+ if (lookup != null)
+ {
+ transactionManager = lookup.getTransactionManager();
+ configuration.getRuntimeConfig().setTransactionManager(transactionManager);
+ }
+ }
+ catch (Exception e)
+ {
+ log.info("failed looking up TransactionManager, will not use transactions", e);
+ }
+ }
+
+ if (transactionManager == null && configuration.isInvocationBatchingEnabled())
+ {
+ log.info("Using a batchMode transaction manager");
+ transactionManager = BatchModeTransactionManager.getInstance();
+ }
+ return componentType.cast(transactionManager);
+ }
+}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/factories/context/ContextFactory.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -22,7 +22,9 @@
package org.jboss.starobrno.factories.context;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.context.InvocationContextImpl;
import org.jboss.starobrno.context.TransactionContext;
+import org.jboss.starobrno.context.TransactionContextImpl;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
@@ -35,12 +37,15 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 3.0
*/
-public interface ContextFactory
+public class ContextFactory
{
/**
* @return a new invocation context
*/
- InvocationContext createInvocationContext();
+ public InvocationContext createInvocationContext()
+ {
+ return new InvocationContextImpl();
+ }
/**
* @param tx JTA transaction to associate the new context with
@@ -50,5 +55,8 @@
* @throws javax.transaction.SystemException
* in the event of an invalid transaction
*/
- TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException;
+ public TransactionContext createTransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ return new TransactionContextImpl(tx);
+ }
}
\ No newline at end of file
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/BaseTransactionalContextInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,7 +21,7 @@
*/
package org.jboss.starobrno.interceptors;
-import org.jboss.cache.config.Option;
+import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.context.TransactionContext;
import org.jboss.starobrno.factories.annotations.Inject;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/interceptors/InvocationContextInterceptor.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -22,8 +22,8 @@
package org.jboss.starobrno.interceptors;
-import org.jboss.cache.config.Option;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.starobrno.RPCManager;
import org.jboss.starobrno.commands.VisitableCommand;
import org.jboss.starobrno.commands.tx.CommitCommand;
import org.jboss.starobrno.commands.tx.PrepareCommand;
@@ -32,10 +32,10 @@
import org.jboss.starobrno.commands.write.PutKeyValueCommand;
import org.jboss.starobrno.commands.write.PutMapCommand;
import org.jboss.starobrno.commands.write.RemoveCommand;
+import org.jboss.starobrno.config.Option;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.annotations.Inject;
import org.jboss.starobrno.transaction.GlobalTransaction;
-import org.jboss.starobrno.RPCManager;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/loader/CacheLoader.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -21,19 +21,18 @@
*/
package org.jboss.starobrno.loader;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.List;
-import java.util.Map;
-
import net.jcip.annotations.ThreadSafe;
-
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.AbstractCacheLoader;
+import org.jboss.starobrno.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.List;
+import java.util.Map;
+
/**
* A {@link org.jboss.cache.loader.CacheLoader} implementation persists and load keys to and from
* secondary storage, such as a database or filesystem. Typically,
@@ -90,7 +89,7 @@
*
* @param c The cache on which this loader works
*/
- void setCache(CacheSPI<K,V> c);
+ void setCache(CacheSPI<K, V> c);
/**
* Returns all keys and values from the persistent store, given a {@link org.jboss.cache.Fqn}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/lock/StripedLockManager.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -23,16 +23,16 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.lock.MVCCLockManager;
import org.jboss.cache.util.concurrent.locks.LockContainer;
import org.jboss.cache.util.concurrent.locks.OwnableReentrantLock;
import org.jboss.cache.util.concurrent.locks.OwnableReentrantLockContainer;
import org.jboss.cache.util.concurrent.locks.ReentrantLockContainer;
+import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import javax.transaction.TransactionManager;
import java.util.List;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/MVCCEntryWrapper.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -23,13 +23,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.starobrno.DataContainer;
+import org.jboss.starobrno.config.Configuration;
import org.jboss.starobrno.context.InvocationContext;
import org.jboss.starobrno.factories.EntryFactory;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.Start;
import org.jboss.starobrno.lock.LockManager;
import java.util.Map.Entry;
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/mvcc/RepeatableReadEntry.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -24,7 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.mvcc.RepeatableReadNode;
-import org.jboss.cache.optimistic.DataVersioningException;
+import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.DataContainer;
import static org.jboss.starobrno.mvcc.ReadCommittedEntry.Flags.CHANGED;
@@ -62,7 +62,7 @@
{
String errormsg = new StringBuilder().append("Detected write skew on key [").append(getKey()).append("]. Another process has changed the node since we last read it!").toString();
if (log.isWarnEnabled()) log.warn(errormsg + ". Unable to copy node for update.");
- throw new DataVersioningException(errormsg);
+ throw new CacheException(errormsg);
}
}
Modified: core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java
===================================================================
--- core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-10-08 16:22:51 UTC (rev 6883)
+++ core/branches/flat/src/main/java/org/jboss/starobrno/transaction/TransactionTable.java 2008-10-08 16:24:08 UTC (rev 6884)
@@ -23,12 +23,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
+import org.jboss.starobrno.CacheException;
import org.jboss.starobrno.context.TransactionContext;
+import org.jboss.starobrno.factories.annotations.Inject;
+import org.jboss.starobrno.factories.annotations.NonVolatile;
import org.jboss.starobrno.factories.context.ContextFactory;
import org.jgroups.Address;
17 years, 2 months
JBoss Cache SVN: r6883 - core/branches/flat/src/main/docbook/userguide/en/modules.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-10-08 12:22:51 -0400 (Wed, 08 Oct 2008)
New Revision: 6883
Modified:
core/branches/flat/src/main/docbook/userguide/en/modules/eviction_policies.xml
Log:
Moved stuff
Modified: core/branches/flat/src/main/docbook/userguide/en/modules/eviction_policies.xml
===================================================================
--- core/branches/flat/src/main/docbook/userguide/en/modules/eviction_policies.xml 2008-10-08 16:22:44 UTC (rev 6882)
+++ core/branches/flat/src/main/docbook/userguide/en/modules/eviction_policies.xml 2008-10-08 16:22:51 UTC (rev 6883)
@@ -516,10 +516,10 @@
<literal>org.jboss.cache.eviction.EvictionPolicy</literal>
</listitem>
<listitem>
- <literal>org.jboss.cache.eviction.EvictionAlgorithm</literal>
+ <literal>org.jboss.starobrno.eviction.EvictionAlgorithm</literal>
</listitem>
<listitem>
- <literal>org.jboss.cache.eviction.EvictionQueue</literal>
+ <literal>org.jboss.starobrno.eviction.EvictionQueue</literal>
</listitem>
<listitem>
<literal>org.jboss.cache.config.EvictionPolicyConfig</literal>
17 years, 2 months