Introduction to Oracle Coherence

7 篇文章 0 订阅
4 篇文章 0 订阅


序:曾因为项目方财大气粗,并且极度青睐Oralce,幸而能在项目中接触并使用Oracle Coherence。期间我在公司内部做过一次Oracle Coherence的分享,为保证听众中的外国朋友不致于全场“坐飞机”,讲述内容以英文呈现。在此将讲述材料进一步整理与更多的朋友分享,就当是保证它的“原汁原味”吧,就不做翻译了,还请大家不要因此拍砖^_^

-----------------------------------------------------华丽分隔线----------------------------------------------------------------

 

Agenda

 

What is Coherence?
Demonstration
Technical
Code Examples
Architectural Patterns

 

What is Coherence?


Distributed Memory Data Management Solution(aka: Data Grid)

 

How Can a Data Grid Help?
1. Provides a reliable data tier with a single, consistent view of data
2. Enables dynamic data capacity including fault tolerance and load balancing
3. Ensures that data capacity scales with processing capacity

 

Oracle Grid Computing: Enterprise Ready

1. Common Shared Application Infrastructure (Application Virtualization)
2. Data Virtualization (Data as a Service)
3. Middle tier scale out for Grid Based OLTP
4. Massive Persistent scale out with Oracle RAC

 

Requirements of Enterprise Data Grid

Reliable

1. Built for continuous operation
2. Data Fault Tolerance
3. Self-Diagnosis and Healing
4. “Once and Only Once” Processing

Scalable
1. Dynamically Expandable
2. No data loss at any volume
3. No interruption of service
4. Leverage Commodity Hardware
5. Cost Effective

Universal
1. Single view of data
2. Single management view
3. Simple programming model
4. Any Application
5. Any Data Source

Data
1. Data Caching
2. Analytics
3. Transaction Processing
4. Event Processing

 

How Does Coherence Data Grid Work?

1. Cluster of nodes holding % of primary data locally
2. Back-up of primary data is distributed across all other nodes
3. Logical view of all data from any node



1. All nodes verify health of each other
2. In the event a node is unhealthy, other nodes diagnose state



1. Unhealthy node isolated from cluster
2. Remaining nodes redistribute primary and back-up responsibilities to healthy nodes


Customers & Coherence?
Caching:
Applications request data from the Data Grid rather than backend data sources

Analytics: Applications ask the Data Grid questions from simple queries to advanced scenario modeling

Transactions: Data Grid acts as a transactional System of Record, hosting data and business logic

Events: Automated processing based on event

 

Coherence Demonstration


Topology #1 - Replicated Cache



Topology #2 - Partitioned Cache

Topology #2 - Guaranteed Cluster Resiliency

Topology #2 - Partitioned Failover

Topology #2a – Cache Client/Cache Server

 

Topology #3 - Near Cache

Use Case: Coherence*Web
1. Coherence*Web is an HTTP session-management module (built-in feature of Coherence)
2. Supports a wide range of application servers.
3. Does not require any changes to the application.
4. Coherence*Web uses the NearCache technology to provide fully fault-tolerant caching, with almost unlimited scalability (to several hundred cluster nodes without issue).
5. Heterogeneous applications running on mixed hardware/OS/application servers can share common user session data. This dramatically simplifies supporting Single-Sign-On across applications.

 

Coherence*Web: Session State Management

Build slide to show state is recoverable from the data grid.  There is multiple important points here – the biggest is the ability to separate the session state to a tier independent of the application – you are offloading horsepower requirements in the middletier app server to the grid and getting significant reliability as a result of making this coherence.

 

Read-Through Caching

 

Write-Through Caching

 

Write-Behind Caching
 

 

Coherence Code Examples

 

Clustering Java Processes 

Java代码   收藏代码
  1. Cluster cluster = CacheFactory.ensureCluster();  

·Joins an existing cluster or forms a new cluster
Time “to join” configurable

·cluster contains information about the Cluster
Cluster Name
Members
Locations
Processes

·No “master” servers
·No “server registries”

 

Leaving a Cluster 

Java代码   收藏代码
  1. CacheFactory.shutdown();  

·Leaves the current cluster
·shutdown blocks until “data” is safe

·Failing to call shutdown results in Coherence having to detect process death/exit and recover information from another process. 

·Death detection and recovery is automatic

 

Using a Cache get, put, size & remove  

Java代码   收藏代码
  1. NamedCache nc = CacheFactory.getCache(“mine”);  
  2.   
  3. Object previous = nc.put(“key”, “hello world”);  
  4.   
  5. Object current = nc.get(“key”);  
  6.   
  7. int size = nc.size();  
  8.   
  9. Object value = nc.remove(“key”);  

 

·CacheFactory resolves cache names (ie: “mine”) to configured NamedCaches

·NamedCache provides data topology agnostic access to information
·NamedCache interfaces implement several interfaces;
  ·java.util.Map, Jcache,

  ·ObservableMap*,

  ·ConcurrentMap*,

  ·QueryMap*,

  ·InvocableMap*

(* Coherence Extensions)
 

Using a Cache keySet, entrySet, containsKey 

