Developing Applications with Oracle Coherence
Total Page:16
File Type:pdf, Size:1020Kb
Oracle® Fusion Middleware Developing Applications with Oracle Coherence 14c (14.1.1.0.0) F23526-09 May 2021 Oracle Fusion Middleware Developing Applications with Oracle Coherence, 14c (14.1.1.0.0) F23526-09 Copyright © 2008, 2021, Oracle and/or its affiliates. Primary Author: Oracle Corporation This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial computer software" or "commercial computer software documentation" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government. This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle. Contents Preface Audience xxx Documentation Accessibility xxx Related Documents xxxi Conventions xxxi Part I Getting Started 1 Introduction to Coherence Basic Concepts 1-1 Clustered Data Management 1-1 A single API for the logical layer, XML configuration for the physical layer 1-2 Caching Strategies 1-2 Data Storage Options 1-3 Serialization Options 1-3 Configurability and Extensibility 1-3 Namespace Hierarchy 1-4 Read/Write Caching 1-4 NamedCache 1-4 NamedCache Usage Patterns 1-5 Querying the Cache 1-5 Invocation Service 1-6 Event Programming 1-6 Transactions 1-7 HTTP Session Management 1-7 Object-Relational Mapping Integration 1-7 C++/.NET Integration 1-7 Management and Monitoring 1-7 iii 2 Building Your First Coherence Application Task 1: Define the Example Cache 2-1 Task 2: Configure and Start the Example Cluster 2-2 Task 3: Create and Run a Basic Coherence Standalone Application 2-3 Create the Sample Standalone Application 2-3 Run the Sample Standalone Application 2-4 Verify the Example Cache 2-4 Task 4: Create and Run a Basic Coherence JavaEE Web Application 2-5 Create the Sample Web Application 2-5 Deploy and Run the Sample Web Application 2-7 Verify the Example Cache 2-7 3 Understanding Configuration Overview of the Default Configuration Files 3-1 Specifying an Operational Configuration File 3-2 Using the Default Operational Override File 3-2 Specifying an Operational Override File 3-3 Defining Override Files for Specific Operational Elements 3-4 Viewing Which Operational Override Files are Loaded 3-5 Specifying a Cache Configuration File 3-6 Using a Default Cache Configuration File 3-6 Overriding the Default Cache Configuration File 3-7 Using the Cache Configuration File System Property 3-8 Viewing Which Cache Configuration File is Loaded 3-8 Specifying a POF Configuration File 3-8 Overriding the Default POF Configuration File 3-9 Using the POF Configuration File System Property 3-10 Combining Multiple POF Configuration Files 3-10 Viewing Which POF Configuration Files are Loaded 3-11 Specifying Management Configuration Files 3-12 Specifying a Custom Report Group Configuration File 3-12 Overriding the Default Report Group Configuration File 3-13 Using the Report Group Configuration File System Property 3-14 Specifying an MBean Configuration File 3-14 Using the Default MBean Configuration Override File 3-14 Using the MBean Configuration File System Property 3-15 Viewing Which Management Configuration Files are Loaded 3-15 Disabling Schema Validation 3-16 Understanding the XML Override Feature 3-16 Using the Predefined Override Files 3-17 iv Defining Custom Override Files 3-18 Defining Multiple Override Files for the Same Element 3-20 Changing Configuration Using System Properties 3-21 Using Preconfigured System Properties 3-21 Creating Custom System Properties 3-22 4 Debugging in Coherence Overview of Debugging in Coherence 4-1 Configuring Logging 4-2 Changing the Log Level 4-2 Changing the Log Destination 4-3 Sending Log Messages to a File 4-3 Changing the Log Message Format 4-4 Setting the Logging Character Limit 4-5 Using JDK Logging for Coherence Logs 4-5 Mapping JDK Log Levels with Coherence Log Levels 4-6 Using Log4J 2 Logging for Coherence Logs 4-7 Using Log4J Logging for Coherence Logs 4-8 Mapping Log4J Log Levels with Coherence Log Levels 4-9 Using SLF4J for Coherence Logs 4-10 Performing Remote Debugging 4-10 Distributed Tracing 4-10 Configuring Tracing 4-12 Externally Managed Tracer 4-13 Traced Operations in Coherence 4-13 User-initiated Tracing 4-13 Troubleshooting Coherence-Based Applications 4-14 Using Coherence Logs 4-14 Using JMX Management and Coherence Reports 4-14 Using JVM Options to Help Debug 4-15 Using Distributed Tracing 4-15 Capturing Thread Dumps 4-15 Capturing Heap Dumps 4-17 Monitoring the Operating System 4-17 Part II Using Coherence Clusters 5 Introduction to Coherence Clusters Cluster Overview 5-1 v Understanding Clustered Services 5-1 Understanding TCMP 5-3 6 Setting Up a Cluster Overview of Setting Up Clusters 6-1 Specifying a Cluster's Name 6-1 Specifying a Cluster Member's Identity 6-2 Configuring Multicast Communication 6-4 Specifying a Cluster's Multicast Address and Port 6-4 Changing the Multicast Socket Interface 6-5 Disabling Multicast Communication 6-5 Specifying the Multicast Time-to-Live 6-6 Specifying the Multicast Join Timeout 6-6 Changing the Multicast Threshold 6-7 Specifying a Cluster Member's Unicast Address 6-8 Changing the Default Unicast Address 6-8 Changing the Default Unicast Port 6-9 Using Well Known Addresses 6-10 Specifying WKA Addresses 6-11 Specifying a WKA Address Provider 6-13 Enabling Single-Server Mode 6-14 Configuring Death Detection 6-15 Changing TCP-Ring Settings 6-15 Changing the Heartbeat Interval 6-16 Disabling Death Detection 6-17 Specifying Cluster Priorities 6-17 Specifying a Cluster Member's Priority 6-18 Specifying Communication Thread Priorities 6-18 Specifying Thread Priorities for Services 6-19 Configuring Firewalls for Cluster Members 6-19 7 Starting and Stopping Cluster Members Starting Cache Servers 7-1 Overview of the DefaultCacheServer Class 7-1 Starting Cache Servers From the Command Line 7-2 Starting Cache Servers Programmatically 7-3 Starting Cache Clients 7-3 Disabling Local Storage 7-3 Using the CacheFactory Class to Start a Cache Client 7-4 vi Stopping Cluster Members 7-5 Prerequisites for Stopping All Cluster Members 7-5 Stopping Cluster Members From the Command Line 7-5 Stopping Cache Servers Programmatically 7-6 Performing