Oracle Fusion Middleware/Coherence

3장. Coherence Examples 실행

수상한 김토끼 2022. 5. 16. 17:12

안녕하세요.

'수상한 김토끼' 입니다.

2장의 설치에 이어 Oracle의 in-memory 캐시 솔루션인 Coherence 예제를 실행해 보겠습니다.

 

이 블로그 글은 미들웨어 경험이 없으신 분들도 쉽게 따라 하실 수 있도록 쉽게 작성하는 것이 목표입니다.

설명을 보고 진행하시다가 궁금하신 내용은 댓글로 문의하시면 가능한 범위 내에서 알려 드리도록 하겠습니다.


1. Coherence Examples

코히어런스가 무엇이며 어떻게 사용하는지를 알아보려면 함께 제공 된 예제를 실행해 보며 확인해 보는게

가장 좋을 것으로 판단되어 코히어런스 설치 완료 후 예제에 대해 알아보려고 합니다.

 

관련 내용은 공식 문서를 통해 자세히 알아보실 수 있습니다.

https://docs.oracle.com/middleware/12213/coherence/install/running-coherence-examples.htm#COHIN5885

 

Running the Coherence Examples

ObserverExample demonstrates how to use a MapListener to monitor cache events such as when cache data has been inserted, updated, and removed. There is no immediate output when this example is run. The registered listener outputs the entry when it is inser

docs.oracle.com


2. Coherence Examples build

코히어런스 예제를 실행하기 위해서는 구성 된 환경에 맞게 build를 수행해야 합니다.

 

예제를 실행하기 위해서는 $JAVA_HOME과 $COHERENCE_HOME 변수가 지정되어 있어야 하며

다음과 같이 지정 및 확인이 가능합니다.

1
2
3
4
5
[coherence@coherence ~]$ export COHERENCE_HOME=/home/coherence/coherence14c
[coherence@coherence ~]$ export JAVA_HOME=/home/coherence/jdk1.8.0_321
[coherence@coherence ~]$ env | grep _HOME
COHERENCE_HOME=/home/coherence/coherence14c
JAVA_HOME=/home/coherence/jdk1.8.0_321
cs

 

6.3.1.3 build Instructions for Java

예제 중 첫번째 contacts를 build 해 보겠습니다.

build는 $COHERENCE_HOME/coherence/examples/java/bin 경로의 build 파일을 이용하며

build <예제명> 으로 수행합니다.

1
2
3
4
5
[coherence@coherence bin]$ ls
build  build.cmd  function_set_env  function_set_example_env  run  run-cache-server  run-cache-server.cmd  run.cmd  set_env.cmd  set_example_env.cmd
[coherence@coherence bin]$ ./build contacts
building contacts from com/tangosol/examples/contacts ...
Please refer to readme.txt for instructions on how to run the contacts example
cs

 

코히어런스가 정상적으로 설치 되었으며, $JAVA_HOME과 $COHERENCE_HOME이 정상적으로 지정되어 있으면 위와 같이 빌드가 마무리 됩니다.

 

해당 예제를 실행하는 방법은 다음과 같습니다.


3. Coherence Examples Run

코히어런스 예제는 다음 2단계를 통해 실행할 수 있습니다.

 

1. $COHERENCE_HOME/coherence/examples/java/bin 경로의 run-cache-server 실행
2. $COHERENCE_HOME/coherence/examples/java/bin 경로의 run <예제명> 실행

6.4.1.3 Instructions for Java

 

2단계에서 build한 contacts 예제를 실행 해 보겠습니다.


