Search This Blog

Monday 20 December 2010

Querying Coherence Cache from JRuby

To complete the Coherence/JRuby demos this final demo shows how we can query the cache using filters to show the data we are interested in. From this demo you can see our cache has the oracle data dictionary view ALL_DB_OBJECTS data which was loaded from an 11.2.0.2 RDBMS. The output will make that obvious.

JRuby script is as follows - coh-extend-client-query.rb
require 'java'
require 'C:/jdev/scripting/demos/jruby/extendclient-coherence/extenddemo.jar'
require 'C:/jdev/coherence/36/coherence/lib/coherence.jar'

include_class "pas.au.coherence.extend.server.AllDBObject"
import com.tangosol.net.CacheFactory
import com.tangosol.net.NamedCache
import java.util.Date
import java.lang.System
import java.math.BigDecimal
import java.util.Set

puts "***********************************************"
puts "Coherence 3.6 Extend Client Example from JRUBY"
puts "***********************************************"

print "Started at ", Date.new.toString, "\n"

begin

  # setup required properties to connect to proxy server as extend client
  System.setProperty("tangosol.pof.enabled", "true")
  System.setProperty("tangosol.pof.config", "extend-pof-config.xml")
  System.setProperty("tangosol.coherence.cacheconfig", "client-cache-config.xml")
  System.setProperty("proxy.host", "papicell-au2.au.oracle.com")

  # get named cache alldbobjs
  alldbobjs = CacheFactory.getCache("alldbobjs")

  #retrieve size of cache
  print "\nCache [alldbobjs] size  = " + alldbobjs.size().to_s + "\n\n"
  
  #retrieve all SCOTT schema entries
  filter = com.tangosol.util.filter.EqualsFilter.new("getOwner", "SCOTT")
  scottObjects = alldbobjs.entrySet(filter)
  
  #iterate through SCOTT's objects 
  print "\nTotal of " + scottObjects.size().to_s + " cache entries found \n"

  print "Is scottObjects empty : ", scottObjects.empty?, "\n"
  puts
  
  iterator = scottObjects.iterator()
  while iterator.hasNext()
    entry = iterator.next()
    print "Key : [" + entry.getKey().to_s + "] "
    print "Value : [Owner=" + entry.getValue().getOwner() + 
          ", objectName=" + entry.getValue().getObjectName() +
          ", objectType=" + entry.getValue().getObjectType() + "]"
    puts
  end
  
rescue 
  print "\n** Error occured **\n"
 print "Failed to access Coherence Cluster from proxy server -> \n", $!, "\n\n"
  
end

puts
print "Ended at ", Date.new.toString, "\n"

The output when run shows the SCOTT schema objects being queried from the cache


C:\jdev\scripting\demos\jruby\extendclient-coherence>vi coh-extend-client-query.rb


C:\jdev\scripting\demos\jruby\extendclient-coherence>jrb coh-extend-client-query.rb
***********************************************
Coherence 3.6 Extend Client Example from JRUBY
***********************************************
Started at Mon Dec 20 07:36:52 EST 2010
2010-12-20 07:36:52.752/0.869 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:
/jdev/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence.xml"
2010-12-20 07:36:52.756/0.873 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/jde
v/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2010-12-20 07:36:52.756/0.873 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-
override.xml" is not specified
2010-12-20 07:36:52.759/0.876 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml"
is not specified


Oracle Coherence Version 3.6.0.0 Build 17229
 Grid Edition: Development mode
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.


2010-12-20 07:36:52.945/1.062 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Loaded cache configuration from "jar:file:/C:/jd
ev/scripting/demos/jruby/extendclient-coherence/extenddemo.jar!/client-cache-config.xml"
2010-12-20 07:36:53.107/1.224 Oracle Coherence GE 3.6.0.0 (thread=RemoteCache:TcpInitiator, member=n/a): Loaded POF configuration fro
m "jar:file:/C:/jdev/scripting/demos/jruby/extendclient-coherence/extenddemo.jar!/extend-pof-config.xml"
2010-12-20 07:36:53.111/1.228 Oracle Coherence GE 3.6.0.0 (thread=RemoteCache:TcpInitiator, member=n/a): Loaded included POF configur
ation from "jar:file:/C:/jdev/coherence/36/coherence/lib/coherence.jar!/coherence-pof-config.xml"
2010-12-20 07:36:53.214/1.331 Oracle Coherence GE 3.6.0.0 (thread=RemoteCache:TcpInitiator, member=n/a): Started: TcpInitiator{Name=Rem
oteCache:TcpInitiator, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), PingInterval=0, PingTimeout=0, RequestTimeout=0, Con
nectTimeout=0, SocketProvider=SystemSocketProvider, RemoteAddresses=[papicell-au2.au.oracle.com/10.187.80.136:9099]}
2010-12-20 07:36:53.218/1.335 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Opening Socket connection to 10.187.80.136:9099
2010-12-20 07:36:53.220/1.337 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Connected to 10.187.80.136:9099


