[jbosscache-commits] JBoss Cache SVN: r5066 - in core/trunk/src: test/java/org/jboss/cache/replicated and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Jan 8 10:38:10 EST 2008


Author: manik.surtani at jboss.com
Date: 2008-01-08 10:38:10 -0500 (Tue, 08 Jan 2008)
New Revision: 5066

Modified:
   core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
   core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java
Log:
Refactored a lot of unnecessary code in CacheImpl

Modified: core/trunk/src/main/java/org/jboss/cache/CacheImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2008-01-08 15:13:15 UTC (rev 5065)
+++ core/trunk/src/main/java/org/jboss/cache/CacheImpl.java	2008-01-08 15:38:10 UTC (rev 5066)
@@ -11,7 +11,6 @@
 import org.jboss.cache.buddyreplication.BuddyManager;
 import org.jboss.cache.buddyreplication.GravitateResult;
 import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Option;
 import org.jboss.cache.config.RuntimeConfig;
 import org.jboss.cache.factories.ComponentRegistry;
 import org.jboss.cache.factories.InterceptorChainFactory;
@@ -20,7 +19,6 @@
 import org.jboss.cache.interceptors.Interceptor;
 import org.jboss.cache.invocation.NodeInvocationDelegate;
 import org.jboss.cache.invocation.RemoteCacheInvocationDelegate;
-import org.jboss.cache.loader.CacheLoader;
 import org.jboss.cache.loader.CacheLoaderManager;
 import org.jboss.cache.lock.IsolationLevel;
 import org.jboss.cache.lock.LockStrategyFactory;
@@ -131,7 +129,7 @@
     * Set<Fqn> of Fqns of the topmost node of internal regions that should
     * not included in standard state transfers.
     */
-   private Set<Fqn> internalFqns = new HashSet<Fqn>();
+   private final Set<Fqn> internalFqns = new HashSet<Fqn>();
 
    /**
     * Marshaller if register to handle marshalling
@@ -163,11 +161,6 @@
     */
    private BuddyManager buddyManager;
 
-   /**
-    * State transfer manager. Do not access this field directly -- use the getter
-    */
-   private StateTransferManager stateTransferManager;
-
    private RemoteCacheInvocationDelegate remoteDelegate;
 
    /**
@@ -195,7 +188,7 @@
    /**
     * Constructs an uninitialized CacheImpl.
     */
-   protected CacheImpl() throws Exception
+   protected CacheImpl()
    {
       this(new Configuration());
    }
@@ -203,7 +196,7 @@
    /**
     * Constructs an uninitialized CacheImpl.
     */
-   protected CacheImpl(Configuration configuration) throws Exception
+   protected CacheImpl(Configuration configuration)
    {
       this.configuration = configuration;
       this.componentRegistry = new ComponentRegistry(configuration);
@@ -223,7 +216,7 @@
 
    @Inject
    private void injectDependencies(Notifier notifier, RegionManager regionManager, TransactionManager transactionManager, Marshaller marshaller,
-                                   TransactionTable transactionTable, StateTransferManager stateTransferManager, NodeFactory nodeFactory,
+                                   TransactionTable transactionTable, NodeFactory nodeFactory,
                                    CacheSPI spi, CacheMessageListener messageListener, @ComponentName("remoteDelegate")RemoteCacheInvocationDelegate remoteDelegate,
                                    Interceptor interceptorChain, BuddyManager buddyManager)
    {
@@ -231,7 +224,6 @@
       this.regionManager = regionManager;
       this.transactionManager = transactionManager;
       this.transactionTable = transactionTable;
-      this.stateTransferManager = stateTransferManager;
       this.nodeFactory = nodeFactory;
       this.spi = spi;
       this.messageListener = messageListener;
@@ -298,24 +290,6 @@
       return transactionTable;
    }
 
-   /**
-    * Returns the contents of the TransactionTable as a string.
-    */
-   public String dumpTransactionTable()
-   {
-      return transactionTable.toString(true);
-   }
-
-   /**
-    * Returns the underlying cache loader in use.
-    */
-   public CacheLoader getCacheLoader()
-   {
-      if (cacheLoaderManager == null)
-         return null;
-      return cacheLoaderManager.getCacheLoader();
-   }
-
    private void setUseReplQueue(boolean flag)
    {
       if (flag)
@@ -339,7 +313,6 @@
       }
    }
 
