Sunday, September 5, 2010

ALSB (OSB) Coherence Cache Provider

From OSB logs:



Creating WorkManager from "weblogic.wsee.mdb.DispatchPolicy" WorkManagerMBean for application "ALSB Coherence Cache Provider"

Oracle Coherence 3.5.3/465p2 (member=n/a): Loaded operational configuration from resource "zip:/Oracle/Middleware/coherence_3.5/lib/coherence.jar!/tangosol-coherence.xml

Oracle Coherence 3.5.3/465p2 (member=n/a): Loaded operational overrides from resource "zip:/Oracle/Middleware/user_projects/domains/OSBDomainBasic/servers/AdminServer/tmp/_WL_user/ALSB Coherence Cache Provider/sm027g/APP-INF/lib/com.bea.alsb.coherence-impl.jar!/tangosol-coherence-override.xml


Oracle Coherence 3.5.3/465p2 (member=n/a): Loaded operational overrides from resource "file:/Oracle/Middleware/user_projects/domains/OSBDomainBasic/config/osb/coherence/osb-coherence-override.xml




Oracle Coherence 3.5.3/465p2 (member=n/a): Created a new cluster "OSB-cluster" with Member(Id=1, Timestamp=2010-09-04 19:00:46.957, Address=127.0.0.1:7890, MachineId=32896, Location=site:localdomain,machine:localhost,process:9285, Role=OSB-node, Edition=Grid Edition, Mode=Production, CpuCount=2, SocketCount=2) UID=0x7F0000010000012ADDB16DED80801ED2




So I gather that OSB internally uses the "ALSB Coherence Cache Provider" Enterprise Application, deployed as /Oracle/Middleware/Oracle_OSB1/lib/coherence.ear and targeted to the cluster.

This ear contains:

jar xvf coherence.ear

created: META-INF/
inflated: META-INF/MANIFEST.MF
inflated: META-INF/application.xml
created: APP-INF/
created: APP-INF/classes/
created: APP-INF/classes/com/
created: APP-INF/classes/com/bea/
created: APP-INF/classes/com/bea/alsb/
created: APP-INF/classes/com/bea/alsb/coherence/
created: APP-INF/classes/com/bea/alsb/coherence/init/
created: APP-INF/lib/
inflated: APP-INF/classes/com/bea/alsb/coherence/init/CoherenceAppListener$1.class
inflated: APP-INF/classes/com/bea/alsb/coherence/init/CoherenceAppListener.class
inflated: APP-INF/lib/com.bea.alsb.coherence-impl.jar
inflated: META-INF/weblogic-application.xml



the META-INF/weblogic-application.xml is revealing, basically it says "disregard any classes com.tangosol...." already loaded in the System classpath and load them in my EAR classloader. THIS IS EXTREMELY IMPORTANT! For multiple clusters to work in the same JVM, the coherence framework classes must be loaded in separate classloaders!



        com.bea.alsb.coherence.init.CoherenceAppListener


        com.tangosol.*





Here is the content of the "client-side" library jar, with the strategic tangosol-coherence-override.xml:


jar xvf com.bea.alsb.coherence-impl.jar
created: META-INF/
inflated: META-INF/MANIFEST.MF
created: com/
created: com/bea/
created: com/bea/alsb/
created: com/bea/alsb/coherence/
created: com/bea/alsb/coherence/impl/
created: com/bea/alsb/coherence/impl/messages/
inflated: com/bea/alsb/coherence/impl/messages/CoherenceLogLogger$MessageLoggerInitializer.class
inflated: com/bea/alsb/coherence/impl/messages/CoherenceLogLogger.class
inflated: com/bea/alsb/coherence/impl/messages/CoherenceLogLogLocalizer.properties
inflated: com/bea/alsb/coherence/impl/messages/CoherenceLogLogLocalizerDetail.properties
inflated: tangosol-coherence-override.xml
inflated: com/bea/alsb/coherence/impl/CacheValue.class
inflated: com/bea/alsb/coherence/impl/CoherenceCache$1.class
inflated: com/bea/alsb/coherence/impl/CoherenceCache$RemoveProcessor.class
inflated: com/bea/alsb/coherence/impl/CoherenceCache.class
inflated: com/bea/alsb/coherence/impl/CoherenceNotInstalledException.class
inflated: com/bea/alsb/coherence/impl/CoherenceProvider.class
inflated: com/bea/alsb/coherence/impl/CoherenceProviderFactory.class
inflated: com/bea/alsb/coherence/impl/ConfigurationException.class
inflated: com/bea/alsb/coherence/impl/OwnerValueExtractor.class



in this instance, tangosol-coherence-override.xml doesn't override the OOTB settings, it simply defines the cluster-name:


    
        
            OSB-cluster
            OSB-node
        
    
    
        jdk
        Oracle Coherence {version} (member={member}): {text}
    