Cache [alldbobjs] size  = 99927




Total of 55 cache entries found
Is scottObjects empty : false


Key : [82967] Value : [Owner=SCOTT, objectName=TEST_STRING, objectType=TABLE]
Key : [126758] Value : [Owner=SCOTT, objectName=Host2, objectType=JAVA CLASS]
Key : [128400] Value : [Owner=SCOTT, objectName=DISPLAYPROPERTIES, objectType=FUNCTION]
Key : [173453] Value : [Owner=SCOTT, objectName=SYS_LOB0000173452C00002$$, objectType=LOB]
Key : [128399] Value : [Owner=SCOTT, objectName=CheckProperties, objectType=JAVA CLASS]
Key : [85457] Value : [Owner=SCOTT, objectName=JUNKPR, objectType=PROCEDURE]
Key : [150089] Value : [Owner=SCOTT, objectName=HELLOWORLDPKG, objectType=PACKAGE]
Key : [155471] Value : [Owner=SCOTT, objectName=CELCIUSTOFAHRENHEIT, objectType=FUNCTION]
Key : [91848] Value : [Owner=SCOTT, objectName=SYS_C0019928, objectType=INDEX]
Key : [82964] Value : [Owner=SCOTT, objectName=TEST_TYP, objectType=TYPE]
Key : [150088] Value : [Owner=SCOTT, objectName=pas/au/jsp/DemoJSP, objectType=JAVA CLASS]
Key : [82966] Value : [Owner=SCOTT, objectName=TEST_PROC1, objectType=PROCEDURE]
Key : [91846] Value : [Owner=SCOTT, objectName=SYS_LOB0000091845C00002$$, objectType=LOB]
Key : [73200] Value : [Owner=SCOTT, objectName=PK_DEPT, objectType=INDEX]
Key : [91849] Value : [Owner=SCOTT, objectName=xp_cmdshell, objectType=JAVA CLASS]
Key : [91855] Value : [Owner=SCOTT, objectName=xp_cmdshell, objectType=JAVA SOURCE]
Key : [126760] Value : [Owner=SCOTT, objectName=HOST_API, objectType=PACKAGE BODY]
Key : [173456] Value : [Owner=SCOTT, objectName=FORMMODEL_INS_TRG, objectType=TRIGGER]
Key : [73199] Value : [Owner=SCOTT, objectName=DEPT, objectType=TABLE]
Key : [155571] Value : [Owner=SCOTT, objectName=SAYHELLONAME, objectType=FUNCTION]
Key : [169925] Value : [Owner=SCOTT, objectName=DEPT_LIST_TABLE, objectType=TYPE]
Key : [173144] Value : [Owner=SCOTT, objectName=CUSTOMER, objectType=TABLE]
Key : [91850] Value : [Owner=SCOTT, objectName=DOIT, objectType=PROCEDURE]
Key : [160445] Value : [Owner=SCOTT, objectName=runhttprequest, objectType=JAVA SOURCE]
Key : [169926] Value : [Owner=SCOTT, objectName=WS_PACKAGE, objectType=PACKAGE]
Key : [73204] Value : [Owner=SCOTT, objectName=SALGRADE, objectType=TABLE]
Key : [160648] Value : [Owner=SCOTT, objectName=SYS_C0046421, objectType=INDEX]
Key : [140715] Value : [Owner=SCOTT, objectName=DRIVERVERSION, objectType=PROCEDURE]
Key : [160446] Value : [Owner=SCOTT, objectName=RunHttpRequest, objectType=JAVA CLASS]
Key : [173455] Value : [Owner=SCOTT, objectName=FORMMODEL_PK, objectType=INDEX]
Key : [73202] Value : [Owner=SCOTT, objectName=PK_EMP, objectType=INDEX]
Key : [169927] Value : [Owner=SCOTT, objectName=WS_PACKAGE, objectType=PACKAGE BODY]
Key : [173452] Value : [Owner=SCOTT, objectName=FORMMODEL, objectType=TABLE]
Key : [79037] Value : [Owner=SCOTT, objectName=XML_PACKAGE, objectType=PACKAGE]
Key : [91845] Value : [Owner=SCOTT, objectName=CREATE$JAVA$LOB$TABLE, objectType=TABLE]
Key : [160890] Value : [Owner=SCOTT, objectName=MYTEST3, objectType=TABLE]
Key : [160647] Value : [Owner=SCOTT, objectName=CAL, objectType=TABLE]
Key : [155581] Value : [Owner=SCOTT, objectName=SAYHELLONAME_SYS, objectType=FUNCTION]
Key : [79038] Value : [Owner=SCOTT, objectName=XML_PACKAGE, objectType=PACKAGE BODY]
Key : [169924] Value : [Owner=SCOTT, objectName=DEPT_TYPE, objectType=TYPE]
Key : [85455] Value : [Owner=SCOTT, objectName=Junk, objectType=JAVA SOURCE]
Key : [155472] Value : [Owner=SCOTT, objectName=CELCIUSTOFAHRENHEIT1, objectType=FUNCTION]
Key : [155473] Value : [Owner=SCOTT, objectName=CELCIUSTOFAHRENHEIT2, objectType=FUNCTION]
Key : [173457] Value : [Owner=SCOTT, objectName=FORMMODEL_UPD_TRG, objectType=TRIGGER]
Key : [180988] Value : [Owner=SCOTT, objectName=ALL_DB_OBJECTS, objectType=TABLE]
Key : [160447] Value : [Owner=SCOTT, objectName=FN_RUN_HTTP_REQUEST, objectType=FUNCTION]
Key : [150090] Value : [Owner=SCOTT, objectName=HELLOWORLDPKG, objectType=PACKAGE BODY]
Key : [91851] Value : [Owner=SCOTT, objectName=JAVA$OPTIONS, objectType=TABLE]
Key : [173458] Value : [Owner=SCOTT, objectName=FORMMODEL_ID_SEQ, objectType=SEQUENCE]
Key : [85456] Value : [Owner=SCOTT, objectName=Junk, objectType=JAVA CLASS]
Key : [162619] Value : [Owner=SCOTT, objectName=TMP_JD_TEST, objectType=TABLE]
Key : [126759] Value : [Owner=SCOTT, objectName=HOST_API, objectType=PACKAGE]
Key : [73201] Value : [Owner=SCOTT, objectName=EMP, objectType=TABLE]
Key : [73203] Value : [Owner=SCOTT, objectName=BONUS, objectType=TABLE]
Key : [126757] Value : [Owner=SCOTT, objectName=HOST2, objectType=JAVA SOURCE]


