Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
Conflicts: distributed-executor/executing-on-key-owner/src/main/java/VerifyTask.java
- Loading branch information
Showing
190 changed files
with
2,378 additions
and
728 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>cluster</artifactId> | ||
<name>Cluster</name> | ||
|
||
<parent> | ||
<groupId>com.hazelcast.samples</groupId> | ||
<artifactId>code-samples</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.hazelcast</groupId> | ||
<artifactId>hazelcast-all</artifactId> | ||
<version>${hazelcast.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import com.hazelcast.cluster.ClusterState; | ||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.instance.GroupProperty; | ||
|
||
public class ClusterFrozenState { | ||
|
||
public static void main(String[] args) { | ||
System.setProperty(GroupProperty.PHONE_HOME_ENABLED.getName(), "false"); | ||
|
||
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | ||
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); | ||
|
||
System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); | ||
System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); | ||
|
||
instance2.getCluster().changeClusterState(ClusterState.FROZEN); | ||
System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); | ||
System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); | ||
|
||
// shutdown 1st instance and start it back | ||
// it should re-join to the 2nd node | ||
instance1.shutdown(); | ||
instance1 = Hazelcast.newHazelcastInstance(); | ||
|
||
System.out.println("Instance-1 Members: " + instance1.getCluster().getMembers()); | ||
System.out.println("Instance-2 Members: " + instance2.getCluster().getMembers()); | ||
System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); | ||
System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); | ||
|
||
// a new instance cannot join to a frozen cluster | ||
try { | ||
Hazelcast.newHazelcastInstance(); | ||
} catch (IllegalStateException expected) { | ||
System.err.println("New node cannot join to the cluster: " + expected); | ||
} | ||
|
||
Hazelcast.shutdownAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import com.hazelcast.cluster.ClusterState; | ||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.core.IMap; | ||
|
||
public class ClusterPassiveState { | ||
|
||
public static void main(String[] args) { | ||
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | ||
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); | ||
|
||
System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); | ||
System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); | ||
|
||
IMap<Object, Object> map = instance2.getMap("test-map"); | ||
// initialize partition assignments before taking cluster to the PASSIVE state | ||
map.size(); | ||
|
||
instance2.getCluster().changeClusterState(ClusterState.PASSIVE); | ||
System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); | ||
System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); | ||
|
||
// shutdown 1st instance and start it back | ||
// it should re-join to the 2nd node | ||
instance1.shutdown(); | ||
instance1 = Hazelcast.newHazelcastInstance(); | ||
|
||
System.out.println("Instance-1 Members: " + instance1.getCluster().getMembers()); | ||
System.out.println("Instance-2 Members: " + instance2.getCluster().getMembers()); | ||
System.out.println("Instance-1 Cluster State: " + instance1.getCluster().getClusterState()); | ||
System.out.println("Instance-2 Cluster State: " + instance2.getCluster().getClusterState()); | ||
|
||
// readonly operations are allowed | ||
System.out.println("map.get() = " + map.get("key")); | ||
System.out.println("map.containsKey() = " + map.containsKey("key")); | ||
|
||
// non-readonly operations are NOT allowed | ||
try { | ||
map.put("key", "value"); | ||
} catch (IllegalStateException e) { | ||
System.err.println("Cannot put! Cluster is in PASSIVE state! -> " + e); | ||
} | ||
|
||
Hazelcast.shutdownAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.HazelcastInstance; | ||
|
||
public class ClusterShutdown { | ||
|
||
public static void main(String[] args) { | ||
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | ||
final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); | ||
|
||
System.out.println("Instance-1 members: " + instance1.getCluster().getMembers()); | ||
System.out.println("Instance-2 members: " + instance2.getCluster().getMembers()); | ||
|
||
// shutdown cluster | ||
instance2.getCluster().shutdown(); | ||
|
||
System.out.println("Instance-1: Is running?: " + instance1.getLifecycleService().isRunning()); | ||
System.out.println("Instance-2: Is running?: " + instance2.getLifecycleService().isRunning()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
distributed-collections/queuestore/src/main/resources/hazelcast.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
<hazelcast xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.hazelcast.com/schema/config | ||
http://www.hazelcast.com/schema/config/hazelcast-config-3.2.xsd" | ||
http://www.hazelcast.com/schema/config/hazelcast-config-3.6.xsd" | ||
xmlns="http://www.hazelcast.com/schema/config"> | ||
|
||
<!-- we need to configure the queue store here --> | ||
<queue name="queue"> | ||
|
||
</queue> | ||
|
||
</hazelcast> | ||
</hazelcast> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
distributed-executor/executing-on-all-members/src/main/java/SlaveMember.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
distributed-executor/executing-on-key-owner/src/main/java/SlaveMember.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.