Archive

Posts Tagged ‘Java’

Java Pipes vs. Sockets in a Single JVM

In a recent project I should have implemented an InputStream in a java code. There are many ways to achieve this and in this blog post I will show off the performance of just two of them, Sockets and Pipes ( PipedInputStream and PipedOutputStream ).

Scenario is really simple, I’ll send both 10 and 100 million messages from producer to consumer for each scenario. Message is just a sentence, “This is a message sent from Producer”.

I run all the scenario for 3 times and then get the average due to some os environment factor, other processes etc. And also I used the PrintStream as data writer for both test and BufferedReader for reader.

Buffer values can be set for Pipes by passing the long value to the PipedInputStream constructor. And for socket, buffer can be set from BufferedReader constructor. Buffer value for this test is 1024*1024*8 for both scenarios.

Results:

Pipe Socket
10M msg 12sec 26sec
100M msg 72sec 239sec

The main code of the test:

public class PipeAndSocketTester {

	public static void main(String args[]) throws IOException {
		boolean autoFlush = false;
		long messageNumber = 10000000;

		PipedOutputStream pos = new PipedOutputStream();
		PipedInputStream pis = new PipedInputStream(pos, 1024*1024*10);

		new PipeWriter(pos,messageNumber,autoFlush).start();
		new PipeReader(pis).start();

		// after above code executed I remove the pipe code then execute follows
		new SocketWriter(4544,messageNumber).start();
		new SocketReader(4544,1024*1024*10).start();

	}
}
}
Categories: Java Tags: ,

Oracle Event Processing – Pattern Matching Example 2

In previous post I showed off one of the pattern matching feature of Oracle Event Processing and in this section I am gonna show another example of it.

There are many built-in functions which can be used in CQL. I think one of the most important these functions is the prev function. Prev function facilitates accessing the previous elements in the same stream/partition easily.

Consider this scenario, we have stock values as below and I would like to find out the pattern; firstly average value of previous 3 elements should be greater than 10 and the last value greater than the last value of the previous condition.

If we want to write to CQL code of our requirements it would look like:

CQL Example

With numbers lets try to understand how the pattern can be matched ( left side: incoming events; right side: expression about pattern matching):

Events and patterns

 

Run the application:

output

As shown in above, after the 13 and 33 pattern has been matched and output was produced.

 

 

Oracle Event Processing – Pattern Matching Example

Event processing technologies became famous in recent years. Companies realizes that they need to take real time action in order to satisfy customer requirements or handle several component issues happened in some internal system or advertising etc.

Oracle Event processing has several processing methods in order to process incoming real time data. In this blog post I will show off one of the pattern matching operations.

Consider, you desire to find out which stock firstly increases then decreases three times and increases again. For example;

6.48;6.47;6.46;6.48;6.49;6.48;6.47;6.46;6.47;6.46;6.45;6.44;6.43;6.42;6.43

In the above numbers we will find out the pattern which starts with 6.48 and ends with 6.47. Because it firstly incremented from 6.48 to 6.49 and then decreased three times ( 6.48,6.47,6.46 ) and then increased from 6.46 to 6.47 again.

I am using the Oracle Event Processing 11.1.1.7 for Windows 64bit and Cygwin as windows terminal.

I changed a little bit the HelloWorld default cep application. The most crucial part is the CQL Processor part, how should I implement the CQL in order to find out the patterns?

OCEP Cql Processor Pattern Matching

OCEP Cql Processor Pattern Matching

Let’s look at the clauses in briefly.

StockProcessor is the name of the cql processor.
PARTITION BY shortName: Partition incoming data by shortName ( CQL Engines calculates each partition individually. For example, ORCL, IBM, GOOG prices are computed individually. )
MEASURES : Which values, fields will be in the output
PATTERN : Order of conditions ( Look at regular expression for more details )
DEFINE : Defining the conditions, “A as” means the define condition A.

Run the application and type the stock name and prices as in below:

OCEP Cql Processor Pattern Matching Demo

OCEP Cql Processor Pattern Matching Demo