Ended at Mon Dec 20 07:36:54 EST 2010

Thursday 16 December 2010

Access Coherence Cache from JRuby as an Extend client

In my previous example below I wanted to quickly join a coherence cluster from JRuby and basically did it the easiest way possible by simply becoming a member in the cluster.

Access Coherence Cache from JRuby/Jython scripts

In the example below we will we use JRuby as a Coherence*Extend client using POF (Portable Object Format) and we do this for the following reasons.

1. Being a console application we want to connect/disconnect many times a day and even though we are a storage disabled member it results in overhead which an extend client avoids.
2. Being an extend client we are storage disabled by default.
3. Using POF has many advantages ranging from performance benefits to language independence, although in this example we are using it from a Java enabled client.

So our JRuby code is now as follows.
require 'java'
require 'C:/jdev/scripting/demos/jruby/extendclient-coherence/extenddemo.jar'
require 'C:/jdev/coherence/36/coherence/lib/coherence.jar'

include_class "pas.au.coherence.extend.server.AllDBObject"
import com.tangosol.net.CacheFactory
import com.tangosol.net.NamedCache
import java.util.Date
import java.lang.System
import java.math.BigDecimal

puts "***********************************************"
puts "Coherence 3.6 Extend Client Example from JRUBY"
puts "***********************************************"

print "Started at ", Date.new.toString, "\n"

