`
longgangbai
  • 浏览: 7371227 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
阅读更多

   在一个Java Project中添加Coherence.jar,在jar文件中config目录中存在默认的coherence的配置信息。

package com.etrip.app;

import com.tangosol.net.CacheFactory; 
import com.tangosol.net.NamedCache;
/**
 * 一个简单的Coherence的使用采用默认的coherence cache config配置文件
 * 
 * @Title: TODO
 * @Description: 实现TODO
 * @Copyright:Copyright (c) 2011
 * @Company:
 * @Date:2013-1-4
 * @author 
 * @version 1.0
 */
public class CoherenceCache {
    NamedCache cache;
    public CoherenceCache() {
    }
   
   /**
    * 从 CacheFactory 类中创建了一个缓存实例。使用 CacheFactory 类的 getCache() 
    * 方法创建一个 NamedCache。使用一个映射到分布式缓存模式的缓存名称 VirtualCache。
	* Named cache = CacheFactory.getCache ( "VirtualCache");
	* NamedCache 是一个保存整个集群中的节点所共享的资源的 java.util.Map。
	* 使用 put() 方法添加缓存项。cache.put (key, "Hello Cache");
	* 可以使用 get() 方法检索缓存项。
	* System.out.println((String)cache.get("hello"));
    */
   public void putCache(){
        cache = CacheFactory.getCache("VirtualCache"); 
       String key = "hello"; 
       cache.put (key, "Hello Cache"); 
   
   }
   
   
   public void retrieveCache(){
       System.out.println((String)cache.get("hello"));
   }
   
    public static void main (String [] args) {
	    CoherenceCache cache = new CoherenceCache(); 
	    cache.putCache();
	    cache.retrieveCache();
    }
    
}


 

执行结果如下:

 

2013-01-05 17:15:54.099/0.830 Oracle Coherence 3.7.1.1 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/D:/app/Oracle/Middleware/coherence_3.7/lib/coherence.jar!/tangosol-coherence.xml"
2013-01-05 17:15:54.151/0.882 Oracle Coherence 3.7.1.1 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/D:/app/Oracle/Middleware/coherence_3.7/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2013-01-05 17:15:54.152/0.883 Oracle Coherence 3.7.1.1 <D5> (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
2013-01-05 17:15:54.175/0.906 Oracle Coherence 3.7.1.1 <D5> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified

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

2013-01-05 17:15:54.518/1.249 Oracle Coherence GE 3.7.1.1 <Info> (thread=main, member=n/a): Loaded cache configuration from "jar:file:/D:/app/Oracle/Middleware/coherence_3.7/lib/coherence.jar!/coherence-cache-config.xml"
2013-01-05 17:15:55.550/2.281 Oracle Coherence GE 3.7.1.1 <D4> (thread=main, member=n/a): TCMP bound to /172.30.101.179:8092 using SystemSocketProvider
2013-01-05 17:15:55.987/2.718 Oracle Coherence GE 3.7.1.1 <Info> (thread=Cluster, member=n/a): This Member(Id=4, Timestamp=2013-01-05 17:15:55.923, Address=172.30.101.179:8092, MachineId=6892, Location=site:,machine:longgangbai-PC,process:3772, Role=EtripAppCoherenceCache, Edition=Grid Edition, Mode=Development, CpuCount=4, SocketCount=4) joined cluster "cluster:0xFCDB" with senior Member(Id=1, Timestamp=2013-01-05 16:44:45.949, Address=172.30.101.179:8088, MachineId=6892, Location=site:,machine:longgangbai-PC,process:7048, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=4, SocketCount=4)
2013-01-05 17:15:56.184/2.915 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Member(Id=3, Timestamp=2013-01-05 17:11:40.531, Address=172.30.101.179:8090, MachineId=6892, Location=site:,machine:longgangbai-PC,process:3900, Role=CoherenceConsole) joined Cluster with senior member 1
2013-01-05 17:15:56.205/2.936 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Member 3 joined Service Management with senior member 3
2013-01-05 17:15:56.206/2.937 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Member 1 joined Service Management with senior member 1
2013-01-05 17:15:56.206/2.937 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Member 1 joined Service DistributedCache with senior member 1
2013-01-05 17:15:56.206/2.937 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Member 1 joined Service ReplicatedCache with senior member 1
2013-01-05 17:15:56.206/2.937 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Member 1 joined Service OptimisticCache with senior member 1
2013-01-05 17:15:56.206/2.938 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Member 1 joined Service InvocationService with senior member 1
2013-01-05 17:15:56.209/2.940 Oracle Coherence GE 3.7.1.1 <Info> (thread=main, member=n/a): Started cluster Name=cluster:0xFCDB

Group{Address=224.3.7.0, Port=37000, TTL=4}

MasterMemberSet(
  ThisMember=Member(Id=4, Timestamp=2013-01-05 17:15:55.923, Address=172.30.101.179:8092, MachineId=6892, Location=site:,machine:longgangbai-PC,process:3772, Role=EtripAppCoherenceCache)
  OldestMember=Member(Id=1, Timestamp=2013-01-05 16:44:45.949, Address=172.30.101.179:8088, MachineId=6892, Location=site:,machine:longgangbai-PC,process:7048, Role=CoherenceServer)
  ActualMemberSet=MemberSet(Size=3
    Member(Id=1, Timestamp=2013-01-05 16:44:45.949, Address=172.30.101.179:8088, MachineId=6892, Location=site:,machine:longgangbai-PC,process:7048, Role=CoherenceServer)
    Member(Id=3, Timestamp=2013-01-05 17:11:40.531, Address=172.30.101.179:8090, MachineId=6892, Location=site:,machine:longgangbai-PC,process:3900, Role=CoherenceConsole)
    Member(Id=4, Timestamp=2013-01-05 17:15:55.923, Address=172.30.101.179:8092, MachineId=6892, Location=site:,machine:longgangbai-PC,process:3772, Role=EtripAppCoherenceCache)
    )
  MemberId|ServiceVersion|ServiceJoined|MemberState
    1|3.7.1|2013-01-05 16:44:45.949|JOINED,
    3|3.7.1|2013-01-05 17:11:40.531|JOINED,
    4|3.7.1|2013-01-05 17:15:56.197|JOINED
  RecycleMillis=1200000
  RecycleSet=MemberSet(Size=0
    )
  )

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

2013-01-05 17:15:56.253/2.984 Oracle Coherence GE 3.7.1.1 <D5> (thread=Invocation:Management, member=4): Service Management joined the cluster with senior service member 1
2013-01-05 17:15:56.699/3.430 Oracle Coherence GE 3.7.1.1 <D5> (thread=DistributedCache, member=4): Service DistributedCache joined the cluster with senior service member 1
2013-01-05 17:15:56.780/3.511 Oracle Coherence GE 3.7.1.1 <D4> (thread=DistributedCache, member=4): Asking member 1 for 128 primary partitions
Hello Cache
2013-01-05 17:15:56.929/3.660 Oracle Coherence GE 3.7.1.1 <D4> (thread=ShutdownHook, member=4): ShutdownHook: stopping cluster node
2013-01-05 17:15:56.931/3.662 Oracle Coherence GE 3.7.1.1 <D5> (thread=DistributedCache, member=n/a): Service DistributedCache left the cluster
2013-01-05 17:15:56.933/3.664 Oracle Coherence GE 3.7.1.1 <D5> (thread=Invocation:Management, member=n/a): Service Management left the cluster
2013-01-05 17:15:56.939/3.670 Oracle Coherence GE 3.7.1.1 <D5> (thread=Cluster, member=n/a): Service Cluster left the cluster
 

 

分享到:
评论

相关推荐

    mybatis简单使用demo

    mybatis简单使用mybatis简单使用demomybatis简单使用demomybatis简单使用demomybatis简单使用demomybatis简单使用demomybatis简单使用demomybatis简单使用demomybatis简单使用demomybatis简单使用demomybatis简单...

    android 串口测试demo 代码简单 无bug 完美运行

    android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo 代码简单 无bug 完美运行 android 串口测试demo...

    转盘抽奖demo 转盘抽奖demo

    转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖demo转盘抽奖...

    小程序源码 简单demo(带后台)

    小程序源码 简单demo(带后台)小程序源码 简单demo(带后台)小程序源码 简单demo(带后台)小程序源码 简单demo(带后台)小程序源码 简单demo(带后台)小程序源码 简单demo(带后台)小程序源码 简单demo(带...

    javafx 的一个简单演示demo

    javafx 的一个简单演示demo

    clientDEMO clientdemo调试软件

    《clientDEMO:一款强大的监控调试工具》 在IT行业中,高效的监控与调试能力是确保系统稳定运行的关键。clientDEMO就是这样一款专为监控和调试而设计的专业软件,它在网络管理领域扮演着不可或缺的角色。这款工具以...

    微信小程序demo:简易抽奖(源代码+截图)

    微信小程序demo:简易抽奖(源代码+截图)微信小程序demo:简易抽奖(源代码+截图)微信小程序demo:简易抽奖(源代码+截图)微信小程序demo:简易抽奖(源代码+截图)微信小程序demo:简易抽奖(源代码+截图)微信小程序demo...

    各类网页设计项目demo演示

    增加3D相片demo增加文章note_jekyll更正图片档名增加作品集:表单删除tab选项卡的背景图更改posts/rwd的文章更改导航栏更正图片档名更正图片档名添加RWD文章各类网页设计项目demo演示各类网页设计项目demo演示各类...

    jFinal最简易DEMO

    《jFinal最简易DEMO解析及实践指南》 在编程世界中,轻量级框架因其简洁高效的特点,常常受到开发者的青睐。本文将深入解析“jFinal最简易DEMO”,帮助初学者理解并掌握这个基于Java的Web开发框架——jFinal的基本...

    Vitamio简易播放demo

    "Vitamio简易播放demo"是利用Vitamio框架创建的一个基本示例,用于演示如何将该框架集成到项目中并验证其正确运行。 首先,让我们深入了解一下Vitamio框架的核心特性: 1. **多媒体支持**:Vitamio支持多种音视频...

    微信小程序学习demo:基础接口演示demo(源代码+截图)

    微信小程序学习demo:基础接口演示demo(源代码+截图)微信小程序学习demo:基础接口演示demo(源代码+截图)微信小程序学习demo:基础接口演示demo(源代码+截图)微信小程序学习demo:基础接口演示demo(源代码+截图)微信...

    微信小程序经典demo学习案例:学习用demo(源代码+截图)

    微信小程序经典demo学习案例:学习用demo(源代码+截图)微信小程序经典demo学习案例:学习用demo(源代码+截图)微信小程序经典demo学习案例:学习用demo(源代码+截图)微信小程序经典demo学习案例:学习用demo(源代码+...

    Qt 多线程及简单实例 demo

    Qt 多线程及简单实例 demo。 多线程的几大特点: 1.多线程的执行顺序无法保证,与操作系统的调度策略和线程优先级等因素有关。 2.多线程的切换可能发生在任何时刻、任何地点。 3.多线程对代码的敏感度高,因此对...

    通联支付官方demo_DEMO_通联支付DEMO_通联支付官方demo_

    通联支付官方demo

    05实现mybatis简单crud功能demo

    05实现mybatis简单crud功能demo05实现mybatis简单crud功能demo05实现mybatis简单crud功能demo05实现mybatis简单crud功能demo05实现mybatis简单crud功能demo05实现mybatis简单crud功能demo05实现mybatis简单crud功能...

    小程序源码 移动端小商城DEMO (商城demo源码) (代码源)

    小程序源码 移动端小商城DEMO (商城demo源码) (代码源)小程序源码 移动端小商城DEMO (商城demo源码) (代码源)小程序源码 移动端小商城DEMO (商城demo源码) (代码源)小程序源码 移动端小商城DEMO (商城demo源码) ...

    easyui简易demo

    这个“easyui简易demo”是一个示例项目,展示了如何在实际应用中使用 EasyUI,并且包含了 SQL 语句,意味着它可能涉及数据库操作的演示。 EasyUI 的核心特点包括其简洁的 API 设计和丰富的预定义样式,这使得开发者...

    海康网络相机获取视频流简易DEMO

    海康网络相机截取视频流并解压简易DEMO 调用NET_DVR_RealPlay_V30()播放函数,启用回调PlayM4_SetDecCallBack()分析回调流,使用回调函数DecCBFun()截取视频流,分析并解压,等到char * pbuf图像

    小程序源码 简单小商城模板 (商城demo源码) (代码源)

    小程序源码 简单小商城模板 (商城demo源码) (代码源)小程序源码 简单小商城模板 (商城demo源码) (代码源)小程序源码 简单小商城模板 (商城demo源码) (代码源)小程序源码 简单小商城模板 (商城demo源码) (代码源)小...

    一些html页面或是效果的demo

    一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果的demo 一些html页面或是效果...

Global site tag (gtag.js) - Google Analytics