And the Initializing class does this:

package com.bea.alsb.coherence.init;

import com.bea.alsb.coherence.CacheProviderManager;
import com.bea.alsb.coherence.impl.*;
import com.bea.alsb.coherence.init.messages.CoherenceLogLogger;
import java.util.logging.*;
import weblogic.application.ApplicationLifecycleEvent;
import weblogic.application.ApplicationLifecycleListener;
import weblogic.logging.LoggingHelper;

public class CoherenceAppListener extends ApplicationLifecycleListener
{

    public CoherenceAppListener()
    {
    }

    public void preStart(ApplicationLifecycleEvent evt)
    {
        try
        {
            redirectCoherenceLogger();
            com.bea.alsb.coherence.CacheProvider provider = CoherenceProviderFactory.newInstance("/coherence/osb-coherence-cache-config.xml");
            CacheProviderManager.initialize(provider);
            CoherenceLogLogger.logCacheProviderInitialized(provider);
        }
        catch(CoherenceNotInstalledException ex)
        {
            CacheProviderManager.reset();
            CoherenceLogLogger.raiseCoherenceNotInstalled();
        }
        catch(ConfigurationException ex)
        {
            CacheProviderManager.reset();
            CoherenceLogLogger.raiseInvalidConfiguration(ex);
        }
    }

    public void postStop(ApplicationLifecycleEvent applicationLifecycleEvent)
    {
        try
        {
            CacheProviderManager.reset();
            CoherenceLogLogger.logCacheProviderReset();
        }
        catch(Exception ex)
        {
            CoherenceLogLogger.raiseShutdownError(ex);
        }
    }

    private static void redirectCoherenceLogger()
    {
        Handler h = new Handler() {

            public void close()
                throws SecurityException
            {
            }

            public void flush()
            {
            }

            public void publish(LogRecord record)
            {
                if(serverLogger != null)
                    serverLogger.log(record);
            }

            Logger serverLogger;

           
            {
                serverLogger = LoggingHelper.getServerLogger();
            }
        }
;
        Logger coherenceLogger = Logger.getLogger("Coherence");
        coherenceLogger.setLevel(Level.ALL);
        coherenceLogger.addHandler(h);
        coherenceLogger.setUseParentHandlers(false);
    }

    private static final String CONFIG_FILE = "/coherence/osb-coherence-cache-config.xml";
    private static final String COHERENCE_LOGGER_NAME = "Coherence";
}







This osb-coherence-cache-config.xml is actually in $DOMAIN_HOME/config/osb/coherence/osb-coherence-cache-config.xml, this file was shown above.



Incidentally, the content of $DOMAIN_HOME/config/osb/coherence/osb-coherence-override.xml contains the network parameters for this cluster; it is evident that each cluster must provide its configuration:



        
        
                
                        
                
                    
127.0.0.1
7890
127.0.0.1
7890
0



But, wait a second, what is this com.bea.alsb.coherence.CacheProviderManager ?

It turns out that CacheProviderManager is in /Oracle/Middleware/Oracle_OSB1/lib/modules/com.bea.alsb.coherence-api.jar. It's a basic singleton holder class for a SINGLE instance of CacheProvider - which means that in OSB only 1 OSB cache provider is supported. So if we want to access to our "custom " cache provider we must find another path: it's necessary to instantiate the tangosol classes in the same EAR (or WAR) where the client resides; or otherwise find a mechanism where we register the classloader of the CacheProvider and we retrieve from somewhere else.

1 comment:

praveen kumar dendukuri said...

OSB ResultCache Invalidation:

Hi,

I am working on OSB-Coherence Integration.But i am not getting how the data is stored in OSB Resultcache. when i connected to the Resultcache through Coherence Console and when i type list there,it is displaying as below:



Map (?): cache /osb/service/ResultCache

2013-07-30 19:20:54.888/13.256 Oracle Coherence GE 3.6.0.4 (thread=main, member=3): Loaded cache configuration from "file:/D:/Oracle/Middleware/user_projects/domai

2013-07-30 19:20:55.112/13.480 Oracle Coherence GE 3.6.0.4 (thread=DistributedCache:ORA-OSB-deployments, member=3): Service ORA-OSB-deployments joined the cluster wi



expiring-distributed

ORA-OSB-deployments





expiring-backing-map





true





Map (/osb/service/ResultCache): list

PipelineResultCacheKey[BusinessService Customer/CustomerBS,getCustomerdetails,3) = owner=BusinessService Customer/CustomerBS,value=[B@1167e3a5


But i want to know exactly what is the datatype of key it is using and the object structure(skeleton of the object) which it is storing as value.



Any suggestions would be great.


Thanks,

Praveen