begin

  # setup required properties to connect to proxy server as extend client
  System.setProperty("tangosol.coherence.cacheconfig", "client-cache-config.xml")
  System.setProperty("tangosol.pof.enabled", "true")
  System.setProperty("tangosol.pof.config", "extend-pof-config.xml")
  System.setProperty("proxy.host", "papicell-au2.au.oracle.com")

  # get named cache alldbobjs
  alldbobjs = CacheFactory.getCache("alldbobjs")

  #retrieve size of cache
  print "\nCache [alldbobjs] size  = " + alldbobjs.size().to_s + "\n\n"

  #retrieve one record
  objectid = BigDecimal.new(54)

  objectrecord = AllDBObject.new
  objectrecord = alldbobjs.get(objectid)

  puts "Record 54 = " + objectrecord.to_s
  puts

rescue
  print "\n** Error occured **\n"
        print "Failed to access Coherence Cluster from proxy server ", $!, "\n\n"

end

print "Ended at ", Date.new.toString, "\n"
From the code we have done the following.

1. Used a client cache config file to connect as an extend client, basically connect to an extend proxy which is a cluster member.

2. We provide a client JAR file which contains our domain objects and config files that being extenddemo.jar

3. The client cache config is defined as follows.
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">

<cache-config>
  <caching-scheme-mapping>
    <cache-mapping>
      <cache-name>alldbobjs</cache-name>
      <scheme-name>remote</scheme-name>
    </cache-mapping>
  </caching-scheme-mapping>
  <caching-schemes>
    <remote-cache-scheme>
      <scheme-name>remote</scheme-name>
      <initiator-config>
        <tcp-initiator>
          <remote-addresses>
            <socket-address>
              <address system-property="proxy.host">
  papicell-au2.au.oracle.com
       </address>
              <port system-property="proxy.port">
                9099
              </port>
              <reusable>true</reusable>
            </socket-address>
          </remote-addresses>
        </tcp-initiator>
      </initiator-config>
    </remote-cache-scheme>
  </caching-schemes>
</cache-config>

So when we run this we get output as follows.

C:\jdev\scripting\demos\jruby\extendclient-coherence>jrb coh-extend-client.rb
***********************************************
Coherence 3.6 Extend Client Example from JRUBY
***********************************************
Started at Thu Dec 16 14:08:06 EST 2010
2010-12-16 14:08:06.114/1.033 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:
/jdev/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence.xml"
2010-12-16 14:08:06.118/1.037 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/jde
v/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2010-12-16 14:08:06.118/1.037 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-
override.xml" is not specified
2010-12-16 14:08:06.121/1.040 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml"
is not specified


Oracle Coherence Version 3.6.0.0 Build 17229
 Grid Edition: Development mode
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.


2010-12-16 14:08:06.304/1.223 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Loaded cache configuration from "jar:file:/C:/jd
ev/scripting/demos/jruby/extendclient-coherence/extenddemo.jar!/client-cache-config.xml"
2010-12-16 14:08:06.472/1.391 Oracle Coherence GE 3.6.0.0 (thread=RemoteCache:TcpInitiator, member=n/a): Loaded POF configuration fro
m "jar:file:/C:/jdev/scripting/demos/jruby/extendclient-coherence/extenddemo.jar!/extend-pof-config.xml"
2010-12-16 14:08:06.475/1.394 Oracle Coherence GE 3.6.0.0 (thread=RemoteCache:TcpInitiator, member=n/a): Loaded included POF configur
ation from "jar:file:/C:/jdev/coherence/36/coherence/lib/coherence.jar!/coherence-pof-config.xml"
2010-12-16 14:08:06.567/1.486 Oracle Coherence GE 3.6.0.0 (thread=RemoteCache:TcpInitiator, member=n/a): Started: TcpInitiator{Name=Rem
oteCache:TcpInitiator, State=(SERVICE_STARTED), ThreadCount=0, Codec=Codec(Format=POF), PingInterval=0, PingTimeout=0, RequestTimeout=0, Con
nectTimeout=0, SocketProvider=SystemSocketProvider, RemoteAddresses=[papicell-au2.au.oracle.com/10.187.80.136:9099]}
2010-12-16 14:08:06.572/1.491 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Opening Socket connection to 10.187.80.136:9099
2010-12-16 14:08:06.580/1.499 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Connected to 10.187.80.136:9099


