本文整理了Java中com.hazelcast.core.MultiMap
类的一些代码示例,展示了MultiMap
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiMap
类的具体详情如下:
包路径:com.hazelcast.core.MultiMap
类名称:MultiMap
[英]A specialized map whose keys can be associated with multiple values.
Gotchas:
Supports Quorum com.hazelcast.config.QuorumConfig since 3.10 in cluster versions 3.10 and higher.
[中]一种特殊的映射,其键可以与多个值相关联。
哥查斯:
*方法——包括但不限于get、containsKey、containsValue、remove、put、lock和unlock——不使用哈希代码和密钥的equals实现。相反,它们使用哈希代码和对象的二进制(序列化)形式的相等值。
*方法(包括但不限于get、remove、keySet、values和entrySet)返回值的集合克隆。集合不受映射的支持,因此对映射的更改不会反映在集合中,反之亦然。
支持仲裁com。黑兹卡斯特。配置。QuorumConfig自3.10版起在群集版本3.10及更高版本中使用。
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
// Start the Embedded Hazelcast Cluster Member.
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
// Get the Distributed MultiMap from Cluster.
MultiMap<String, String> multiMap = hz.getMultiMap("my-distributed-multimap");
// Put values in the map against the same key
multiMap.put("my-key", "value1");
multiMap.put("my-key", "value2");
multiMap.put("my-key", "value3");
// Print out all the values for associated with key called "my-key"
Collection<String> values = multiMap.get("my-key");
System.out.println(values);
// remove specific key/value pair
multiMap.remove("my-key", "value2");
// Shutdown the Hazelcast Cluster Member
hz.shutdown();
}
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
public static void main(String[] args) {
HazelcastInstance hz = Hazelcast.newHazelcastInstance();
MultiMap<String, String> map = hz.getMultiMap("map");
for (String key : map.keySet()) {
Collection<String> values = map.get(key);
System.out.printf("%s -> %s\n", key, values);
}
}
}
代码示例来源:origin: FlavioF/quartz-scheduler-hazelcast-jobstore
@Override
public void clearAllSchedulingData()
throws JobPersistenceException {
jobsByKey.clear();
triggersByKey.clear();
jobsByGroup.clear();
triggersByGroup.clear();
calendarsByName.clear();
pausedTriggerGroups.clear();
pausedJobGroups.clear();
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
private static void executeMultiMap() {
System.out.println("### MultiMap Execution Started... ###");
int key = RANDOM.nextInt(100);
int value = RANDOM.nextInt(100);
MultiMap<Integer, Integer> multimap = (MultiMap<Integer, Integer>) context.getBean("multiMap", MultiMap.class);
multimap.put(key, value);
System.out.println("A random pair is added to multiMap.");
System.out.println("Added value: " + multimap.get(key) + "\n");
}
代码示例来源:origin: spring-projects/spring-integration-extensions
private boolean isEventComingFromNonRegisteredHazelcastInstance(
final HazelcastInstance hazelcastInstance,
final Set<SocketAddress> localSocketAddressesSet,
final InetSocketAddress socketAddressOfEvent) {
final MultiMap<SocketAddress, SocketAddress> configMultiMap = hazelcastInstance
.getMultiMap(HazelcastLocalInstanceRegistrar.SPRING_INTEGRATION_INTERNAL_CLUSTER_MULTIMAP);
return configMultiMap.size() > 0
&& !configMultiMap.values().contains(socketAddressOfEvent)
&& localSocketAddressesSet.contains(configMultiMap.keySet().iterator().next());
}
代码示例来源:origin: hazelcast/hazelcast-jet
protected void handleSize(String[] args) {
int size = 0;
String iteratorStr = args[0];
if (iteratorStr.startsWith("s.")) {
size = getSet().size();
} else if (iteratorStr.startsWith("m.")) {
size = getMap().size();
} else if (iteratorStr.startsWith("mm.")) {
size = getMultiMap().size();
} else if (iteratorStr.startsWith("q.")) {
size = getQueue().size();
} else if (iteratorStr.startsWith("l.")) {
size = getList().size();
}
println("Size = " + size);
}
代码示例来源:origin: hazelcast/hazelcast-jet
protected void handleContains(String[] args) {
String iteratorStr = args[0];
boolean key = lowerCaseInternal(iteratorStr).endsWith("key");
String data = args[1];
boolean result = false;
if (iteratorStr.startsWith("s.")) {
result = getSet().contains(data);
} else if (iteratorStr.startsWith("m.")) {
result = (key) ? getMap().containsKey(data) : getMap().containsValue(data);
} else if (iteratorStr.startsWith("mmm.")) {
result = (key) ? getMultiMap().containsKey(data) : getMultiMap().containsValue(data);
} else if (iteratorStr.startsWith("q.")) {
result = getQueue().contains(data);
} else if (iteratorStr.startsWith("l.")) {
result = getList().contains(data);
}
println("Contains: " + result);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
protected void handleClear(String[] args) {
String iteratorStr = args[0];
if (iteratorStr.startsWith("s.")) {
getSet().clear();
} else if (iteratorStr.startsWith("m.")) {
getMap().clear();
} else if (iteratorStr.startsWith("mm.")) {
getMultiMap().clear();
} else if (iteratorStr.startsWith("q.")) {
getQueue().clear();
} else if (iteratorStr.startsWith("l.")) {
getList().clear();
}
println("Cleared all.");
}
代码示例来源:origin: com.hazelcast/hazelcast-all
protected void handleAddListener(String[] args) {
String first = args[0];
if (first.startsWith("s.")) {
getSet().addItemListener(this, true);
} else if (first.startsWith("m.")) {
if (args.length > 1) {
getMap().addEntryListener(this, args[1], true);
} else {
getMap().addEntryListener(this, true);
}
} else if (first.startsWith("mm.")) {
if (args.length > 1) {
getMultiMap().addEntryListener(this, args[1], true);
} else {
getMultiMap().addEntryListener(this, true);
}
} else if (first.startsWith("q.")) {
getQueue().addItemListener(this, true);
} else if (first.startsWith("t.")) {
getTopic().addMessageListener(this);
} else if (first.startsWith("l.")) {
getList().addItemListener(this, true);
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
it = getSet().iterator();
} else if (iteratorStr.startsWith("m.")) {
it = getMap().keySet().iterator();
} else if (iteratorStr.startsWith("mm.")) {
it = getMultiMap().keySet().iterator();
} else if (iteratorStr.startsWith("q.")) {
it = getQueue().iterator();
} else if (iteratorStr.startsWith("l.")) {
it = getList().iterator();
代码示例来源:origin: hazelcast/hazelcast-code-samples
public void run() {
map.put(key, new byte[valueSize]);
}
});
代码示例来源:origin: spring-projects/spring-integration-extensions
.getMultiMap(HazelcastLocalInstanceRegistrar.SPRING_INTEGRATION_INTERNAL_CLUSTER_MULTIMAP);
if (configMultiMap.containsKey(removedMemberSocketAddress)) {
SocketAddress newAdminSocketAddress = getNewAdminInstanceSocketAddress(
configMultiMap, removedMemberSocketAddress);
for (SocketAddress socketAddress : configMultiMap.values()) {
if (!socketAddress.equals(removedMemberSocketAddress)) {
configMultiMap.put(newAdminSocketAddress, socketAddress);
configMultiMap.remove(removedMemberSocketAddress);
configMultiMap.remove(configMultiMap.keySet().iterator().next(), removedMemberSocketAddress);
代码示例来源:origin: org.vert-x/vertx-core
public Collection<HazelcastServerID> action() throws Exception {
return map.get(subName);
}
}.run();
代码示例来源:origin: org.apache.camel/camel-hazelcast
private void delete(Object oid) {
this.cache.remove(oid);
}
代码示例来源:origin: spring-projects/spring-integration-extensions
public static void testEventDrivenForMultiMapEntryEvents(
final MultiMap<Integer, HazelcastIntegrationTestUser> multiMap,
final PollableChannel channel, final String cacheName) {
multiMap.put(1, new HazelcastIntegrationTestUser(1, "TestName1", "TestSurname1"));
Message<?> msg = channel.receive(TIMEOUT);
verifyEntryEvent(msg, cacheName, EntryEventType.ADDED);
multiMap.put(1,
new HazelcastIntegrationTestUser(1, "TestName1", "TestSurnameUpdated"));
msg = channel.receive(TIMEOUT);
verifyEntryEvent(msg, cacheName, EntryEventType.ADDED);
multiMap.remove(1);
msg = channel.receive(TIMEOUT);
verifyEntryEvent(msg, cacheName, EntryEventType.REMOVED);
msg = channel.receive(TIMEOUT);
verifyEntryEvent(msg, cacheName, EntryEventType.REMOVED);
multiMap.put(2, new HazelcastIntegrationTestUser(2, "TestName2", "TestSurname2"));
msg = channel.receive(TIMEOUT);
verifyEntryEvent(msg, cacheName, EntryEventType.ADDED);
multiMap.clear();
msg = channel.receive(TIMEOUT);
verifyEntryEvent(msg, cacheName, EntryEventType.CLEAR_ALL);
}
代码示例来源:origin: spring-projects/spring-integration-extensions
private void syncConfigurationMultiMap(HazelcastInstance hazelcastInstance) {
Lock lock = hazelcastInstance.getLock(SPRING_INTEGRATION_INTERNAL_CLUSTER_LOCK);
lock.lock();
try {
MultiMap<SocketAddress, SocketAddress> multiMap = hazelcastInstance
.getMultiMap(SPRING_INTEGRATION_INTERNAL_CLUSTER_MULTIMAP);
for (HazelcastInstance localInstance : Hazelcast.getAllHazelcastInstances()) {
SocketAddress localInstanceSocketAddress = localInstance.getLocalEndpoint().getSocketAddress();
if (multiMap.size() == 0) {
multiMap.put(localInstanceSocketAddress, localInstanceSocketAddress);
}
else {
multiMap.put(multiMap.keySet().iterator().next(), localInstanceSocketAddress);
}
}
}
finally {
lock.unlock();
}
}
代码示例来源:origin: spring-projects/spring-integration-extensions
private static void verifyMultiMapForPayload(
final MultiMap<Integer, HazelcastIntegrationTestUser> multiMap) {
int index = 1;
assertNotNull(multiMap);
assertEquals(true, multiMap.size() == DATA_COUNT);
SortedSet<Integer> keys = new TreeSet<>(multiMap.keySet());
for (Integer key : keys) {
assertNotNull(key);
assertEquals(index, key.intValue());
HazelcastIntegrationTestUser user = multiMap.get(key).iterator().next();
verifyHazelcastIntegrationTestUser(user, index);
index++;
}
}
代码示例来源:origin: org.opendaylight.nic/intent-mapping-hazelcast
@Override
public boolean delete(String outerKey) {
if(outerKey != null)
return false;
if (outerKey.isEmpty()) {
return true;
}
if (getMultiMap().get(outerKey) != null) {
getMultiMap().clear();
}
return true;
}
}
代码示例来源:origin: FlavioF/quartz-scheduler-hazelcast-jobstore
@Override
public List<String> getJobGroupNames()
throws JobPersistenceException {
return newArrayList(jobsByGroup.keySet());
}
代码示例来源:origin: org.vert-x/vertx-core
public Void action() throws Exception {
for (Map.Entry<String, HazelcastServerID> entry: map.entrySet()) {
HazelcastServerID hid = entry.getValue();
if (hid.serverID.equals(serverID)) {
map.remove(entry.getKey(), hid);
}
}
return null;
}
}.run();
内容来源于网络,如有侵权,请联系作者删除!