-
    /**
     * Returns the replication queue.
     */
@@ -843,13 +816,6 @@
 
       componentRegistry.stop();
 
-      // before closing the channel stop the buddy manager
-//      if (buddyManager != null && buddyManager.isEnabled())
-//      {
-//         log.debug("stop(): stopping buddy manager");
-//         buddyManager.stop();
-//      }
-
       if (channel != null)
       {
          log.info("stop(): closing the channel");
@@ -879,16 +845,6 @@
          repl_queue.stop();
       }
 
-      // now done in the CLM
-//      if (cacheLoaderManager != null)
-//      {
-//         log.debug("stop(): stopping cache loader manager");
-//         cacheLoaderManager.stopCacheLoader();
-//      }
-
-      // now done in the region manager
-//      if (regionManager.isUsingEvictions()) regionManager.stopEvictionThread();
-
       if (notifier != null)
       {
          notifier.notifyCacheStopped(spi, spi.getInvocationContext());
@@ -910,42 +866,8 @@
       return cacheStatus;
    }
 
-   /* ----------------------- End of MBeanSupport ----------------------- */
 
-   /* ----------------------- Start of buddy replication specific methods ------------*/
-
    /**
-    * Sets the buddy replication configuration element
-    *
-    * @param config
-    */
-//   private void setBuddyReplicationConfig(BuddyReplicationConfig config)
-//   {
-//      if (config != null)
-//      {
-//         buddyManager = new BuddyManager(config);
-//         if (!buddyManager.isEnabled())
-//         {
-//            buddyManager = null;
-//         }
-//         else
-//         {
-//            internalFqns.add(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
-//         }
-//      }
-//   }
-
-   /**
-    * Retrieves the Buddy Manager configured.
-    *
-    * @return null if buddy replication is not enabled.
-    */
-   public BuddyManager getBuddyManager()
-   {
-      return buddyManager;
-   }
-
-   /**
     * 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
@@ -958,24 +880,7 @@
       return Collections.unmodifiableSet(internalFqns);
    }
 
-   /* ----------------------- End of buddy replication specific methods ------------*/
-
    /**
-    * Loads the indicated Fqn, plus all parents recursively from the
-    * CacheLoader. If no CacheLoader is present, this is a no-op
-    *
-    * @param fqn
-    * @throws Exception
-    */
-   public void load(String fqn) throws Exception
-   {
-      if (cacheLoaderManager != null)
-      {
-         cacheLoaderManager.preload(Fqn.fromString(fqn), true, true);
-      }
-   }
-
-   /**
     * Returns the address of the coordinator or null if there is no
     * coordinator.
     * Waits until the membership view is updated.
@@ -1027,7 +932,7 @@
       }
 
       // Recursively remove any children
-      Set children = getChildrenNames(subtree);
+      Set children = spi.getChildrenNames(subtree);
       if (children != null)
       {
          for (Object s : children)
@@ -1099,29 +1004,6 @@
    // -----------  End Marshalling and State Transfer -----------------------
 
    /**
-    * @param fqn fqn String name to retrieve from cache
-    * @return DataNode corresponding to the fqn. Null if does not exist. No guarantees wrt replication,
-    *         cache loading are given if the underlying node is modified
-    */
-   public Node get(String fqn) throws CacheException
-   {
-      return get(Fqn.fromString(fqn));
-   }
-
-   /**
-    * Returns a DataNode corresponding to the fully qualified name or null if
-    * does not exist.
-    * No guarantees wrt replication, cache loading are given if the underlying node is modified
-    *
-    * @param fqn name of the DataNode to retreive
-    */
-   public Node get(Fqn<?> fqn) throws CacheException
-   {
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.getNodeMethodLocal_id, fqn);
-      return (Node) invokeMethod(m, true);
-   }
-
-   /**
     * Returns the raw data of the node; called externally internally.
     */
    public Node _get(Fqn<?> fqn) throws CacheException
@@ -1139,19 +1021,6 @@
       return n.getDataDirect();
    }
 