Cache [alldbobjs] size  = 99927


Record 54 = AllDbObject - owner: SYS ,objectName: I_CDEF2 ,subObjectName: null ,objectId: 54 ,dataObjectId: 54 ,objectType: INDEX ,created:
2009-08-15 ,lastDDLTime: 2009-08-15 ,timestamp: 2009-08-15:00:16:51 ,status: VALID ,temporrary: N ,generated: N ,secondary: N ,namespace: 4
,editionName: null


Ended at Thu Dec 16 14:08:06 EST 2010

Monday 6 December 2010

Access Coherence Cache from JRuby/Jython scripts

The following example show how to use JRuby or Jython to access Coherence caches. Although this is basic and simply using the cache config file out of coherence.jar it gives you enough to see how simple it is to join the cluster as member and access coherence.jar from these 2 scripting languages.

I could of easily used groovy here as well but decided to stick with jruby and jython for now. Also the script members that join the cluster are storage disabled meaning that they must connect to node which is storage enabled to add data to the cache.

For this demo I have the following installed.
  • Coherence 3.6
  • JDK 1.6
  • JRuby 1.5.6
  • Jython 2.5.1
PRE STEPS

1. Start a cache server as follows. We do this to ensure we have a storage enabled node. The cache config file being used is the one inside coherence.jar. 

C:\jdev\coherence\36\coherence\bin>cache-server.cmd

In the example below jy = jython and jrb = jruby executables.

JRUBY

1. Create a ruby script as follows.
require 'java'
require 'C:/jdev/coherence/36/coherence/lib/coherence.jar'

import com.tangosol.net.CacheFactory
import com.tangosol.net.NamedCache
import java.util.Date
import java.lang.System

puts "*********************************"
puts "Coherence 3.6 Example from JRUBY"
puts "*********************************"

print "Started at ", Date.new.toString, "\n"

begin

  # ensure we are storage disabled
  System.setProperty("tangosol.coherence.distributed.localstorage", "false")
  
  CacheFactory.ensureCluster

  # get named cache
  testcache = CacheFactory.getCache("Test")

  # add data to cache
  testcache.put("1", "pas apicella")

  # retrive data from cache
  puts "Cache entry 1 = " + testcache.get("1")
  
rescue 
 print "Failed to access Coherence Cluster ", $!, "\n"
 
ensure 
  CacheFactory.shutdown
  
end

print "Ended at ", Date.new.toString, "\n"

2. Run it as follows ensuring your reference coherence.jar correctly

> jrb coherence.rb

Output as follows


C:\jdev\scripting\demos\jruby>jrb coherence.rb
*********************************
Coherence 3.6 Example from JRUBY
*********************************
Started at Mon Dec 06 11:38:09 EST 2010
2010-12-06 11:38:09.939/0.855 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:
/jdev/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence.xml"
2010-12-06 11:38:09.942/0.858 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/jde
v/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2010-12-06 11:38:09.943/0.859 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-
override.xml" is not specified
2010-12-06 11:38:09.946/0.862 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml"
is not specified


Oracle Coherence Version 3.6.0.0 Build 17229
 Grid Edition: Development mode
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.


2010-12-06 11:38:10.474/1.390 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): TCMP bound to /10.187.114.243:8090 using SystemSoc
ketProvider
2010-12-06 11:38:11.683/2.600 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): This Member(Id=2, Timestamp=2010-12-06 11:38:
11.675, Address=10.187.114.243:8090, MachineId=50163, Location=machine:paslap-au,process:3824, Role=JrubyMain, Edition=Grid Edition, Mode=De
velopment, CpuCount=4, SocketCount=4) joined cluster "cluster:0xC4DB" with senior Member(Id=1, Timestamp=2010-12-06 11:37:53.952, Address=10
.187.114.243:8088, MachineId=50163, Location=machine:paslap-au,process:1280, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, C
puCount=4, SocketCount=4)
2010-12-06 11:38:11.693/2.609 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service Cluster with senior mem
ber 1
2010-12-06 11:38:11.693/2.609 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service Management with senior
member 1
2010-12-06 11:38:11.693/2.609 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service DistributedCache with s
enior member 1
2010-12-06 11:38:11.693/2.609 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service ReplicatedCache with se
nior member 1
2010-12-06 11:38:11.693/2.609 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service OptimisticCache with se
nior member 1
2010-12-06 11:38:11.693/2.609 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service InvocationService with
senior member 1
2010-12-06 11:38:11.697/2.613 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Started cluster Name=cluster:0xC4DB