3.1. run-cache-server

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
[coherence@coherence bin]$ ls
build  build.cmd  function_set_env  function_set_example_env  run  run-cache-server  run-cache-server.cmd  run.cmd  set_env.cmd  set_example_env.cmd
[coherence@coherence bin]$ ./run-cache-server &
[14689
[coherence@coherence bin]$ 2022-05-16 16:48:10.683/0.661 Oracle Coherence 14.1.1.0.0 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/home/coherence/coherence14c/coherence/lib/coherence.jar!/tangosol-coherence.xml"
2022-05-16 16:48:10.836/0.814 Oracle Coherence 14.1.1.0.0 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/home/coherence/coherence14c/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2022-05-16 16:48:10.837/0.815 Oracle Coherence 14.1.1.0.0 <Info> (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
2022-05-16 16:48:10.850/0.828 Oracle Coherence 14.1.1.0.0 <Info> (thread=main, member=n/a): Optional configuration override "cache-factory-config.xml" is not specified
2022-05-16 16:48:10.851/0.829 Oracle Coherence 14.1.1.0.0 <Info> (thread=main, member=n/a): Optional configuration override "cache-factory-builder-config.xml" is not specified
2022-05-16 16:48:10.851/0.829 Oracle Coherence 14.1.1.0.0 <Info> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified
 
Oracle Coherence Version 14.1.1.0.0 Build 77467
 Grid Edition: Development mode
Copyright (c) 20002020, Oracle and/or its affiliates. All rights reserved.
 
2022-05-16 16:48:11.069/1.047 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/home/coherence/coherence14c/coherence/examples/java/resource/config/examples-cache-config.xml"
2022-05-16 16:48:11.509/1.487 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=n/a): The cluster name has not been configured, a value of "coherence's cluster" has been automatically generated
2022-05-16 16:48:11.573/1.551 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=n/a): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory
2022-05-16 16:48:11.972/1.950 Oracle Coherence GE 14.1.1.0.0 <Warning> (thread=main, member=n/a): Local address "127.0.0.1" is a loopback address; this cluster node will not connect to nodes located on different machines
2022-05-16 16:48:11.995/1.973 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=n/a): TCMP bound to /127.0.0.1:45823 using SystemDatagramSocketProvider
2022-05-16 16:48:15.320/5.298 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=NameService:TcpAcceptor, member=n/a): TcpAcceptor now listening for connections on coherence.sub05100041460.coherencevcn.oraclevcn.com:45823.3
2022-05-16 16:48:15.321/5.299 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Cluster, member=n/a): NameService now listening for connections on coherence.sub05100041460.coherencevcn.oraclevcn.com:5555.3
2022-05-16 16:48:15.322/5.301 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Cluster, member=n/a): Created a new cluster "coherence's cluster" with Member(Id=1, Timestamp=2022-05-16 16:48:12.067, Address=127.0.0.1:45823, MachineId=10131, Location=machine:localhost,process:4692, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=2, SocketCount=2)
2022-05-16 16:48:15.349/5.327 Oracle Coherence GE 14.1.1.0.0 <D5> (thread=Transport:TransportService, member=n/a): Service TransportService is bound to tmb://127.0.0.1:45823.60250
2022-05-16 16:48:15.358/5.336 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Transport:TransportService, member=n/a): Service TransportService joined the cluster with senior service member 1
2022-05-16 16:48:15.362/5.340 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=n/a): Started cluster Name=coherence's cluster, ClusterPort=5555
 
WellKnownAddressList(
  127.0.0.1
  )
 
MasterMemberSet(
  ThisMember=Member(Id=1, Timestamp=2022-05-16 16:48:12.067, Address=127.0.0.1:45823, MachineId=10131, Location=machine:localhost,process:4692, Role=CoherenceServer)
  OldestMember=Member(Id=1, Timestamp=2022-05-16 16:48:12.067, Address=127.0.0.1:45823, MachineId=10131, Location=machine:localhost,process:4692, Role=CoherenceServer)
  ActualMemberSet=MemberSet(Size=1
    Member(Id=1, Timestamp=2022-05-16 16:48:12.067, Address=127.0.0.1:45823, MachineId=10131, Location=machine:localhost,process:4692, Role=CoherenceServer)
    )
  MemberId|ServiceJoined|MemberState|Version
    1|2022-05-16 16:48:12.067|JOINED|14.1.1.0.0
  RecycleMillis=1200000
  RecycleSet=MemberSet(Size=0
    )
  )
 
TcpRing{Connections=[]}
IpMonitor{Addresses=0, Timeout=15s}
 
