Introduction to Oracle Coherence

序:曾因为项目方财大气粗,并且极度青睐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 

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 

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  

NamedCache nc = CacheFactory.getCache(“mine”);

Object previous = nc.put(“key”, “hello world”);

Object current = nc.get(“key”);

int size = nc.size();

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 

NamedCache nc = CacheFactory.getCache(“mine”);

Set keys = nc.keySet();

Set entries = nc.entrySet();

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 

NamedCache nc = CacheFactory.getCache(“stocks”);

nc.addMapListener(new MapListener() {
    public void onInsert(MapEvent mapEvent) {
    }
    public void onUpdate(MapEvent mapEvent) {
    }

    public void onDelete(MapEvent mapEvent) {
    }
 });

 

·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 

NamedCache nc = CacheFactory.getCache(“people”);

Set keys = nc.keySet( new LikeFilter(“getLastName”, “%Stone%”));

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 

NamedCache nc = CacheFactory.getCache(“stocks”);

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 

NamedCache nc = CacheFactory.getCache(“stocks”);

Double total = (Double)nc.aggregate(AlwaysFilter.INSTANCE,new DoubleSum(“getQuantity”));

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 

NamedCache nc = CacheFactory.getCache(“stocks”);

nc.invokeAll(new EqualsFilter(“getSymbol”, “ORCL”), new StockSplitProcessor());

...

class StockSplitProcessor extends AbstractProcessor {

     Object process(Entry entry) {

          Stock stock = (Stock)entry.getValue(); 

          stock.quantity *= 2;

          entry.setValue(stock);

          return null;
     }

}

 

·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/

内容概要:本文档详细介绍了Android开发中内容提供者(ContentProvider)的使用方法及其在应用间数据共享的作用。首先解释了ContentProvider作为四大组件之一,能够为应用程序提供统一的数据访问接口,支持不同应用间的跨进程数据共享。接着阐述了ContentProvider的核心方法如onCreate、insert、delete、update、query和getType的具体功能与应用场景。文档还深入讲解了Uri的结构和作用,它是ContentProvider中用于定位资源的重要标识。此外,文档说明了如何通过ContentResolver在客户端应用中访问其他应用的数据,并介绍了Android 6.0及以上版本的运行时权限管理机制,包括权限检查、申请及处理用户的选择结果。最后,文档提供了具体的实例,如通过ContentProvider读写联系人信息、监听短信变化、使用FileProvider发送彩信和安装应用等。 适合人群:对Android开发有一定了解,尤其是希望深入理解应用间数据交互机制的开发者。 使用场景及目标:①掌握ContentProvider的基本概念和主要方法的应用;②学会使用Uri进行资源定位;③理解并实现ContentResolver访问其他应用的数据;④熟悉Android 6.0以后版本的权限管理流程;⑤掌握FileProvider在发送彩信和安装应用中的应用。 阅读建议:建议读者在学习过程中结合实际项目练习,特别是在理解和实现ContentProvider、ContentResolver以及权限管理相关代码时,多进行代码调试和测试,确保对每个知识点都有深刻的理解。
开发语言:Java 框架:SSM(Spring、Spring MVC、MyBatis) JDK版本:JDK 1.8 或以上 开发工具:Eclipse 或 IntelliJ IDEA Maven版本:Maven 3.3 或以上 数据库:MySQL 5.7 或以上 此压缩包包含了本毕业设计项目的完整内容,具体包括源代码、毕业论文以及演示PPT模板。 项目配置完成后即可运行,若需添加额外功能,可根据需求自行扩展。 运行条件 确保已安装 JDK 1.8 或更高版本,并正确配置 Java 环境变量。 使用 Eclipse 或 IntelliJ IDEA 打开项目,导入 Maven 依赖,确保依赖包下载完成。 配置数据库环境,确保 MySQL 服务正常运行,并导入项目中提供的数据库脚本。 在 IDE 中启动项目,确认所有服务正常运行。 主要功能简述: 用户管理:系统管理员负责管理所有用户信息,包括学生、任课老师、班主任、院系领导和学校领导的账号创建、权限分配等。 数据维护:管理员可以动态更新和维护系统所需的数据,如学生信息、课程安排、学年安排等,确保系统的正常运行。 系统配置:管理员可以对系统进行配置,如设置数据库连接参数、调整系统参数等,以满足不同的使用需求。 身份验证:系统采用用户名和密码进行身份验证,确保只有授权用户才能访问系统。不同用户类型(学生、任课老师、班主任、院系领导、学校领导、系统管理员)具有不同的操作权限。 权限控制:系统根据用户类型分配不同的操作权限,确保用户只能访问和操作其权限范围内的功能和数据。 数据安全:系统采取多种措施保障数据安全,如数据库加密、访问控制等,防止数据泄露和非法访问。 请假审批流程:系统支持请假申请的逐级审批,包括班主任审批和院系领导审批(针对超过三天的请假)。学生可以随时查看请假申请的审批进展情况。 请假记录管理:系统记录学生的所有请假记录,包括请假时间、原因、审批状态及审批意见等,供学生和审批人员查询。 学生在线请假:学生可以通过系统在线填写请假申请,包括请假的起止日期和请假原因,并提交给班主任审批。超过三天的请假需经班主任审批后,再由院系领导审批。 出勤信息记录:任课老师可以在线记录学生的上课出勤情况,包括迟到、早退、旷课和请假等状态。 出勤信息查询:学生、任课老师、班主任、院系领导和学校领导均可根据权限查看不同范围的学生上课出勤信息。学生可以查看自己所有学年的出勤信息,任课老师可以查看所教班级的出勤信息,班主任和院系领导可以查看本班或本院系的出勤信息,学校领导可以查看全校的出勤信息。 出勤统计与分析:系统提供出勤统计功能,可以按班级、学期等条件统计学生的出勤情况,帮助管理人员了解学生的出勤状况
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值