4 Replies Latest reply on Aug 22, 2007 10:12 AM by manik

    Can TcpDelegatingCacheLoader only delegate remove node?

    rikr2

      Can TcpDelegatingCacheLoader only delegate remove operation?


        • 1. Re: Can TcpDelegatingCacheLoader only delegate remove node?
          manik

          No.

          If you want this behaviour, subclass TDCL and override the methods you don't want operations for.

          • 2. Re: Can TcpDelegatingCacheLoader only delegate remove node?
            rikr2

            Thanks for your help

            • 3. Re: Can TcpDelegatingCacheLoader only delegate remove node?
              rikr2

              Hey Manik I subclass TcpDelegatingCacheLoader in this way:



              package org.jboss.cache.loader.tcp;
              
              import java.util.Iterator;
              import java.util.List;
              import java.util.Map;
              import java.util.Set;
              
              import org.jboss.cache.Fqn;
              import org.jboss.cache.Modification;
              import org.jboss.cache.loader.DelegatingCacheLoader;
              
              public class MyTcpDelegatingCacheLoader extends TcpDelegatingCacheLoader {
              
               @Override
               protected void delegatePut(Fqn name, Map attributes) throws Exception {
               //nothing to do
               }
              
               @Override
               protected Object delegatePut(Fqn name, Object key, Object value) throws Exception {
               //nothing to do
               return null;
               }
              
              
               @Override
               protected Map delegateGet(Fqn arg0) throws Exception {
               return null;
               }
              
               @Override
               protected Set delegateGetChildrenNames(Fqn arg0) throws Exception {
               return null;
               }
              
               @Override
               protected void delegatePut(List modifications) throws Exception {
               synchronized (out)
               {
              
               out.reset();
               out.writeInt(DelegatingCacheLoader.putList);
               int length = modifications != null ? modifications.size() : 0;
               out.writeInt(length);
               if (length > 0)
               {
               for (Iterator it = modifications.iterator(); it.hasNext();)
               {
               Modification m = (Modification) it.next();
              
               if (m.getType() == Modification.REMOVE_NODE) { //added by me
               m.writeExternal(out);
               }
               }
               }
               out.flush();
               Object retval = in.readObject();
               if (retval instanceof Exception)
               throw(Exception) retval;
               }
              
               }
              
              
              }


              and I configure my Caches in this manner:
              TcpCacheServer

              <?xml version="1.0" encoding="UTF-8"?>
              
              <!-- ===================================================================== -->
              <!-- -->
              <!-- Sample PojoCache Service Configuration -->
              <!-- -->
              <!-- ===================================================================== -->
              
              <server>
              
               <!-- Used inside JBoss AS -->
               <classpath codebase="./lib" archives="jboss-cache-jdk50.jar, jgroups.jar"/>
              
               <!-- ==================================================================== -->
               <!-- Defines configuration -->
               <!-- ==================================================================== -->
              
               <mbean code="org.jboss.cache.aop.PojoCache"
               name="jboss.cache:service=BackEndCache">
              
               <!-- Used inside JBoss AS -->
               <depends>jboss:service=Naming</depends>
               <depends>jboss:service=TransactionManager</depends>
              
               <!--
               Configure the TransactionManager
              
               <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
               -->
               <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
               <!--
               Node locking scheme:
               OPTIMISTIC
               PESSIMISTIC (default)
               -->
               <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
              
               <!--
               Note that this attribute is IGNORED if your NodeLockingScheme above is OPTIMISTIC.
              
               Isolation level : SERIALIZABLE
               REPEATABLE_READ (default)
               READ_COMMITTED
               READ_UNCOMMITTED
               NONE
               -->
               <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
              
               <!--
               Valid modes are LOCAL
               REPL_ASYNC
               REPL_SYNC
               INVALIDATION_ASYNC
               INVALIDATION_SYNC
               -->
               <attribute name="CacheMode">LOCAL</attribute>
               <!--
               <attribute name="UseInterceptorMbeans">true</attribute>
               -->
               <!-- Name of cluster. Needs to be the same for all clusters, in order
               to find each other
               -->
               <attribute name="ClusterName">BackEndCache-Cluster</attribute>
              
               <!-- JGroups protocol stack properties. Can also be a URL,
               e.g. file:/home/bela/default.xml
               <attribute name="ClusterProperties"></attribute>
               -->
               <!-- This ORIGINAL CONFIF OF JGROUPS -->
               <attribute name="ClusterConfig">
               <config>
               <!-- UDP: if you have a multihomed machine,
               set the bind_addr attribute to the appropriate NIC IP address -->
               <!-- UDP: On Windows machines, because of the media sense feature
               being broken with multicast (even after disabling media sense)
               set the loopback attribute to true -->
               <UDP mcast_addr="228.1.2.5" mcast_port="45577"
               ip_ttl="64" ip_mcast="true"
               mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
               ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
               loopback="false"/>
               <PING timeout="2000" num_initial_members="3"
               up_thread="false" down_thread="false"/>
               <MERGE2 min_interval="10000" max_interval="20000"/>
               <!-- <FD shun="true" up_thread="true" down_thread="true"/> -->
              
               <FD_SOCK/>
               <VERIFY_SUSPECT timeout="1500"
               up_thread="false" down_thread="false"/>
               <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
               up_thread="false" down_thread="false"/>
               <pbcast.STABLE desired_avg_gossip="20000"
               up_thread="false" down_thread="false"/>
               <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
               down_thread="false"/>
               <FRAG frag_size="8192"
               down_thread="false" up_thread="false"/>
               <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
               shun="true" print_local_addr="true"/>
               <pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/>
               </config>
               </attribute>
              
              
               <!--
               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
               -->
               <attribute name="InitialStateRetrievalTimeout">20000</attribute>
              
               <!--
               Number of milliseconds to wait until all responses for a
               synchronous call have been received.
               -->
               <attribute name="SyncReplTimeout">15000</attribute>
              
               <!-- Max number of milliseconds to wait for a lock acquisition -->
               <attribute name="LockAcquisitionTimeout">10000</attribute>
              
               <!--
               <attribute name="EvictionPolicyClass"></attribute>
               -->
              
               <!-- Name of the eviction policy class. We have commented it off to disable eviction.
               -->
               <attribute name="EvictionPolicyClass">org.jboss.cache.aop.eviction.AopLRUPolicy</attribute>
              
               <!-- Specific eviction policy configurations. This is LRU -->
               <attribute name="EvictionPolicyConfig">
               <config>
               <attribute name="wakeUpIntervalSeconds">5</attribute>
               <!-- Cache wide default -->
               <region name="/_default_">
               <attribute name="maxNodes">1000</attribute>
               <attribute name="timeToLiveSeconds">600</attribute>
               <attribute name="maxAgeSeconds">1200</attribute>>
               </region>
               <!--
              
               <region name="/aop">
               <attribute name="maxNodes">5</attribute>
               <attribute name="timeToLiveSeconds">4</attribute>
               </region>
               <region name="/pojo">
               <attribute name="maxNodes">100</attribute>
               <attribute name="timeToLiveSeconds">4</attribute>
               </region>
               <region name="/testMaxNode">
               <attribute name="maxNodes">4</attribute>
               <attribute name="timeToLiveSeconds">100</attribute>
               </region> -->
               </config>
               </attribute>
               </mbean>
              
               <mbean code="org.jboss.cache.loader.tcp.TcpCacheServer" name="jboss.cache:service=TcpCacheServer">
               <depends optional-attribute-name="Cache"
               proxy-type="attribute">jboss.cache:service=BackEndCache</depends>
               <attribute name="BindAddress">${jboss.bind.address:localhost}</attribute>
               <attribute name="Port">7500</attribute>
               <attribute name="MBeanServerName"></attribute>
               <!--<attribute name="CacheName">jboss.cache:service=TreeCache</attribute>-->
               </mbean>
              </server>




              TcpDelegatingCacheLoader


              <?xml version="1.0" encoding="UTF-8"?>
              
              <!-- ===================================================================== -->
              <!-- -->
              <!-- Sample PojoCache Service Configuration -->
              <!-- -->
              <!-- ===================================================================== -->
              
              <server>
              
               <!-- Used inside JBoss AS -->
               <classpath codebase="./lib" archives="jboss-cache-jdk50.jar, jgroups.jar"/>
              
               <!-- ==================================================================== -->
               <!-- Defines configuration -->
               <!-- ==================================================================== -->
              
               <mbean code="org.jboss.cache.aop.PojoCache"
               name="jboss.cache:service=DelegatingCacheLoader">
              
               <!-- Used inside JBoss AS -->
               <depends>jboss:service=Naming</depends>
               <depends>jboss:service=TransactionManager</depends>
              
               <!--
               Configure the TransactionManager
              
               <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
               -->
               <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute>
              
               <!--
               Node locking scheme:
               OPTIMISTIC
               PESSIMISTIC (default)
               -->
               <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
              
               <!--
               Note that this attribute is IGNORED if your NodeLockingScheme above is OPTIMISTIC.
              
               Isolation level : SERIALIZABLE
               REPEATABLE_READ (default)
               READ_COMMITTED
               READ_UNCOMMITTED
               NONE
               -->
               <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
              
               <!--
               Valid modes are LOCAL
               REPL_ASYNC
               REPL_SYNC
               INVALIDATION_ASYNC
               INVALIDATION_SYNC
               -->
               <attribute name="CacheMode">LOCAL</attribute>
              
               <!-- Name of cluster. Needs to be the same for all clusters, in order
               to find each other
               -->
               <attribute name="ClusterName">DelegatingCacheLoader-Cluster</attribute>
              
               <!-- JGroups protocol stack properties. Can also be a URL,
               e.g. file:/home/bela/default.xml
               <attribute name="ClusterProperties"></attribute>
               -->
               <!-- This ORIGINAL CONFIF OF JGROUPS -->
               <attribute name="ClusterConfig">
               <config>
               <!-- UDP: if you have a multihomed machine,
               set the bind_addr attribute to the appropriate NIC IP address -->
               <!-- UDP: On Windows machines, because of the media sense feature
               being broken with multicast (even after disabling media sense)
               set the loopback attribute to true -->
               <UDP mcast_addr="228.1.2.3" mcast_port="48866"
               ip_ttl="64" ip_mcast="true"
               mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
               ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
               loopback="false"/>
               <PING timeout="2000" num_initial_members="3"
               up_thread="false" down_thread="false"/>
               <MERGE2 min_interval="10000" max_interval="20000"/>
               <!-- <FD shun="true" up_thread="true" down_thread="true"/> -->
              
               <FD_SOCK/>
               <VERIFY_SUSPECT timeout="1500"
               up_thread="false" down_thread="false"/>
               <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
               up_thread="false" down_thread="false"/>
               <pbcast.STABLE desired_avg_gossip="20000"
               up_thread="false" down_thread="false"/>
               <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10"
               down_thread="false"/>
               <FRAG frag_size="8192"
               down_thread="false" up_thread="false"/>
               <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
               shun="true" print_local_addr="true"/>
               <pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/>
               </config>
               </attribute>
              
               <!--
               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
               -->
               <attribute name="InitialStateRetrievalTimeout">20000</attribute>
              
               <!--
               Number of milliseconds to wait until all responses for a
               synchronous call have been received.
               -->
               <attribute name="SyncReplTimeout">15000</attribute>
              
               <!-- Max number of milliseconds to wait for a lock acquisition -->
               <attribute name="LockAcquisitionTimeout">10000</attribute>
              
               <!--
               <attribute name="EvictionPolicyClass"></attribute>
               -->
              
               <!-- Name of the eviction policy class. We have commented it off to disable eviction.
               -->
               <attribute name="EvictionPolicyClass">org.jboss.cache.aop.eviction.AopLRUPolicy</attribute>
              
               <!-- Specific eviction policy configurations. This is LRU -->
               <attribute name="EvictionPolicyConfig">
               <config>
               <attribute name="wakeUpIntervalSeconds">5</attribute>
               <!-- Cache wide default -->
               <region name="/_default_">
               <attribute name="maxNodes">1000</attribute>
               <attribute name="timeToLiveSeconds">600</attribute>
               <attribute name="maxAgeSeconds">1200</attribute>>
               </region>
               <!--
               <region name="/aop">
               <attribute name="maxNodes">5</attribute>
               <attribute name="timeToLiveSeconds">4</attribute>
               </region>
               <region name="/pojo">
               <attribute name="maxNodes">100</attribute>
               <attribute name="timeToLiveSeconds">4</attribute>
               </region>
               <region name="/testMaxNode">
               <attribute name="maxNodes">4</attribute>
               <attribute name="timeToLiveSeconds">100</attribute>
               </region> -->
               </config>
               </attribute>
               <attribute name="CacheLoaderConfiguration">
               <config>
               <cacheloader>
               <class>org.jboss.cache.loader.tcp.MyTcpDelegatingCacheLoader</class>
               <!--<class>com.procyonsoluciones.mobistore.core.commom.cache.TcpDelegatingCache</class> -->
               <properties>
               host=localhost
               port=7500
               </properties>
               <ignoreModifications>true</ignoreModifications>
               </cacheloader>
               </config>
               </attribute>
               </mbean>
              
              </server>



              Later I try to store an object in my DelegatingCacheLoader through JMX Console (key= name, value = myname) and when i invoke the put Operation in DelegatingCacheLoader service this never end, it seems to be waiting for something. No error message is thrown. did I some wrong or i need to configure something else?

              Thanks in advance

              • 4. Re: Can TcpDelegatingCacheLoader only delegate remove node?
                manik

                get and getChildrenNames should return empty collections, not nulls. Nulls imply that the node in question does not exist.