-   /**
-    * Retrieves a defensively copied data map of the underlying node.
-    *
-    * @param fqn
-    * @return map of data, or an empty map
-    * @throws CacheException
-    */
-   public Map getData(Fqn<?> fqn) throws CacheException
-   {
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.getDataMapMethodLocal_id, fqn);
-      return (Map) invokeMethod(m, true);
-   }
-
    public Set _getKeys(Fqn<?> fqn) throws CacheException
    {
       NodeSPI n = findNode(fqn);
@@ -1163,31 +1032,6 @@
       return new HashSet(keys);
    }
 
-   /**
-    * Finds a node given its name and returns the value associated with a given key in its <code>data</code>
-    * map. Returns null if the node was not found in the cache or the key was not found in the hashmap.
-    *
-    * @param fqn The fully qualified name of the node.
-    * @param key The key.
-    */
-   public Object get(String fqn, Object key) throws CacheException
-   {
-      return get(Fqn.fromString(fqn), key);
-   }
-
-
-   /**
-    * Finds a node given its name and returns the value associated with a given key in its <code>data</code>
-    * map. Returns null if the node was not found in the cache or the key was not found in the hashmap.
-    *
-    * @param fqn The fully qualified name of the node.
-    * @param key The key.
-    */
-   public Object get(Fqn<?> fqn, Object key) throws CacheException
-   {
-      return get(fqn, key, true);
-   }
-
    public Object _get(Fqn<?> fqn, Object key, boolean sendNodeEvent) throws CacheException
    {
       InvocationContext ctx = spi.getInvocationContext();
@@ -1207,13 +1051,6 @@
       return n.getDirect(key);
    }
 
