Hazelcast-Documentation-3.8.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Hazelcast Documentation version 3.8 Jul 18, 2017 2 In-Memory Data Grid - Hazelcast | Documentation: version 3.8 Publication date Jul 18, 2017 Copyright © 2017 Hazelcast, Inc. Permission to use, copy, modify and distribute this document for any purpose and without fee is hereby granted in perpetuity, provided that the above copyright notice and this paragraph appear in all copies. Contents 1 Preface 19 1.1 Hazelcast IMDG Editions......................................... 19 1.2 Hazelcast IMDG Architecture....................................... 19 1.3 Hazelcast IMDG Plugins.......................................... 19 1.4 Licensing.................................................. 20 1.5 Trademarks................................................. 20 1.6 Customer Support............................................. 20 1.7 Release Notes................................................ 20 1.8 Contributing to Hazelcast IMDG..................................... 20 1.9 Partners................................................... 20 1.10 Phone Home................................................ 20 1.11 Typographical Conventions........................................ 21 2 Document Revision History 23 3 Getting Started 25 3.1 Installation................................................. 25 3.1.1 Hazelcast IMDG.......................................... 25 3.1.2 Hazelcast IMDG Enterprise.................................... 25 3.1.3 Setting the License Key...................................... 26 3.1.4 Upgrading from 3.x........................................ 27 3.1.5 Upgrading from 2.x........................................ 28 3.2 Starting the Member and Client..................................... 30 3.3 Using the Scripts In The Package..................................... 32 3.4 Deploying On Amazon EC2........................................ 32 3.5 Deploying On Microsoft Azure...................................... 32 3.6 Deploying On Pivotal Cloud Foundry.................................. 32 3.7 Deploying using Docker.......................................... 33 3 4 CONTENTS 4 Hazelcast Overview 35 4.1 Sharding in Hazelcast........................................... 36 4.2 Hazelcast Topology............................................. 36 4.3 Why Hazelcast?............................................... 36 4.4 Data Partitioning.............................................. 38 4.4.1 How the Data is Partitioned.................................... 40 4.4.2 Partition Table........................................... 40 4.4.3 Repartitioning........................................... 41 4.5 Use Cases.................................................. 41 4.6 Resources.................................................. 41 5 Understanding Configuration 43 5.1 Configuring Declaratively......................................... 43 5.1.1 Composing Declarative Configuration.............................. 44 5.2 Configuring Programmatically....................................... 45 5.3 Configuring with System Properties................................... 46 5.4 Configuring within Spring Context.................................... 47 5.5 Checking Configuration.......................................... 47 5.6 Using Wildcards.............................................. 48 5.7 Using Variables............................................... 48 6 Setting Up Clusters 51 6.1 Discovering Cluster Members....................................... 51 6.1.1 Discovering Members by Multicast................................ 51 6.1.2 Discovering Members by TCP................................... 52 6.1.3 Discovering Members within EC2 Cloud............................. 53 6.1.4 Discovering Members within Azure Cloud............................ 53 6.1.5 Discovering Members with jclouds................................ 53 6.1.6 Discovering Native Clients..................................... 53 6.2 Creating Cluster Groups.......................................... 54 6.3 User Code Deployment - BETA...................................... 55 6.3.1 Configuring User Code Deployment............................... 55 6.4 Partition Group Configuration...................................... 56 6.4.1 Grouping Types.......................................... 56 6.5 Logging Configuration........................................... 59 6.6 Other Network Configurations....................................... 60 6.6.1 Public Address........................................... 60 6.6.2 Port................................................. 60 6.6.3 Outbound Ports.......................................... 61 6.6.4 Reuse Address........................................... 62 CONTENTS 5 6.6.5 Join................................................. 62 6.6.6 Interfaces.............................................. 65 6.6.7 IPv6 Support............................................ 65 7 Rolling Member Upgrades 67 7.1 Terminology................................................. 67 7.2 Hazelcast Members Compatibility Guarantees.............................. 67 7.3 Rolling Upgrade Procedure........................................ 67 7.4 Network Partitions and Rolling Upgrades................................ 68 7.5 Rolling Upgrade FAQ........................................... 68 8 Distributed Data Structures 71 8.1 Map..................................................... 74 8.1.1 Getting a Map and Putting an Entry.............................. 74 8.1.2 Backing Up Maps......................................... 77 8.1.3 Map Eviction............................................ 78 8.1.4 Evicting Map Entries....................................... 78 8.1.5 Setting In-Memory Format.................................... 83 8.1.6 Using High-Density Memory Store with Map.......................... 84 8.1.7 Loading and Storing Persistent Data............................... 85 8.1.8 Creating Near Cache for Map................................... 92 8.1.9 Locking Maps............................................ 92 8.1.10 Lock Split-Brain Protection with Pessimistic Locking...................... 95 8.1.11 Accessing Entry Statistics..................................... 95 8.1.12 Map Listener............................................ 96 8.1.13 Listening to Map Entries with Predicates............................ 96 8.1.14 Removing Bulk Map Entries with Predicates.......................... 98 8.1.15 Adding Interceptors........................................ 98 8.1.16 Preventing Out of Memory Exceptions.............................. 101 8.2 Queue.................................................... 102 8.2.1 Getting a Queue and Putting Items............................... 102 8.2.2 Creating an Example Queue.................................... 103 8.2.3 Setting a Bounded Queue..................................... 105 8.2.4 Queueing with Persistent Datastore............................... 105 8.2.5 Split-Brain Protection for Queue................................. 107 8.2.6 Configuring Queue......................................... 107 8.3 MultiMap.................................................. 108 8.3.1 Getting a MultiMap and Putting an Entry........................... 108 8.3.2 Configuring MultiMap....................................... 109 8.4 Set...................................................... 110 6 CONTENTS 8.4.1 Getting a Set and Putting Items................................. 110 8.4.2 Configuring Set........................................... 111 8.5 List..................................................... 111 8.5.1 Getting a List and Putting Items................................. 112 8.5.2 Configuring List.......................................... 112 8.6 Ringbuffer.................................................. 113 8.6.1 Getting a Ringbuffer and Reading Items............................. 113 8.6.2 Adding Items to a Ringbuffer................................... 113 8.6.3 IQueue vs. Ringbuffer....................................... 113 8.6.4 Configuring Ringbuffer Capacity................................. 114 8.6.5 Backing Up Ringbuffer....................................... 114 8.6.6 Configuring Ringbuffer Time To Live............................... 114 8.6.7 Setting Ringbuffer Overflow Policy................................ 115 8.6.8 Ringbuffer with Persistent Datastore............................... 115 8.6.9 Configuring Ringbuffer In-Memory Format........................... 116 8.6.10 Adding Batched Items....................................... 116 8.6.11 Reading Batched Items...................................... 117 8.6.12 Using Async Methods....................................... 117 8.6.13 Ringbuffer Configuration Examples................................ 118 8.7 Topic..................................................... 118 8.7.1 Getting a Topic and Publishing Messages............................ 119 8.7.2 Getting Topic Statistics...................................... 119 8.7.3 Understanding Topic Behavior.................................. 120 8.7.4 Configuring Topic......................................... 121 8.8 Reliable Topic................................................ 122 8.8.1 Sample Reliable ITopic Code................................... 122 8.8.2 Slow Consumers.......................................... 122 8.8.3 Configuring Reliable Topic.................................... 123 8.9 Lock..................................................... 123 8.9.1 Using Try-Catch Blocks with Locks............................... 123 8.9.2 Releasing Locks with tryLock Timeout.............................. 124 8.9.3 Avoiding Waiting Threads with