2022-05-16 16:48:15.375/5.353 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
2022-05-16 16:48:15.440/5.418 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=1): Loaded Reporter configuration from "jar:file:/home/coherence/coherence14c/coherence/lib/coherence.jar!/reports/report-group.xml"
2022-05-16 16:48:15.481/5.459 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=1): JMXConnectorServer now listening for connections on coherence.sub05100041460.coherencevcn.oraclevcn.com
2022-05-16 16:48:15.494/5.472 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=1): Loaded Reporter configuration from "jar:file:/home/coherence/coherence14c/coherence/lib/coherence.jar!/reports/report-group.xml"
2022-05-16 16:48:15.736/5.714 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): Loaded POF configuration from "file:/home/coherence/coherence14c/coherence/examples/java/resource/config/pof-config.xml"
2022-05-16 16:48:15.767/5.745 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): Loaded included POF configuration from "jar:file:/home/coherence/coherence14c/coherence/lib/coherence.jar!/coherence-pof-config.xml"
2022-05-16 16:48:15.952/5.930 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): Service PartitionedPofCache joined the cluster with senior service member 1
2022-05-16 16:48:15.973/5.951 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): Service PartitionedPofCache: sending PartitionConfig ConfigSync to all
2022-05-16 16:48:16.018/5.996 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): This member has become the distribution coordinator for MemberSet(Size=1
  Member(Id=1, Timestamp=2022-05-16 16:48:12.067, Address=127.0.0.1:45823, MachineId=10131, Location=machine:localhost,process:4692, Role=CoherenceServer)
  )
2022-05-16 16:48:16.070/6.048 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): Partition ownership has stabilized with 1 nodes
2022-05-16 16:48:16.071/6.049 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Proxy:TcpProxyService:TcpAcceptor, member=1): TcpAcceptor now listening for connections on coherence.sub05100041460.coherencevcn.oraclevcn.com:45823.35156
2022-05-16 16:48:16.080/6.058 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Proxy:TcpProxyService, member=1): Service TcpProxyService joined the cluster with senior service member 1
2022-05-16 16:48:16.087/6.065 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Invocation:InvocationService, member=1): Service InvocationService joined the cluster with senior service member 1
2022-05-16 16:48:16.096/6.074 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=main, member=1):
Services
  (
  ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, OldestMemberId=1}
  TransportService{Name=TransportService, State=(SERVICE_STARTED), Id=1, OldestMemberId=1}
  InvocationService{Name=Management, State=(SERVICE_STARTED), Id=2, OldestMemberId=1}
  PartitionedCache{Name=PartitionedPofCache, State=(SERVICE_STARTED), Id=3, OldestMemberId=1, LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0, CoordinatorId=1}
  ProxyService{Name=TcpProxyService, State=(SERVICE_STARTED), Id=4, OldestMemberId=1}
  InvocationService{Name=InvocationService, State=(SERVICE_STARTED), Id=5, OldestMemberId=1}
  )
 
Started DefaultCacheServer...
cs

캐시 서버가 정상적으로 실행되었습니다.


3.2. run contacts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
[coherence@coherence bin]$ ls
build  build.cmd  function_set_env  function_set_example_env  run  run-cache-server  run-cache-server.cmd  run.cmd  set_env.cmd  set_example_env.cmd
[coherence@coherence bin]$ ./run contacts
redirecting Coherence logging to contacts.log...
2022-05-16 16:49:47.550/97.528 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Cluster, member=1): Member(Id=2, Timestamp=2022-05-16 16:49:47.348, Address=127.0.0.1:36827, MachineId=10131, Location=machine:localhost,process:4752, Role=TangosolExamplesContactsDriver) joined Cluster with senior member 1
2022-05-16 16:49:47.860/97.838 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=SelectionService(channels=6, selector=MultiplexedSelector(sun.nio.ch.EPollSelectorImpl@43015c69), id=26970580), member=1): Connection established with tmb://127.0.0.1:36827.48290
2022-05-16 16:49:47.890/97.868 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Transport:TransportService, member=1): Member 2 joined Service TransportService with senior member 1
2022-05-16 16:49:47.897/97.875 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Invocation:Management, member=1): Member 2 joined Service Management with senior member 1
2022-05-16 16:49:48.633/98.612 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): Member 2 joined Service PartitionedPofCache with senior member 1
 
------contacts examples begin------
 
------LoaderExample begins------
.........Added 10000 entries to cache
 