-
-   protected Object get(Fqn<?> fqn, Object key, boolean sendNodeEvent) throws CacheException
-   {
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.getKeyValueMethodLocal_id, fqn, key, sendNodeEvent);
-      return invokeMethod(m, true);
-   }
-
    /**
     * Checks whether a given node exists in current in-memory state of the cache.
     * Does not acquire any locks in doing so (result may be dirty read). Does
@@ -1286,8 +1123,7 @@
 
 
    /**
-    * Checks whether a given key exists in the given node. Does not interact with CacheLoader, so the behavior is
-    * different from {@link #get(Fqn,Object)}
+    * Checks whether a given key exists in the given node. Does not interact with the interceptor stack.
     *
     * @param fqn The fully qualified name of the node
     * @param key
@@ -1299,284 +1135,6 @@
       return n != null && n.getKeysDirect().contains(key);
    }
 
-
-   /**
-    * Adds a new node to the cache and sets its data. If the node doesn not yet exist, it will be created.
-    * Also, parent nodes will be created if not existent. If the node already has data, then the new data
-    * will override the old one. If the node already existed, a nodeModified() notification will be generated.
-    * Otherwise a nodeCreated() motification will be emitted.
-    *
-    * @param fqn  The fully qualified name of the new node
-    * @param data The new data. May be null if no data should be set in the node.
-    */
-   public void put(String fqn, Map data) throws CacheException
-   {
-      put(Fqn.fromString(fqn), data);
-   }
-
-   /**
-    * Sets a node's data. If the node does not yet exist, it will be created.
-    * Also, parent nodes will be created if not existent. If the node already has data, then the new data
-    * will override the old one. If the node already existed, a nodeModified() notification will be generated.
-    * Otherwise a nodeCreated() motification will be emitted.
-    *
-    * @param fqn  The fully qualified name of the new node
-    * @param data The new data. May be null if no data should be set in the node.
-    */
-   public void put(Fqn<?> fqn, Map data) throws CacheException
-   {
-      put(fqn, data, false);
-   }
-
-   public void put(Fqn<?> fqn, Map data, boolean erase) throws CacheException
-   {
-      GlobalTransaction tx = getCurrentTransaction();
-      MethodCall m;
-      if (erase)
-      {
-         m = MethodCallFactory.create(MethodDeclarations.putDataEraseMethodLocal_id, tx, fqn, data, true, true);
-      }
-      else
-      {
-         m = MethodCallFactory.create(MethodDeclarations.putDataMethodLocal_id, tx, fqn, data, true);
-      }
-      invokeMethod(m, true);
-   }
-
-   /**
-    * Adds a key and value to a given node. If the node doesn't exist, it will be created. If the node
-    * already existed, a nodeModified() notification will be generated. Otherwise a
-    * nodeCreated() motification will be emitted.
-    *
-    * @param fqn   The fully qualified name of the node
-    * @param key   The key
-    * @param value The value
-    * @return Object The previous value (if any), if node was present
-    */
-   public Object put(String fqn, Object key, Object value) throws CacheException
-   {
-      return put(Fqn.fromString(fqn), key, value);
-   }
-
-   /**
-    * Adds a key and value to a given node. If the node doesn't exist, it will be created. If the node
-    * already existed, a nodeModified() notification will be generated. Otherwise a
-    * nodeCreated() motification will be emitted.
-    *
-    * @param fqn   The fully qualified name of the node
-    * @param key   The key
-    * @param value The value
-    * @return Object The previous value (if any), if node was present
-    */
-   public Object put(Fqn<?> fqn, Object key, Object value) throws CacheException
-   {
-      GlobalTransaction tx = getCurrentTransaction();
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal_id, tx, fqn, key, value, true);
-      return invokeMethod(m, true);
-   }
-
-   /**
-    * Removes the node from the cache.
-    *
-    * @param fqn The fully qualified name of the node.
-    */
-   public void remove(String fqn) throws CacheException
-   {
-      remove(Fqn.fromString(fqn));
-   }
-
-   /**
-    * Removes the node from the cache.
-    *
-    * @param fqn The fully qualified name of the node.
-    */
-   public boolean remove(Fqn fqn) throws CacheException
-   {
-      GlobalTransaction tx = getCurrentTransaction();
-      // special case if we are removing the root.  Remove all children instead.
-      if (fqn.isRoot())
-      {
-         boolean result = true;
-         // we need to preserve options
-         InvocationContext ctx = spi.getInvocationContext();
-         Option o = ctx.getOptionOverrides();
-         for (Object childName : _getChildrenNames(fqn))
-         {
-            ctx.setOptionOverrides(o);
-            result = remove(new Fqn<Object>(fqn, childName)) && result;
-         }
-
-         return result;
-      }
-      else
-      {
-         MethodCall m = MethodCallFactory.create(MethodDeclarations.removeNodeMethodLocal_id, tx, fqn, true);
-         Object retval = invokeMethod(m, true);
-         return retval != null && (Boolean) retval;
-      }
-   }
-
-   /**
-    * Called by eviction policy provider. Note that eviction is done only in
-    * local mode, that is, it doesn't replicate the node removal. This will
-    * cause the replication nodes to not be synchronizing, which is fine since
-    * the value will be fetched again when {@link #get} returns null. After
-    * that, the contents will be in sync.
-    *
-    * @param fqn Will remove everythign assoicated with this fqn.
-    * @throws CacheException
-    */
-   public void evict(Fqn fqn) throws CacheException
-   {
-      if (fqn.isRoot())
-      {
-         // special treatment for root eviction
-         // we need to preserve options
-         InvocationContext ctx = spi.getInvocationContext();
-         Option o = ctx.getOptionOverrides();
-         for (Object childName : _getChildrenNames(fqn))
-         {
-            ctx.setOptionOverrides(o);
-            evict(new Fqn<Object>(fqn, childName));
-         }
-      }
-      else
-      {
-         MethodCall m = MethodCallFactory.create(MethodDeclarations.evictNodeMethodLocal_id, fqn);
-         invokeMethod(m, true);
-      }
-   }
-
-   /**
-    * Removes <code>key</code> from the node's hashmap
-    *
-    * @param fqn The fullly qualified name of the node
-    * @param key The key to be removed
-    * @return The previous value, or null if none was associated with the given key
-    */
-   public Object remove(String fqn, Object key) throws CacheException
-   {
-      return remove(Fqn.fromString(fqn), key);
-   }
-
-   /**
-    * Removes <code>key</code> from the node's hashmap
-    *
-    * @param fqn The fullly qualified name of the node
-    * @param key The key to be removed
-    * @return The previous value, or null if none was associated with the given key
-    */
-   public Object remove(Fqn<?> fqn, Object key) throws CacheException
-   {
-      GlobalTransaction tx = getCurrentTransaction();
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.removeKeyMethodLocal_id, tx, fqn, key, true);
-      return invokeMethod(m, true);
-   }
-
-   /**
-    * Lock a given node (or the entire subtree starting at this node)
-    * @param fqn The FQN of the node
-    * @param owner The owner. This is simply a key into a hashtable, and can be anything, e.g.
-    * a GlobalTransaction, the current thread, or a special object. If null, it is set to Thread.currentThread()
-    * @param lock_type The type of lock (RO, RW). Needs to be of type DataNode.LOCK_TYPE_READ or DataNode.LOCK_TYPE_WRITE
-    * @param lock_recursive If true, the entire subtree is locked, else only the given node
-    * @throws CacheException If node doesn't exist, a NodeNotExistsException is throw. Other exceptions are
-    * LockingException, TimeoutException and UpgradeException
-    */
-   //   public void lock(Fqn fqn, Object owner, int lock_type, boolean lock_recursive) throws CacheException {
-   //
-   //   }
-
-   /**
-    * Unlock a given node (or the entire subtree starting at this node)
-    * @param fqn The FQN of the node
-    * @param owner The owner. This is simply a key into a hashtable, and can be anything, e.g.
-    * a GlobalTransaction, the current thread, or a special object. If null, it is set to Thread.currentThread()
-    * @param unlock_recursive If true, the entire subtree is unlocked, else only the given node
-    * @param force Release the lock even if we're not the owner
-    */
-   //   public void unlock(Fqn fqn, Object owner, boolean unlock_recursive, boolean force) {
-   //
-   //   }
-
-   /**
-    * Releases all locks for this node and the entire node subtree.
-    */
-   public void releaseAllLocks(String fqn)
-   {
-      releaseAllLocks(Fqn.fromString(fqn));
-   }
-
-   /**
-    * Releases all locks for this node and the entire node subtree.
-    */
-   public void releaseAllLocks(Fqn fqn)
-   {
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.releaseAllLocksMethodLocal_id, fqn);
-      try
-      {
-         invokeMethod(m, true);
-      }
-      catch (CacheException e)
-      {
-         log.error("failed releasing all locks for " + fqn, e);
-      }
-   }
-
-   /**
-    * Prints a representation of the node defined by <code>fqn</code>.
-    * Output includes name, fqn and data.
-    */
-   public String print(String fqn)
-   {
-      return print(Fqn.fromString(fqn));
-   }
-
-   /**
-    * Prints a representation of the node defined by <code>fqn</code>.
-    * Output includes name, fqn and data.
-    */
-   public String print(Fqn fqn)
-   {
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.printMethodLocal_id, fqn);
-      Object retval = null;
-      try
-      {
-         retval = invokeMethod(m, true);
-      }
-      catch (Throwable e)
-      {
-         retval = e;
-      }
-      if (retval != null)
-      {
-         return retval.toString();
-      }
-      else
-      {
-         return "";
-      }
-   }
-
-   /**
-    * 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.
-    */
-   public <E> Set<E> getChildrenNames(Fqn<E> fqn) throws CacheException
-   {
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.getChildrenNamesMethodLocal_id, fqn);
-      Set<E> retval = null;
-      retval = (Set<E>) invokeMethod(m, true);
-      if (retval != null)
-         retval = Collections.unmodifiableSet(new HashSet<E>(retval));
-      else
-         retval = Collections.emptySet();
-      return retval;
-   }
-
    @SuppressWarnings("unchecked")
    public <E> Set<E> _getChildrenNames(Fqn<E> fqn) throws CacheException
    {
@@ -1805,7 +1363,7 @@
       if ((preferredMode = spi.getInvocationContext().getOptionOverrides().getGroupRequestMode()) > -1)
          modeToUse = preferredMode;
 
-      RspList rsps = null;
+      RspList rsps;
       List retval;
       Vector<Address> validMembers;
 
@@ -1814,7 +1372,6 @@
          return null;
       }
 
