Skip to content

Commit 877706d

Browse files
added hazelcast client, removed id generator
1 parent 897e245 commit 877706d

2 files changed

Lines changed: 71 additions & 65 deletions

File tree

hazelcast/pom.xml

Lines changed: 68 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,77 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<groupId>com.baeldung</groupId>
5-
<artifactId>hazelcast</artifactId>
6-
<version>0.0.1-SNAPSHOT</version>
7-
<name>hazelcast</name>
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.baeldung</groupId>
5+
<artifactId>hazelcast</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<name>hazelcast</name>
88

9-
<dependencies>
10-
<!-- hazelcast -->
11-
<dependency>
12-
<groupId>com.hazelcast</groupId>
13-
<artifactId>hazelcast-all</artifactId>
14-
<version>${hazelcast.version}</version>
15-
</dependency>
16-
17-
<!-- utils -->
18-
<dependency>
19-
<groupId>org.slf4j</groupId>
20-
<artifactId>slf4j-api</artifactId>
21-
<version>${org.slf4j.version}</version>
22-
</dependency>
23-
24-
<dependency>
25-
<groupId>ch.qos.logback</groupId>
26-
<artifactId>logback-classic</artifactId>
27-
<version>${logback.version}</version>
28-
</dependency>
29-
30-
<dependency>
31-
<groupId>ch.qos.logback</groupId>
32-
<artifactId>logback-core</artifactId>
33-
<version>${logback.version}</version>
34-
</dependency>
9+
<dependencies>
10+
<dependency>
11+
<groupId>com.hazelcast</groupId>
12+
<artifactId>hazelcast</artifactId>
13+
<version>${hazelcast.version}</version>
14+
</dependency>
15+
16+
<dependency>
17+
<groupId>com.hazelcast</groupId>
18+
<artifactId>hazelcast-client</artifactId>
19+
<version>3.7.2</version>
20+
</dependency>
21+
22+
<!-- utils -->
23+
<dependency>
24+
<groupId>org.slf4j</groupId>
25+
<artifactId>slf4j-api</artifactId>
26+
<version>${org.slf4j.version}</version>
27+
</dependency>
28+
29+
<dependency>
30+
<groupId>ch.qos.logback</groupId>
31+
<artifactId>logback-classic</artifactId>
32+
<version>${logback.version}</version>
33+
</dependency>
34+
35+
<dependency>
36+
<groupId>ch.qos.logback</groupId>
37+
<artifactId>logback-core</artifactId>
38+
<version>${logback.version}</version>
39+
</dependency>
3540

36-
</dependencies>
41+
</dependencies>
3742

38-
<build>
39-
<finalName>hazelcast</finalName>
40-
<resources>
41-
<resource>
42-
<directory>src/main/resources</directory>
43-
<filtering>true</filtering>
44-
</resource>
45-
</resources>
43+
<build>
44+
<finalName>hazelcast</finalName>
45+
<resources>
46+
<resource>
47+
<directory>src/main/resources</directory>
48+
<filtering>true</filtering>
49+
</resource>
50+
</resources>
4651

47-
<plugins>
48-
<plugin>
49-
<groupId>org.apache.maven.plugins</groupId>
50-
<artifactId>maven-compiler-plugin</artifactId>
51-
<version>${maven-compiler-plugin.version}</version>
52-
<configuration>
53-
<source>1.8</source>
54-
<target>1.8</target>
55-
</configuration>
56-
</plugin>
57-
</plugins>
58-
</build>
52+
<plugins>
53+
<plugin>
54+
<groupId>org.apache.maven.plugins</groupId>
55+
<artifactId>maven-compiler-plugin</artifactId>
56+
<version>${maven-compiler-plugin.version}</version>
57+
<configuration>
58+
<source>1.8</source>
59+
<target>1.8</target>
60+
</configuration>
61+
</plugin>
62+
</plugins>
63+
</build>
5964

60-
<properties>
61-
<!-- hazelcast -->
62-
<hazelcast.version>3.7</hazelcast.version>
63-
64-
<!-- logging -->
65-
<org.slf4j.version>1.7.21</org.slf4j.version>
66-
<logback.version>1.1.7</logback.version>
65+
<properties>
66+
<!-- hazelcast -->
67+
<hazelcast.version>3.7.2</hazelcast.version>
68+
69+
<!-- logging -->
70+
<org.slf4j.version>1.7.21</org.slf4j.version>
71+
<logback.version>1.1.7</logback.version>
6772

68-
<!-- maven plugins -->
69-
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
70-
</properties>
73+
<!-- maven plugins -->
74+
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
75+
</properties>
7176

7277
</project>

hazelcast/src/main/java/com/baeldung/hazelcast/cluster/ServerNode.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public static void main(String[] args) {
1616
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
1717
Map<Long, String> countryMap = hazelcastInstance.getMap("country");
1818
IdGenerator idGenerator = hazelcastInstance.getIdGenerator("newid");
19-
Long countryIdGenerator = idGenerator.newId() == 0L ? 1L : idGenerator.newId();
20-
countryMap.put(countryIdGenerator, "Country1");
19+
for (int i = 0; i < 10; i++) {
20+
countryMap.put(idGenerator.newId(), "message" + 1);
21+
}
2122
logger.info("Country map size: " + countryMap.size());
2223
}
2324
}

0 commit comments

Comments
 (0)