------LoaderExample completed------
 
------QueryExample begins------
MA Residents
MA Residents, Work Elsewhere
ConverterEntry{Key="John Fwlawrj", Value="John Fwlawrj
Addresses
Home: 873 Beacon St.
 
Lmldubjsnc, MA 04472
US
Work: Yoyodyne Propulsion Systems
330 Lectroid Rd.
Grover's Mill, FM 02310
US
Phone Numbers
work: +11 63 775 6818783
home: +11 46 431 2441646
Birth Date: 1952-01-05 (70 years old)"}
ConverterEntry{Key="John Tbruzf", Value="John Tbruzf
Addresses
Home: 165 Beacon St.
 
Dchziw, MA 02622
US
Work: Yoyodyne Propulsion Systems
330 Lectroid Rd.
Grover's Mill, OR 06965
US
Phone Numbers
work: +11 78 173 7512756
home: +11 43 607 3995997
Birth Date: 1968-01-01 (54 years old)"}
ConverterEntry{Key="John Tfaduhind", Value="John Tfaduhind
Addresses
Home: 953 Beacon St.
 
... 중략 ...
 
Knxdxmwyyd, MA 52213
US
Work: 200 Newbury St.
Yoyodyne, Ltd.
Boston, MA 02116
US
Phone Numbers
work: +11 39 350 6583674
home: +11 74 179 7533217
Birth Date: 1967-01-01 (55 years old)
entry updated
old value:
John Pjynrscwqz
Addresses
Home: 29 Beacon St.
 
Lsrdwmhsa, MA 34782
US
Work: 201 Newbury St.
Yoyodyne, Ltd.
Boston, MA 02116
US
Phone Numbers
work: +11 60 355 9953572
home: +11 94 510 7493163
Birth Date: 1966-01-01 (56 years old)
new value:
John Pjynrscwqz
Addresses
Home: 29 Beacon St.
 
Lsrdwmhsa, MA 34782
US
Work: 200 Newbury St.
Yoyodyne, Ltd.
Boston, MA 02116
US
Phone Numbers
work: +11 60 355 9953572
home: +11 94 510 7493163
Birth Date: 1966-01-01 (56 years old)
 
------Recalculate the age attribute------
 
------ProcessorExample completed------
 
------SimpleMapListener removed------
 
------ObserverExample completed------
 
------contacts examples completed------
2022-05-16 17:04:59.879/1009.857 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Cluster, member=1): TcpRing disconnected from Member(Id=3, Timestamp=2022-05-16 17:04:56.089, Address=127.0.0.1:35797, MachineId=10131, Location=machine:localhost,process:4817, Role=TangosolExamplesContactsDriver) due to a peer departure (end of stream); removing the member.
2022-05-16 17:04:59.879/1009.857 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Invocation:Management, member=1): Member 3 left service Management with senior member 1
2022-05-16 17:04:59.879/1009.857 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Cluster, member=1): Member(Id=3, Timestamp=2022-05-16 17:04:59.879, Address=127.0.0.1:35797, MachineId=10131, Location=machine:localhost,process:4817, Role=TangosolExamplesContactsDriver) left Cluster with senior member 1
2022-05-16 17:04:59.880/1009.858 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=DistributedCache:PartitionedPofCache, member=1): Member 3 left service PartitionedPofCache with senior member 1
2022-05-16 17:04:59.880/1009.858 Oracle Coherence GE 14.1.1.0.0 <Info> (thread=Transport:TransportService, member=1): Member 3 left service TransportService with senior member 1
cs

 

예제가 로드 되었고 10,000개의 연락처를 cache에 add 하는 과정이 성공하였습니다.

 

이와 같이 사용 환경(Java, C++ 등)에 맞게 example을 build하여 실행 해 보실 수 있으니 다른 예제들도 수행 해 보시고

상황에 맞는 샘플을 찾아 적용해 보시면 좋을 것 같습니다.


이번 장은 이정도로 마무리하겠습니다. 여러 유용한 예제가 있으니 꼭 확인 해 보시길 바랍니다.

다음 장에서는 contacts 예제 소스를 보며 코히어런스가 어떤 방식으로 동작하는지 알아보도록 하겠습니다.