-      validMembers = null;
       if (mbrs != null)
          validMembers = new Vector<Address>(mbrs);
       else
@@ -2172,7 +1729,7 @@
 
       NodeSPI n;
       NodeSPI parent_node;
-      MethodCall undo_op = null;
+      MethodCall undo_op;
 
       if (trace)
       {
@@ -2292,8 +1849,8 @@
    public Object _remove(GlobalTransaction tx, Fqn fqn, Object key, boolean create_undo_ops)
          throws CacheException
    {
-      MethodCall undo_op = null;
-      Object old_value = null;
+      MethodCall undo_op;
+      Object old_value;
 
       if (trace)
       {
@@ -2581,21 +2138,6 @@
    }
 
    /**
-    * Evicts a key/value pair from a node's attributes. Note that this is <em>local</em>, will not be replicated.
-    * @param fqn
-    * @param key
-    * @throws CacheException
-    */
-   //    public void _evict(Fqn fqn, Object key) throws CacheException {
-   //       if(!exists(fqn)) return;
-   //       boolean create_undo_ops = false;
-   //       boolean sendNodeEvent = false;
-   //       boolean eviction=true;
-   //       _removeData(null, fqn, create_undo_ops, sendNodeEvent, eviction);
-   //    }
-
-
-   /**
     * Compensating method to {@link #_remove(GlobalTransaction,Fqn,boolean)}.
     */
    public void _addChild(GlobalTransaction gtx, Fqn parent_fqn, Object child_name, Node cn, boolean undoOps)
@@ -2642,49 +2184,6 @@
 
 
    /**
-    * Replicates changes across to other nodes in the cluster.  Invoked by the
-    * ReplicationInterceptor.  Calls need to be forwarded to the
-    * ReplicationInterceptor in this interceptor chain. This method will later
-    * be moved entirely into the ReplicationInterceptor.
-    */
-   public Object _replicate(MethodCall method_call) throws Throwable
-   {
-      try
-      {
-         Object retVal = invokeMethod(method_call, false);
-         // we only need to return values for a set of remote calls; not every call.
-         if (MethodDeclarations.returnValueForRemoteCall(method_call.getMethodId()))
-         {
-            return retVal;
-         }
-         else
-         {
-            return null;
-         }
-      }
-      catch (Throwable ex)
-      {
-         if (method_call.getMethodId() != MethodDeclarations.putForExternalReadMethodLocal_id
-               || method_call.getMethodId() != MethodDeclarations.putForExternalReadVersionedMethodLocal_id)
-         {
-            if (!MethodDeclarations.isBuddyGroupOrganisationMethod(method_call.getMethodId()) && log.isWarnEnabled())
-               log.warn("replication failure with method_call " + method_call + " exception", ex);
-            throw ex;
-         }
-         else return null;
-
-      }
-   }
-
-   /**
-    * Replicates a list of method calls.
-    */
-   public void _replicate(List<MethodCall> methodCalls) throws Throwable
-   {
-      for (MethodCall methodCall : methodCalls) _replicate(methodCall);
-   }
-
-   /**
     * 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.
@@ -2882,42 +2381,6 @@
    }
 
    /**
-    * Returns the CacheLoaderManager.
-    */
-   public CacheLoaderManager getCacheLoaderManager()
-   {
-      return cacheLoaderManager;
-   }
-
-   /**
-    * Sets the CacheLoaderManager.
-    */
-   public void setCacheLoaderManager(CacheLoaderManager cacheLoaderManager)
-   {
-      this.cacheLoaderManager = cacheLoaderManager;
-   }
-
-   /**
-    * @return an instance of {@link Notifier} which has been configured with this instance of CacheImpl.
-    */
-   public Notifier getNotifier()
-   {
-      return notifier;
-   }
-
-   /**
-    * New API to efficiently relocate a node
-    *
-    * @since 2.0.0
-    */
-   public void move(Fqn<?> nodeToMove, Fqn<?> newParent)
-   {
-      // this needs to be passed up the interceptor chain
-      MethodCall m = MethodCallFactory.create(MethodDeclarations.moveMethodLocal_id, nodeToMove, newParent);
-      invokeMethod(m, true);
-   }
-
-   /**
     * Called by reflection
     *
     * @param newParentFqn
@@ -3019,7 +2482,6 @@
       {
          channel.disconnect();
          channel.close();
-//         channel.disconnect();
       }
    }
 
@@ -3132,7 +2594,7 @@
    private boolean isValid(Transaction tx)
    {
       if (tx == null) return false;
-      int status = -1;
+      int status;
       try
       {
          status = tx.getStatus();
@@ -3237,36 +2699,7 @@
       return gtx;
    }
 
-
-   private void blockUntilCacheStarts() throws InterruptedException
-   {
-      int pollFrequencyMS = 100;
-      long startupWaitTime = configuration.getStateRetrievalTimeout();
-      long giveUpTime = System.currentTimeMillis() + startupWaitTime;
-
-      while (System.currentTimeMillis() < giveUpTime)
-      {
-         if (cacheStatus.allowInvocations()) break;
-         Thread.sleep(pollFrequencyMS);
-      }
-
-   }
-
    /**
-    * Invokes a method against this object. Contains the logger_ic for handling
-    * the various use cases, e.g. mode (local, repl_async, repl_sync),
-    * transaction (yes or no) and locking (yes or no).
-    * <p/>
-    * Only sets originLocal on the invocation context IF this is explicitly passed in as <tt>false</tt>
-    * If passed in as <tt>true</tt> then it is not set; but whatever default exists in the invocation
-    * context is used.  For example, it may be set prior to calling invokeMethod()
-    */
-   protected Object invokeMethod(MethodCall m, boolean originLocal) throws CacheException
-   {
-      throw new UnsupportedOperationException("DEPRECATED and should not be used!!");
-   }
-
-   /**
     * Returns an object suitable for use in node locking, either the current
     * transaction or the current thread if there is no transaction.
     */
@@ -3402,50 +2835,6 @@
       return toReturn;
    }
 
-//   private void initialiseCacheLoaderManager() throws CacheException
-//   {
-//      if (cacheLoaderManager == null)
-//      {
-//         cacheLoaderManager = new CacheLoaderManager();
-//      }
-//      cacheLoaderManager.setConfig(configuration.getCacheLoaderConfig(), spi);
-//   }
-
-   /**
-    * Sets the CacheLoader to use.
-    * Provided for backwards compatibility.
-    *
-    * @param loader
-    * @deprecated only provided for backward compat
-    */
-//   @Deprecated
-//   public void setCacheLoader(CacheLoader loader)
-//   {
-//      log.warn("Using deprecated config method setCacheLoader.  This element will be removed in future, please use CacheLoaderConfiguration instead.");
-//
-//      try
-//      {
-//         if (cacheLoaderManager == null) initialiseCacheLoaderManager();
-//      }
-//      catch (Exception e)
-//      {
-//         log.warn("Problem setting cache loader.  Perhaps your cache loader config has not been set yet?");
-//      }
-//      cacheLoaderManager.setCacheLoader(loader);
-//   }
-
-   /**
-    * Purges the contents of all configured {@link CacheLoader}s
-    */
-   public void purgeCacheLoaders() throws Exception
-   {
-      if (cacheLoaderManager != null) cacheLoaderManager.purgeLoaders(true);
-   }
-
-   // ---------------------------------------------------------------
-   // END: Methods to provide backward compatibility with older cache loader config settings
-   // ---------------------------------------------------------------
-
    private void initialiseChannelAndRpcDispatcher() throws CacheException
    {
       channel = configuration.getRuntimeConfig().getChannel();
@@ -3499,7 +2888,6 @@
       // always use the InactiveRegionAwareRpcDispatcher - exceptions due to regions not being active should not propagate to remote
       // nodes as errors. - Manik
       disp = new InactiveRegionAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(), remoteDelegate);
-      //            disp = new RpcDispatcher(channel, ml, this, this);
 
       disp.setRequestMarshaller(marshaller);
       disp.setResponseMarshaller(marshaller);
@@ -3538,44 +2926,9 @@
       return modifiable == null ? null : Collections.unmodifiableList(modifiable);
    }
 
