diff --git a/cluster-quorum/pom.xml b/cluster-quorum/pom.xml index 82385d952..f650ecc78 100644 --- a/cluster-quorum/pom.xml +++ b/cluster-quorum/pom.xml @@ -4,6 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + cluster-quorum Cluster Quorum 0.1-SNAPSHOT @@ -18,8 +19,10 @@ com.hazelcast - hazelcast + hazelcast-all ${hazelcast.version} - + + + \ No newline at end of file diff --git a/cluster/pom.xml b/cluster/pom.xml deleted file mode 100644 index e2795912f..000000000 --- a/cluster/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - 4.0.0 - - cluster - Cluster - - - com.hazelcast.samples - code-samples - 0.1-SNAPSHOT - ../pom.xml - - - - - com.hazelcast - hazelcast-all - ${hazelcast.version} - - - - diff --git a/cluster/src/main/java/ClusterFrozenState.java b/cluster/src/main/java/ClusterFrozenState.java deleted file mode 100644 index 1320983a0..000000000 --- a/cluster/src/main/java/ClusterFrozenState.java +++ /dev/null @@ -1,40 +0,0 @@ -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(); - } -} diff --git a/cluster/src/main/java/ClusterPassiveState.java b/cluster/src/main/java/ClusterPassiveState.java deleted file mode 100644 index df3fa305a..000000000 --- a/cluster/src/main/java/ClusterPassiveState.java +++ /dev/null @@ -1,46 +0,0 @@ -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 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(); - } -} diff --git a/cluster/src/main/java/ClusterShutdown.java b/cluster/src/main/java/ClusterShutdown.java deleted file mode 100644 index 0a53557cb..000000000 --- a/cluster/src/main/java/ClusterShutdown.java +++ /dev/null @@ -1,19 +0,0 @@ -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()); - } -} diff --git a/distributed-collections/boundedblockingqueue/src/main/resources/hazelcast.xml b/distributed-collections/boundedblockingqueue/src/main/resources/hazelcast.xml index 11dc8ec1f..593b62c6e 100644 --- a/distributed-collections/boundedblockingqueue/src/main/resources/hazelcast.xml +++ b/distributed-collections/boundedblockingqueue/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ 10 - + \ No newline at end of file diff --git a/distributed-collections/queuestore/src/main/resources/hazelcast.xml b/distributed-collections/queuestore/src/main/resources/hazelcast.xml index a89d1d620..2636e455b 100644 --- a/distributed-collections/queuestore/src/main/resources/hazelcast.xml +++ b/distributed-collections/queuestore/src/main/resources/hazelcast.xml @@ -1,9 +1,11 @@ + - + + \ No newline at end of file diff --git a/distributed-collections/ringbuffer/src/main/resources/hazelcast.xml b/distributed-collections/ringbuffer/src/main/resources/hazelcast.xml index a3f74f09e..e81714ad7 100644 --- a/distributed-collections/ringbuffer/src/main/resources/hazelcast.xml +++ b/distributed-collections/ringbuffer/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -14,4 +14,4 @@ 5 - + \ No newline at end of file diff --git a/distributed-executor/basic-executor/src/main/java/EchoTask.java b/distributed-executor/basic-executor/src/main/java/EchoTask.java index ab5094405..e08f94017 100644 --- a/distributed-executor/basic-executor/src/main/java/EchoTask.java +++ b/distributed-executor/basic-executor/src/main/java/EchoTask.java @@ -1,7 +1,6 @@ import java.io.Serializable; public class EchoTask implements Runnable, Serializable { - private final String msg; public EchoTask(String msg) { @@ -12,9 +11,7 @@ public void run() { try { Thread.sleep(5000); } catch (InterruptedException e) { - e.printStackTrace(); } - - System.out.println("Echo: " + msg); + System.out.println("Echo:" + msg); } } diff --git a/distributed-executor/basic-executor/src/main/java/MasterMember.java b/distributed-executor/basic-executor/src/main/java/MasterMember.java index f007ff239..f7e7a00ee 100644 --- a/distributed-executor/basic-executor/src/main/java/MasterMember.java +++ b/distributed-executor/basic-executor/src/main/java/MasterMember.java @@ -3,15 +3,13 @@ import com.hazelcast.core.IExecutorService; public class MasterMember { - public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IExecutorService executor = hz.getExecutorService("executor"); - - for (int i = 1; i <= 1; i++) { + for (int k = 1; k <= 1; k++) { Thread.sleep(1000); - System.out.println("Producing echo task: " + i); - executor.execute(new EchoTask("" + i)); + System.out.println("Producing echo task: " + k); + executor.execute(new EchoTask("" + k)); } System.out.println("MasterMember finished!"); diff --git a/distributed-executor/executing-on-all-members/src/main/java/MasterMember.java b/distributed-executor/executing-on-all-members/src/main/java/MasterMember.java index edbd1de89..94c3afd90 100644 --- a/distributed-executor/executing-on-all-members/src/main/java/MasterMember.java +++ b/distributed-executor/executing-on-all-members/src/main/java/MasterMember.java @@ -8,20 +8,16 @@ import java.util.concurrent.Future; public class MasterMember { - public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); Map map = hz.getMap("map"); - for (int i = 0; i < 5; i++) { + for (int k = 0; k < 5; k++) map.put(UUID.randomUUID().toString(), 1); - } IExecutorService executor = hz.getExecutorService("executor"); - Map> result = executor.submitToAllMembers(new SumTask()); int sum = 0; - for (Future future : result.values()) { + for (Future future : result.values()) sum += future.get(); - } System.out.println("Result: " + sum); } diff --git a/distributed-executor/executing-on-all-members/src/main/java/SlaveMember.java b/distributed-executor/executing-on-all-members/src/main/java/SlaveMember.java index 700cdb6e6..afd273380 100644 --- a/distributed-executor/executing-on-all-members/src/main/java/SlaveMember.java +++ b/distributed-executor/executing-on-all-members/src/main/java/SlaveMember.java @@ -1,7 +1,6 @@ import com.hazelcast.core.Hazelcast; public class SlaveMember { - public static void main(String[] args) { Hazelcast.newHazelcastInstance(); } diff --git a/distributed-executor/executing-on-all-members/src/main/java/SumTask.java b/distributed-executor/executing-on-all-members/src/main/java/SumTask.java index 9b47077fb..9d4392b80 100644 --- a/distributed-executor/executing-on-all-members/src/main/java/SumTask.java +++ b/distributed-executor/executing-on-all-members/src/main/java/SumTask.java @@ -5,8 +5,8 @@ import java.io.Serializable; import java.util.concurrent.Callable; -public class SumTask implements Callable, Serializable, HazelcastInstanceAware { - +public class SumTask implements + Callable, Serializable, HazelcastInstanceAware { private transient HazelcastInstance hz; public void setHazelcastInstance(HazelcastInstance hz) { @@ -20,7 +20,7 @@ public Integer call() throws Exception { System.out.println("Calculating for key: " + key); result += map.get(key); } - System.out.println("Local result: " + result); + System.out.println("Local Result: " + result); return result; } } diff --git a/distributed-executor/executing-on-key-owner/src/main/java/MasterMember.java b/distributed-executor/executing-on-key-owner/src/main/java/MasterMember.java index 350c0cf46..22d0b8bf2 100644 --- a/distributed-executor/executing-on-key-owner/src/main/java/MasterMember.java +++ b/distributed-executor/executing-on-key-owner/src/main/java/MasterMember.java @@ -6,17 +6,13 @@ import java.util.UUID; public class MasterMember { - public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); Map map = hz.getMap("map"); - for (int i = 0; i < 10; i++) { + for (int k = 0; k < 10; k++) map.put(UUID.randomUUID().toString(), ""); - } - IExecutorService executor = hz.getExecutorService("executor"); - for (String key : map.keySet()) { + for (String key : map.keySet()) executor.executeOnKeyOwner(new VerifyTask(key), key); - } } } diff --git a/distributed-executor/executing-on-key-owner/src/main/java/SlaveMember.java b/distributed-executor/executing-on-key-owner/src/main/java/SlaveMember.java index 700cdb6e6..afd273380 100644 --- a/distributed-executor/executing-on-key-owner/src/main/java/SlaveMember.java +++ b/distributed-executor/executing-on-key-owner/src/main/java/SlaveMember.java @@ -1,7 +1,6 @@ import com.hazelcast.core.Hazelcast; public class SlaveMember { - public static void main(String[] args) { Hazelcast.newHazelcastInstance(); } diff --git a/distributed-executor/executing-on-key-owner/src/main/java/VerifyTask.java b/distributed-executor/executing-on-key-owner/src/main/java/VerifyTask.java index 82492d9a3..b46ac9807 100644 --- a/distributed-executor/executing-on-key-owner/src/main/java/VerifyTask.java +++ b/distributed-executor/executing-on-key-owner/src/main/java/VerifyTask.java @@ -5,7 +5,6 @@ import java.io.Serializable; public class VerifyTask implements Runnable, Serializable, HazelcastInstanceAware { - private final String key; private transient HazelcastInstance hz; @@ -20,6 +19,6 @@ public void setHazelcastInstance(HazelcastInstance hz) { public void run() { IMap map = hz.getMap("map"); boolean localKey = map.localKeySet().contains(key); - System.out.println("Key " + key + " is local: " + localKey); + System.out.println("Key is local:" + localKey); } } diff --git a/distributed-executor/executing-on-lite-members/src/main/java/ComputationHeavyTask.java b/distributed-executor/executing-on-lite-members/src/main/java/ComputationHeavyTask.java index 6b77e0850..4c6c9d377 100644 --- a/distributed-executor/executing-on-lite-members/src/main/java/ComputationHeavyTask.java +++ b/distributed-executor/executing-on-lite-members/src/main/java/ComputationHeavyTask.java @@ -4,8 +4,8 @@ import java.io.Serializable; import java.util.concurrent.Callable; -public class ComputationHeavyTask implements Callable, Serializable, HazelcastInstanceAware { - +public class ComputationHeavyTask implements + Callable, Serializable, HazelcastInstanceAware { private transient HazelcastInstance hz; public void setHazelcastInstance(HazelcastInstance hz) { diff --git a/distributed-executor/executing-on-lite-members/src/main/java/StartDataMember.java b/distributed-executor/executing-on-lite-members/src/main/java/StartDataMember.java index 542590719..cefc8ed17 100644 --- a/distributed-executor/executing-on-lite-members/src/main/java/StartDataMember.java +++ b/distributed-executor/executing-on-lite-members/src/main/java/StartDataMember.java @@ -6,13 +6,10 @@ import java.util.concurrent.Future; public class StartDataMember { - public static void main(String[] args) throws Exception { - HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IExecutorService executor = hz.getExecutorService("executor"); - - Future future = executor.submit(new ComputationHeavyTask(), MemberSelectors.LITE_MEMBER_SELECTOR); - + final HazelcastInstance hz = Hazelcast.newHazelcastInstance(); + final IExecutorService executor = hz.getExecutorService("executor"); + final Future future = executor.submit(new ComputationHeavyTask(), MemberSelectors.LITE_MEMBER_SELECTOR); System.out.println("Result: " + future.get()); } } diff --git a/distributed-executor/executing-on-lite-members/src/main/java/StartLiteMember.java b/distributed-executor/executing-on-lite-members/src/main/java/StartLiteMember.java index 5b1421648..9b12a2231 100644 --- a/distributed-executor/executing-on-lite-members/src/main/java/StartLiteMember.java +++ b/distributed-executor/executing-on-lite-members/src/main/java/StartLiteMember.java @@ -2,11 +2,9 @@ import com.hazelcast.core.Hazelcast; public class StartLiteMember { - public static void main(String[] args) { - Config config = new Config(); + final Config config = new Config(); config.setLiteMember(true); - Hazelcast.newHazelcastInstance(config); } } diff --git a/distributed-executor/executing-on-specific-member/src/main/java/EchoTask.java b/distributed-executor/executing-on-specific-member/src/main/java/EchoTask.java index 28d1cdae2..2565b8100 100644 --- a/distributed-executor/executing-on-specific-member/src/main/java/EchoTask.java +++ b/distributed-executor/executing-on-specific-member/src/main/java/EchoTask.java @@ -8,6 +8,6 @@ public EchoTask(String msg) { } public void run() { - System.out.println("Echo: " + msg); + System.out.println(msg); } } diff --git a/distributed-executor/executing-on-specific-member/src/main/java/MasterMember.java b/distributed-executor/executing-on-specific-member/src/main/java/MasterMember.java index 4e7218c71..498f9e854 100644 --- a/distributed-executor/executing-on-specific-member/src/main/java/MasterMember.java +++ b/distributed-executor/executing-on-specific-member/src/main/java/MasterMember.java @@ -4,13 +4,11 @@ import com.hazelcast.core.Member; public class MasterMember { - public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IExecutorService executorService = hz.getExecutorService("executor"); - for (Member member : hz.getCluster().getMembers()) { - EchoTask task = new EchoTask(member.getSocketAddress().toString()); + EchoTask task = new EchoTask("echo" + member.getSocketAddress()); executorService.executeOnMember(task, member); } } diff --git a/distributed-executor/executing-on-specific-member/src/main/java/SlaveMember.java b/distributed-executor/executing-on-specific-member/src/main/java/SlaveMember.java index 700cdb6e6..afd273380 100644 --- a/distributed-executor/executing-on-specific-member/src/main/java/SlaveMember.java +++ b/distributed-executor/executing-on-specific-member/src/main/java/SlaveMember.java @@ -1,7 +1,6 @@ import com.hazelcast.core.Hazelcast; public class SlaveMember { - public static void main(String[] args) { Hazelcast.newHazelcastInstance(); } diff --git a/distributed-executor/execution-callback/src/main/java/FibonacciCallable.java b/distributed-executor/execution-callback/src/main/java/FibonacciCallable.java index 024b070ac..5b8b2edc6 100644 --- a/distributed-executor/execution-callback/src/main/java/FibonacciCallable.java +++ b/distributed-executor/execution-callback/src/main/java/FibonacciCallable.java @@ -2,7 +2,6 @@ import java.util.concurrent.Callable; public class FibonacciCallable implements Callable, Serializable { - private final int input; public FibonacciCallable(int input) { @@ -18,10 +17,7 @@ private long calculate(int n) { System.out.println("FibonacciCallable is interrupted"); throw new RuntimeException("FibonacciCallable is interrupted"); } - if (n <= 1) { - return n; - } else { - return calculate(n - 1) + calculate(n - 2); - } + if (n <= 1) return n; + else return calculate(n - 1) + calculate(n - 2); } -} +} \ No newline at end of file diff --git a/distributed-executor/execution-callback/src/main/java/MasterMember.java b/distributed-executor/execution-callback/src/main/java/MasterMember.java index 15fb28016..ac1dfea5d 100644 --- a/distributed-executor/execution-callback/src/main/java/MasterMember.java +++ b/distributed-executor/execution-callback/src/main/java/MasterMember.java @@ -4,11 +4,9 @@ import com.hazelcast.core.IExecutorService; public class MasterMember { - public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); IExecutorService executor = hz.getExecutorService("executor"); - ExecutionCallback executionCallback = new ExecutionCallback() { public void onFailure(Throwable t) { t.printStackTrace(); @@ -18,7 +16,6 @@ public void onResponse(Long response) { System.out.println("Result: " + response); } }; - executor.submit(new FibonacciCallable(10), executionCallback); System.out.println("Fibonacci task submitted"); } diff --git a/distributed-executor/futures/src/main/java/FibonacciCallable.java b/distributed-executor/futures/src/main/java/FibonacciCallable.java index b97de062f..f93fe238d 100644 --- a/distributed-executor/futures/src/main/java/FibonacciCallable.java +++ b/distributed-executor/futures/src/main/java/FibonacciCallable.java @@ -2,7 +2,6 @@ import java.util.concurrent.Callable; public class FibonacciCallable implements Callable, Serializable { - private final int input; public FibonacciCallable(int input) { @@ -14,10 +13,7 @@ public Long call() { } private long calculate(int n) { - if (n <= 1) { - return n; - } else { - return calculate(n - 1) + calculate(n - 2); - } + if (n <= 1) return n; + else return calculate(n - 1) + calculate(n - 2); } -} +} \ No newline at end of file diff --git a/distributed-executor/futures/src/main/java/MasterMember.java b/distributed-executor/futures/src/main/java/MasterMember.java index 9ecfa6268..fc15c8745 100644 --- a/distributed-executor/futures/src/main/java/MasterMember.java +++ b/distributed-executor/futures/src/main/java/MasterMember.java @@ -7,22 +7,19 @@ import java.util.concurrent.TimeoutException; public class MasterMember { - public static void main(String[] args) throws Exception { + HazelcastInstance hz = Hazelcast.newHazelcastInstance(); + IExecutorService executor = hz.getExecutorService("executor"); int n = 10; - if (args.length != 0) { + if (args.length != 0){ n = Integer.parseInt(args[0]); } - - HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IExecutorService executor = hz.getExecutorService("executor"); - Future future = executor.submit(new FibonacciCallable(n)); try { long result = future.get(10, TimeUnit.SECONDS); System.out.println("Result: " + result); - } catch (TimeoutException e) { - System.err.println("A timeout occurred!"); + } catch (TimeoutException ex) { + System.out.println("A timeout happened"); future.cancel(true); } } diff --git a/distributed-executor/scale-out/src/main/java/EchoTask.java b/distributed-executor/scale-out/src/main/java/EchoTask.java index ab5094405..cd2cb4b0b 100644 --- a/distributed-executor/scale-out/src/main/java/EchoTask.java +++ b/distributed-executor/scale-out/src/main/java/EchoTask.java @@ -1,7 +1,6 @@ import java.io.Serializable; public class EchoTask implements Runnable, Serializable { - private final String msg; public EchoTask(String msg) { @@ -14,7 +13,6 @@ public void run() { } catch (InterruptedException e) { e.printStackTrace(); } - - System.out.println("Echo: " + msg); + System.out.println("echo:" + msg); } } diff --git a/distributed-executor/scale-out/src/main/java/MasterMember.java b/distributed-executor/scale-out/src/main/java/MasterMember.java index 0bd2571c5..5d200b432 100644 --- a/distributed-executor/scale-out/src/main/java/MasterMember.java +++ b/distributed-executor/scale-out/src/main/java/MasterMember.java @@ -3,17 +3,14 @@ import com.hazelcast.core.IExecutorService; public class MasterMember { - public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IExecutorService executor = hz.getExecutorService("executor"); - for (int i = 1; i <= 1000; i++) { + for (int k = 1; k <= 1000; k++) { Thread.sleep(1000); - System.out.println("Producing echo task: " + i); - executor.execute(new EchoTask("" + i)); + System.out.println("Producing echo task: " + k); + executor.execute(new EchoTask("" + k)); } - System.out.println("MasterMember finished!"); } } diff --git a/distributed-executor/scale-out/src/main/java/SlaveMember.java b/distributed-executor/scale-out/src/main/java/SlaveMember.java index 700cdb6e6..afd273380 100644 --- a/distributed-executor/scale-out/src/main/java/SlaveMember.java +++ b/distributed-executor/scale-out/src/main/java/SlaveMember.java @@ -1,7 +1,6 @@ import com.hazelcast.core.Hazelcast; public class SlaveMember { - public static void main(String[] args) { Hazelcast.newHazelcastInstance(); } diff --git a/distributed-executor/scale-out/src/main/resources/hazelcast.xml b/distributed-executor/scale-out/src/main/resources/hazelcast.xml index 3f8e1e265..3151a0e0b 100644 --- a/distributed-executor/scale-out/src/main/resources/hazelcast.xml +++ b/distributed-executor/scale-out/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -12,4 +12,4 @@ 1 - + \ No newline at end of file diff --git a/distributed-executor/scale-up/src/main/java/EchoTask.java b/distributed-executor/scale-up/src/main/java/EchoTask.java index ab5094405..cd2cb4b0b 100644 --- a/distributed-executor/scale-up/src/main/java/EchoTask.java +++ b/distributed-executor/scale-up/src/main/java/EchoTask.java @@ -1,7 +1,6 @@ import java.io.Serializable; public class EchoTask implements Runnable, Serializable { - private final String msg; public EchoTask(String msg) { @@ -14,7 +13,6 @@ public void run() { } catch (InterruptedException e) { e.printStackTrace(); } - - System.out.println("Echo: " + msg); + System.out.println("echo:" + msg); } } diff --git a/distributed-executor/scale-up/src/main/java/MasterMember.java b/distributed-executor/scale-up/src/main/java/MasterMember.java index da594ee9a..f711020b8 100644 --- a/distributed-executor/scale-up/src/main/java/MasterMember.java +++ b/distributed-executor/scale-up/src/main/java/MasterMember.java @@ -3,17 +3,14 @@ import com.hazelcast.core.IExecutorService; public class MasterMember { - public static void main(String[] args) throws Exception { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IExecutorService executor = hz.getExecutorService("executor"); - for (int i = 1; i <= 1000; i++) { + for (int k = 1; k <= 1000; k++) { Thread.sleep(1000); - System.out.println("Producing Task: " + i); - executor.execute(new EchoTask("" + i)); + System.out.println("Producing Task: " + k); + executor.execute(new EchoTask("" + k)); } - System.out.println("MasterMember finished!"); } } diff --git a/distributed-executor/scale-up/src/main/resources/hazelcast.xml b/distributed-executor/scale-up/src/main/resources/hazelcast.xml index faab3ef7d..3a62d8add 100644 --- a/distributed-executor/scale-up/src/main/resources/hazelcast.xml +++ b/distributed-executor/scale-up/src/main/resources/hazelcast.xml @@ -1,8 +1,8 @@ 5 - + \ No newline at end of file diff --git a/distributed-executor/scale-up/start.sh b/distributed-executor/scale-up/start.sh old mode 100755 new mode 100644 diff --git a/distributed-map/aggregations/src/main/resources/hazelcast.xml b/distributed-map/aggregations/src/main/resources/hazelcast.xml index 403dfe9f2..390a19e1a 100644 --- a/distributed-map/aggregations/src/main/resources/hazelcast.xml +++ b/distributed-map/aggregations/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -17,4 +17,4 @@ 1 - + \ No newline at end of file diff --git a/distributed-map/backup/src/main/resources/hazelcast.xml b/distributed-map/backup/src/main/resources/hazelcast.xml index 403dfe9f2..390a19e1a 100644 --- a/distributed-map/backup/src/main/resources/hazelcast.xml +++ b/distributed-map/backup/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -17,4 +17,4 @@ 1 - + \ No newline at end of file diff --git a/distributed-map/custom-attributes/src/main/java/com/test/car/Car.java b/distributed-map/custom-attributes/src/main/java/com/test/car/Car.java index 90783f633..6c7d03377 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/car/Car.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/car/Car.java @@ -33,8 +33,8 @@ public Object getAttribute(String name) { @Override public String toString() { - return "Car{" - + "attributes=" + attributes - + '}'; + return "Car{" + + "attributes=" + attributes + + '}'; } } diff --git a/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeDemo.java b/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeDemo.java index 4510f33e8..0de7b8d4e 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeDemo.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeDemo.java @@ -13,17 +13,16 @@ public class CarAttributeDemo { public static void main(String[] args) throws ParseException { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IMap map = hz.getMap("cars"); + IMap map = hz.getMap("cars"); - map.put(1, new Car("Audi Q7", 250, 22000)); - map.put(2, new Car("BMW X5", 312, 34000)); - map.put(3, new Car("Porsche Cayenne", 408, 57000)); + map.put("1", new Car("Audi Q7", 250, 22000)); + map.put("2", new Car("BMW X5", 312, 34000)); + map.put("3", new Car("Porsche Cayenne", 408, 57000)); - // we're using a custom attribute called 'attribute' which is provided by the 'CarAttributeExtractor' - // we are also passing an argument 'mileage' to the extractor - Set cars = (Set) map.values(new SqlPredicate("attribute[mileage] < 30000")); - System.out.println("Cars: " + cars); - - Hazelcast.shutdownAll(); + // We're using a custom attribute called 'attribute' which is provided by the 'CarAttributeExtractor' + // We are also passing an argument 'mileage' to the extractor + Set employees = (Set) map.values(new SqlPredicate("attribute[mileage] < 30000")); + System.out.println("Cars:" + employees); } + } diff --git a/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeExtractor.java b/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeExtractor.java index 176fedf16..642f1c0c9 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeExtractor.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/car/attribute/CarAttributeExtractor.java @@ -4,10 +4,13 @@ import com.hazelcast.query.extractor.ValueExtractor; import com.test.car.Car; +import java.util.Calendar; + public class CarAttributeExtractor extends ValueExtractor { @Override public void extract(Car car, String argument, ValueCollector valueCollector) { valueCollector.addObject(car.getAttribute(argument)); } + } diff --git a/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDemo.java b/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDemo.java index 90f499f5d..56596d8c5 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDemo.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDemo.java @@ -13,16 +13,15 @@ public class CarTripDemo { public static void main(String[] args) throws ParseException { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IMap map = hz.getMap("cars"); + IMap map = hz.getMap("cars"); - map.put(1, new Car("Audi Q7").setTrip(1000, 3000)); - map.put(2, new Car("BMW X5").setTrip(3000, 5000)); - map.put(3, new Car("Porsche Cayenne").setTrip(2000, 8000)); + map.put("1", new Car("Audi Q7").setTrip(1000, 3000)); + map.put("2", new Car("BMW X5").setTrip(3000, 5000)); + map.put("3", new Car("Porsche Cayenne").setTrip(2000, 8000)); - // we're using a custom 'tripDistance' attribute which is provided by the 'CarTripDistanceExtractor' - Set cars = (Set) map.values(new SqlPredicate("tripDistance < 3000")); - System.out.println("Cars: " + cars); - - Hazelcast.shutdownAll(); + // We're using a custom 'tripDistance' attribute which is provided by the 'CarTripDistanceExtractor' + Set employees = (Set) map.values(new SqlPredicate("tripDistance < 3000")); + System.out.println("Cars:" + employees); } + } diff --git a/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDistanceExtractor.java b/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDistanceExtractor.java index 5b547d8d1..5e2195034 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDistanceExtractor.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/car/trip/CarTripDistanceExtractor.java @@ -12,4 +12,5 @@ public void extract(Car car, String argument, ValueCollector valueCollector) { Integer tripStopMileage = (Integer) car.getAttribute("tripStop"); valueCollector.addObject(tripStopMileage - tripStartMileage); } + } diff --git a/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractor.java b/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractor.java index 7ec3ec7b1..08dd5ede8 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractor.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractor.java @@ -12,4 +12,5 @@ public void extract(Customer customer, String argument, ValueCollector valueColl int age = Calendar.getInstance().get(Calendar.YEAR) - customer.yearOfBirth; valueCollector.addObject(age); } + } diff --git a/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractorDemo.java b/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractorDemo.java index 6fa503555..bca881690 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractorDemo.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/customer/AgeExtractorDemo.java @@ -12,16 +12,15 @@ public class AgeExtractorDemo { public static void main(String[] args) throws ParseException { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IMap map = hz.getMap("customers"); + IMap map = hz.getMap("people"); - map.put(1, new Customer("James", "Bond", 1975)); - map.put(2, new Customer("Eathen", "Hunt", 1965)); - map.put(3, new Customer("Roger", "Moore", 1995)); + map.put("1", new Customer("james", "bond", 1975)); + map.put("2", new Customer("eathen", "hunt", 1965)); + map.put("3", new Customer("roger", "moore", 1995)); - // we're using a custom attribute 'age' which is provided by the 'AgeExtractor' - Set customers = (Set) map.values(new SqlPredicate("age < 50")); - System.out.println("Customers: " + customers); - - Hazelcast.shutdownAll(); + // We're using a custom attribute 'age' which is provided by the 'AgeExtractor' + Set employees = (Set) map.values(new SqlPredicate("age < 50")); + System.out.println("Employees:" + employees); } + } diff --git a/distributed-map/custom-attributes/src/main/java/com/test/customer/Customer.java b/distributed-map/custom-attributes/src/main/java/com/test/customer/Customer.java index e2d5e24e8..e552e84e3 100644 --- a/distributed-map/custom-attributes/src/main/java/com/test/customer/Customer.java +++ b/distributed-map/custom-attributes/src/main/java/com/test/customer/Customer.java @@ -19,11 +19,12 @@ public Customer(String name, String surname, int yearOfBirth) { @Override public String toString() { - return "Customer{" - + "id='" + id + '\'' - + ", name='" + name + '\'' - + ", surname='" + surname + '\'' - + ", yearOfBirth=" + yearOfBirth - + '}'; + return "Customer{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", surname='" + surname + '\'' + + ", yearOfBirth=" + yearOfBirth + + '}'; } + } diff --git a/distributed-map/custom-attributes/src/main/resources/hazelcast.xml b/distributed-map/custom-attributes/src/main/resources/hazelcast.xml index 9c1b8168a..472a06d4a 100644 --- a/distributed-map/custom-attributes/src/main/resources/hazelcast.xml +++ b/distributed-map/custom-attributes/src/main/resources/hazelcast.xml @@ -37,11 +37,4 @@ - - - - age - - - - + \ No newline at end of file diff --git a/distributed-map/entry-processor/src/main/resources/hazelcast.xml b/distributed-map/entry-processor/src/main/resources/hazelcast.xml index 4964c3557..cdade8d2e 100644 --- a/distributed-map/entry-processor/src/main/resources/hazelcast.xml +++ b/distributed-map/entry-processor/src/main/resources/hazelcast.xml @@ -1,10 +1,11 @@ - + + \ No newline at end of file diff --git a/distributed-map/eviction/src/main/resources/hazelcast.xml b/distributed-map/eviction/src/main/resources/hazelcast.xml index 24a30a970..6e01eb374 100644 --- a/distributed-map/eviction/src/main/resources/hazelcast.xml +++ b/distributed-map/eviction/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ 20 0 - + \ No newline at end of file diff --git a/distributed-map/hashcode-and-equals/src/main/resources/hazelcast.xml b/distributed-map/hashcode-and-equals/src/main/resources/hazelcast.xml index abc8eedf2..0d3dea4dd 100644 --- a/distributed-map/hashcode-and-equals/src/main/resources/hazelcast.xml +++ b/distributed-map/hashcode-and-equals/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -10,4 +10,5 @@ BINARY - + + \ No newline at end of file diff --git a/distributed-map/in-memory-format/src/main/resources/hazelcast.xml b/distributed-map/in-memory-format/src/main/resources/hazelcast.xml index 73ad0941d..c69ba7052 100644 --- a/distributed-map/in-memory-format/src/main/resources/hazelcast.xml +++ b/distributed-map/in-memory-format/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -15,4 +15,5 @@ OBJECT - + + \ No newline at end of file diff --git a/distributed-map/index/src/main/resources/hazelcast.xml b/distributed-map/index/src/main/resources/hazelcast.xml index f3fe9a4d9..aec95323b 100644 --- a/distributed-map/index/src/main/resources/hazelcast.xml +++ b/distributed-map/index/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -16,4 +16,5 @@ - + + \ No newline at end of file diff --git a/distributed-map/mapstore/src/main/resources/hazelcast.xml b/distributed-map/mapstore/src/main/resources/hazelcast.xml index b890972e0..b7f7466d7 100644 --- a/distributed-map/mapstore/src/main/resources/hazelcast.xml +++ b/distributed-map/mapstore/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -8,4 +8,4 @@ jdbc.PersonMapStore - + \ No newline at end of file diff --git a/distributed-map/near-cache/src/main/resources/hazelcast.xml b/distributed-map/near-cache/src/main/resources/hazelcast.xml index d1e5ff276..22d27d257 100644 --- a/distributed-map/near-cache/src/main/resources/hazelcast.xml +++ b/distributed-map/near-cache/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ true - + \ No newline at end of file diff --git a/distributed-map/query-collections/src/main/java/com/test/query/QueryCollectionsDemo.java b/distributed-map/query-collections/src/main/java/com/test/query/QueryCollectionsDemo.java index 6de663460..a10aa859d 100644 --- a/distributed-map/query-collections/src/main/java/com/test/query/QueryCollectionsDemo.java +++ b/distributed-map/query-collections/src/main/java/com/test/query/QueryCollectionsDemo.java @@ -16,21 +16,16 @@ public class QueryCollectionsDemo { public static void main(String[] args) { HazelcastInstance hz = Hazelcast.newHazelcastInstance(); - IMap map = hz.getMap("map"); + IMap map = hz.getMap("map"); - map.put(1, new Person("Georg", limb("left-leg"), limb("right-leg"))); - map.put(2, new Person("Peter", limb("left-hand"), limb("right-hand"))); - map.put(3, new Person("Hans", limb("left-leg"), limb("right-leg"))); - map.put(4, new Person("Stefanie", limb("left-arm"), limb("right-arm"))); + map.put("1", new Person("peter", limb("left-hand"), limb("right-hand"))); + map.put("2", new Person("hans", limb("left-leg"), limb("right-leg"))); Set employees = (Set) map.values(new SqlPredicate("limbs[any].name == right-leg")); - System.out.println("People: " + employees); - - Hazelcast.shutdownAll(); + System.out.println("People:" + employees); } public static class Person implements Serializable { - final String name; final List limbs; @@ -41,12 +36,11 @@ private Person(String name, Limb... limbs) { @Override public String toString() { - return "Person{name='" + name + "'}"; + return "Person{name='" + name + '}'; } } public static class Limb implements Serializable { - final String name; public Limb(String name) { diff --git a/distributed-primitives/semaphore/src/main/resources/hazelcast.xml b/distributed-primitives/semaphore/src/main/resources/hazelcast.xml index 15e15bede..8d96560e2 100644 --- a/distributed-primitives/semaphore/src/main/resources/hazelcast.xml +++ b/distributed-primitives/semaphore/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -12,4 +12,5 @@ 3 - + + \ No newline at end of file diff --git a/distributed-topic/reliable-topic/src/main/resources/hazelcast.xml b/distributed-topic/reliable-topic/src/main/resources/hazelcast.xml index 8b03d02c0..85aa1e0df 100644 --- a/distributed-topic/reliable-topic/src/main/resources/hazelcast.xml +++ b/distributed-topic/reliable-topic/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -20,4 +20,4 @@ BLOCK - + \ No newline at end of file diff --git a/enterprise/continuous-query-cache/pom.xml b/enterprise/continuous-query-cache/pom.xml index 4887b9ac7..5c5e2da65 100644 --- a/enterprise/continuous-query-cache/pom.xml +++ b/enterprise/continuous-query-cache/pom.xml @@ -2,11 +2,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 jar + + + javax.cache + cache-api + 1.0.0 + + continuous-query-cache - Enterprise - Continuous Query Cache + Continuous Query Cache (CQC) - Continuous Query Cache samples. + All the code samples for CQC diff --git a/enterprise/hd-imap/pom.xml b/enterprise/hd-imap/pom.xml deleted file mode 100644 index ee33c8362..000000000 --- a/enterprise/hd-imap/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - 4.0.0 - jar - - hd-imap - Enterprise - HD IMap - HD IMap samples - - - enterprise - com.hazelcast.samples.enterprise - 0.1-SNAPSHOT - ../pom.xml - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.6 - 1.6 - - - - - - diff --git a/enterprise/hd-imap/src/main/java/HDEviction.java b/enterprise/hd-imap/src/main/java/HDEviction.java deleted file mode 100644 index 33c35f09b..000000000 --- a/enterprise/hd-imap/src/main/java/HDEviction.java +++ /dev/null @@ -1,61 +0,0 @@ -import com.hazelcast.config.Config; -import com.hazelcast.config.EvictionPolicy; -import com.hazelcast.config.InMemoryFormat; -import com.hazelcast.config.MapConfig; -import com.hazelcast.config.MaxSizeConfig; -import com.hazelcast.config.NativeMemoryConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.memory.MemorySize; -import com.hazelcast.memory.MemoryUnit; - -import java.util.Map; - -import static com.hazelcast.config.MaxSizeConfig.MaxSizePolicy.PER_NODE; - -public class HDEviction { - - private static final String LICENSE_KEY = ""; - private static final int MAX_ENTRY_COUNT = 1000; - - public static void main(String[] args) { - HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(newConfig()); - - Map map = hazelcastInstance.getMap("map"); - for (int i = 0; i < 10 * MAX_ENTRY_COUNT; i++) { - map.put("key-" + i, "value-" + i); - } - - System.out.println("Map size is " + map.size() + " and it is below the allowed max entry count " + MAX_ENTRY_COUNT); - - hazelcastInstance.shutdown(); - } - - public static Config newConfig() { - MaxSizeConfig maxSizeConfig = new MaxSizeConfig(); - maxSizeConfig.setMaxSizePolicy(PER_NODE); - maxSizeConfig.setSize(MAX_ENTRY_COUNT); - - MapConfig mapConfig = new MapConfig(); - mapConfig.setName("default"); - mapConfig.setInMemoryFormat(InMemoryFormat.NATIVE); - mapConfig.setEvictionPolicy(EvictionPolicy.LRU); - mapConfig.setMaxSizeConfig(maxSizeConfig); - mapConfig.setMinEvictionCheckMillis(0); - - MemorySize memorySize = new MemorySize(128, MemoryUnit.MEGABYTES); - NativeMemoryConfig memoryConfig = new NativeMemoryConfig(); - memoryConfig.setEnabled(true); - memoryConfig.setSize(memorySize); - memoryConfig.setAllocatorType(NativeMemoryConfig.MemoryAllocatorType.STANDARD); - - Config config = new Config(); - config.addMapConfig(mapConfig); - config.setNativeMemoryConfig(memoryConfig); - if (!LICENSE_KEY.isEmpty()) { - config.setLicenseKey(LICENSE_KEY); - } - - return config; - } -} diff --git a/enterprise/hd-imap/src/main/java/HDSimplePopulation.java b/enterprise/hd-imap/src/main/java/HDSimplePopulation.java deleted file mode 100644 index 6d9d9012d..000000000 --- a/enterprise/hd-imap/src/main/java/HDSimplePopulation.java +++ /dev/null @@ -1,49 +0,0 @@ -import com.hazelcast.config.Config; -import com.hazelcast.config.InMemoryFormat; -import com.hazelcast.config.MapConfig; -import com.hazelcast.config.NativeMemoryConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.memory.MemorySize; -import com.hazelcast.memory.MemoryUnit; - -import java.util.Map; - -public class HDSimplePopulation { - - private static final String LICENSE_KEY = ""; - - public static void main(String[] args) { - HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(newConfig()); - - Map map = hazelcastInstance.getMap("map"); - map.put("1", "Tokyo"); - map.put("2", "Paris"); - map.put("3", "New York"); - - System.out.println("Inserted " + map.size() + " entries into maps hd memory"); - - hazelcastInstance.shutdown(); - } - - public static Config newConfig() { - MapConfig mapConfig = new MapConfig(); - mapConfig.setName("default"); - mapConfig.setInMemoryFormat(InMemoryFormat.NATIVE); - - MemorySize memorySize = new MemorySize(128, MemoryUnit.MEGABYTES); - NativeMemoryConfig memoryConfig = new NativeMemoryConfig(); - memoryConfig.setEnabled(true); - memoryConfig.setSize(memorySize); - memoryConfig.setAllocatorType(NativeMemoryConfig.MemoryAllocatorType.STANDARD); - - Config config = new Config(); - config.addMapConfig(mapConfig); - config.setNativeMemoryConfig(memoryConfig); - if (!LICENSE_KEY.isEmpty()) { - config.setLicenseKey(LICENSE_KEY); - } - - return config; - } -} diff --git a/enterprise/hd-imap/src/main/java/nearcache/ClientHDNearCache.java b/enterprise/hd-imap/src/main/java/nearcache/ClientHDNearCache.java deleted file mode 100644 index aeadac8a8..000000000 --- a/enterprise/hd-imap/src/main/java/nearcache/ClientHDNearCache.java +++ /dev/null @@ -1,80 +0,0 @@ -package nearcache; - -import com.hazelcast.client.HazelcastClient; -import com.hazelcast.client.config.ClientConfig; -import com.hazelcast.config.Config; -import com.hazelcast.config.EvictionConfig; -import com.hazelcast.config.NativeMemoryConfig; -import com.hazelcast.config.NearCacheConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; -import com.hazelcast.memory.MemorySize; - -import static com.hazelcast.config.EvictionConfig.MaxSizePolicy.USED_NATIVE_MEMORY_PERCENTAGE; -import static com.hazelcast.config.InMemoryFormat.NATIVE; -import static com.hazelcast.config.NativeMemoryConfig.MemoryAllocatorType.STANDARD; -import static com.hazelcast.memory.MemoryUnit.MEGABYTES; - -public class ClientHDNearCache { - - private static final String LICENSE_KEY = ""; - - public static void main(String[] args) { - // start server - HazelcastInstance server = Hazelcast.newHazelcastInstance(newConfig()); - - // start client - HazelcastInstance client = HazelcastClient.newHazelcastClient(newClientConfig("mapName")); - - IMap map = client.getMap("mapName"); - for (int i = 0; i < 1000; i++) { - map.put("key-" + i, "value-" + i); - } - - // first `get` puts remote entry into near-cache - for (int i = 0; i < 1000; i++) { - map.get("key-" + i); - } - - long ownedEntryCount = map.getLocalMapStats().getNearCacheStats().getOwnedEntryCount(); - System.out.println("Near cache includes " + ownedEntryCount + " entries"); - - client.shutdown(); - server.shutdown(); - } - - public static Config newConfig() { - Config config = new Config(); - if (!LICENSE_KEY.isEmpty()) { - config.setLicenseKey(LICENSE_KEY); - } - - return config; - } - - private static ClientConfig newClientConfig(String mapName) { - NativeMemoryConfig memoryConfig = new NativeMemoryConfig(); - memoryConfig.setEnabled(true); - memoryConfig.setSize(new MemorySize(128, MEGABYTES)); - memoryConfig.setAllocatorType(STANDARD); - - NearCacheConfig nearCacheConfig = new NearCacheConfig(); - EvictionConfig evictionConfig = nearCacheConfig.getEvictionConfig(); - evictionConfig.setMaximumSizePolicy(USED_NATIVE_MEMORY_PERCENTAGE); - evictionConfig.setSize(90); - nearCacheConfig.setInMemoryFormat(NATIVE); - nearCacheConfig.setInvalidateOnChange(true); - nearCacheConfig.setCacheLocalEntries(true); - nearCacheConfig.setName(mapName); - - ClientConfig clientConfig = new ClientConfig(); - clientConfig.setNativeMemoryConfig(memoryConfig); - clientConfig.addNearCacheConfig(nearCacheConfig); - if (!LICENSE_KEY.isEmpty()) { - clientConfig.setLicenseKey(LICENSE_KEY); - } - - return clientConfig; - } -} diff --git a/enterprise/hd-imap/src/main/java/nearcache/ServerHDNearCache.java b/enterprise/hd-imap/src/main/java/nearcache/ServerHDNearCache.java deleted file mode 100644 index da9a05ad9..000000000 --- a/enterprise/hd-imap/src/main/java/nearcache/ServerHDNearCache.java +++ /dev/null @@ -1,68 +0,0 @@ -package nearcache; - -import com.hazelcast.config.Config; -import com.hazelcast.config.EvictionConfig; -import com.hazelcast.config.MapConfig; -import com.hazelcast.config.NativeMemoryConfig; -import com.hazelcast.config.NearCacheConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; -import com.hazelcast.memory.MemorySize; - -import static com.hazelcast.config.EvictionConfig.MaxSizePolicy.USED_NATIVE_MEMORY_PERCENTAGE; -import static com.hazelcast.config.InMemoryFormat.NATIVE; -import static com.hazelcast.config.NativeMemoryConfig.MemoryAllocatorType.STANDARD; -import static com.hazelcast.memory.MemoryUnit.MEGABYTES; - -public class ServerHDNearCache { - - private static final String LICENSE_KEY = ""; - - public static void main(String[] args) { - HazelcastInstance node = Hazelcast.newHazelcastInstance(newConfig()); - IMap map = node.getMap("default"); - for (int i = 0; i < 1000; i++) { - map.put("key-" + i, "value-" + i); - } - - // first `get` puts remote entry into near-cache - for (int i = 0; i < 1000; i++) { - map.get("key-" + i); - } - - long ownedEntryCount = map.getLocalMapStats().getNearCacheStats().getOwnedEntryCount(); - System.out.println("Near cache includes " + ownedEntryCount + " entries"); - - node.shutdown(); - } - - private static Config newConfig() { - NearCacheConfig nearCacheConfig = new NearCacheConfig(); - EvictionConfig evictionConfig = nearCacheConfig.getEvictionConfig(); - evictionConfig.setMaximumSizePolicy(USED_NATIVE_MEMORY_PERCENTAGE); - evictionConfig.setSize(90); - nearCacheConfig.setInMemoryFormat(NATIVE); - nearCacheConfig.setInvalidateOnChange(true); - nearCacheConfig.setCacheLocalEntries(true); - nearCacheConfig.setName("default"); - - MapConfig mapConfig = new MapConfig(); - mapConfig.setName("default"); - mapConfig.setNearCacheConfig(nearCacheConfig); - - NativeMemoryConfig memoryConfig = new NativeMemoryConfig(); - memoryConfig.setEnabled(true); - memoryConfig.setSize(new MemorySize(128, MEGABYTES)); - memoryConfig.setAllocatorType(STANDARD); - - Config config = new Config(); - config.addMapConfig(mapConfig); - config.setNativeMemoryConfig(memoryConfig); - if (!LICENSE_KEY.isEmpty()) { - config.setLicenseKey(LICENSE_KEY); - } - - return config; - } -} diff --git a/enterprise/hd-memory-client-server/hd-memory-examples-client/src/main/resources/hazelcast-client-hd-memory.xml b/enterprise/hd-memory-client-server/hd-memory-examples-client/src/main/resources/hazelcast-client-hd-memory.xml index 9b7ccfcbe..31732f89e 100644 --- a/enterprise/hd-memory-client-server/hd-memory-examples-client/src/main/resources/hazelcast-client-hd-memory.xml +++ b/enterprise/hd-memory-client-server/hd-memory-examples-client/src/main/resources/hazelcast-client-hd-memory.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - diff --git a/enterprise/hd-memory-client-server/hd-memory-examples-server/src/main/resources/hazelcast-hd-memory.xml b/enterprise/hd-memory-client-server/hd-memory-examples-server/src/main/resources/hazelcast-hd-memory.xml index b2acc9b7d..960c0134a 100644 --- a/enterprise/hd-memory-client-server/hd-memory-examples-server/src/main/resources/hazelcast-hd-memory.xml +++ b/enterprise/hd-memory-client-server/hd-memory-examples-server/src/main/resources/hazelcast-hd-memory.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - diff --git a/enterprise/hot-restart/pom.xml b/enterprise/hot-restart/pom.xml deleted file mode 100644 index 4d6f5d0b8..000000000 --- a/enterprise/hot-restart/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - enterprise - com.hazelcast.samples.enterprise - 0.1-SNAPSHOT - - 4.0.0 - - hot-restart - Hot Restart - - - - javax.cache - cache-api - 1.0.0 - - - diff --git a/enterprise/hot-restart/src/main/java/JCacheHotRestart.java b/enterprise/hot-restart/src/main/java/JCacheHotRestart.java deleted file mode 100644 index 5f9e78c6f..000000000 --- a/enterprise/hot-restart/src/main/java/JCacheHotRestart.java +++ /dev/null @@ -1,63 +0,0 @@ -import com.hazelcast.cache.impl.HazelcastServerCachingProvider; -import com.hazelcast.config.CacheConfig; -import com.hazelcast.config.Config; -import com.hazelcast.config.HotRestartPersistenceConfig; -import com.hazelcast.config.JoinConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.nio.IOUtil; - -import javax.cache.Cache; -import javax.cache.spi.CachingProvider; -import java.io.File; - -public class JCacheHotRestart { - - private static final String LICENSE_KEY = "---- LICENSE KEY ----"; - - private static final String hotRestartRootDir = System.getProperty("java.io.tmpdir") - + File.separatorChar + "hazelcast-hot-restart"; - - public static void main(String[] args) { - IOUtil.delete(new File(hotRestartRootDir)); - - Config config = new Config(); - config.setLicenseKey(LICENSE_KEY); - - config.getNetworkConfig().setPort(5701).setPortAutoIncrement(false); - JoinConfig join = config.getNetworkConfig().getJoin(); - join.getMulticastConfig().setEnabled(false); - join.getTcpIpConfig().setEnabled(true).clear().addMember("127.0.0.1"); - - HotRestartPersistenceConfig hotRestartConfig = config.getHotRestartPersistenceConfig(); - hotRestartConfig.setEnabled(true).setBaseDir(new File(hotRestartRootDir)); - - HazelcastInstance instance = Hazelcast.newHazelcastInstance(config); - - Cache cache = createCache(instance); - for (int i = 0; i < 10; i++) { - cache.put(i, "value" + i); - } - - instance.shutdown(); - - instance = Hazelcast.newHazelcastInstance(config); - cache = createCache(instance); - - for (int i = 0; i < 10; i++) { - System.out.println("cache.get(" + i + ") = " + cache.get(i)); - } - - Hazelcast.shutdownAll(); - } - - private static Cache createCache(HazelcastInstance instance) { - CachingProvider cachingProvider = HazelcastServerCachingProvider - .createCachingProvider(instance); - - CacheConfig cacheConfig = new CacheConfig("cache"); - cacheConfig.getHotRestartConfig().setEnabled(true); - - return cachingProvider.getCacheManager().createCache("cache", cacheConfig); - } -} diff --git a/enterprise/hot-restart/src/main/java/JCacheHotRestartMultipleNodes.java b/enterprise/hot-restart/src/main/java/JCacheHotRestartMultipleNodes.java deleted file mode 100644 index 1a78c7923..000000000 --- a/enterprise/hot-restart/src/main/java/JCacheHotRestartMultipleNodes.java +++ /dev/null @@ -1,81 +0,0 @@ -import com.hazelcast.cache.impl.HazelcastServerCachingProvider; -import com.hazelcast.cluster.ClusterState; -import com.hazelcast.config.CacheConfig; -import com.hazelcast.config.Config; -import com.hazelcast.config.HotRestartPersistenceConfig; -import com.hazelcast.config.JoinConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.nio.IOUtil; - -import javax.cache.Cache; -import javax.cache.spi.CachingProvider; -import java.io.File; - -public class JCacheHotRestartMultipleNodes { - - private static final String LICENSE_KEY = "---- LICENSE KEY ----"; - - private static final String hotRestartRootDir = System.getProperty("java.io.tmpdir") - + File.separatorChar + "hazelcast-hot-restart"; - - public static void main(String[] args) { - IOUtil.delete(new File(hotRestartRootDir)); - - HazelcastInstance instance1 = newHazelcastInstance(5701); - HazelcastInstance instance2 = newHazelcastInstance(5702); - - Cache cache = createCache(instance1); - for (int i = 0; i < 50; i++) { - cache.put(i, "value" + i); - } - - instance2.getCluster().shutdown(); - - // Offloading to a thread. - // Because all instances should start in parallel - // to be able to do hot-restart cluster verification - new Thread() { - public void run() { - newHazelcastInstance(5701); - } - }.start(); - - instance2 = newHazelcastInstance(5702); - instance2.getCluster().changeClusterState(ClusterState.ACTIVE); - - cache = createCache(instance2); - for (int i = 0; i < 50; i++) { - System.out.println("cache.get(" + i + ") = " + cache.get(i)); - } - - Hazelcast.shutdownAll(); - } - - private static HazelcastInstance newHazelcastInstance(int port) { - Config config = new Config(); - config.setLicenseKey(LICENSE_KEY); - - config.getNetworkConfig().setPort(port).setPortAutoIncrement(false); - JoinConfig join = config.getNetworkConfig().getJoin(); - join.getMulticastConfig().setEnabled(false); - join.getTcpIpConfig().setEnabled(true).clear() - .addMember("127.0.0.1:5701") - .addMember("127.0.0.1:5702"); - - HotRestartPersistenceConfig hotRestartConfig = config.getHotRestartPersistenceConfig(); - hotRestartConfig.setEnabled(true).setBaseDir(new File(hotRestartRootDir)); - - return Hazelcast.newHazelcastInstance(config); - } - - private static Cache createCache(HazelcastInstance instance) { - CachingProvider cachingProvider = HazelcastServerCachingProvider - .createCachingProvider(instance); - - CacheConfig cacheConfig = new CacheConfig("cache"); - cacheConfig.getHotRestartConfig().setEnabled(true); - - return cachingProvider.getCacheManager().createCache("cache", cacheConfig); - } -} diff --git a/enterprise/hot-restart/src/main/java/JCacheRollingRestart.java b/enterprise/hot-restart/src/main/java/JCacheRollingRestart.java deleted file mode 100644 index a304e701e..000000000 --- a/enterprise/hot-restart/src/main/java/JCacheRollingRestart.java +++ /dev/null @@ -1,72 +0,0 @@ -import com.hazelcast.cache.impl.HazelcastServerCachingProvider; -import com.hazelcast.cluster.ClusterState; -import com.hazelcast.config.CacheConfig; -import com.hazelcast.config.Config; -import com.hazelcast.config.HotRestartPersistenceConfig; -import com.hazelcast.config.JoinConfig; -import com.hazelcast.core.Hazelcast; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.nio.IOUtil; - -import javax.cache.Cache; -import javax.cache.spi.CachingProvider; -import java.io.File; - -public class JCacheRollingRestart { - - private static final String LICENSE_KEY = "---- LICENSE KEY ----"; - - private static final String hotRestartRootDir = System.getProperty("java.io.tmpdir") - + File.separatorChar + "hazelcast-hot-restart"; - - public static void main(String[] args) { - IOUtil.delete(new File(hotRestartRootDir)); - - HazelcastInstance instance1 = newHazelcastInstance(5701); - HazelcastInstance instance2 = newHazelcastInstance(5702); - - Cache cache = createCache(instance2); - for (int i = 0; i < 50; i++) { - cache.put(i, "value" + i); - } - - instance2.getCluster().changeClusterState(ClusterState.PASSIVE); - - instance1.shutdown(); - instance1 = newHazelcastInstance(5701); - - instance1.getCluster().changeClusterState(ClusterState.ACTIVE); - - for (int i = 0; i < 50; i++) { - System.out.println("cache.get(" + i + ") = " + cache.get(i)); - } - - Hazelcast.shutdownAll(); - } - - private static HazelcastInstance newHazelcastInstance(int port) { - Config config = new Config(); - config.setLicenseKey(LICENSE_KEY); - config.getNetworkConfig().setPort(port).setPortAutoIncrement(false); - JoinConfig join = config.getNetworkConfig().getJoin(); - join.getMulticastConfig().setEnabled(false); - join.getTcpIpConfig().setEnabled(true).clear() - .addMember("127.0.0.1:5701") - .addMember("127.0.0.1:5702"); - - HotRestartPersistenceConfig hotRestartConfig = config.getHotRestartPersistenceConfig(); - hotRestartConfig.setEnabled(true).setBaseDir(new File(hotRestartRootDir)); - - return Hazelcast.newHazelcastInstance(config); - } - - private static Cache createCache(HazelcastInstance instance) { - CachingProvider cachingProvider = HazelcastServerCachingProvider - .createCachingProvider(instance); - - CacheConfig cacheConfig = new CacheConfig("cache"); - cacheConfig.getHotRestartConfig().setEnabled(true); - - return cachingProvider.getCacheManager().createCache("cache", cacheConfig); - } -} diff --git a/enterprise/pom.xml b/enterprise/pom.xml index cd8699234..4e2b38196 100644 --- a/enterprise/pom.xml +++ b/enterprise/pom.xml @@ -25,8 +25,6 @@ hd-memory-client-server continuous-query-cache client-ssl - hd-imap - hot-restart diff --git a/enterprise/wan-replication/src/main/java/com/hazelcast/cache/wanreplication/filter/SampleCacheWanEventFilter.java b/enterprise/wan-replication/src/main/java/com/hazelcast/cache/wanreplication/filter/SampleCacheWanEventFilter.java index 243d3f598..89fb778ce 100644 --- a/enterprise/wan-replication/src/main/java/com/hazelcast/cache/wanreplication/filter/SampleCacheWanEventFilter.java +++ b/enterprise/wan-replication/src/main/java/com/hazelcast/cache/wanreplication/filter/SampleCacheWanEventFilter.java @@ -6,15 +6,12 @@ /** * Sample {@link CacheWanEventFilter} implementation. - * It filters entries if their value starts with "filter". + * It simply allows all events to be replicated, no filtering is applied. */ -public class SampleCacheWanEventFilter implements CacheWanEventFilter { +public class SampleCacheWanEventFilter implements CacheWanEventFilter { @Override - public boolean filter(String s, CacheEntryView cacheEntryView, WanFilterEventType wanFilterEventType) { - if (cacheEntryView.getValue().startsWith("filter")) { - return true; - } + public boolean filter(String s, CacheEntryView cacheEntryView, WanFilterEventType wanFilterEventType) { return false; } } diff --git a/enterprise/wan-replication/src/main/java/com/hazelcast/map/wanreplication/filter/SampleMapWanEventFilter.java b/enterprise/wan-replication/src/main/java/com/hazelcast/map/wanreplication/filter/SampleMapWanEventFilter.java index efa8ffe20..f52f9e921 100644 --- a/enterprise/wan-replication/src/main/java/com/hazelcast/map/wanreplication/filter/SampleMapWanEventFilter.java +++ b/enterprise/wan-replication/src/main/java/com/hazelcast/map/wanreplication/filter/SampleMapWanEventFilter.java @@ -6,14 +6,11 @@ /** * Sample {@link MapWanEventFilter} implementation. - * It filters entries if their value starts with "filter". + * It simply allows all events to be replicated, no filtering is applied. */ -public class SampleMapWanEventFilter implements MapWanEventFilter { +public class SampleMapWanEventFilter implements MapWanEventFilter { @Override - public boolean filter(String s, EntryView entryView, WanFilterEventType wanFilterEventType) { - if (entryView.getValue().startsWith("filter")) { - return true; - } + public boolean filter(String s, EntryView entryView, WanFilterEventType wanFilterEventType) { return false; } } diff --git a/hazelcast-integration/filter-based-session-replication/src/main/webapp/WEB-INF/hazelcast.xml b/hazelcast-integration/filter-based-session-replication/src/main/webapp/WEB-INF/hazelcast.xml index 71cccad23..d9c32ee4b 100644 --- a/hazelcast-integration/filter-based-session-replication/src/main/webapp/WEB-INF/hazelcast.xml +++ b/hazelcast-integration/filter-based-session-replication/src/main/webapp/WEB-INF/hazelcast.xml @@ -1,6 +1,6 @@ http://localhost:8090/mancenter - + \ No newline at end of file diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/pom.xml b/hazelcast-integration/hibernate-2ndlevel-cache/pom.xml index 78a5367b3..2ba9f2829 100644 --- a/hazelcast-integration/hibernate-2ndlevel-cache/pom.xml +++ b/hazelcast-integration/hibernate-2ndlevel-cache/pom.xml @@ -19,7 +19,7 @@ org.hibernate hibernate-core - 4.3.11.Final + 4.3.8.Final diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateDB.java b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateDB.java new file mode 100644 index 000000000..4fc5773f8 --- /dev/null +++ b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateDB.java @@ -0,0 +1,32 @@ +package com.hazelcast.hibernate; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +/** + * Created by Esref Ozturk on 08.07.2014. + */ +public class CreateDB { + public static void main( String args[] ){ + try { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); + } + catch( Exception e ){ + System.out.println(e); + } + try { + Connection conn = DriverManager.getConnection("jdbc:derby:hibernateDB;create=true", new Properties()); + Statement st = conn.createStatement(); + st.executeUpdate("create table EMPLOYEE( id INT PRIMARY KEY NOT NULL, " + + "first_name VARCHAR(20) default NULL," + + "last_name VARCHAR(20) default NULL," + + "salary INT default NULL)"); + } + catch( SQLException s){ + s.printStackTrace(); + } + } +} diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateTable.java b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateTable.java deleted file mode 100644 index f91605d77..000000000 --- a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateTable.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hazelcast.hibernate; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; - -/** - * @author Esref Ozturk - */ -public class CreateTable { - - public static void main(String args[]) { - try { - Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); - } catch (Exception e) { - e.printStackTrace(); - } - try { - Connection conn = DriverManager.getConnection("jdbc:derby:hibernateDB;create=true", new Properties()); - Statement st = conn.createStatement(); - st.executeUpdate("CREATE TABLE employee(id INT PRIMARY KEY NOT NULL" - + ", first_name VARCHAR(20) default NULL" - + ", last_name VARCHAR(20) default NULL" - + ", salary INT default NULL)"); - } catch (SQLException e) { - e.printStackTrace(); - } - } -} diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/DropTable.java b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/DropTable.java deleted file mode 100644 index c6a13e234..000000000 --- a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/DropTable.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hazelcast.hibernate; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; - -public class DropTable { - - public static void main(String args[]) { - try { - Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); - } catch (Exception e) { - e.printStackTrace(); - } - try { - Connection conn = DriverManager.getConnection("jdbc:derby:hibernateDB;create=true", new Properties()); - Statement st = conn.createStatement(); - st.executeUpdate("DROP TABLE employee"); - } catch (SQLException e) { - e.printStackTrace(); - } - } -} diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java index e7149d981..42b95bc57 100644 --- a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java +++ b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java @@ -1,55 +1,44 @@ package com.hazelcast.hibernate; /** - * @author Esref Ozturk + * Created by Esref Ozturk on 26.06.2014. */ -@SuppressWarnings("unused") -public class Employee { +public class Employee { private int id; private String firstName; private String lastName; private int salary; - public Employee() { - } - - public Employee(int id, String fname, String lname, int salary) { + public Employee() {} + public Employee(int id , String fname, String lname, int salary) { this.id = id; this.firstName = fname; this.lastName = lname; this.salary = salary; } - public int getId() { return id; } - - public void setId(int id) { + public void setId( int id ) { this.id = id; } - public String getFirstName() { return firstName; } - - public void setFirstName(String first_name) { + public void setFirstName( String first_name ) { this.firstName = first_name; } - public String getLastName() { return lastName; } - - public void setLastName(String last_name) { + public void setLastName( String last_name ) { this.lastName = last_name; } - public int getSalary() { return salary; } - - public void setSalary(int salary) { + public void setSalary( int salary ) { this.salary = salary; } -} +} \ No newline at end of file diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployee.java b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployee.java index 0b2819eaf..5ef4926cd 100644 --- a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployee.java +++ b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployee.java @@ -1,85 +1,107 @@ package com.hazelcast.hibernate; +import com.hazelcast.core.Hazelcast; +import com.hazelcast.core.HazelcastInstance; +import com.hazelcast.hibernate.instance.HazelcastAccessor; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; +import java.util.Iterator; import java.util.List; import java.util.Scanner; +import java.util.logging.Logger; /** - * @author Esref Ozturk + * Created by Esref Ozturk on 26.06.2014. */ + public class ManageEmployee { + private static SessionFactory factory; + private static Session session1,session2,currentSession; + private static Transaction tx1,tx2,currentTx; + private static Scanner reader; + private static String command; + private static int current; + + HazelcastInstance hazelcastInstance = HazelcastAccessor.getHazelcastInstance(factory); + public static void main(String[] args) throws InterruptedException { - SessionFactory factory; - try { + try{ factory = new Configuration().configure().buildSessionFactory(); - } catch (Throwable ex) { - System.err.println("Failed to create sessionFactory object: " + ex.getMessage()); + }catch (Throwable ex) { + System.err.println("Failed to create sessionFactory object." + ex); throw new ExceptionInInitializerError(ex); } - Scanner reader = new Scanner(System.in); - Session session1 = factory.openSession(); - Transaction tx1 = session1.beginTransaction(); - Session session2 = factory.openSession(); - Transaction tx2 = session2.beginTransaction(); - Session currentSession = session1; - Transaction currentTx = tx1; - int current = 1; + reader = new Scanner(System.in); + session1 = factory.openSession(); + tx1 = session1.beginTransaction(); + session2 = factory.openSession(); + tx2 = session2.beginTransaction(); + currentSession = session1; + currentTx = tx1; + current = 1; + - while (true) { + for(;;){ Thread.sleep(100); - System.out.print("[" + current + ". session] Enter command: "); - String command = reader.nextLine(); - if (command.equals("list")) { + System.out.print( "["+ current +". session]command: "); + command = reader.nextLine(); + if( command.equals("list") ){ List employees = currentSession.createQuery("FROM Employee").list(); - for (Object entry : employees) { - Employee employee = (Employee) entry; + for (Iterator iterator = + employees.iterator(); iterator.hasNext();){ + Employee employee = (Employee) iterator.next(); System.out.print("Id: " + employee.getId()); - System.out.print(", first name: " + employee.getFirstName()); - System.out.print(", last name: " + employee.getLastName()); - System.out.println(", salary: " + employee.getSalary()); + System.out.print(" First Name: " + employee.getFirstName()); + System.out.print(" Last Name: " + employee.getLastName()); + System.out.println(" Salary: " + employee.getSalary()); } - } else if (command.equals("add")) { + } + else if( command.equals("add") ){ System.out.print("Id: "); int id = reader.nextInt(); reader.nextLine(); - System.out.print("First name: "); + System.out.print("First Name: "); String fname = reader.nextLine(); - System.out.print("Last name: "); + System.out.print("Last Name: "); String lname = reader.nextLine(); System.out.print("Salary: "); int salary = reader.nextInt(); reader.nextLine(); Employee employee = new Employee(id, fname, lname, salary); currentSession.save(employee); - } else if (command.equals("delete")) { + } + else if( command.equals("delete") ){ System.out.print("EmployeeID: "); int employeeId = reader.nextInt(); reader.nextLine(); Employee employee; employee = (Employee) currentSession.get(Employee.class, employeeId); currentSession.delete(employee); - } else if (command.equals("close")) { + } + else if( command.equals("close") ){ currentTx.commit(); currentSession.close(); - } else if (command.equals("open")) { - if (current == 1) { + } + else if( command.equals("open") ){ + if( current==1 ){ session1 = factory.openSession(); tx1 = session1.beginTransaction(); currentSession = session1; currentTx = tx1; - } else { + } + else{ session2 = factory.openSession(); tx2 = session2.beginTransaction(); currentSession = session2; currentTx = tx2; } - } else if (command.equals("help")) { + } + else if( command.equals("help") ){ System.out.println("help this menu"); System.out.println("list list all employees"); System.out.println("add add an employee"); @@ -88,30 +110,37 @@ public static void main(String[] args) throws InterruptedException { System.out.println("close commit transaction and close session"); System.out.println("change change between two sessions"); System.out.println("exit exit"); - } else if (command.equals("exit")) { - if (!tx1.wasCommitted()) { + } + else if( command.equals("exit") ) { + if( !tx1.wasCommitted()){ tx1.commit(); session1.close(); } - if (!tx2.wasCommitted()) { + if( !tx2.wasCommitted()){ tx2.commit(); session2.close(); } factory.close(); break; - } else if (command.equals("change")) { - if (currentSession.equals(session1)) { + } + else if( command.equals("change") ){ + if( currentSession.equals( session1 ) ) { currentSession = session2; currentTx = tx2; current = 2; - } else { + } + else { currentSession = session1; currentTx = tx1; current = 1; } - } else { - System.out.println("Command not found. Use help."); + } + else{ + System.out.println("command not found. Use help menu"); } } + + } -} + +} \ No newline at end of file diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/Employee.hbm.xml b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/Employee.hbm.xml index 44b149b3a..9f89ea67d 100644 --- a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/Employee.hbm.xml +++ b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/Employee.hbm.xml @@ -4,7 +4,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> - + This class contains the employee detail. @@ -13,4 +13,4 @@ - + \ No newline at end of file diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hazelcast.xml b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hazelcast.xml index 822675d84..e5ae8b270 100644 --- a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hazelcast.xml +++ b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hazelcast.xml @@ -1,5 +1,4 @@ - + hibernate @@ -67,6 +66,8 @@ NONE 0 25 + 3 + true com.hazelcast.map.merge.PassThroughMergePolicy @@ -110,4 +111,4 @@ - + \ No newline at end of file diff --git a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hibernate.cfg.xml b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hibernate.cfg.xml index 2f9cb57f1..00c08e846 100644 --- a/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hibernate.cfg.xml +++ b/hazelcast-integration/hibernate-2ndlevel-cache/src/main/resources/hibernate.cfg.xml @@ -1,16 +1,16 @@ - - true - false - true - com.hazelcast.hibernate.HazelcastCacheRegionFactory - false - 127.0.0.1 - hibernate - password - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:hibernateDB - - - + + true + false + true + com.hazelcast.hibernate.HazelcastCacheRegionFactory + false + 127.0.0.1 + hibernate + password + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:hibernateDB + + + \ No newline at end of file diff --git a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateDB.java b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateDB.java new file mode 100644 index 000000000..fd635c74b --- /dev/null +++ b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateDB.java @@ -0,0 +1,32 @@ +package com.hazelcast.hibernate; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +/** +* Created by tgrl on 29.01.2015. +*/ +public class CreateDB { + public static void main( String args[] ){ + try { + Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); + } + catch( Exception e ){ + System.out.println(e); + } + try { + Connection conn = DriverManager.getConnection("jdbc:derby:hibernateDB;create=true", new Properties()); + Statement st = conn.createStatement(); + st.executeUpdate("create table EMPLOYEE( id INT PRIMARY KEY NOT NULL, " + + "first_name VARCHAR(20) default NULL," + + "last_name VARCHAR(20) default NULL," + + "salary INT default NULL)"); + } + catch( SQLException s){ + s.printStackTrace(); + } + } +} diff --git a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateTable.java b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateTable.java deleted file mode 100644 index 2b19e7c8c..000000000 --- a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/CreateTable.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.hazelcast.hibernate; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; - -/** - * @author tgrl - */ -public class CreateTable { - - public static void main(String args[]) { - try { - Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); - } catch (Exception e) { - e.printStackTrace(); - } - try { - Connection conn = DriverManager.getConnection("jdbc:derby:hibernateDB;create=true", new Properties()); - Statement st = conn.createStatement(); - st.executeUpdate("CREATE TABLE employee(id INT PRIMARY KEY NOT NULL" - + ", first_name VARCHAR(20) default NULL" - + ", last_name VARCHAR(20) default NULL" - + ", salary INT default NULL)"); - } catch (SQLException e) { - e.printStackTrace(); - } - } -} diff --git a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/DropTable.java b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/DropTable.java deleted file mode 100644 index c6a13e234..000000000 --- a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/DropTable.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.hazelcast.hibernate; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; - -public class DropTable { - - public static void main(String args[]) { - try { - Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); - } catch (Exception e) { - e.printStackTrace(); - } - try { - Connection conn = DriverManager.getConnection("jdbc:derby:hibernateDB;create=true", new Properties()); - Statement st = conn.createStatement(); - st.executeUpdate("DROP TABLE employee"); - } catch (SQLException e) { - e.printStackTrace(); - } - } -} diff --git a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java index 2eaa49190..f1729ed95 100644 --- a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java +++ b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/Employee.java @@ -7,12 +7,11 @@ import javax.persistence.Table; /** - * @author tgrl - */ +* Created by tgrl on 29.01.2015. +*/ @Entity @Cacheable -@Table(name = "employee") -@SuppressWarnings("unused") +@Table(name = "EMPLOYEE") public class Employee { @Id @@ -28,45 +27,35 @@ public class Employee { @Column(name = "salary") private int salary; - public Employee() { - } - - public Employee(int id, String fname, String lname, int salary) { + public Employee() {} + public Employee(int id , String fname, String lname, int salary) { this.id = id; this.firstName = fname; this.lastName = lname; this.salary = salary; } - public int getId() { return id; } - - public void setId(int id) { + public void setId( int id ) { this.id = id; } - public String getFirstName() { return firstName; } - - public void setFirstName(String first_name) { + public void setFirstName( String first_name ) { this.firstName = first_name; } - public String getLastName() { return lastName; } - - public void setLastName(String last_name) { + public void setLastName( String last_name ) { this.lastName = last_name; } - public int getSalary() { return salary; } - - public void setSalary(int salary) { + public void setSalary( int salary ) { this.salary = salary; } } diff --git a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployeeJPA.java b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployeeJPA.java index 20cdaaab1..7cd5e6ec4 100644 --- a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployeeJPA.java +++ b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/java/com/hazelcast/hibernate/ManageEmployeeJPA.java @@ -1,6 +1,5 @@ package com.hazelcast.hibernate; -import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.IMap; import com.hazelcast.hibernate.instance.HazelcastAccessor; @@ -27,7 +26,7 @@ import java.util.Scanner; /** - * @author tgrl + * Created by tgrl on 29.01.2015. */ public class ManageEmployeeJPA { @@ -36,14 +35,15 @@ public class ManageEmployeeJPA { public static final int ENTRY_COUNT = 20; public static final String SELECT_A_FROM_EMPLOYEE_A = "Select a from Employee a"; private static EntityManager em; + private static Scanner reader; + private static String command; private static Statistics statistics; private static HazelcastInstance hazelcast; public static void main(String[] args) { init(); populateDb(); - processConsoleCommand(); - Hazelcast.shutdownAll(); + processConsoleComand(); } private static void populateDb() { @@ -82,15 +82,18 @@ private static void registerMBean(SessionFactory sessionFactory) { } } - private static void processConsoleCommand() { - Scanner reader = new Scanner(System.in); - while (true) { + private static void processConsoleComand() { + reader = new Scanner(System.in); + while (true){ System.out.println("Command: "); - String command = reader.nextLine(); - if (command.equals("list")) { + command = reader.nextLine(); + if (command.equals("list")){ + System.out.println("List: "); listEmployee(); - } else if (command.equals("add")) { + + }else if (command.equals("add")){ + System.out.print("Id: "); int id = reader.nextInt(); reader.nextLine(); @@ -100,12 +103,17 @@ private static void processConsoleCommand() { String lname = reader.nextLine(); System.out.print("Salary: "); int salary = reader.nextInt(); + createEmployee(id, fname, lname, salary); - } else if (command.equals("remove")) { + + }else if (command.equals("remove")){ + System.out.println("Key: "); int id = reader.nextInt(); removeEmployee(id); - } else if (command.equals("update")) { + + }else if (command.equals("update")){ + System.out.print("Id: "); int id = reader.nextInt(); reader.nextLine(); @@ -117,18 +125,18 @@ private static void processConsoleCommand() { int salary = reader.nextInt(); System.out.print("Key: "); int key = reader.nextInt(); + updateEmployee(id, fname, lname, salary, key); } else if (command.equals("show")) { System.out.println("Key: "); int id = reader.nextInt(); showEmployee(id); - } else if (command.equals("stats")) { + } else if (command.equals("stats")){ printStatistics(); - } else if (command.endsWith("exit")) { - break; } else { System.err.println("Command not found: " + command); } + reader.nextLine(); } } @@ -171,7 +179,8 @@ private static void printHibernateStatistics() { } String regionName = "com.hazelcast.hibernate.Employee"; - SecondLevelCacheStatistics cacheStats = statistics.getSecondLevelCacheStatistics(regionName); + SecondLevelCacheStatistics cacheStats = statistics.getSecondLevelCacheStatistics( + regionName); if (cacheStats != null) { System.out.println("Hibernate.SecondLevelCacheStatistics stats for " + regionName); System.out.println(cacheStats); @@ -186,8 +195,8 @@ private static void createEmployee(int id, String first_name, String last_name, em.persist(emp); em.getTransaction().commit(); } - - private static void removeEmployee(int key) { + + private static void removeEmployee(int key){ Employee employee = em.find(Employee.class, key); if (employee != null) { em.getTransaction().begin(); @@ -195,15 +204,16 @@ private static void removeEmployee(int key) { em.getTransaction().commit(); } } - - private static void listEmployee() { + + private static void listEmployee(){ List employeeList = em .createQuery(SELECT_A_FROM_EMPLOYEE_A, Employee.class) .getResultList(); - for (Employee employee : employeeList) { + for (Employee employee : employeeList){ printEmployee(employee); } + } private static void printEmployee(Employee employee) { @@ -213,7 +223,7 @@ private static void printEmployee(Employee employee) { System.out.println("Salary: " + employee.getSalary()); } - private static void updateEmployee(int id, String first_name, String last_name, int salary, int key) { + private static void updateEmployee(int id, String first_name, String last_name, int salary, int key){ Employee employee = em.find(Employee.class, key); em.getTransaction().begin(); employee.setId(id); @@ -222,4 +232,6 @@ private static void updateEmployee(int id, String first_name, String last_name, employee.setSalary(salary); em.getTransaction().commit(); } + } + diff --git a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/META-INF/persistence.xml b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/META-INF/persistence.xml index 764f0ebe3..fc48128a5 100644 --- a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/META-INF/persistence.xml +++ b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/META-INF/persistence.xml @@ -7,10 +7,11 @@ org.hibernate.ejb.HibernatePersistence - - - - + + + + + @@ -28,4 +29,4 @@ - + \ No newline at end of file diff --git a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/hazelcast.xml b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/hazelcast.xml index 822675d84..e5ae8b270 100644 --- a/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/hazelcast.xml +++ b/hazelcast-integration/hibernate-jpa-2ndlevel-cache/src/main/resources/hazelcast.xml @@ -1,5 +1,4 @@ - + hibernate @@ -67,6 +66,8 @@ NONE 0 25 + 3 + true com.hazelcast.map.merge.PassThroughMergePolicy @@ -110,4 +111,4 @@ - + \ No newline at end of file diff --git a/hazelcast-integration/mongodb/src/main/resources/hazelcast.xml b/hazelcast-integration/mongodb/src/main/resources/hazelcast.xml index b460dc255..b475b12ef 100644 --- a/hazelcast-integration/mongodb/src/main/resources/hazelcast.xml +++ b/hazelcast-integration/mongodb/src/main/resources/hazelcast.xml @@ -18,10 +18,11 @@ --> + http://localhost:8080/mancenter - - - 4.0.0 - - - com.hazelcast.samples - hazelcast-integration - 0.1-SNAPSHOT - - - springboot-caching-jcache - jar - Spring Boot: Hazelcast via Spring JCache - Spring Boot Hazelcast Integration Example via Spring JCache - - - - org.springframework.boot - spring-boot-starter-cache - - - javax.cache - cache-api - 1.0.0 - - - - - - - - org.springframework.boot - spring-boot-starter-parent - pom - import - 1.3.1.RELEASE - - - - - - - org.springframework.boot - spring-boot-maven-plugin - 1.3.1.RELEASE - - com.hazelcast.springboot.caching.BootifulMember - - - - - - diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/BootifulClient.java b/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/BootifulClient.java deleted file mode 100644 index 38b543b67..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/BootifulClient.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -import java.util.concurrent.TimeUnit; - -import static java.lang.String.format; -import static java.lang.System.nanoTime; -import static java.lang.System.out; - -/** - * Hazelcast Client initialized by Spring Boot auto configuration - * - * @author Viktor Gamov on 12/26/15. - * Twitter: @gamussa - */ - -@SpringBootApplication(scanBasePackages = "com.hazelcast.springboot.caching.BootifulClient") -// disable Hazelcast Auto Configuration, and use JCache configuration for the client example -@EnableAutoConfiguration(exclude = {HazelcastAutoConfiguration.class}) -@EnableCaching -public class BootifulClient { - - public static void main(String[] args) { - new SpringApplicationBuilder() - .sources(BootifulClient.class) - .profiles("client") - .run(args); - } - - @Bean - public IDummyBean dummyBean() { - return new DummyBean(); - } - - @Component - static class Runner implements CommandLineRunner { - - @Autowired - IDummyBean dummy; - - @Override public void run(String... strings) throws Exception { - - String logFormat = "%s call took %d millis with result: %s"; - long start1 = nanoTime(); - String city = dummy.getCity(); - long end1 = nanoTime(); - out.println(format(logFormat, "First", TimeUnit.NANOSECONDS.toMillis(end1 - start1), city)); - - long start2 = nanoTime(); - city = dummy.getCity(); - long end2 = nanoTime(); - out.println(format(logFormat, "Second", TimeUnit.NANOSECONDS.toMillis(end2 - start2), city)); - } - } -} diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/BootifulMember.java b/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/BootifulMember.java deleted file mode 100644 index e9b874139..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/BootifulMember.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cache.annotation.EnableCaching; - -/** - * Hazelcast member initialized by Spring Boot auto configuration - * - * @author Viktor Gamov on 12/26/15. - * Twitter: @gamussa - */ -@SpringBootApplication(scanBasePackages = "com.hazelcast.springboot.caching.BootifulMember") -@EnableAutoConfiguration( - exclude = { - // disable Hazelcast Auto Configuration, and use JCache configuration for the member example - HazelcastAutoConfiguration.class - }) -@EnableCaching -public class BootifulMember { - public static void main(String[] args) { - new SpringApplicationBuilder() - .profiles("member") - .sources(BootifulMember.class) - .run(args); - } -} diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/DummyBean.java b/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/DummyBean.java deleted file mode 100644 index d649d907f..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/DummyBean.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import java.util.concurrent.TimeUnit; - -public class DummyBean implements IDummyBean { - - @Override - public String getCity() { - System.out.println("DummyBean.getCity() called!"); - try { - // emulation of slow method - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return "Ankara"; - } -} diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/IDummyBean.java b/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/IDummyBean.java deleted file mode 100644 index 52df35c32..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/java/com/hazelcast/springboot/caching/IDummyBean.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import javax.cache.annotation.CacheResult; - -public interface IDummyBean { - - @CacheResult(cacheName = "city") - String getCity(); -} diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/resources/application-client.properties b/hazelcast-integration/springboot-caching-jcache/src/main/resources/application-client.properties deleted file mode 100644 index f03625020..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/resources/application-client.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# -# Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -spring.cache.type=jcache -spring.cache.jcache.provider=com.hazelcast.client.cache.impl.HazelcastClientCachingProvider diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/resources/application-member.properties b/hazelcast-integration/springboot-caching-jcache/src/main/resources/application-member.properties deleted file mode 100644 index a56f64f91..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/resources/application-member.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# -# Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -spring.cache.type=jcache -spring.cache.jcache.provider=com.hazelcast.cache.impl.HazelcastServerCachingProvider diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/resources/banner.txt b/hazelcast-integration/springboot-caching-jcache/src/main/resources/banner.txt deleted file mode 100644 index 83a7e7c6e..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/resources/banner.txt +++ /dev/null @@ -1,8 +0,0 @@ - _ _ _ _ ______ _ -| | | | | | | | _ | ___ \ | | -| |_| | __ _ _______| | ___ __ _ ___| |_ _| |_| |_/ / ___ ___ | |_ -| _ |/ _` |_ / _ | |/ __/ _` / __| __|_ _| ___ \/ _ \ / _ \| __| -| | | | (_| |/ | __| | (_| (_| \__ | |_ |_| | |_/ | (_) | (_) | |_ -\_| |_/\__,_/___\___|_|\___\__,_|___/\__ \____/ \___/ \___/ \__| - - diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/resources/hazelcast-client.xml b/hazelcast-integration/springboot-caching-jcache/src/main/resources/hazelcast-client.xml deleted file mode 100644 index 61c7afa32..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/resources/hazelcast-client.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - bootifulcluster - bootiful-pass - - - - -
127.0.0.1
-
-
-
diff --git a/hazelcast-integration/springboot-caching-jcache/src/main/resources/hazelcast.xml b/hazelcast-integration/springboot-caching-jcache/src/main/resources/hazelcast.xml deleted file mode 100644 index 5df5825e2..000000000 --- a/hazelcast-integration/springboot-caching-jcache/src/main/resources/hazelcast.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - bootifulcluster - bootiful-pass - - - - - - - - true - true - - - diff --git a/hazelcast-integration/springboot-caching-jcache/startBootifulClient.sh b/hazelcast-integration/springboot-caching-jcache/startBootifulClient.sh deleted file mode 100755 index fda980598..000000000 --- a/hazelcast-integration/springboot-caching-jcache/startBootifulClient.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -java -cp target/lib/*:target/classes com.hazelcast.springboot.caching.BootifulClient diff --git a/hazelcast-integration/springboot-caching-jcache/startBootifulMember.sh b/hazelcast-integration/springboot-caching-jcache/startBootifulMember.sh deleted file mode 100755 index 89a29878d..000000000 --- a/hazelcast-integration/springboot-caching-jcache/startBootifulMember.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -java -cp target/lib/*:target/classes com.hazelcast.springboot.caching.BootifulMember diff --git a/hazelcast-integration/springboot-caching/README.adoc b/hazelcast-integration/springboot-caching/README.adoc deleted file mode 100644 index 028c8cbfa..000000000 --- a/hazelcast-integration/springboot-caching/README.adoc +++ /dev/null @@ -1,44 +0,0 @@ -= Spring Boot Hazelcast Integration Example via Spring Framework Caching Abstraction -Viktor Gamov , © 2015 Hazelcast, Inc. -2015-12-28 -:revdate: 2015-12-27 1:11:50 -0600 -:linkattrs: -:ast: * -:y: ✓ -:n: ✘ -:y: icon:check-sign[role="green"] -:n: icon:check-minus[role="red"] -:c: icon:file-text-alt[role="blue"] -:toc: auto -:toc-placement: auto -:toc-position: right -:toc-title: Table of content -:toclevels: 3 -:idprefix: -:idseparator: - -:sectanchors: -:icons: font -:source-highlighter: highlight.js -:highlightjs-theme: idea -:experimental: - -Spring Boot Hazelcast Integration Example via http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html[Spring Framework Caching Abstraction]. - -NOTE: This example *doesn't* have the dependencies on JSR-107 / JCache jars. -For JCache example, use `springboot-caching-jcache` project. - -toc::[] - -This is an example of Spring Boot Caching Auto Configuration feature for Hazelcast and Spring Framework Caching Abstraction: - -- A `BootifulMember` is a Spring Boot application with fully auto-configured embedded Hazelcast member. -During application startup, Spring Boot scans classpath for `hazelcast.xml` and automatically instantiates Spring's -`CacheManager` bean backed by `HazelcastInstance`. -Use `startBootifulMember.sh` to start a cluster member from command line. -- `BootifulClient` also uses Spring Boot auto configuration for Hazelcast. -It scans Spring Configuration for `CacheManager` bean backed by `HazelcastClient.newHazelcastClientinstance()` and picks `hazelcast-client.xml` from classpath. -Use `startBootifulClient.sh` to start a client and connect to the cluster from command line. - -NOTE: By running `mvn package spring-boot:repackage`, Spring Boot maven plugin will generate executable jar `java -jar - ..` with `BootifulMember` as a main class. - diff --git a/hazelcast-integration/springboot-caching/pom.xml b/hazelcast-integration/springboot-caching/pom.xml deleted file mode 100644 index 5ce9c88d8..000000000 --- a/hazelcast-integration/springboot-caching/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - 4.0.0 - - - com.hazelcast.samples - hazelcast-integration - 0.1-SNAPSHOT - - - springboot-caching - jar - Spring Boot: Hazelcast via Spring Caching Abstraction - Spring Boot Hazelcast Integration Example via Spring Caching Abstraction - - - - org.springframework.boot - spring-boot-starter-cache - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - org.springframework.boot - spring-boot-starter-parent - pom - import - 1.3.1.RELEASE - - - - - - - org.springframework.boot - spring-boot-maven-plugin - 1.3.1.RELEASE - - com.hazelcast.springboot.caching.BootifulMember - - - - - - diff --git a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/BootifulClient.java b/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/BootifulClient.java deleted file mode 100644 index cd66a1648..000000000 --- a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/BootifulClient.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import com.hazelcast.client.HazelcastClient; -import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.spring.cache.HazelcastCacheManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cache.CacheManager; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.cache.interceptor.KeyGenerator; -import org.springframework.cache.interceptor.SimpleKeyGenerator; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Profile; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import java.util.concurrent.TimeUnit; - -import static java.lang.String.format; -import static java.lang.System.nanoTime; - -/** - * Hazelcast Client initialized by Spring Boot auto configuration - * - * @author Viktor Gamov on 12/26/15. - * Twitter: @gamussa - */ - -@SpringBootApplication(scanBasePackages = "com.hazelcast.springboot.caching.BootifulClient") -@EnableCaching -public class BootifulClient { - - public static void main(String[] args) { - new SpringApplicationBuilder() - .sources(BootifulClient.class) - .profiles("client") - .run(args); - } - - @Bean - public IDummyBean dummyBean() { - return new DummyBean(); - } - - @Bean - CacheManager cacheManager() { - return new HazelcastCacheManager(hazelcastInstance()); - } - - @Bean - KeyGenerator keyGenerator() { - return new SimpleKeyGenerator(); - } - - @Bean - @Profile("client") - HazelcastInstance hazelcastInstance() { - // for client HazelcastInstance LocalMapStatistics will not available - return HazelcastClient.newHazelcastClient(); - // return Hazelcast.newHazelcastInstance(); - } - - @RestController - static class CityController { - - private final Logger logger = LoggerFactory.getLogger(CityController.class); - - @Autowired - IDummyBean dummy; - - @Autowired - HazelcastInstance hazelcastInstance; - - @RequestMapping("/city") - public String getCity() { - String logFormat = "%s call took %d millis with result: %s"; - long start1 = nanoTime(); - String city = dummy.getCity(); - long end1 = nanoTime(); - logger.info(format(logFormat, "Rest", TimeUnit.NANOSECONDS.toMillis(end1 - start1), city)); - return city; - } - - @RequestMapping(value = "city/{city}", method = RequestMethod.GET) - public String setCity(@PathVariable String city) { - return dummy.setCity(city); - } - - } -} diff --git a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/BootifulMember.java b/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/BootifulMember.java deleted file mode 100644 index 0b5ebb1b5..000000000 --- a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/BootifulMember.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration; -import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.cache.annotation.EnableCaching; - -/** - * Hazelcast member initialized by Spring Boot auto configuration - * - * @author Viktor Gamov on 12/26/15. - * Twitter: @gamussa - */ -@SpringBootApplication(scanBasePackages = "com.hazelcast.springboot.caching.BootifulMember") -@EnableCaching -@EnableAutoConfiguration(exclude = {EmbeddedServletContainerAutoConfiguration.class, WebMvcAutoConfiguration.class}) -public class BootifulMember { - - public static void main(String[] args) { - new SpringApplicationBuilder() - .profiles("member") - .sources(BootifulMember.class) - .run(args); - } -} diff --git a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/DummyBean.java b/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/DummyBean.java deleted file mode 100644 index b4a610389..000000000 --- a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/DummyBean.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import java.util.concurrent.TimeUnit; - -public class DummyBean implements IDummyBean { - - @Override - public String getCity() { - System.out.println("DummyBean.getCity() called!"); - try { - // emulation of slow method - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return "Ankara"; - } - - @Override public String setCity(String city) { - return city; - } -} diff --git a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/IDummyBean.java b/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/IDummyBean.java deleted file mode 100644 index b1d1d6780..000000000 --- a/hazelcast-integration/springboot-caching/src/main/java/com/hazelcast/springboot/caching/IDummyBean.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package com.hazelcast.springboot.caching; - -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; - -public interface IDummyBean { - - @Cacheable("city") - String getCity(); - - @CachePut(value = "city", key = "#city + 1") - String setCity(String city); -} diff --git a/hazelcast-integration/springboot-caching/src/main/resources/application-client.properties b/hazelcast-integration/springboot-caching/src/main/resources/application-client.properties deleted file mode 100644 index d0f0b07d0..000000000 --- a/hazelcast-integration/springboot-caching/src/main/resources/application-client.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# -# Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# - -spring.cache.type=hazelcast -server.port=8081 -management.port=9001 diff --git a/hazelcast-integration/springboot-caching/src/main/resources/application-member.properties b/hazelcast-integration/springboot-caching/src/main/resources/application-member.properties deleted file mode 100644 index 0d7f4ad07..000000000 --- a/hazelcast-integration/springboot-caching/src/main/resources/application-member.properties +++ /dev/null @@ -1,19 +0,0 @@ -# -# -# Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -spring.cache.type=hazelcast -spring.main.web-environment=false diff --git a/hazelcast-integration/springboot-caching/src/main/resources/banner.txt b/hazelcast-integration/springboot-caching/src/main/resources/banner.txt deleted file mode 100644 index 83a7e7c6e..000000000 --- a/hazelcast-integration/springboot-caching/src/main/resources/banner.txt +++ /dev/null @@ -1,8 +0,0 @@ - _ _ _ _ ______ _ -| | | | | | | | _ | ___ \ | | -| |_| | __ _ _______| | ___ __ _ ___| |_ _| |_| |_/ / ___ ___ | |_ -| _ |/ _` |_ / _ | |/ __/ _` / __| __|_ _| ___ \/ _ \ / _ \| __| -| | | | (_| |/ | __| | (_| (_| \__ | |_ |_| | |_/ | (_) | (_) | |_ -\_| |_/\__,_/___\___|_|\___\__,_|___/\__ \____/ \___/ \___/ \__| - - diff --git a/hazelcast-integration/springboot-caching/src/main/resources/hazelcast-client.xml b/hazelcast-integration/springboot-caching/src/main/resources/hazelcast-client.xml deleted file mode 100644 index 61c7afa32..000000000 --- a/hazelcast-integration/springboot-caching/src/main/resources/hazelcast-client.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - bootifulcluster - bootiful-pass - - - - -
127.0.0.1
-
-
-
diff --git a/hazelcast-integration/springboot-caching/src/main/resources/hazelcast.xml b/hazelcast-integration/springboot-caching/src/main/resources/hazelcast.xml deleted file mode 100644 index 1fa08ab35..000000000 --- a/hazelcast-integration/springboot-caching/src/main/resources/hazelcast.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - bootifulcluster - bootiful-pass - - http://localhost:8080/mancenter - - - - - - - diff --git a/hazelcast-integration/springboot-caching/startBootifulClient.sh b/hazelcast-integration/springboot-caching/startBootifulClient.sh deleted file mode 100755 index fda980598..000000000 --- a/hazelcast-integration/springboot-caching/startBootifulClient.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -java -cp target/lib/*:target/classes com.hazelcast.springboot.caching.BootifulClient diff --git a/hazelcast-integration/springboot-caching/startBootifulMember.sh b/hazelcast-integration/springboot-caching/startBootifulMember.sh deleted file mode 100755 index 89a29878d..000000000 --- a/hazelcast-integration/springboot-caching/startBootifulMember.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -java -cp target/lib/*:target/classes com.hazelcast.springboot.caching.BootifulMember diff --git a/jcache/src/main/java/com/hazelcast/examples/AbstractApp.java b/jcache/src/main/java/com/hazelcast/examples/AbstractApp.java index bd8bc2222..7b4416f83 100644 --- a/jcache/src/main/java/com/hazelcast/examples/AbstractApp.java +++ b/jcache/src/main/java/com/hazelcast/examples/AbstractApp.java @@ -10,7 +10,6 @@ import java.io.File; import java.net.URI; import java.util.Iterator; -import java.util.Properties; import java.util.Random; import java.util.concurrent.TimeUnit; @@ -53,13 +52,9 @@ public class AbstractApp { * initialize the JCache Manager that we will use for creating and getting a cache object */ public CacheManager initCacheManager(URI uri) { - return initCacheManager(uri, null); - } - - public CacheManager initCacheManager(URI uri, Properties properties) { //resolve a cache manager cachingProvider = Caching.getCachingProvider(); - return cachingProvider.getCacheManager(uri, null, properties); + return cachingProvider.getCacheManager(uri, null); } public CacheManager initCacheManager() { diff --git a/jcache/src/main/java/com/hazelcast/examples/QuorumExample.java b/jcache/src/main/java/com/hazelcast/examples/QuorumExample.java index 2b78c2748..77d327f3f 100644 --- a/jcache/src/main/java/com/hazelcast/examples/QuorumExample.java +++ b/jcache/src/main/java/com/hazelcast/examples/QuorumExample.java @@ -2,7 +2,6 @@ import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; - import javax.cache.Cache; import javax.cache.CacheManager; import javax.cache.Caching; @@ -12,31 +11,30 @@ public class QuorumExample { private static final String CACHE_NAME = "cache-with-quorum"; - public static void main(String[] args) throws URISyntaxException { + public static void main(String[] args) + throws URISyntaxException { System.setProperty("hazelcast.jcache.provider.type", "server"); System.setProperty("hazelcast.config", "classpath:hazelcast-quorum.xml"); - // this creates a cluster with 1 node + //this creates a cluster with 1 node HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); - // this creates a new node and joins the cluster creating a cluster with 2 nodes + //this creates a new node and joins the cluster creating a cluster with 2 nodes CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(); - // Quorum will succeed Cache cache = cacheManager.getCache(CACHE_NAME); - cache.put("key", "we have the quorum"); + cache.put("key", "value"); - System.out.println("Quorum is satisfied, so the following put will throw no exception"); + System.out.println("Quorum is satisfied and key/value put into the cache without problem"); - System.out.println("Shutdown one instance, so there won't be enough members for quorum presence"); + System.out.println("Now killing one instance, and there won't be enough members for quorum presence"); instance1.getLifecycleService().shutdown(); - // Quorum will fail - System.out.println("The following put operation will fail"); + System.out.println("Following put operation will fail"); try { - cache.put("key2", "will not succeed"); - } catch (Exception expected) { - System.out.println("Put operation failed with expected QuorumException: " + expected.getMessage()); + cache.put("key2", "value2"); + } catch (Exception e) { + System.out.println("Put operation failed with exception -> " + e.getMessage()); } Hazelcast.shutdownAll(); } diff --git a/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataConsumer.java b/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataConsumer.java index 00714d819..9e72a8977 100644 --- a/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataConsumer.java +++ b/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataConsumer.java @@ -1,14 +1,11 @@ package com.hazelcast.examples.jcache.client; -import com.hazelcast.cache.HazelcastCachingProvider; import com.hazelcast.cache.ICache; import com.hazelcast.examples.AbstractApp; import javax.cache.Cache; import javax.cache.CacheManager; -import java.net.URI; import java.util.Iterator; -import java.util.Properties; /** * This will try to iterate over cache values and remove them @@ -29,12 +26,9 @@ public void runApp() //Force client be used as a provider clientSetup(); - Properties properties1 = HazelcastCachingProvider.propertiesByLocation("classpath:hazelcast-client-c1.xml"); - Properties properties2 = HazelcastCachingProvider.propertiesByLocation("classpath:hazelcast-client-c2.xml"); - //first thin is we need to initialize the cache Managers for each cluster - final CacheManager cacheManager1 = initCacheManager(uri1, properties1); - final CacheManager cacheManager2 = initCacheManager(uri2, properties2); + final CacheManager cacheManager1 = initCacheManager(uri1); + final CacheManager cacheManager2 = initCacheManager(uri2); //create a cache with the provided name final Cache cacheAtCluster1 = cacheManager1.getCache("theCache",String.class, Integer.class); @@ -49,54 +43,48 @@ public void runApp() } public void startConsumerTask(final Cache cacheAtCluster) { - if (cacheAtCluster != null) { - Thread t = new Thread(new Runnable() { - @Override - public void run() { - while (!Thread.interrupted()){ - final Iterator> iterator = cacheAtCluster.iterator(); - while (iterator.hasNext()) { - final Cache.Entry entry = iterator.next(); - //value maybe null which means it is expired - if(entry.getValue() != null) { - //poor entry just remove - iterator.remove(); - //do something with entry, save to db etc. - } - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - return; + Thread t = new Thread(new Runnable() { + @Override + public void run() { + while (!Thread.interrupted()){ + final Iterator> iterator = cacheAtCluster.iterator(); + while (iterator.hasNext()) { + final Cache.Entry entry = iterator.next(); + //value maybe null which means it is expired + if(entry.getValue() != null) { + //poor entry just remove + iterator.remove(); + //do something with entry, save to db etc. } } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + return; + } } - }); - t.start(); - } else { - System.out.println("Provided cache doesn't exist on cluster"); - } + } + }); + t.start(); } private void displayCacheSize(final String alias, final ICache icache) { - if (icache != null) { - Thread t = new Thread(new Runnable() { - @Override - public void run() { - while (!Thread.interrupted()){ - System.out.println("Cache: "+alias+" size:"+icache.size()); - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - return; - } + Thread t = new Thread(new Runnable() { + @Override + public void run() { + while (!Thread.interrupted()){ + System.out.println("Cache: "+alias+" size:"+icache.size()); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + return; } } - }); - t.start(); - } + } + }); + t.start(); } } diff --git a/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataProducer.java b/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataProducer.java index 97d44bf2f..52eea3df7 100644 --- a/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataProducer.java +++ b/jcache/src/main/java/com/hazelcast/examples/jcache/client/ClientDataProducer.java @@ -1,12 +1,10 @@ package com.hazelcast.examples.jcache.client; -import com.hazelcast.cache.HazelcastCachingProvider; import com.hazelcast.examples.AbstractApp; import javax.cache.Cache; import javax.cache.CacheManager; import javax.cache.expiry.Duration; -import java.util.Properties; import java.util.Random; import java.util.UUID; import java.util.concurrent.TimeUnit; @@ -32,12 +30,9 @@ public void runApp() //Force client be used as a provider clientSetup(); - Properties properties1 = HazelcastCachingProvider.propertiesByLocation("classpath:hazelcast-client-c1.xml"); - Properties properties2 = HazelcastCachingProvider.propertiesByLocation("classpath:hazelcast-client-c2.xml"); - //first thin is we need to initialize the cache Managers for each cluster - final CacheManager cacheManager1 = initCacheManager(uri1, properties1); - final CacheManager cacheManager2 = initCacheManager(uri2, properties2); + final CacheManager cacheManager1 = initCacheManager(uri1); + final CacheManager cacheManager2 = initCacheManager(uri2); //create a cache with the provided name final Cache cacheAtCluster1 = initCache("theCache", cacheManager1, new Duration(TimeUnit.SECONDS,10)); diff --git a/jcache/src/main/java/com/hazelcast/examples/listener/PartitionLostListenerUsage.java b/jcache/src/main/java/com/hazelcast/examples/listener/PartitionLostListenerUsage.java index e648ac7e3..48180e3ed 100644 --- a/jcache/src/main/java/com/hazelcast/examples/listener/PartitionLostListenerUsage.java +++ b/jcache/src/main/java/com/hazelcast/examples/listener/PartitionLostListenerUsage.java @@ -1,5 +1,6 @@ package com.hazelcast.examples.listener; + import com.hazelcast.cache.ICache; import com.hazelcast.cache.impl.HazelcastServerCachingProvider; import com.hazelcast.cache.impl.event.CachePartitionLostEvent; @@ -11,61 +12,48 @@ import javax.cache.Cache; import javax.cache.CacheManager; -import java.util.concurrent.CountDownLatch; import static com.hazelcast.cache.impl.HazelcastServerCachingProvider.createCachingProvider; public class PartitionLostListenerUsage { - public static void main(String[] args) throws InterruptedException { - - final CountDownLatch latch = new CountDownLatch(1); + public static void main(String[] args) { String cacheName1 = "myCache1"; String cacheName2 = "myCache2"; - HazelcastInstance serverInstance1 = Hazelcast.newHazelcastInstance(new Config()); - HazelcastInstance serverInstance2 = Hazelcast.newHazelcastInstance(new Config()); - - HazelcastServerCachingProvider cachingProvider = createCachingProvider(serverInstance1); - CacheManager cacheManager = cachingProvider.getCacheManager(); + HazelcastInstance serverInstance1 = Hazelcast.newHazelcastInstance(new Config()); + HazelcastInstance serverInstance2 = Hazelcast.newHazelcastInstance(new Config()); - CacheConfig config1 = new CacheConfig(); - // might lose data if any node crashes - config1.setBackupCount(0); - Cache cache1 = cacheManager.createCache(cacheName1, config1); + final HazelcastServerCachingProvider cachingProvider = createCachingProvider(serverInstance1); + final CacheManager cacheManager = cachingProvider.getCacheManager(); + final CacheConfig config1 = new CacheConfig(); + config1.setBackupCount(0); //might lose data if any node crashes + final Cache cache1 = cacheManager.createCache(cacheName1, config1); cache1.put(1, "Berlin"); + final ICache iCache1 = cache1.unwrap(ICache.class); - ICache iCache1 = cache1.unwrap(ICache.class); iCache1.addPartitionLostListener(new CachePartitionLostListener() { @Override public void partitionLost(CachePartitionLostEvent cachePartitionLostEvent) { System.out.println(cachePartitionLostEvent); - latch.countDown(); } }); - CacheConfig config2 = new CacheConfig(); - // keeps its data if a single node crashes - config2.setBackupCount(1); - Cache cache2 = cacheManager.createCache(cacheName2, config2); - + final CacheConfig config2 = new CacheConfig(); + config2.setBackupCount(1); //keeps its data if a single node crashes + final Cache cache2 = cacheManager.createCache(cacheName2, config2); cache1.put(1, "Berlin"); + final ICache iCache2 = cache2.unwrap(ICache.class); - ICache iCache2 = cache2.unwrap(ICache.class); iCache2.addPartitionLostListener(new CachePartitionLostListener() { @Override public void partitionLost(CachePartitionLostEvent cachePartitionLostEvent) { - System.err.println("This line should not be printed! " + cachePartitionLostEvent); + System.out.println("This line will not be printed! " + cachePartitionLostEvent); } }); - System.out.println("Terminating second Hazelcast instance..."); serverInstance2.getLifecycleService().terminate(); - - // wait for a least one CachePartitionLostEvent - latch.await(); - Hazelcast.shutdownAll(); } } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/AbstractCacheSplitBrainSample.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/AbstractCacheSplitBrainSample.java index 9e766341f..a8113fed5 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/AbstractCacheSplitBrainSample.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/AbstractCacheSplitBrainSample.java @@ -66,14 +66,16 @@ protected static void assertEquals(Object expected, Object actual) { protected static void assertEquals(String message, Object expected, Object actual) { if (equalsRegardingNull(expected, actual)) { return; + } else { + failNotEquals(message, expected, actual); } - failNotEquals(message, expected, actual); } private static boolean equalsRegardingNull(Object expected, Object actual) { if (expected == null) { return actual == null; } + return isEquals(expected, actual); } @@ -93,8 +95,8 @@ private static String format(String message, Object expected, Object actual) { String expectedString = String.valueOf(expected); String actualString = String.valueOf(actual); if (expectedString.equals(actualString)) { - return formatted - + "expected: " + formatClassAndValue(expected, expectedString) + return formatted + "expected: " + + formatClassAndValue(expected, expectedString) + " but was: " + formatClassAndValue(actual, actualString); } else { return formatted + "expected:<" + expectedString + "> but was:<" + actualString + ">"; @@ -138,17 +140,12 @@ protected static void sleepAtLeastMillis(long sleepFor) { protected static void assertClusterSize(int expectedSize, HazelcastInstance instance) { int clusterSize = instance.getCluster().getMembers().size(); if (expectedSize != clusterSize) { - Node node = getNode(instance); - if (node == null) { - throw new NullPointerException("node is null!"); - } - ConnectionManager connectionManager = node.getConnectionManager(); + ConnectionManager connectionManager = getNode(instance).getConnectionManager(); int activeConnectionCount = connectionManager.getActiveConnectionCount(); - throw new AssertionError(String.format( - "Cluster size is not correct. Expected: %d Actual: %d ActiveConnectionCount: %d", + throw new AssertionError(String.format("Cluster size is not correct. Expected: %d Actual: %d %s", expectedSize, clusterSize, - activeConnectionCount)); + "ActiveConnectionCount: " + activeConnectionCount)); } } @@ -169,16 +166,16 @@ protected static void assertOpenEventually(String message, CountDownLatch latch) try { boolean completed = latch.await(ASSERT_EVENTUALLY_TIMEOUT, TimeUnit.SECONDS); if (message == null) { - assertTrue(String.format("CountDownLatch failed to complete within %d seconds, count left: %d", - ASSERT_EVENTUALLY_TIMEOUT, - latch.getCount()), - completed); + assertTrue(String.format("CountDownLatch failed to complete within %d seconds , count left: %d", + ASSERT_EVENTUALLY_TIMEOUT, + latch.getCount()), + completed); } else { - assertTrue(String.format("%s, failed to complete within %d seconds, count left: %d", - message, - ASSERT_EVENTUALLY_TIMEOUT, - latch.getCount()), - completed); + assertTrue(String.format("%s, failed to complete within %d seconds , count left: %d", + message, + ASSERT_EVENTUALLY_TIMEOUT, + latch.getCount()), + completed); } } catch (InterruptedException e) { throw new RuntimeException(e); @@ -272,9 +269,6 @@ private static void checkPartitionCountGreaterOrEqualMemberCount(HazelcastInstan int memberCount = cluster.getMembers().size(); Node node = getNode(instance); - if (node == null) { - throw new NullPointerException("node is null!"); - } InternalPartitionService internalPartitionService = node.getPartitionService(); int partitionCount = internalPartitionService.getPartitionCount(); @@ -293,7 +287,8 @@ protected static Config newProgrammaticConfig() { protected static Config newDeclarativeConfig() { try { - Config config = new XmlConfigBuilder("jcache/src/main/resources/hazelcast-splitbrain.xml").build(); + Config config = + new XmlConfigBuilder("jcache/src/main/resources/hazelcast-splitbrain.xml").build(); config.setProperty(GroupProperty.MERGE_FIRST_RUN_DELAY_SECONDS, "5"); config.setProperty(GroupProperty.MERGE_NEXT_RUN_DELAY_SECONDS, "3"); config.getGroupConfig().setName(generateRandomString(10)); @@ -303,8 +298,8 @@ protected static Config newDeclarativeConfig() { } } - protected static CacheConfig newCacheConfig(String cacheName, String mergePolicy) { - CacheConfig cacheConfig = new CacheConfig(); + protected static CacheConfig newCacheConfig(String cacheName, String mergePolicy) { + CacheConfig cacheConfig = new CacheConfig(); cacheConfig.setName(cacheName); cacheConfig.setMergePolicy(mergePolicy); return cacheConfig; @@ -324,6 +319,7 @@ public void stateChanged(LifecycleEvent event) { latch.countDown(); } } + } private static class SampleMemberShipListener implements MembershipListener { @@ -336,6 +332,7 @@ private SampleMemberShipListener(int countdown) { @Override public void memberAdded(MembershipEvent membershipEvent) { + } @Override @@ -345,7 +342,9 @@ public void memberRemoved(MembershipEvent membershipEvent) { @Override public void memberAttributeChanged(MemberAttributeEvent memberAttributeEvent) { + } + } protected static CountDownLatch simulateSplitBrain(HazelcastInstance h1, HazelcastInstance h2) { @@ -362,4 +361,5 @@ protected static CountDownLatch simulateSplitBrain(HazelcastInstance h1, Hazelca return lifeCycleListener.latch; } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/CacheSplitBrainSampleWithCustomCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/CacheSplitBrainSampleWithCustomCacheMergePolicy.java index d7f812b8a..c238df7b8 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/CacheSplitBrainSampleWithCustomCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/CacheSplitBrainSampleWithCustomCacheMergePolicy.java @@ -27,7 +27,7 @@ abstract class CacheSplitBrainSampleWithCustomCacheMergePolicy extends AbstractC protected abstract Config getConfig(); - protected abstract Cache getCache(String cacheName, CacheManager cacheManager); + protected abstract Cache getCache(String cacheName, CacheManager cacheManager); protected void run() { try { @@ -44,8 +44,8 @@ protected void run() { CacheManager cacheManager1 = cachingProvider1.getCacheManager(); CacheManager cacheManager2 = cachingProvider2.getCacheManager(); - Cache cache1 = getCache(CACHE_NAME, cacheManager1); - Cache cache2 = getCache(CACHE_NAME, cacheManager2); + Cache cache1 = getCache(CACHE_NAME, cacheManager1); + Cache cache2 = getCache(CACHE_NAME, cacheManager2); // TODO We assume that until here and also while doing get/put, cluster is still splitted. // This assumptions seems fragile due to time sensitivity. @@ -53,13 +53,13 @@ protected void run() { String key = generateKeyOwnedBy(h1); cache1.put(key, "value"); - cache2.put(key, 1); + cache2.put(key,Integer.valueOf(1)); assertOpenEventually(splitBrainCompletedLatch); assertClusterSizeEventually(2, h1); assertClusterSizeEventually(2, h2); - Cache cacheTest = cacheManager2.getCache(CACHE_NAME); + Cache cacheTest = cacheManager2.getCache(CACHE_NAME); Object value = cacheTest.get(key); assertTrue("Value with key `" + key + "` should be there!", value != null); assertTrue("Value with key `" + key + "` should be Integer!", value instanceof Integer); @@ -78,4 +78,5 @@ public Object merge(String cacheName, CacheEntryView mergingEntry, CacheEntryVie return null; } } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/DeclarativeCacheSplitBrainSampleWithCustomCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/DeclarativeCacheSplitBrainSampleWithCustomCacheMergePolicy.java index bbbbb2841..cac585ac8 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/DeclarativeCacheSplitBrainSampleWithCustomCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/DeclarativeCacheSplitBrainSampleWithCustomCacheMergePolicy.java @@ -17,11 +17,12 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { + protected Cache getCache(String cacheName, CacheManager cacheManager) { return cacheManager.getCache(cacheName); } public static void main(String[] args) { new DeclarativeCacheSplitBrainSampleWithCustomCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/ProgrammaticCacheSplitBrainSampleWithCustomCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/ProgrammaticCacheSplitBrainSampleWithCustomCacheMergePolicy.java index c26f391b6..702b70d52 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/ProgrammaticCacheSplitBrainSampleWithCustomCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/custom/ProgrammaticCacheSplitBrainSampleWithCustomCacheMergePolicy.java @@ -18,12 +18,13 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { - CacheConfig cacheConfig = newCacheConfig(cacheName, CustomCacheMergePolicy.class.getName()); + protected Cache getCache(String cacheName, CacheManager cacheManager) { + CacheConfig cacheConfig = newCacheConfig(cacheName, CustomCacheMergePolicy.class.getName()); return cacheManager.createCache(cacheName, cacheConfig); } public static void main(String[] args) { new ProgrammaticCacheSplitBrainSampleWithCustomCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/CacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/CacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java index a94282de8..377e1aed8 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/CacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/CacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java @@ -26,7 +26,7 @@ abstract class CacheSplitBrainSampleWithHigherHitsCacheMergePolicy extends Abstr protected abstract Config getConfig(); - protected abstract Cache getCache(String cacheName, CacheManager cacheManager); + protected abstract Cache getCache(String cacheName, CacheManager cacheManager); protected void run() { try { @@ -43,8 +43,8 @@ protected void run() { CacheManager cacheManager1 = cachingProvider1.getCacheManager(); CacheManager cacheManager2 = cachingProvider2.getCacheManager(); - Cache cache1 = getCache(CACHE_NAME, cacheManager1); - Cache cache2 = getCache(CACHE_NAME, cacheManager2); + Cache cache1 = getCache(CACHE_NAME, cacheManager1); + Cache cache2 = getCache(CACHE_NAME, cacheManager2); // TODO We assume that until here and also while doing get/put, cluster is still splitted. // This assumptions seems fragile due to time sensitivity. @@ -67,11 +67,12 @@ protected void run() { assertClusterSizeEventually(2, h1); assertClusterSizeEventually(2, h2); - Cache cacheTest = cacheManager2.getCache(CACHE_NAME); + Cache cacheTest = cacheManager2.getCache(CACHE_NAME); assertEquals("higherHitsValue", cacheTest.get("key1")); assertEquals("higherHitsValue2", cacheTest.get("key2")); } finally { HazelcastInstanceFactory.shutdownAll(); } } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/DeclarativeCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/DeclarativeCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java index 3a6fc3e6c..8b30a0f94 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/DeclarativeCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/DeclarativeCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java @@ -17,11 +17,12 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { + protected Cache getCache(String cacheName, CacheManager cacheManager) { return cacheManager.getCache(cacheName); } public static void main(String[] args) { new DeclarativeCacheSplitBrainSampleWithHigherHitsCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/ProgrammaticCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/ProgrammaticCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java index 889231793..c82b2b71f 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/ProgrammaticCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/higherhits/ProgrammaticCacheSplitBrainSampleWithHigherHitsCacheMergePolicy.java @@ -19,12 +19,13 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { - CacheConfig cacheConfig = newCacheConfig(cacheName, HigherHitsCacheMergePolicy.class.getName()); + protected Cache getCache(String cacheName, CacheManager cacheManager) { + CacheConfig cacheConfig = newCacheConfig(cacheName, HigherHitsCacheMergePolicy.class.getName()); return cacheManager.createCache(cacheName, cacheConfig); } public static void main(String[] args) { new ProgrammaticCacheSplitBrainSampleWithHigherHitsCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/CacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/CacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java index b603dacb1..f596b5012 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/CacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/CacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java @@ -26,7 +26,7 @@ abstract class CacheSplitBrainSampleWithLatestAccessCacheMergePolicy extends Abs protected abstract Config getConfig(); - protected abstract Cache getCache(String cacheName, CacheManager cacheManager); + protected abstract Cache getCache(String cacheName, CacheManager cacheManager); protected void run() { try { @@ -43,8 +43,8 @@ protected void run() { CacheManager cacheManager1 = cachingProvider1.getCacheManager(); CacheManager cacheManager2 = cachingProvider2.getCacheManager(); - Cache cache1 = getCache(CACHE_NAME, cacheManager1); - Cache cache2 = getCache(CACHE_NAME, cacheManager2); + Cache cache1 = getCache(CACHE_NAME, cacheManager1); + Cache cache2 = getCache(CACHE_NAME, cacheManager2); // TODO We assume that until here and also while doing get/put, cluster is still splitted. // This assumptions seems fragile due to time sensitivity. @@ -71,11 +71,12 @@ protected void run() { assertClusterSizeEventually(2, h1); assertClusterSizeEventually(2, h2); - Cache cacheTest = cacheManager1.getCache(CACHE_NAME); + Cache cacheTest = cacheManager1.getCache(CACHE_NAME); assertEquals("LatestUpdatedValue", cacheTest.get("key1")); assertEquals("LatestUpdatedValue2", cacheTest.get("key2")); } finally { HazelcastInstanceFactory.shutdownAll(); } } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/DeclarativeCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/DeclarativeCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java index 40694ad92..9c379cc34 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/DeclarativeCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/DeclarativeCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java @@ -17,11 +17,12 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { + protected Cache getCache(String cacheName, CacheManager cacheManager) { return cacheManager.getCache(cacheName); } public static void main(String[] args) { new DeclarativeCacheSplitBrainSampleWithLatestAccessCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/ProgrammaticCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/ProgrammaticCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java index 2d91711a1..6dc6ac281 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/ProgrammaticCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/latestaccess/ProgrammaticCacheSplitBrainSampleWithLatestAccessCacheMergePolicy.java @@ -19,12 +19,13 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { - CacheConfig cacheConfig = newCacheConfig(cacheName, LatestAccessCacheMergePolicy.class.getName()); + protected Cache getCache(String cacheName, CacheManager cacheManager) { + CacheConfig cacheConfig = newCacheConfig(cacheName, LatestAccessCacheMergePolicy.class.getName()); return cacheManager.createCache(cacheName, cacheConfig); } public static void main(String[] args) { new ProgrammaticCacheSplitBrainSampleWithLatestAccessCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/CacheSplitBrainSampleWithPassThroughCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/CacheSplitBrainSampleWithPassThroughCacheMergePolicy.java index 883f2c8cb..6c44446c1 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/CacheSplitBrainSampleWithPassThroughCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/CacheSplitBrainSampleWithPassThroughCacheMergePolicy.java @@ -26,7 +26,7 @@ abstract class CacheSplitBrainSampleWithPassThroughCacheMergePolicy extends Abst protected abstract Config getConfig(); - protected abstract Cache getCache(String cacheName, CacheManager cacheManager); + protected abstract Cache getCache(String cacheName, CacheManager cacheManager); protected void run() { try { @@ -43,8 +43,8 @@ protected void run() { CacheManager cacheManager1 = cachingProvider1.getCacheManager(); CacheManager cacheManager2 = cachingProvider2.getCacheManager(); - Cache cache1 = getCache(CACHE_NAME, cacheManager1); - Cache cache2 = getCache(CACHE_NAME, cacheManager2); + Cache cache1 = getCache(CACHE_NAME, cacheManager1); + Cache cache2 = getCache(CACHE_NAME, cacheManager2); String key = generateKeyOwnedBy(h1); cache1.put(key, "value"); @@ -55,10 +55,11 @@ protected void run() { assertClusterSizeEventually(2, h1); assertClusterSizeEventually(2, h2); - Cache cacheTest = cacheManager2.getCache(CACHE_NAME); + Cache cacheTest = cacheManager2.getCache(CACHE_NAME); assertEquals("passThroughValue", cacheTest.get(key)); } finally { HazelcastInstanceFactory.shutdownAll(); } } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/DeclarativeCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/DeclarativeCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java index 9a11b9964..3b219f19c 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/DeclarativeCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/DeclarativeCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java @@ -17,11 +17,12 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { + protected Cache getCache(String cacheName, CacheManager cacheManager) { return cacheManager.getCache(cacheName); } public static void main(String[] args) { new DeclarativeCacheSplitBrainSampleWithPassThroughCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/ProgrammaticCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/ProgrammaticCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java index 7a1ea0651..0c27ed530 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/ProgrammaticCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/passthrough/ProgrammaticCacheSplitBrainSampleWithPassThroughCacheMergePolicy.java @@ -19,12 +19,13 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { - CacheConfig cacheConfig = newCacheConfig(cacheName, PassThroughCacheMergePolicy.class.getName()); + protected Cache getCache(String cacheName, CacheManager cacheManager) { + CacheConfig cacheConfig = newCacheConfig(cacheName, PassThroughCacheMergePolicy.class.getName()); return cacheManager.createCache(cacheName, cacheConfig); } public static void main(String[] args) { new ProgrammaticCacheSplitBrainSampleWithPassThroughCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/CacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/CacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java index cfc9ce363..cd38d3625 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/CacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/CacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java @@ -25,7 +25,7 @@ abstract class CacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy extends Abst protected abstract Config getConfig(); - protected abstract Cache getCache(String cacheName, CacheManager cacheManager); + protected abstract Cache getCache(String cacheName, CacheManager cacheManager); protected void run() { try { @@ -42,8 +42,8 @@ protected void run() { CacheManager cacheManager1 = cachingProvider1.getCacheManager(); CacheManager cacheManager2 = cachingProvider2.getCacheManager(); - Cache cache1 = getCache(CACHE_NAME, cacheManager1); - Cache cache2 = getCache(CACHE_NAME, cacheManager2); + Cache cache1 = getCache(CACHE_NAME, cacheManager1); + Cache cache2 = getCache(CACHE_NAME, cacheManager2); // TODO We assume that until here and also while doing get/put, cluster is still splitted. // This assumptions seems fragile due to time sensitivity. @@ -57,11 +57,12 @@ protected void run() { assertClusterSizeEventually(2, h1); assertClusterSizeEventually(2, h2); - Cache cacheTest = cacheManager2.getCache(CACHE_NAME); + Cache cacheTest = cacheManager2.getCache(CACHE_NAME); assertEquals("PutIfAbsentValue1", cacheTest.get("key1")); assertEquals("PutIfAbsentValue2", cacheTest.get("key2")); } finally { HazelcastInstanceFactory.shutdownAll(); } } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/DeclarativeCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/DeclarativeCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java index 705671e84..fb903fe35 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/DeclarativeCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/DeclarativeCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java @@ -17,11 +17,12 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { + protected Cache getCache(String cacheName, CacheManager cacheManager) { return cacheManager.getCache(cacheName); } public static void main(String[] args) { new DeclarativeCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/ProgrammaticCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java b/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/ProgrammaticCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java index e004854fd..c81244377 100644 --- a/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/ProgrammaticCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java +++ b/jcache/src/main/java/com/hazelcast/examples/splitbrain/putifabsent/ProgrammaticCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy.java @@ -19,12 +19,13 @@ protected Config getConfig() { } @Override - protected Cache getCache(String cacheName, CacheManager cacheManager) { - CacheConfig cacheConfig = newCacheConfig(cacheName, PutIfAbsentCacheMergePolicy.class.getName()); + protected Cache getCache(String cacheName, CacheManager cacheManager) { + CacheConfig cacheConfig = newCacheConfig(cacheName, PutIfAbsentCacheMergePolicy.class.getName()); return cacheManager.createCache(cacheName, cacheConfig); } public static void main(String[] args) { new ProgrammaticCacheSplitBrainSampleWithPutIfAbsentCacheMergePolicy().run(); } + } diff --git a/jcache/src/main/resources/hazelcast-client-c1.xml b/jcache/src/main/resources/hazelcast-client-c1.xml index e4ebd0b79..c7baea7f6 100644 --- a/jcache/src/main/resources/hazelcast-client-c1.xml +++ b/jcache/src/main/resources/hazelcast-client-c1.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - @@ -33,9 +33,7 @@ 1 - - com.hazelcast.examples.jcache.client.PortableDomainObjectExample$DomainObjectPortableFactory - + com.hazelcast.examples.jcache.client.PortableDomainObjectExample$DomainObjectPortableFactory diff --git a/jcache/src/main/resources/hazelcast-client-c2.xml b/jcache/src/main/resources/hazelcast-client-c2.xml index 406167fbc..5182d6d08 100644 --- a/jcache/src/main/resources/hazelcast-client-c2.xml +++ b/jcache/src/main/resources/hazelcast-client-c2.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - diff --git a/jcache/src/main/resources/hazelcast-client.xml b/jcache/src/main/resources/hazelcast-client.xml index a0d9e4b19..fc723ebf5 100644 --- a/jcache/src/main/resources/hazelcast-client.xml +++ b/jcache/src/main/resources/hazelcast-client.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - diff --git a/jcache/src/main/resources/hazelcast-declarative-eviction-test.xml b/jcache/src/main/resources/hazelcast-declarative-eviction-test.xml index e7099c204..42189e7a3 100644 --- a/jcache/src/main/resources/hazelcast-declarative-eviction-test.xml +++ b/jcache/src/main/resources/hazelcast-declarative-eviction-test.xml @@ -1,9 +1,10 @@ + - +
\ No newline at end of file diff --git a/jcache/src/main/resources/hazelcast-declarative-full.xml b/jcache/src/main/resources/hazelcast-declarative-full.xml index 71602a31c..2387f2f21 100644 --- a/jcache/src/main/resources/hazelcast-declarative-full.xml +++ b/jcache/src/main/resources/hazelcast-declarative-full.xml @@ -1,11 +1,12 @@ + - - + + true true true @@ -15,7 +16,7 @@ - + OBJECT @@ -23,4 +24,4 @@ 1 - + \ No newline at end of file diff --git a/jcache/src/main/resources/hazelcast-declarative-listener-test.xml b/jcache/src/main/resources/hazelcast-declarative-listener-test.xml index 564bf28c9..048458195 100644 --- a/jcache/src/main/resources/hazelcast-declarative-listener-test.xml +++ b/jcache/src/main/resources/hazelcast-declarative-listener-test.xml @@ -1,8 +1,9 @@ + @@ -10,4 +11,4 @@ - + \ No newline at end of file diff --git a/jcache/src/main/resources/hazelcast.xml b/jcache/src/main/resources/hazelcast.xml index 5f993a4b9..c478f6554 100644 --- a/jcache/src/main/resources/hazelcast.xml +++ b/jcache/src/main/resources/hazelcast.xml @@ -1,14 +1,12 @@ 1 - - com.hazelcast.examples.jcache.client.PortableDomainObjectExample$DomainObjectPortableFactory - + com.hazelcast.examples.jcache.client.PortableDomainObjectExample$DomainObjectPortableFactory - + \ No newline at end of file diff --git a/learning-basics/configure-logging/src/main/resources/hazelcast.xml b/learning-basics/configure-logging/src/main/resources/hazelcast.xml index 49f849580..c895767ab 100644 --- a/learning-basics/configure-logging/src/main/resources/hazelcast.xml +++ b/learning-basics/configure-logging/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -8,4 +8,4 @@ - + \ No newline at end of file diff --git a/learning-basics/configure-xml/src/main/resources/hazelcast-client-network-config.xml b/learning-basics/configure-xml/src/main/resources/hazelcast-client-network-config.xml index 74bef1e27..3fd199a7a 100644 --- a/learning-basics/configure-xml/src/main/resources/hazelcast-client-network-config.xml +++ b/learning-basics/configure-xml/src/main/resources/hazelcast-client-network-config.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - diff --git a/learning-basics/configure-xml/src/main/resources/hazelcast-client.xml b/learning-basics/configure-xml/src/main/resources/hazelcast-client.xml index 944646db4..318859d84 100644 --- a/learning-basics/configure-xml/src/main/resources/hazelcast-client.xml +++ b/learning-basics/configure-xml/src/main/resources/hazelcast-client.xml @@ -15,7 +15,7 @@ ~ limitations under the License. --> - diff --git a/learning-basics/configure-xml/src/main/resources/hazelcast-network-config.xml b/learning-basics/configure-xml/src/main/resources/hazelcast-network-config.xml index e16d28289..85d4f8e59 100644 --- a/learning-basics/configure-xml/src/main/resources/hazelcast-network-config.xml +++ b/learning-basics/configure-xml/src/main/resources/hazelcast-network-config.xml @@ -1,6 +1,6 @@ 7000 @@ -8,4 +8,4 @@ 127.0.0.1 - + \ No newline at end of file diff --git a/learning-basics/configure-xml/src/main/resources/hazelcast.xml b/learning-basics/configure-xml/src/main/resources/hazelcast.xml index b9268410c..78b9e27ec 100644 --- a/learning-basics/configure-xml/src/main/resources/hazelcast.xml +++ b/learning-basics/configure-xml/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -8,4 +8,4 @@ 1234 - + \ No newline at end of file diff --git a/learning-basics/destroying-instances/src/main/resources/hazelcast.xml b/learning-basics/destroying-instances/src/main/resources/hazelcast.xml index 62c49f81e..5bd16f0e2 100644 --- a/learning-basics/destroying-instances/src/main/resources/hazelcast.xml +++ b/learning-basics/destroying-instances/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -8,4 +8,4 @@ - + \ No newline at end of file diff --git a/learning-basics/loading-instances/src/main/resources/hazelcast.xml b/learning-basics/loading-instances/src/main/resources/hazelcast.xml index e7e05bc43..167782545 100644 --- a/learning-basics/loading-instances/src/main/resources/hazelcast.xml +++ b/learning-basics/loading-instances/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/learning-basics/wildcard-configuration/src/main/resources/hazelcast.xml b/learning-basics/wildcard-configuration/src/main/resources/hazelcast.xml index c2d478d00..0502fe11c 100644 --- a/learning-basics/wildcard-configuration/src/main/resources/hazelcast.xml +++ b/learning-basics/wildcard-configuration/src/main/resources/hazelcast.xml @@ -1,10 +1,10 @@ 10 - + \ No newline at end of file diff --git a/monitoring/cluster/pom.xml b/monitoring/cluster/pom.xml index 539674750..07102dcd3 100644 --- a/monitoring/cluster/pom.xml +++ b/monitoring/cluster/pom.xml @@ -4,8 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - monitoring-cluster + cluster Monitoring - Cluster/Member Safety Examples + com.hazelcast.samples.monitoring 0.1-SNAPSHOT @@ -20,4 +21,4 @@
- + \ No newline at end of file diff --git a/network-configuration/aws/src/main/resources/hazelcast.xml b/network-configuration/aws/src/main/resources/hazelcast.xml index 20b68bc24..fbf0895d8 100644 --- a/network-configuration/aws/src/main/resources/hazelcast.xml +++ b/network-configuration/aws/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -14,5 +14,4 @@ - -i \ No newline at end of file + \ No newline at end of file diff --git a/network-configuration/firewall/src/main/resources/hazelcast.xml b/network-configuration/firewall/src/main/resources/hazelcast.xml index 0ad7b191e..fd07d92b9 100644 --- a/network-configuration/firewall/src/main/resources/hazelcast.xml +++ b/network-configuration/firewall/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -10,4 +10,4 @@ - + \ No newline at end of file diff --git a/network-configuration/groups/group1/src/main/resources/hazelcast.xml b/network-configuration/groups/group1/src/main/resources/hazelcast.xml index 748f1693c..7494b9299 100644 --- a/network-configuration/groups/group1/src/main/resources/hazelcast.xml +++ b/network-configuration/groups/group1/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ group1 @@ -11,4 +11,4 @@ - + \ No newline at end of file diff --git a/network-configuration/groups/group2/src/main/resources/hazelcast.xml b/network-configuration/groups/group2/src/main/resources/hazelcast.xml index 369f8f2c4..4116a5a27 100644 --- a/network-configuration/groups/group2/src/main/resources/hazelcast.xml +++ b/network-configuration/groups/group2/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ group2 @@ -11,4 +11,4 @@ - + \ No newline at end of file diff --git a/network-configuration/jclouds/README.md b/network-configuration/jclouds/README.md index e18e64c04..3ad710b53 100644 --- a/network-configuration/jclouds/README.md +++ b/network-configuration/jclouds/README.md @@ -1,19 +1,19 @@ -

About

+

ABOUT

A simple example of hazelcast-jclouds module.

Requirements

-You should include dependencies for providers served under jclouds lab. This example only works for AWS EC2, Google Compute Engine - and other providers, served under jclouds-all-compute. See list of providers here: https://jclouds.apache.org/reference/providers/#compute +You should include dependencies for providers served under jclouds lab. This example only works for google-compute engine and providers, + served under jclouds-all-compute. See list of providers here : https://jclouds.apache.org/reference/providers/#compute

Build

-* `git clone https://github.com/hazelcast/hazelcast-code-samples.git` - Clone the repository +* `git clone https://github.com/hazelcast/hazelcast-code-samples.git` - Clone repo into the local * `cd hazelcast-code-samples/network-configuration/jclouds` -* `mvn install` - Create the JAR `target/jclouds-0.1-SNAPSHOT-jar-with-dependencies.jar` with jclouds dependencies +* `mvn install` - Create an uber jar with jclouds dependencies, it is jclouds-0.1-SNAPSHOT-jar-with-dependencies.jar under target folder.

Configuration

-You should configure `hazelcast.xml` in the folder `resources` accordingly to your cloud provider. -You can find latest configuration options here: http://docs.hazelcast.org/docs/latest-dev/manual/html-single/index.html#discovering-members-with-jclouds +You should configure `hazelcast.xml` under `resources` according to your cloud provider. +You can find latest configuration options here : http://docs.hazelcast.org/docs/latest-dev/manual/html-single/index.html#discovering-members-with-jclouds

Deployment

-Deploy `jclouds-0.1-SNAPSHOT-jar-with-dependencies.jar` to your cloud machines.
-Run `java -cp jclouds-0.1-SNAPSHOT-jar-with-dependencies.jar StartServer` on your deployed machines.
+Deploy `jclouds-0.1-SNAPSHOT-jar-with-dependencies.jar` to your cloud machines
+Run `java -cp jclouds-0.1-SNAPSHOT-jar-with-dependencies.jar StartServer` on machines you deployed
diff --git a/network-configuration/jclouds/src/main/java/Member.java b/network-configuration/jclouds/src/main/java/Member.java index 923a75df9..88ea44872 100644 --- a/network-configuration/jclouds/src/main/java/Member.java +++ b/network-configuration/jclouds/src/main/java/Member.java @@ -1,7 +1,6 @@ import com.hazelcast.core.Hazelcast; public class Member { - public static void main(String[] args) { Hazelcast.newHazelcastInstance(); } diff --git a/network-configuration/jclouds/src/main/resources/hazelcast.xml b/network-configuration/jclouds/src/main/resources/hazelcast.xml index c3b0da9e6..1a62f203d 100644 --- a/network-configuration/jclouds/src/main/resources/hazelcast.xml +++ b/network-configuration/jclouds/src/main/resources/hazelcast.xml @@ -26,7 +26,7 @@ - + @@ -40,4 +40,5 @@ + diff --git a/network-configuration/multicast/src/main/resources/hazelcast.xml b/network-configuration/multicast/src/main/resources/hazelcast.xml index 4964c3557..f55604609 100644 --- a/network-configuration/multicast/src/main/resources/hazelcast.xml +++ b/network-configuration/multicast/src/main/resources/hazelcast.xml @@ -1,10 +1,10 @@ - + \ No newline at end of file diff --git a/network-configuration/partitiongroup/src/main/resources/hazelcast.xml b/network-configuration/partitiongroup/src/main/resources/hazelcast.xml index a4ea43da2..d7e01d5d2 100644 --- a/network-configuration/partitiongroup/src/main/resources/hazelcast.xml +++ b/network-configuration/partitiongroup/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -9,5 +9,6 @@ + - + \ No newline at end of file diff --git a/network-configuration/port/src/main/resources/hazelcast.xml b/network-configuration/port/src/main/resources/hazelcast.xml index 0d519a918..f0061d1ec 100644 --- a/network-configuration/port/src/main/resources/hazelcast.xml +++ b/network-configuration/port/src/main/resources/hazelcast.xml @@ -1,8 +1,8 @@ 5701 - + \ No newline at end of file diff --git a/network-configuration/ssl/src/main/resources/hazelcast.xml b/network-configuration/ssl/src/main/resources/hazelcast.xml index a6c55fb0e..629955bec 100644 --- a/network-configuration/ssl/src/main/resources/hazelcast.xml +++ b/network-configuration/ssl/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -14,4 +14,4 @@ - + \ No newline at end of file diff --git a/network-configuration/symmetric-encryption/src/main/resources/hazelcast.xml b/network-configuration/symmetric-encryption/src/main/resources/hazelcast.xml index c2e8b9cb5..8992ba497 100644 --- a/network-configuration/symmetric-encryption/src/main/resources/hazelcast.xml +++ b/network-configuration/symmetric-encryption/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ 19 - + \ No newline at end of file diff --git a/network-configuration/tcpip/src/main/resources/hazelcast.xml b/network-configuration/tcpip/src/main/resources/hazelcast.xml index 3ed4fe716..d38944f69 100644 --- a/network-configuration/tcpip/src/main/resources/hazelcast.xml +++ b/network-configuration/tcpip/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -9,4 +9,4 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 0bd7b954a..e78a897bb 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ UTF-8 - 3.6-SNAPSHOT + 3.6-RC2-SNAPSHOT @@ -52,7 +52,6 @@ jcache jmx osgi - cluster diff --git a/replicated-map/in-memory-format/src/main/resources/hazelcast.xml b/replicated-map/in-memory-format/src/main/resources/hazelcast.xml index b82357016..7c5b80152 100644 --- a/replicated-map/in-memory-format/src/main/resources/hazelcast.xml +++ b/replicated-map/in-memory-format/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -15,4 +15,6 @@ OBJECT - + + + \ No newline at end of file diff --git a/serialization/bytearray-serializer/src/main/resources/hazelcast.xml b/serialization/bytearray-serializer/src/main/resources/hazelcast.xml index a721a503f..9b4f7b5ed 100644 --- a/serialization/bytearray-serializer/src/main/resources/hazelcast.xml +++ b/serialization/bytearray-serializer/src/main/resources/hazelcast.xml @@ -1,11 +1,11 @@ - + PersonByteArraySerializer - + \ No newline at end of file diff --git a/serialization/global-serializer/src/main/resources/hazelcast.xml b/serialization/global-serializer/src/main/resources/hazelcast.xml index 8d2d7114d..0ade4eea8 100644 --- a/serialization/global-serializer/src/main/resources/hazelcast.xml +++ b/serialization/global-serializer/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -8,4 +8,4 @@ PersonStreamSerializer - + \ No newline at end of file diff --git a/serialization/identified-data-serializable/src/main/resources/hazelcast.xml b/serialization/identified-data-serializable/src/main/resources/hazelcast.xml index 3f39f8a3f..e97f309dd 100644 --- a/serialization/identified-data-serializable/src/main/resources/hazelcast.xml +++ b/serialization/identified-data-serializable/src/main/resources/hazelcast.xml @@ -1,11 +1,12 @@ PersonDataSerializableFactory + - + \ No newline at end of file diff --git a/serialization/kryo-serializer/src/main/resources/hazelcast.xml b/serialization/kryo-serializer/src/main/resources/hazelcast.xml index bc19a5c6e..e8e57c18f 100644 --- a/serialization/kryo-serializer/src/main/resources/hazelcast.xml +++ b/serialization/kryo-serializer/src/main/resources/hazelcast.xml @@ -1,11 +1,11 @@ - + PersonKryoSerializer - + \ No newline at end of file diff --git a/serialization/portable/src/main/resources/hazelcast.xml b/serialization/portable/src/main/resources/hazelcast.xml index 16d31917c..0204f6b1e 100644 --- a/serialization/portable/src/main/resources/hazelcast.xml +++ b/serialization/portable/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -9,4 +9,4 @@ PortableFactoryImpl - + \ No newline at end of file diff --git a/serialization/stream-serializer/src/main/resources/hazelcast.xml b/serialization/stream-serializer/src/main/resources/hazelcast.xml index 2e5d52d51..6f39f7e2c 100644 --- a/serialization/stream-serializer/src/main/resources/hazelcast.xml +++ b/serialization/stream-serializer/src/main/resources/hazelcast.xml @@ -1,15 +1,15 @@ - - - - - + PersonStreamSerializer + CarStreamSerializer + LinkedListStreamSerializer + HashMapStreamSerializer + ExtendedArrayListSerializer - + \ No newline at end of file diff --git a/spi/backups/src/main/resources/hazelcast.xml b/spi/backups/src/main/resources/hazelcast.xml index bbf08684e..fc1cffe2d 100644 --- a/spi/backups/src/main/resources/hazelcast.xml +++ b/spi/backups/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ diff --git a/spi/container/src/main/resources/hazelcast.xml b/spi/container/src/main/resources/hazelcast.xml index 6851b5a30..fc1cffe2d 100644 --- a/spi/container/src/main/resources/hazelcast.xml +++ b/spi/container/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ CounterService - + \ No newline at end of file diff --git a/spi/discovery/pom.xml b/spi/discovery/pom.xml index 9f86bad9b..fd7965eee 100644 --- a/spi/discovery/pom.xml +++ b/spi/discovery/pom.xml @@ -1,18 +1,19 @@ - 4.0.0 - jar + 4.0.0 + pom - discovery-spi - Discovery SPI - - Sample code for implementing discovery providers - + com.hazelcast.samples.spi + discovery-spi + Discovery SPI + + Sample code for implementing discovery providers + - - com.hazelcast.samples.spi - spi - 0.1-SNAPSHOT - ../pom.xml - + + com.hazelcast.samples.spi + spi + 0.1-SNAPSHOT + ../pom.xml + diff --git a/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryConfiguration.java b/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryConfiguration.java index 5047c714a..9dfff3a50 100644 --- a/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryConfiguration.java +++ b/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryConfiguration.java @@ -29,7 +29,8 @@ public class HostsDiscoveryConfiguration { */ public static final PropertyDefinition DOMAIN = new SimplePropertyDefinition("site-domain", PropertyTypeConverter.STRING); - // prevent instantiation + // Prevent instantiation private HostsDiscoveryConfiguration() { } + } diff --git a/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategy.java b/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategy.java index cd405a9ff..42ddb566a 100644 --- a/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategy.java +++ b/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategy.java @@ -38,7 +38,8 @@ /** * THIS CODE IS NOT PRODUCTION READY! */ -public class HostsDiscoveryStrategy extends AbstractDiscoveryStrategy { +public class HostsDiscoveryStrategy + extends AbstractDiscoveryStrategy { private static final String HOSTS_NIX = "/etc/hosts"; private static final String HOSTS_WINDOWS = "%SystemRoot%\\system32\\drivers\\etc\\hosts"; @@ -48,7 +49,7 @@ public class HostsDiscoveryStrategy extends AbstractDiscoveryStrategy { HostsDiscoveryStrategy(ILogger logger, Map properties) { super(logger, properties); - // make it possible to override the value from the configuration on + // Make it possible to override the value from the configuration on // the system's environment or JVM properties -Ddiscovery.hosts.site-domain=some.domain this.siteDomain = getOrNull("discovery.hosts", HostsDiscoveryConfiguration.DOMAIN); } @@ -71,15 +72,12 @@ private List filterHosts() { File hosts = new File(hostsPath); - // read all lines + // Read all lines List lines = readLines(hosts); List assignments = new ArrayList(); for (String line : lines) { - if (line.isEmpty()) { - continue; - } - // example: + // Example: // 192.168.0.1 host1.cluster.local if (matchesDomain(line)) { assignments.add(line); @@ -152,4 +150,5 @@ private InetAddress mapToInetAddress(String address) { throw new RuntimeException("Could not resolve ip address", e); } } + } diff --git a/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategyFactory.java b/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategyFactory.java index 7a9637cf7..b313716d1 100644 --- a/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategyFactory.java +++ b/spi/discovery/src/main/java/com/hazelcast/examples/spi/discovery/HostsDiscoveryStrategyFactory.java @@ -23,13 +23,14 @@ import com.hazelcast.spi.discovery.DiscoveryStrategyFactory; import java.util.Collection; +import java.util.Collections; import java.util.Map; -import static java.util.Collections.singletonList; +public class HostsDiscoveryStrategyFactory + implements DiscoveryStrategyFactory { -public class HostsDiscoveryStrategyFactory implements DiscoveryStrategyFactory { - - private static final Collection PROPERTIES = singletonList(HostsDiscoveryConfiguration.DOMAIN); + private static final Collection PROPERTIES = Collections + .singletonList(HostsDiscoveryConfiguration.DOMAIN); @Override public Class getDiscoveryStrategyType() { @@ -39,6 +40,7 @@ public Class getDiscoveryStrategyType() { @Override public DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger, Map properties) { + return new HostsDiscoveryStrategy(logger, properties); } diff --git a/spi/discovery/src/main/resources/META-INF/services/com.hazelcast.spi.discovery.DiscoveryStrategyFactory b/spi/discovery/src/main/resources/META-INF/services/com.hazelcast.spi.discovery.DiscoveryStrategyFactory index adcd83e12..e6b90b294 100644 --- a/spi/discovery/src/main/resources/META-INF/services/com.hazelcast.spi.discovery.DiscoveryStrategyFactory +++ b/spi/discovery/src/main/resources/META-INF/services/com.hazelcast.spi.discovery.DiscoveryStrategyFactory @@ -1 +1 @@ -com.hazelcast.examples.spi.discovery.HostsDiscoveryStrategyFactory +com.hazelcast.examples.spi.discovery.HostsDiscoveryStrategyFactory \ No newline at end of file diff --git a/spi/discovery/src/main/resources/hazelcast.xml b/spi/discovery/src/main/resources/hazelcast.xml index 3a27b7e75..c78303172 100644 --- a/spi/discovery/src/main/resources/hazelcast.xml +++ b/spi/discovery/src/main/resources/hazelcast.xml @@ -19,28 +19,30 @@ xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - - - true - + + + true + - - - - - - + + + + + + - - - - - - cluster.local - - - - - - + + + + + + + + cluster.local + + + + + + \ No newline at end of file diff --git a/spi/discovery/start.sh b/spi/discovery/start.sh index aab1a265b..0e274015c 100755 --- a/spi/discovery/start.sh +++ b/spi/discovery/start.sh @@ -1,3 +1,3 @@ #!/bin/sh -java -cp target/lib/*:target/classes Test +java -cp target/lib/*:target/classes Test \ No newline at end of file diff --git a/spi/getting-started/src/main/resources/hazelcast.xml b/spi/getting-started/src/main/resources/hazelcast.xml index 6851b5a30..fc1cffe2d 100644 --- a/spi/getting-started/src/main/resources/hazelcast.xml +++ b/spi/getting-started/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ CounterService - + \ No newline at end of file diff --git a/spi/notification/src/main/resources/hazelcast.xml b/spi/notification/src/main/resources/hazelcast.xml index 6851b5a30..fc1cffe2d 100644 --- a/spi/notification/src/main/resources/hazelcast.xml +++ b/spi/notification/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ CounterService - + \ No newline at end of file diff --git a/spi/partition-migration/src/main/resources/hazelcast.xml b/spi/partition-migration/src/main/resources/hazelcast.xml index 6851b5a30..fc1cffe2d 100644 --- a/spi/partition-migration/src/main/resources/hazelcast.xml +++ b/spi/partition-migration/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -13,4 +13,4 @@ CounterService - + \ No newline at end of file diff --git a/spi/proxy/src/main/resources/hazelcast.xml b/spi/proxy/src/main/resources/hazelcast.xml index a479ccdcb..bb20c24cd 100644 --- a/spi/proxy/src/main/resources/hazelcast.xml +++ b/spi/proxy/src/main/resources/hazelcast.xml @@ -1,6 +1,6 @@ @@ -14,4 +14,4 @@ CounterService - + \ No newline at end of file