Skip to content

Commit 97d0c71

Browse files
pkhanalnguyenminhtuanfit
authored andcommitted
Code cleanup
Signed-off-by: nguyenminhtuanfit@gmail.com <nguyenminhtuanfit@gmail.com>
1 parent 877706d commit 97d0c71

3 files changed

Lines changed: 7 additions & 55 deletions

File tree

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
package com.baeldung.hazelcast.cluster;
22

3-
import org.slf4j.Logger;
4-
import org.slf4j.LoggerFactory;
3+
import java.util.Map.Entry;
54

6-
import com.baeldung.hazelcast.listener.CountryEntryListener;
75
import com.hazelcast.client.HazelcastClient;
86
import com.hazelcast.client.config.ClientConfig;
97
import com.hazelcast.config.GroupConfig;
108
import com.hazelcast.core.HazelcastInstance;
119
import com.hazelcast.core.IMap;
1210

1311
public class NativeClient {
14-
private static final Logger logger = LoggerFactory.getLogger(NativeClient.class);
1512

1613
public static void main(String[] args) throws InterruptedException {
1714
ClientConfig config = new ClientConfig();
1815
GroupConfig groupConfig = config.getGroupConfig();
1916
groupConfig.setName("dev");
2017
groupConfig.setPassword("dev-pass");
2118
HazelcastInstance hazelcastInstanceClient = HazelcastClient.newHazelcastClient(config);
22-
IMap<Long, String> countryMap = hazelcastInstanceClient.getMap("country");
23-
countryMap.addEntryListener(new CountryEntryListener(), true);
24-
logger.info("Country map size: " + countryMap.size());
19+
IMap<Long, String> map = hazelcastInstanceClient.getMap("data");
20+
for (Entry<Long, String> entry : map.entrySet()) {
21+
System.out.println(String.format("Key: %d, Value: %s", entry.getKey(), entry.getValue()));
22+
}
2523
}
2624
}

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,18 @@
22

33
import java.util.Map;
44

5-
import org.slf4j.Logger;
6-
import org.slf4j.LoggerFactory;
7-
85
import com.hazelcast.core.Hazelcast;
96
import com.hazelcast.core.HazelcastInstance;
107
import com.hazelcast.core.IdGenerator;
118

129
public class ServerNode {
13-
private static final Logger logger = LoggerFactory.getLogger(ServerNode.class);
1410

1511
public static void main(String[] args) {
1612
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance();
17-
Map<Long, String> countryMap = hazelcastInstance.getMap("country");
13+
Map<Long, String> map = hazelcastInstance.getMap("data");
1814
IdGenerator idGenerator = hazelcastInstance.getIdGenerator("newid");
1915
for (int i = 0; i < 10; i++) {
20-
countryMap.put(idGenerator.newId(), "message" + 1);
16+
map.put(idGenerator.newId(), "message" + 1);
2117
}
22-
logger.info("Country map size: " + countryMap.size());
2318
}
2419
}

hazelcast/src/main/java/com/baeldung/hazelcast/listener/CountryEntryListener.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)