Just after pattern is matched the output event is produced and in this example I just printed the name and last price value of the stock.

I didn’t specify any performance measurements but if the number of distinct stocks are increased performance will be our first concern. However, I would like to share some performance results in a another blog post later.

Coherence Index Performance

In a traditional database we use the index to access filtered data as quickly as possible. In the coherence, indexes are used for same purpose as well, fast access to filtered data. If you wish to retrieve all the items in the cache, likely index are not appropriate for you same as when you use database index. For example, when using the Oracle database and if you use a filter to retrieve data but its selectivity is close to 1, Oracle cost based optimizer can choose to not use the indexes because it’s not necessary since each index operations requires one more I/O. Likewise, in coherence when you wish the get data you should decide correctly whether use it or not.

Anyway, in this blog post I will carry out basic filter operations with and without index.

NamedCache cache = CacheFactory.getCache("persons");
PersonGenerator pg = new PersonGenerator();

cache.putAll(pg.getRandomPeople(2000000));
System.out.println("Cache loaded:"+cache.size()+" elements.");

Filter filter = 
	new OrFilter(
		new AndFilter(
			new EqualsFilter("getFirstName", "Hugo"),
			new GreaterFilter("getAge", 50)
		),
		new AndFilter(
			new EqualsFilter("getFirstName","William"),
			new LessFilter("getAge",50)
		)
		);

Firstly, I connected to the cluster and cache, after that 2 millions of people object is generated, they all put into the cache. Then, filter is created, pay a little bit more attention to here, uppermost the orfilter was used and two and filters was used in the filter. If we convert this filter clause to an sql query it would be :