-   public void addCacheListener(Object listener)
-   {
-      getNotifier().addCacheListener(listener);
-   }
-
-   public void addCacheListener(Fqn<?> region, Object listener)
-   {
-      throw new UnsupportedOperationException("Not implemented in this release");
-   }
-
-   public void removeCacheListener(Object listener)
-   {
-      // BES 2007/5/23 workaround to avoid NPE while we decide whether
-      // to remove notifier in destroy()
-      Notifier n = getNotifier();
-      if (n != null)
-         n.removeCacheListener(listener);
-   }
-
-   public void removeCacheListener(Fqn<?> region, Object listener)
-   {
-      throw new UnsupportedOperationException("Not implemented in this release");
-   }
-
-   public Set<Object> getCacheListeners()
-   {
-      return getNotifier().getCacheListeners();
-   }
-
-   public Set<Object> getCacheListeners(Fqn<?> region)
-   {
-      throw new UnsupportedOperationException("Not implemented in this release");
-   }
-
    private List<Interceptor> getInterceptors()
    {
-      InterceptorChainFactory icf = componentRegistry.getComponent(InterceptorChainFactory.class);
-      return icf.asList(interceptorChain);
+      return InterceptorChainFactory.asList(interceptorChain);
    }
 
    private void setInterceptorChain(Interceptor startOfNewChain)