Java代码   收藏代码
  1. NamedCache nc = CacheFactory.getCache(“mine”);  
  2.   
  3. Set keys = nc.keySet();  
  4.   
  5. Set entries = nc.entrySet();  
  6.   
  7. boolean exists = nc.containsKey(“key”);  

 

·Using a NamedCache is like using a java.util.Map

·What is the difference between a Map and a Cache data-structure?

   · Both use (key,value) pairs for entries
   · Map entries don’t expire
   · Cache entries may expire
   · Maps are typically limited by heap space
   · Caches are typically size limited (by number of entries or memory)
   · Map content is typically in-process (on heap)

 

Observing Cache Changes ObservableMap 

Java代码   收藏代码
  1. NamedCache nc = CacheFactory.getCache(“stocks”);  
  2.   
  3. nc.addMapListener(new MapListener() {  
  4.     public void onInsert(MapEvent mapEvent) {  
  5.     }  
  6.     public void onUpdate(MapEvent mapEvent) {  
  7.     }  
  8.   
  9.     public void onDelete(MapEvent mapEvent) {  
  10.     }  
  11.  });  

 

·Observe changes in real-time as they occur in a NamedCache
·Options exist to optimize events by using Filters, (including pre and post condition checking) and reducing on-the-wire payload (Lite Events)

·Several MapListeners are provided out-of-the-box. 
  ·Abstract, Multiplexing...

 

Querying Caches QueryMap 

Java代码   收藏代码
  1. NamedCache nc = CacheFactory.getCache(“people”);  
  2.   
  3. Set keys = nc.keySet( new LikeFilter(“getLastName”, “%Stone%”));  
  4.   
  5. Set entries = nc.entrySet(new EqualsFilter(“getAge”, 35));  

 

·Query NamedCache keys and entries across a cluster (Data Grid) in parallel* using Filters
·Results may be ordered using natural ordering or custom comparators
·Filters provide support almost all SQL constructs
·Query using non-relational data representations and models
·Create your own Filters 

( * Requires Enterprise Edition or above)

 

 Continuous Observation Continuous Query Caches 

Java代码   收藏代码
  1. NamedCache nc = CacheFactory.getCache(“stocks”);  
  2.   
  3. NamedCache expensiveItems = new ContinuousQueryCache(nc, new GreaterThan(“getPrice”, 1000));  

 

·ContinuousQueryCache provides real-time and in-process copy of filtered cached data
·Use standard or your own custom Filters to limit view
·Access to “view”of cached information is instant

·May use with MapListeners to support rendering real-time local views (aka: Think Client) of Data Grid information.

 

Aggregating Information InvocableMap 

Java代码   收藏代码
  1. NamedCache nc = CacheFactory.getCache(“stocks”);  
  2.   
  3. Double total = (Double)nc.aggregate(AlwaysFilter.INSTANCE,new DoubleSum(“getQuantity”));  
  4.   
  5. Set symbols = (Set)nc.aggregate(new EqualsFilter(“getOwner”, “Larry”), new DistinctValue(“getSymbol”));  

 

·Aggregate values in a NamedCache across a cluster (Data Grid) in parallel* using Filters
·Aggregation constructs include; Distinct, Sum, Min, Max, Average, Having, Group By
·Aggregate using non-relational data models
·Create your own aggregators
(* Requires Enterprise Edition or above)

 

Mutating Information InvocableMap 

Java代码   收藏代码
  1. NamedCache nc = CacheFactory.getCache(“stocks”);  
  2.   
  3. nc.invokeAll(new EqualsFilter(“getSymbol”, “ORCL”), new StockSplitProcessor());  
  4.   
  5. ...  
  6.   
  7. class StockSplitProcessor extends AbstractProcessor {  
  8.   
  9.      Object process(Entry entry) {  
  10.   
  11.           Stock stock = (Stock)entry.getValue();   
  12.   
  13.           stock.quantity *= 2;  
  14.   
  15.           entry.setValue(stock);  
  16.   
  17.           return null;  
  18.      }  
  19.   
  20. }  

 

·Invoke EntryProcessors on zero or more entries in a NamedCache across a cluster (Data Grid) in

·parallel* (using Filters) to perform operations

·Execution occurs where the entries are managed in the cluster, not in the thread calling invoke

·This permits Data + Processing Affinity
(* Requires Enterprise Edition or above)

 

 

Oracle Coherence Architectural Patterns

 

Single Application Process
         

Coherence as “Data Structure”.  Single applications may use Coherence java.util.Map interface implementations (and extensions) for high-performance, highly configurable caching.  Clustering is not required!
 

Clustered Processes

Coherence ensures that there is a consistent view of the data in-memory to all processes.

This is sometimes referred to as a “single-system-image”


Multi Platform Cluster

 

Clustered Application Servers

 

 

With Data Source Integration (Cache Stores)

 

Clustered Second Level Cache (for Hibernate) 

 

Remote Clients connected to Coherence Cluster

 

Interconnected WAN Clusters


 

Getting Oracle Coherence

 

Search:   

http://search.oracle.com

 
Download:

http://www.oracle.com/technology/products/coherence

 
Support:
http://forums.tangosol.com
http://wiki.tangosol.com

  
Read More:
http://www.tangosol.com/

From:http://kei.iteye.com/blog/761109
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值