select * from people where ( firstName="Hugo" and age>50 ) or ( ( firstName="William" and age<50 )

As it is seen here, we are just looking for the firstname and age fields for filtering. If these fields can be used in indexes we could improve the query performance.

To get filtered data we use the entrySet method by passing the Filter object as argument like this:

Set filteredData;
Timer.start();
filteredData = cache.entrySet(filter);
Timer.stop();
System.out.println("Without Index:" + Timer.getDurationMSec());

It prints:

Without Index:12091

Time is milliseconds based.

As you know we don’t use index so far, it is the time to add one:

cache.addIndex(new ReflectionExtractor("getFirstName"), false, null);
Timer.start();
	filteredData = cache.entrySet(filter);
Timer.stop();
System.out.println("With Index:" + Timer.getDurationMSec());

AddIndex method has been used to add index and first parameter of this method is the field’s get method which will be indexed. Second parameter gets a boolean variable and it determines the whether index is sorted or not. Sorted index is useful for range queries like ” age > 20 ” . While creating this index we did not use sorted index because we just looking for equalities, but we’ll use sorted index in the next one.
This code part prints:

With Index:5300

As you see, with one index, entrySet method double times faster than the previous one, without index.
We know that our filter uses two fields, one of them is the firstname which was just before indexed and the other one is the age. We can use age field as well in the index:

cache.addIndex(new ReflectionExtractor("getAge"), false, null);
Timer.start();	
	filteredData = cache.entrySet(filter);
Timer.stop();
System.out.println("With Two Indexes:" + Timer.getDurationMSec());

It prints:

With Two Indexes:1017

In order to get the filtered data set faster we can use the indexed object fields which are used in the filter. If we index the fields which are not used in the filter we won’t get any performance improvement.

cache.removeIndex(new ReflectionExtractor("getFirstName"));
cache.removeIndex(new ReflectionExtractor("getAge"));

cache.addIndex(new ReflectionExtractor("getCitizenNumber"), true, null);
Timer.start();
filteredData = cache.entrySet(filter);
Timer.stop();
System.out.println("With Index BUT Not in the filter:" + Timer.getDurationMSec());

It prints:

With Index BUT Not in the filter:
11391

11391 milliseconds is almost same duration of without index.

TROUG – Coherence Presentation and Demo Video

October 12, 2012 2 comments

Yesterday, I attended Turkish Oracle User Group ( TROUG ) event as a speaker in Bahcesehir University, Istanbul. I talked about cache concept, why do we need to cache and a few Oracle Coherence features. And also I mentioned Coherence Cache topologies such as Replicated Cache, Distributed Cache and Near Cache and also Write,Read Through, Write Behind Queue and Refresh-Ahead mechanisms.

It was delighted but the end of the my presentation I was disappointed with my VirtualBox. When I wanted to make a demo in my Eclipse which runs inside the OEL 5 in VirtualBOX 4, there was something wrong. Some of my Eclipse Launch Configuration have been disappeared in “Run As” section so there was lots of configuration and I lost all of them.

Fortunately, I decided to upload a video which tells the some of Oracle Coherence features and CohQL examples inside the VirtualBox.

You can watch this video in vimeo:

https://vimeo.com/51314443

Here is the my presentation.

How a member can use the existing cache in Coherence

August 23, 2012 1 comment

In the previous post, I’ve explained how a member can join the existing cluster. Before read this post you should understand what was going on there.

At the final in previous post the new member joined the cluster. In this post I’ll explain how a member can use the existing cache ( customers cache which was created by the Eclipse project in this post )

Let’s go on from previous post.
Cluster Join
At the bottom of this screenshot you see that there is a prompt. To use existing cache ( this is the cache it has already created and it’s name is customers ) we type :

Map(?): cache customers

And it gives this output:

As you see the coherence was reading default cache configuration file instead of our cache config file. To force coherence to read our cache configuration file we should edit the JAVA_OPTS parameter in the coherence_join_cluster_test1.sh file ( it was created in previous post ) and add this clause by changing the real path :

-Dtangosol.coherence.cacheconfig=/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config/coherence-cache-config.xml -Dtangosol.pof.config=/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config/pof-config.xml

These xml files are under the src/config folder of the Eclipse project which has already been created.
And also you should change the classpath parameters because in the pof-config.xml file there is a class that should be specified in the classpath to use pof configuration.
To edit classpath parameters, edit the coherence_join_cluster_test1.sh file and go to the line which starts with JAVA_EXEC and change the -cp parameter as :

-cp "-classpath /home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config:/labs/wls1211/coherence_3.7/lib/coherence.jar:/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/bin" 

After editing coherence_join_cluster_test1.sh file save this file as coherence_join_cluster_test2.sh file. The coherence_join_cluster_test2.sh file is here:

Run this sh file.
Then type “cache customers” again in the prompt then you’ll see this output:

As shown in above loaded cache configuration file and pof configuration file is as we wanted. When querying the size of the cache it returns the correct answer:

Map (customers): size
1

Map (customers): 

Joining the Existing Cluster in Coherence

August 21, 2012 3 comments

In previous post I had tried to explain some of the output parameters of Coherence. In this post I will explain how a member can join the existing cluster by setting some parameters.

Before this post you should completed this post:
Running a Coherence Application in Eclipse
We’ve already run this example within Eclipse. Basically it creates a cluster and a cache then put a custom object into the cache. And because of code is over in CustomerTest1.java Coherence Cache automatically closed. To prevent closing automatically we’ll edit the CustomerTest1.java and add the below code to control the application flow.

String dummy;
Scanner user_input = new Scanner( System.in );
dummy = user_input.next( );

And the changed version of CustomerTest1.java is now here:

package com.afsungur.coherence.test;

import java.util.Scanner;

import com.afsungur.coherence.objects.Customer;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;

public class CustomerTest1 {

        public static void main(String args[])
        {
        Customer cust = new Customer("Ahmet Fuat", "Sungur", "Bahcelievler/Istanbul", "afsungur@gmail.com", "5321231231", 34111);
        NamedCache cache = CacheFactory.getCache("customers");
        cache.put(1, cust) ;
        System.out.println("Cache Size:"+cache.size());

        String dummy;
        Scanner user_input = new Scanner( System.in );
        dummy = user_input.next( );

        CacheFactory.shutdown();

        }
}

After editing you can run the application inside Eclipse and then you see that application will wait for some input to terminate the cache server. But before terminating we may allow another member to join the cluster.

By the way you can check which parameters were used to start cluster inside the Eclipse as shown in below :

[oracle@localhost bin]$ ps -ef | grep coherence
oracle    6835  2873  8 13:18 ?        00:00:02 /labs/wls1211/jdk160_29/bin/java -Dtangosol.coherence.cacheconfig=src/config/coherence-cache-config.xml -Dtangosol.coherence.cluster=MyFirstCluster -Dtangosol.pof.config=/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config/pof-config.xml -Dtangosol.coherence.clusterport=7252 -Dfile.encoding=UTF-8 -classpath /home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config:/labs/wls1211/coherence_3.7/lib/coherence.jar:/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/bin com.afsungur.coherence.test.CustomerTest1
oracle    6874  5387  0 13:19 pts/1    00:00:00 grep coherence
[oracle@localhost bin]$ 

And so, how we can add a member to cluster? We know that there is a cluster which serves from 7252 port and also we now the cluster name ( MyFirstCluster ) and so on. We can check this parameters from Run->Run Configurations->Coherence(Main Tab)->Other(Sub Tab).
And also you can check as shown in above by using “ps” linux command.

Under the bin folder of coherence main folder ( something like coherence3.7/bin ), there are some sh files. cache-server.sh and coherence.sh can be used to join cluster. Coherence.sh provides an interactive environment to query the cache for putting, getting, listing or something else. Therefore, we use coherence.sh to join cluster.

Just before running the coherence.sh file we edit file and add below arguments to the line which starts with “JAVA_OPTS=” and then save as the file coherence_join_cluster_test1.sh .

-Dtangosol.coherence.cluster=MyFirstCluster -Dtangosol.coherence.clusterport=7252

Then, start the coherence_join_cluster_test1.sh and the analyse the output:
Cluster Join

Most part of output is similar to single member cluster. But there are a few differences.
First of all, at the top of output you see that new member are using the default operational configuration file which is inside the jar file.
And the middle of the output at the MasterMemberSet section you can see that currently how many members are there in the cluster, what is the current member id (ThisMember part), oldest member id and so on.
At the bottom of page you can see the interactive command line and “Map (?):” is written at the left side. Type “help” and then you can see all available commands.

In this post I’ve explained how a member join the existing cluster. In next post I’ll explain how just joined member can use the existing cache.

Some explanations of Oracle Coherence console output

August 17, 2012 1 comment

I will explain some part of the console output that I shared in previous section.

Console Output

The first three rows are related the tangosol-coherence-override settings. This file is the part of Oracle Coherence configuration and it provides many features for Oracle Coherence Cache Server. Something like multicast parameter, tcp parameter..

As shown in above because of our project has tangosol-coherence-override.xml, coherence server uses this file. If this file does not exist in project folder ( src/config as in previous example ), coherence uses the default file which inside the coherence.jar as shown in below:

2012-08-15 03:57:07.976/0.652 Oracle Coherence 3.7.1.1 <Info> (thread=main, member=n/a): Loaded operational configuration from “jar:file:/labs/wls1211/coherence_3.7/lib/coherence.jar!/tangosol-coherence.xml” 2012-08-15 03:57:08.075/0.752 Oracle Coherence 3.7.1.1 <Info> (thread=main, member=n/a): Loaded operational overrides from “jar:file:/labs/wls1211/coherence_3.7/lib/coherence.jar!/tangosol-coherence-override-dev.xml” 2012-08-15 03:57:08.077/0.753 Oracle Coherence 3.7.1.1 <D5> (thread=main, member=n/a): Optional configuration override “/tangosol-coherence-override.xml” is not specified 2012-08-15 03:57:08.081/0.757 Oracle Coherence 3.7.1.1 <D5> (thread=main, member=n/a): Optional configuration override “/custom-mbeans.xml” is not specified.

You also see that which file is used for coherence cache configuration. As shown in below you see that coherence uses our coherence-cache-config file which under the src directory of project.

2012-08-15 04:38:31.548/1.081 Oracle Coherence GE 3.7.1.1 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/home/oracle/labs/Coh_labs/workspace/CohExam_AFSungur/src/config/coherence-cache-config.xml"

Another important point that we have a warning as you see in the console. These warnings are related the socket buffer parameters in linux. So far I haven’t changed any linux parameter yet but to clear warnings I will have to do a few. If you didn’t see any socket related warning pass this section.

To increase the socket buffer size in linux you should follow these steps:
edit the /etc/sysctl.conf file and add two lines to the file, before adding check the file whether it has written already or not

# increase TCP max buffer
  net.core.rmem_max = 16777216
 net.core.wmem_max = 16777216

After editing you should reload the settings, to do this

[root@localhost ~]# /sbin/sysctl -p

After run that you will see the changed parameter.

And let’s go back to the console, we see the TCMP and cluster-name. TCMP is a protocol that Coherence uses. It has many features like multicast communication, unicast communication and recognize new server which has just joined the cluster or the server which has just dropped from cluster.

Cluster-name parameter provides a name to the cluster so you can create multiple cluster on the same network. In our example cluster-name something like weird hex characters. Because we didn’t imply any name to the cluster. To give a name to the cluster edit the tangosol-coherence-override.xml file and add this lines:

<cluster-config>
      <member-identity>
         <cluster-name system-property="tangosol.coherence.cluster">
            MyCluster</cluster-name>
      </member-identity>
</cluster-config>


After it is added to tangosol-coherence-override.xml rerun the application and cache servers then you’ll see this output:

2012-08-15 04:38:35.707/5.240 Oracle Coherence GE 3.7.1.1 <Info> (thread=Cluster, member=n/a): Created a new cluster "MyFirstCluster" with Member(Id=1, Timestamp=2012-08-15 04:38:32.417, Address=10.0.2.15:8088, MachineId=2063, Location=site:,process:4244, Role=AfsungurCoherenceCustomerTest1, Edition=Grid Edition, Mode=Development, CpuCount=1, SocketCount=1) UID=0x0A00020F000001392A13EC61080F1F98
2012-08-15 04:38:35.712/5.245 Oracle Coherence GE 3.7.1.1 <Info> (thread=main, member=n/a): Started cluster Name=MyFirstCluster

As shown in above there are many attributes which are shared. For example you see that IP address of client, machine id, member id ( this is so useful when you design your load balancing mechanism ), cpu and socket count, role information. Cpu and socket count parameters are 1 because I run coherence on VM within a single cpu.  Role name  allows an application to get together coherence members into special roles. For example cache clients and cache servers. And site name ( location ) provides intelligent routing, load balancing and  disaster recovery planning while you are using WAN clustering, that’s really cool.

In the MasterMembetSet section there are information about the members which are connected the cluster.

And the bottom of the console you see that PofConfiguration is loaded from the file which is under the src/config folder of the project.

Running a Coherence Application in Eclipse

August 15, 2012 3 comments

This is the Part 2 of my Coherence Series.

The first one is Preparing Eclipse OEPE for Oracle Coherence.

In this post I am trying to explain to run a demo coherence application inside the Eclipse.

1 ) First of all I created these packages under the src folder of project:

com.afsungur.coherence.objects
com.afsungur.coherence.test
config

And the files should be placed in these folders as shown in below:

com.afsungur.coherence.objects

  • Customer.java

com.afsungur.coherence.test

  • CustomerTest1.java

config

  • coherence-cache-config.xml
  • pof-config.xml
  • tangosol-coherence-override.xml

2 ) Customer class is a bean and it has getter and setter methods. Also because of it implements the PortableObject there are methods which should be implemented in the class, readExternal and writeExternal.

Customer.java is here:

package com.afsungur.coherence.objects;import java.io.IOException;
import com.tangosol.io.pof.PofReader;
import com.tangosol.io.pof.PofWriter;
import com.tangosol.io.pof.PortableObject;

public class Customer implements PortableObject{
private String surName;
private String address;
private String email;
private String mobileTelephoneNumber;
private int zipCode;
private String name;

/**
* @param name
* @param surName
* @param address
* @param email
* @param mobileTelephoneNumber
* @param zipCode
*/
public Customer(String name, String surName, String address, String email,
String mobileTelephoneNumber, int zipCode) {
super();
this.name = name;
this.surName = surName;
this.address = address;
this.email = email;
this.mobileTelephoneNumber = mobileTelephoneNumber;
this.zipCode = zipCode;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getSurName() {
return surName;
}

public void setSurName(String surName) {
this.surName = surName;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getMobileTelephoneNumber() {
return mobileTelephoneNumber;
}

public void setMobileTelephoneNumber(String mobileTelephoneNumber) {
this.mobileTelephoneNumber = mobileTelephoneNumber;
}

public int getZipCode() {
return zipCode;
}

public void setZipCode(int zipCode) {
this.zipCode = zipCode;
}

@Override
public void readExternal(PofReader pofReader) throws IOException {
// TODO Auto-generated method stub
name = pofReader.readString(NAME);
surName = pofReader.readString(SURNAME);
address = pofReader.readString(ADDRESS);
email = pofReader.readString(EMAIL);
mobileTelephoneNumber = pofReader.readString(MOBILETELEPHONENUMBER);
zipCode = pofReader.readInt(ZIPCODE);

}

@Override
public void writeExternal(PofWriter pofWriter) throws IOException {
// TODO Auto-generated method stub
pofWriter.writeString(NAME,name);
pofWriter.writeString(SURNAME, surName);
pofWriter.writeString(ADDRESS, address);
pofWriter.writeString(EMAIL, email);
pofWriter.writeString(MOBILETELEPHONENUMBER, mobileTelephoneNumber);
pofWriter.writeInt(ZIPCODE, zipCode);
}

private final int NAME=0;
private final int SURNAME=1;
private final int ADDRESS=2;
private final int EMAIL=3;
private final int MOBILETELEPHONENUMBER=4;
private final int ZIPCODE=5;

}

3) CustomerTest1 class is tester class. It creates a customer object and put this object into the customer cache. And also it prints the cache size.

package com.afsungur.coherence.test;

import com.afsungur.coherence.objects.Customer;
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;

public class CustomerTest1 {

public static void main(String args[])
{
Customer cust = new Customer("Ahmet Fuat", "Sungur", "Bahcelievler/Istanbul", "afsungur@gmail.com", "5321231231", 34111);

NamedCache cache = CacheFactory.getCache("customers");
cache.put(1, cust) ;
System.out.println("Cache Size:"+cache.size());

CacheFactory.shutdown();

}
}

4) coherence-cache-config.xml file includes the cache features like expiring time, cache size, cache type. I will explain some features in detail but in this example I used this cache config xml :