@@ -3663,36 +3016,6 @@
       return getConfiguration().getClusterName();
    }
 
-   public void evict(Fqn<?> fqn, boolean recursive)
-   {
-      //this method should be called by eviction thread only, so no transaction - expected (sec param is false)
-      Node node = peek(fqn, false);
-      if (node != null && node.isResident())
-      {
-         return;
-      }
-      if (recursive)
-      {
-         if (node != null)
-         {
-            evictChildren((NodeSPI) node);
-         }
-      }
-      else
-      {
-         evict(fqn);
-      }
-   }
-
-   private void evictChildren(NodeSPI n)
-   {
-      for (Object child : n.getChildrenDirect())
-      {
-         evictChildren((NodeSPI) child);
-      }
-      evict(n.getFqn());
-   }
-
    public Region getRegion(Fqn<?> fqn, boolean createIfAbsent)
    {
       return regionManager.getRegion(fqn, createIfAbsent);
@@ -3703,35 +3026,8 @@
       return regionManager.removeRegion(fqn);
    }
 
-   public boolean removeNode(Fqn<?> fqn)
-   {
-      return remove(fqn);
-   }
-
-   public void putForExternalRead(Fqn<?> fqn, Object key, Object value)
-   {
-      // if the node exists then this should be a no-op.
-      if (!exists(fqn))
-      {
-         spi.getInvocationContext().getOptionOverrides().setFailSilently(true);
-         GlobalTransaction tx = getCurrentTransaction();
-         MethodCall m = MethodCallFactory.create(MethodDeclarations.putForExternalReadMethodLocal_id, tx, fqn, key, value);
-         invokeMethod(m, true);
-      }
-      else
-      {
-         if (log.isDebugEnabled())
-            log.debug("putForExternalRead() called with Fqn " + fqn + " and this node already exists.  This method is hence a no op.");
-      }
-   }
-
    public void _putForExternalRead(GlobalTransaction gtx, Fqn fqn, Object key, Object value)
    {
       _put(gtx, fqn, key, value, true);
    }