Group{Address=224.3.6.0, Port=36000, TTL=4}


MasterMemberSet
  (
  ThisMember=Member(Id=2, Timestamp=2010-12-06 11:38:11.675, Address=10.187.114.243:8090, MachineId=50163, Location=machine:paslap-au,proces
s:3824, Role=JrubyMain)
  OldestMember=Member(Id=1, Timestamp=2010-12-06 11:37:53.952, Address=10.187.114.243:8088, MachineId=50163, Location=machine:paslap-au,proc
ess:1280, Role=CoherenceServer)
  ActualMemberSet=MemberSet(Size=2, BitSetCount=2
    Member(Id=1, Timestamp=2010-12-06 11:37:53.952, Address=10.187.114.243:8088, MachineId=50163, Location=machine:paslap-au,process:1280, R
ole=CoherenceServer)
    Member(Id=2, Timestamp=2010-12-06 11:38:11.675, Address=10.187.114.243:8090, MachineId=50163, Location=machine:paslap-au,process:3824, R
ole=JrubyMain)
    )
  RecycleMillis=1200000
  RecycleSet=MemberSet(Size=0, BitSetCount=0
    )
  )


TcpRing{Connections=[1]}
IpMonitor{AddressListSize=0}


2010-12-06 11:38:11.727/2.643 Oracle Coherence GE 3.6.0.0 (thread=Invocation:Management, member=2): Service Management joined the clust
er with senior service member 1
2010-12-06 11:38:11.788/2.704 Oracle Coherence GE 3.6.0.0 (thread=main, member=2): Loaded cache configuration from "jar:file:/C:/jdev
/coherence/36/coherence/lib/coherence.jar!/coherence-cache-config.xml"
2010-12-06 11:38:12.017/2.933 Oracle Coherence GE 3.6.0.0 (thread=DistributedCache, member=2): Service DistributedCache joined the clus
ter with senior service member 1
Cache entry 1 = pas apicella
2010-12-06 11:38:12.124/3.040 Oracle Coherence GE 3.6.0.0 (thread=Invocation:Management, member=2): Service Management left the cluster


2010-12-06 11:38:12.129/3.045 Oracle Coherence GE 3.6.0.0 (thread=DistributedCache, member=2): Service DistributedCache left the cluste
r
2010-12-06 11:38:12.222/3.138 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=2): Service Cluster left the cluster
Ended at Mon Dec 06 11:38:12 EST 2010


C:\jdev\scripting\demos\jruby>


JYTHON

1. Create a jython script as follows
from com.tangosol.net import CacheFactory, NamedCache
from java.util import Date
from java.lang import System as javasystem

print "*********************************"
print "Coherence 3.6 Example from JYTHON"
print "*********************************"

print "Started at " + Date().toString()

try:

 javasystem.setProperty("tangosol.coherence.distributed.localstorage", "false")
  
 CacheFactory.ensureCluster()
 
 # get named cache
 testcache = CacheFactory.getCache("Test")
 
 # add data to cache
 testcache.put("1", "pas apicella")

 # retrive data from cache
 print "Cache entry 1 = " + testcache.get("1")

except:
    print "Unexpected error:", sys.exc_info()[0]
    raise
    
finally:
    CacheFactory.shutdown()
    
print "Ended at " + Date().toString()
    
    
2. Add coherence.jar to the classpath as shown below.

> set CLASSPATH=C:\jdev\coherence\36\coherence\lib\coherence.jar

3. Run it as follows ensuring your reference coherence.jar correctly

> jy coherence.py

Output as follows