<?xml version="1.0"?><cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
<defaults>
<serializer>pof</serializer>
</defaults><caching-scheme-mapping>
<cache-mapping>
<cache-name>customers</cache-name>
<scheme-name>ExamplesPartitionedPofScheme</scheme-name></cache-mapping></caching-scheme-mapping><caching-schemes>
<distributed-scheme>
<scheme-name>ExamplesPartitionedPofScheme</scheme-name>
<service-name>PartitionedPofCache</service-name>
<backing-map-scheme>
<local-scheme>
<!-- each node will be limited to 32MB -->
<high-units>32M</high-units>
<unit-calculator>binary</unit-calculator>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme><!--
Invocation Service scheme.
-->
<invocation-scheme>
<scheme-name>examples-invocation</scheme-name>
<service-name>InvocationService</service-name>

<autostart system-property="tangosol.coherence.invocation.autostart">true</autostart>
</invocation-scheme>

</caching-schemes>
</cache-config>

5) pof-config.xml file includes the serialized object list which are used inside the project. In this example Customer class should be specified inside the pof-config.xml file. My pof-config.xml file’s content is :

<?xml version="1.0"?>
<pof-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-pof-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-pof-config http://xmlns.oracle.com/coherence/coherence-pof-config/1.1/coherence-pof-config.xsd">
<user-type-list>
<!-- include all "standard" Coherence POF user types -->
<include>coherence-pof-config.xml</include><user-type>
<type-id>1001</type-id>
<class-name>com.afsungur.coherence.objects.Customer</class-name>
</user-type>
</user-type-list><allow-interfaces>true</allow-interfaces>
<allow-subclasses>true</allow-subclasses>
</pof-config>