-
-   public boolean isStarted()
-   {
-      return getCacheStatus() == CacheStatus.STARTED;
-   }
 }

Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java	2008-01-08 15:13:15 UTC (rev 5065)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java	2008-01-08 15:38:10 UTC (rev 5066)
@@ -11,7 +11,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.Cache;
 import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheImpl;
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.DefaultCacheFactory;
 import org.jboss.cache.Fqn;
@@ -1337,56 +1336,4 @@
 
    }
 
-   @CacheListener
-   static class TransactionAborterListener
-   {
-
-      TransactionManager callbackTM;
-      Object mutex = new Object();
-      Exception ex;
-
-      TransactionAborterListener(CacheImpl cache)
-      {
-         callbackTM = cache.getTransactionManager();
-         cache.getNotifier().addCacheListener(this);
-      }
-
-      @NodeModified
-      public void nodeModified(NodeEvent ne)
-      {
-         if (!ne.isPre())
-         {
-            synchronized (mutex)
-            {
-               try
-               {
-                  Transaction tx = callbackTM.getTransaction();
-                  if (tx != null && tx.getStatus() == Status.STATUS_ACTIVE)
-                  {
-                     // this will rollback the transaction
-                     tx.setRollbackOnly();
-                  }
-               }
-               catch (Exception e)
-               {
-                  e.printStackTrace();
-                  if (ex == null)
-                  {
-                     ex = e;
-                  }
-               }
-            }
-         }
-      }
-
-      Exception getCallbackException()
-      {
-         synchronized (mutex)
-         {
-            return ex;
-         }
-      }
-
-   }
-
 }




More information about the jbosscache-commits mailing list