C:\jdev\scripting\demos\jython>jy coherence.py
*********************************
Coherence 3.6 Example from JYTHON
*********************************
Started at Mon Dec 06 11:41:08 EST 2010
2010-12-06 11:41:08.838/1.916 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational configuration from "jar:file:/C:
/jdev/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence.xml"
2010-12-06 11:41:08.844/1.922 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Loaded operational overrides from "jar:file:/C:/jde
v/coherence/36/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2010-12-06 11:41:08.845/1.923 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-
override.xml" is not specified
2010-12-06 11:41:08.851/1.929 Oracle Coherence 3.6.0.0 (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml"
is not specified


Oracle Coherence Version 3.6.0.0 Build 17229
 Grid Edition: Development mode
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.


2010-12-06 11:41:10.012/3.090 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): TCMP bound to /10.187.114.243:8090 using SystemSoc
ketProvider
2010-12-06 11:41:11.191/4.269 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): This Member(Id=3, Timestamp=2010-12-06 11:41:
11.172, Address=10.187.114.243:8090, MachineId=50163, Location=machine:paslap-au,process:6172, Role=PythonUtilJython, Edition=Grid Edition,
Mode=Development, CpuCount=4, SocketCount=4) joined cluster "cluster:0xC4DB" with senior Member(Id=1, Timestamp=2010-12-06 11:37:53.952, Add
ress=10.187.114.243:8088, MachineId=50163, Location=machine:paslap-au,process:1280, Role=CoherenceServer, Edition=Grid Edition, Mode=Develop
ment, CpuCount=4, SocketCount=4)
2010-12-06 11:41:11.207/4.285 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service Cluster with senior mem
ber 1
2010-12-06 11:41:11.207/4.285 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service Management with senior
member 1
2010-12-06 11:41:11.207/4.285 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service DistributedCache with s
enior member 1
2010-12-06 11:41:11.207/4.285 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service ReplicatedCache with se
nior member 1
2010-12-06 11:41:11.207/4.285 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service OptimisticCache with se
nior member 1
2010-12-06 11:41:11.207/4.285 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=n/a): Member 1 joined Service InvocationService with
senior member 1
2010-12-06 11:41:11.210/4.288 Oracle Coherence GE 3.6.0.0 (thread=main, member=n/a): Started cluster Name=cluster:0xC4DB


Group{Address=224.3.6.0, Port=36000, TTL=4}


MasterMemberSet
  (
  ThisMember=Member(Id=3, Timestamp=2010-12-06 11:41:11.172, Address=10.187.114.243:8090, MachineId=50163, Location=machine:paslap-au,proces
s:6172, Role=PythonUtilJython)
  OldestMember=Member(Id=1, Timestamp=2010-12-06 11:37:53.952, Address=10.187.114.243:8088, MachineId=50163, Location=machine:paslap-au,proc
ess:1280, Role=CoherenceServer)
  ActualMemberSet=MemberSet(Size=2, BitSetCount=2
    Member(Id=1, Timestamp=2010-12-06 11:37:53.952, Address=10.187.114.243:8088, MachineId=50163, Location=machine:paslap-au,process:1280, R
ole=CoherenceServer)
    Member(Id=3, Timestamp=2010-12-06 11:41:11.172, Address=10.187.114.243:8090, MachineId=50163, Location=machine:paslap-au,process:6172, R
ole=PythonUtilJython)
    )
  RecycleMillis=1200000
  RecycleSet=MemberSet(Size=0, BitSetCount=0
    )
  )


TcpRing{Connections=[1]}
IpMonitor{AddressListSize=0}


2010-12-06 11:41:11.243/4.321 Oracle Coherence GE 3.6.0.0 (thread=Invocation:Management, member=3): Service Management joined the clust
er with senior service member 1
2010-12-06 11:41:11.300/4.378 Oracle Coherence GE 3.6.0.0 (thread=main, member=3): Loaded cache configuration from "jar:file:/C:/jdev
/coherence/36/coherence/lib/coherence.jar!/coherence-cache-config.xml"
2010-12-06 11:41:11.438/4.516 Oracle Coherence GE 3.6.0.0 (thread=DistributedCache, member=3): Service DistributedCache joined the clus
ter with senior service member 1
Cache entry 1 = pas apicella
2010-12-06 11:41:11.484/4.562 Oracle Coherence GE 3.6.0.0 (thread=Invocation:Management, member=3): Service Management left the cluster


2010-12-06 11:41:11.488/4.566 Oracle Coherence GE 3.6.0.0 (thread=DistributedCache, member=3): Service DistributedCache left the cluste
r
2010-12-06 11:41:11.580/4.658 Oracle Coherence GE 3.6.0.0 (thread=Cluster, member=3): Service Cluster left the cluster
Ended at Mon Dec 06 11:41:11 EST 2010


C:\jdev\scripting\demos\jython>