6) tangosol-coherence-override.xml file includes the cache server feature settings. I am using the default one, I didn’t change anything. Cache server attributes can also be modified in “Run Configurations” menu.

7) So far, I explained the files to run our first test application. In the package explorer you should see the same picture as shown in below:

Coherence Project 1 Package Explorer

But also we should set some coherence configurations to run this application. To do this, first Right Click of project and then select Run As -> Run Configurations

8) In the opened window, at the left side right click Oracle Coherence then click New.

Give a name for this configuration, select project and select main class as shown in below.

Coherence Test Configuration

9 ) Then select Coherence tab and specify the coherence-cache-config.xml file in the Topology section.

Cache Configuration

And at the same window, in the bottom section you should specify the multicast/unicast port/ip settings. You should specify the port number which has not be used yet. You can specify the parameters as shown in below

MultiCast Port

10 ) In Coherence main tab, select the Other sub-tab as shown in below:

Other Tab

Then at the bottom of this window there is a parameter, tangosol-pof-config. On this row at the right side there is a path. You should specify the pof-config.xml path which has already written before ( In step 5 you created the pof-config.xml )

Pof Config

11 ) After you successfully completed these steps, we need to test application. In the “Run Configurations” window, click Run and observe the results.

Console Output

In next post I will explain this output briefly.

