4 Replies Latest reply: Oct 30, 2012 4:18 PM by 691896 RSS

    Push Replication issues

    691896
      Hi guys,

      I am trying to setup push replication in a grid and I am getting an exception when I try to do a put in the replicated cache:
      java.lang.ClassCastException: runtime.util.misc.GUID cannot be cast to com.tangosol.util.Binary
           at com.tangosol.net.cache.ReadWriteBackingMap.instantiateEntry(ReadWriteBackingMap.java:2995)
           at com.tangosol.net.cache.ReadWriteBackingMap$BinaryEntryStoreWrapper.loadInternal(ReadWriteBackingMap.java:5952)
           at com.tangosol.net.cache.ReadWriteBackingMap$StoreWrapper.load(ReadWriteBackingMap.java:4749)
           at com.tangosol.net.cache.ReadWriteBackingMap.get(ReadWriteBackingMap.java:717)
      I think the issue is that this cache is replicated and read-write-backing-map-scheme seems to not work with replicated caches. Is that the case?

      Another thing is that for both replicated and one of the distributed services I need to have some local listeners. Could there be any issue?

      Before trying to use push-replication I was using a <local-scheme> for the backing map but when I try to use with push replication with it I get the following error:
      java.lang.ClassCastException: com.oracle.coherence.patterns.pushreplication.PublishingCacheStore cannot be cast to com.tangosol.net.cache.CacheLoader
           at com.tangosol.net.DefaultConfigurableCacheFactory.instantiateLocalCache(DefaultConfigurableCacheFactory.java:2153)
           at com.tangosol.net.DefaultConfigurableCacheFactory.configureBackingMap(DefaultConfigurableCacheFactory.java:1492)
           at com.tangosol.net.DefaultConfigurableCacheFactory$Manager.instantiateBackingMap(DefaultConfigurableCacheFactory.java:4111)
      Do you think the best way of dealing with this is to continue using <local-scheme> and create an adaptor class from CacheLoader to PublishingCacheStore ?

      Thanks in advance,
      Mikel.

      Config using read-write-backing-map-scheme :
      <?xml version='1.0'?>
      
      <cache-config xmlns:element="class://com.oracle.coherence.environment.extensible.namespaces.XmlElementProcessingNamespaceContentHandler"
                    xmlns:event="class://com.oracle.coherence.patterns.eventdistribution.configuration.EventDistributionNamespaceContentHandler"
                    xmlns:cr="class:com.oracle.coherence.environment.extensible.namespaces.InstanceNamespaceContentHandler">
      
        <defaults>
          <serializer>pof</serializer>
        </defaults>
      
        <caching-scheme-mapping>
          <cache-mapping>
            <cache-name>publishing-cache</cache-name>
            <scheme-name>distributed-scheme-with-publishing-cachestore</scheme-name>
      
            <event:distributor>
              <event:distributor-name>{cache-name}</event:distributor-name>
              <event:distributor-external-name>{site-name}-{cluster-name}-{cache-name}</event:distributor-external-name>
      
              <event:distributor-scheme>
                <event:coherence-based-distributor-scheme/>
              </event:distributor-scheme>
      
              <event:distribution-channels>
                <event:distribution-channel>
                  <event:channel-name system-property="coherence.channel.name">Active1 Publisher</event:channel-name>
                  <event:starting-mode system-property="coherence.channel.starting.mode">enabled</event:starting-mode>
      
                  <event:channel-scheme>
                    <event:remote-cluster-channel-scheme>
                      <event:remote-invocation-service-name>remote-site</event:remote-invocation-service-name>
                      <event:remote-channel-scheme>
                        <event:local-cache-channel-scheme>
                          <event:target-cache-name>publishing-cache</event:target-cache-name>
                          <event:conflict-resolver-scheme>
                            <cr:class classname="com.oracle.coherence.patterns.eventdistribution.channels.cache.BruteForceConflictResolver"/>
                          </event:conflict-resolver-scheme>
                        </event:local-cache-channel-scheme>
                      </event:remote-channel-scheme>
                    </event:remote-cluster-channel-scheme>
                  </event:channel-scheme>
                </event:distribution-channel>
              </event:distribution-channels>
            </event:distributor>
          </cache-mapping>
      
          <cache-mapping>
            <cache-name>CoherenceCachesMetaData</cache-name>
            <scheme-name>caches-meta-info</scheme-name>
          </cache-mapping>
          <cache-mapping>
            <cache-name>*</cache-name>
            <scheme-name>distributed-scheme</scheme-name>
          </cache-mapping>
          <cache-mapping>
            <cache-name>CoherenceCachesIndexes*</cache-name>
            <scheme-name>indexing-scheme</scheme-name>
          </cache-mapping>
        </caching-scheme-mapping>
        <caching-schemes>
      
          <remote-invocation-scheme>
            <service-name>remote-site</service-name>
            <initiator-config>
              <tcp-initiator>
                <remote-addresses>
                  <socket-address>
                    <address>localhost</address>
                    <port>48020</port>
                  </socket-address>
                </remote-addresses>
                <connect-timeout>2s</connect-timeout>
              </tcp-initiator>
              <outgoing-message-handler>
                <request-timeout>5s</request-timeout>
              </outgoing-message-handler>
            </initiator-config>
          </remote-invocation-scheme>
      
          <replicated-scheme>
            <scheme-name>caches-meta-info</scheme-name>
            <service-name>CachesMetadataInfo</service-name>
            <backing-map-scheme>
              <read-write-backing-map-scheme>
                <scheme-ref>distributed-backing-map</scheme-ref>
              </read-write-backing-map-scheme>
            </backing-map-scheme>
          </replicated-scheme>
      
          <distributed-scheme>
            <scheme-name>indexing-scheme</scheme-name>
            <service-name>DistributedCacheIndexing</service-name>
            <thread-count>5</thread-count>
            <partition-count>101</partition-count>
            <backup-count>1</backup-count>
      
            <backing-map-scheme>
              <read-write-backing-map-scheme>
                <internal-cache-scheme>
                  <local-scheme/>
                </internal-cache-scheme>
                <cachestore-scheme>
                  <class-scheme>
                    <class-name>com.oracle.coherence.patterns.pushreplication.PublishingCacheStore</class-name>
                    <init-params>
                      <init-param>
                        <param-type>java.lang.String</param-type>
                        <param-value>{cache-name}</param-value>
                      </init-param>
                    </init-params>
                  </class-scheme>
                </cachestore-scheme>
              </read-write-backing-map-scheme>
            </backing-map-scheme>
      
            <autostart>true</autostart>
          </distributed-scheme>
      
          <distributed-scheme>
            <scheme-name>distributed-scheme</scheme-name>
            <service-name>DistributedCache</service-name>
            <thread-count>5</thread-count>
            <partition-count>101</partition-count>
            <backup-count>1</backup-count>
            <backing-map-scheme>
              <read-write-backing-map-scheme>
                <scheme-ref>distributed-backing-map</scheme-ref>
              </read-write-backing-map-scheme>
            </backing-map-scheme>
            <autostart>true</autostart>
          </distributed-scheme>
      
          <read-write-backing-map-scheme>
            <scheme-name>distributed-backing-map</scheme-name>
            <internal-cache-scheme>
              <local-scheme/>
            </internal-cache-scheme>
            <cachestore-scheme>
              <class-scheme>
                <class-name>com.oracle.coherence.patterns.pushreplication.PublishingCacheStore</class-name>
                <init-params>
                  <init-param>
                    <param-type>java.lang.String</param-type>
                    <param-value>{cache-name}</param-value>
                  </init-param>
                </init-params>
              </class-scheme>
            </cachestore-scheme>
            <listener>
                <class-name>service.data.manager.coherence.impl.DelegateMapListener</class-name>
                <init-params>
                  <init-param>
                    <param-type>java.lang.String</param-type>
                    <param-value>
                      service.data.manager.coherence.impl.index.IndexMapListener,
                      service.data.manager.coherence.impl.MetadataCacheDelegateBackingMapListener
                    </param-value>
                  </init-param>
                  <init-param>
                    <param-type>com.tangosol.net.BackingMapManagerContext</param-type>
                    <param-value>{manager-context}</param-value>
                  </init-param>
                  <init-param>
                    <param-type>java.lang.String</param-type>
                    <param-value>{cache-name}</param-value>
                  </init-param>
                </init-params>
            </listener>
      
          </read-write-backing-map-scheme>
      
          <proxy-scheme>
            <service-name>ExtendTcpProxyService</service-name>
            <acceptor-config>
              <tcp-acceptor>
                <local-address>
                  <address>localhost</address>
                  <port>48010</port>
                </local-address>
              </tcp-acceptor>
            </acceptor-config>
            <autostart>true</autostart>
          </proxy-scheme>
      
          <invocation-scheme>
            <service-name>InvocationService</service-name>
            <thread-count>5</thread-count>
            <autostart>true</autostart>
          </invocation-scheme>
        </caching-schemes>
      </cache-config>
      Config using <local-scheme>:
      <?xml version='1.0'?>
      
      <cache-config xmlns:element="class://com.oracle.coherence.environment.extensible.namespaces.XmlElementProcessingNamespaceContentHandler"
                    xmlns:event="class://com.oracle.coherence.patterns.eventdistribution.configuration.EventDistributionNamespaceContentHandler"
                    xmlns:cr="class:com.oracle.coherence.environment.extensible.namespaces.InstanceNamespaceContentHandler">
      
        <defaults>
          <serializer>pof</serializer>
        </defaults>
      
        <caching-scheme-mapping>
          <cache-mapping>
            <cache-name>publishing-cache</cache-name>
            <scheme-name>distributed-scheme-with-publishing-cachestore</scheme-name>
      
            <event:distributor>
              <event:distributor-name>{cache-name}</event:distributor-name>
              <event:distributor-external-name>{site-name}-{cluster-name}-{cache-name}</event:distributor-external-name>
      
              <event:distributor-scheme>
                <event:coherence-based-distributor-scheme/>
              </event:distributor-scheme>
      
              <event:distribution-channels>
                <event:distribution-channel>
                  <event:channel-name system-property="coherence.channel.name">Active1 Publisher</event:channel-name>
                  <event:starting-mode system-property="coherence.channel.starting.mode">enabled</event:starting-mode>
      
                  <event:channel-scheme>
                    <event:remote-cluster-channel-scheme>
                      <event:remote-invocation-service-name>remote-site</event:remote-invocation-service-name>
                      <event:remote-channel-scheme>
                        <event:local-cache-channel-scheme>
                          <event:target-cache-name>publishing-cache</event:target-cache-name>
                          <event:conflict-resolver-scheme>
                            <cr:class classname="com.oracle.coherence.patterns.eventdistribution.channels.cache.BruteForceConflictResolver"/>
                          </event:conflict-resolver-scheme>
                        </event:local-cache-channel-scheme>
                      </event:remote-channel-scheme>
                    </event:remote-cluster-channel-scheme>
                  </event:channel-scheme>
                </event:distribution-channel>
              </event:distribution-channels>
            </event:distributor>
          </cache-mapping>
      
          <cache-mapping>
            <cache-name>CoherenceCachesMetaData</cache-name>
            <scheme-name>caches-meta-info</scheme-name>
          </cache-mapping>
          <cache-mapping>
            <cache-name>*</cache-name>
            <scheme-name>distributed-scheme</scheme-name>
          </cache-mapping>
          <cache-mapping>
            <cache-name>CoherenceCachesIndexes*</cache-name>
            <scheme-name>indexing-scheme</scheme-name>
          </cache-mapping>
        </caching-scheme-mapping>
        <caching-schemes>
      
          <remote-invocation-scheme>
            <service-name>remote-site</service-name>
            <initiator-config>
              <tcp-initiator>
                <remote-addresses>
                  <socket-address>
                    <address>localhost</address>
                    <port>48020</port>
                  </socket-address>
                </remote-addresses>
                <connect-timeout>2s</connect-timeout>
              </tcp-initiator>
              <outgoing-message-handler>
                <request-timeout>5s</request-timeout>
              </outgoing-message-handler>
            </initiator-config>
          </remote-invocation-scheme>
      
          <replicated-scheme>
            <scheme-name>caches-meta-info</scheme-name>
            <service-name>CachesMetadataInfo</service-name>
            <backing-map-scheme>
              <local-scheme>
                <scheme-ref>distributed-backing-map</scheme-ref>
              </local-scheme>
            </backing-map-scheme>
          </replicated-scheme>
      
          <distributed-scheme>
            <scheme-name>indexing-scheme</scheme-name>
            <service-name>DistributedCacheIndexing</service-name>
            <thread-count>5</thread-count>
            <partition-count>101</partition-count>
            <backup-count>1</backup-count>
      
            <backing-map-scheme>
              <local-scheme>
                <cachestore-scheme>
                  <class-scheme>
                    <class-name>com.oracle.coherence.patterns.pushreplication.PublishingCacheStore</class-name>
                    <init-params>
                      <init-param>
                        <param-type>java.lang.String</param-type>
                        <param-value>{cache-name}</param-value>
                      </init-param>
                    </init-params>
                  </class-scheme>
                </cachestore-scheme>
              </local-scheme>
            </backing-map-scheme>
      
            <autostart>true</autostart>
          </distributed-scheme>
      
          <distributed-scheme>
            <scheme-name>distributed-scheme</scheme-name>
            <service-name>DistributedCache</service-name>
            <thread-count>5</thread-count>
            <partition-count>101</partition-count>
            <backup-count>1</backup-count>
            <backing-map-scheme>
              <local-scheme>
                <scheme-ref>distributed-backing-map</scheme-ref>
              </local-scheme>
            </backing-map-scheme>
            <autostart>true</autostart>
          </distributed-scheme>
      
          <local-scheme>
            <scheme-name>distributed-backing-map</scheme-name>
            <cachestore-scheme>
              <class-scheme>
                <class-name>com.oracle.coherence.patterns.pushreplication.PublishingCacheStore</class-name>
                <init-params>
                  <init-param>
                    <param-type>java.lang.String</param-type>
                    <param-value>{cache-name}</param-value>
                  </init-param>
                </init-params>
              </class-scheme>
            </cachestore-scheme>
            <listener>
                <class-name>service.data.manager.coherence.impl.DelegateMapListener</class-name>
                <init-params>
                  <init-param>
                    <param-type>java.lang.String</param-type>
                    <param-value>
                      service.data.manager.coherence.impl.index.IndexMapListener,
                      service.data.manager.coherence.impl.MetadataCacheDelegateBackingMapListener
                    </param-value>
                  </init-param>
                  <init-param>
                    <param-type>com.tangosol.net.BackingMapManagerContext</param-type>
                    <param-value>{manager-context}</param-value>
                  </init-param>
                  <init-param>
                    <param-type>java.lang.String</param-type>
                    <param-value>{cache-name}</param-value>
                  </init-param>
                </init-params>
            </listener>
      
          </local-scheme>
      
          <proxy-scheme>
            <service-name>ExtendTcpProxyService</service-name>
            <acceptor-config>
              <tcp-acceptor>
                <local-address>
                  <address>localhost</address>
                  <port>48010</port>
                </local-address>
              </tcp-acceptor>
            </acceptor-config>
            <autostart>true</autostart>
          </proxy-scheme>
      
          <invocation-scheme>
            <service-name>InvocationService</service-name>
            <thread-count>5</thread-count>
            <autostart>true</autostart>
          </invocation-scheme>
        </caching-schemes>
      </cache-config>
      Edited by: Mikel_Alcon on Aug 30, 2012 10:43 AM
        • 1. Re: Push Replication issues
          691896
          Now I've been trying to do an adaptor from CacheStore to BinaryEntryStore, but CacheStore does not have all the information required for constructing a BinaryEntry (previousValue).

          My last idea of how to deal with this is to put a backingmap listener that pass the events to the PublishingCacheStore.

          Is this Ok?

          Thanks in advance,
          Mikel.
          • 2. Re: Push Replication issues
            691896
            Anyone has this issue?
            • 3. Re: Push Replication issues
              691896
              Anyone had this issue?
              • 4. Re: Push Replication issues
                691896
                What I've endup doing for Replicated Caches is the following:

                Put a backing map listener to the replicated cache. Inside the listener I have a PublishMessageProcessor instance. So everytime I receive an event I create a mock binaryEntry ( I am extending SimpleBinaryEntry and pass the context of the replicated cache). In this way I am able to publish the events and it reach the other side (another cluster).

                In the other side ( the cluster that receives the event) what I've done is to extend LocalCacheEventChannel to overwrite the send method since CacheEventChannelHelper assumes that the local cache is a Binary cache. There I process the event and do my own conflict resolution ( I could use conflict resolver but for my case I only have one replicated cache with a very well defined resolving mechanism.

                Anyone thinks this is a bad idea? Should I be doing it in another way ?

                Thanks in advance,
                Mikel.