Preparing Eclipse OEPE for Oracle Coherence

August 14, 2012 2 comments

Oracle Coherence provides a data grid mechanism to use most accessed data in many different ways. It is scalable and high available and it has many advanced features to handle records inside. I will be explaining some of Oracle Coherence features in a few posts. First topic of this series is this post.

Eclipse is the most used Java development environment and I will use this IDE for my Oracle Coherence post series.

By the way I am using one of the Oracle VM template for VirtualBOX  ( Enterprise Java Development Template ) to run Oracle Coherence, Eclipse. And OS and linux kernel version of VM is here:

[root@localhost etc]# cat /proc/version
Linux version 2.6.18-194.el5 (mockbuild@ca-build10.us.oracle.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Mon Mar 29 20:06:41 EDT 2010
[root@localhost etc]#

To use Oracle Coherence in the Eclipse you should follow these steps:

1 ) Download Eclipse OEPE 12c ( Oracle Enterprise Pack for Eclipse ) ~400MB
2 ) Download Oracle Coherence 3.7.1 coherence.jar ~10MB
3 ) Create a new Java Standalone Project

Create Java Project

I specify the project name as “CohExam_AFSungur”

4 ) Add library to your project, you should use User Library

Add Library to Java Project

User Library

Then you select User Library you should specify the path of coherence.jar file.

5 ) After you successfully imported coherence.jar file to our project we can finish the creation of the java project.

Then we can configure the Project Facets of our just created project.

6 ) Press Right Click of your project and then select Properties.

Then in the opened window choose Project Facets as in below:

Project Facet

Click Convert to faceted from link.

7 ) Then check Oracle Coherence and bottom of screen you see Further configuration available, click it.

Then import and check Coherence371 and finish it.

8 ) Eventually, you should see the project something like this:

Project Status

If you see the 3 xml files and coherence.jar file as shown in the above you completed this section successfully.

In next chapters I will unveil some of Oracle Coherence features with examples.

So far you’ve imported Coherence library to your project and then in your java class you can use all available coherence methods.  And also you can configure cache and cache server parameters by editing xml files.

Follow

Get every new post delivered to your Inbox.

Join 71 other followers