com.hazelcast.core.MultiMap.remove()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中com.hazelcast.core.MultiMap.remove()方法的一些代码示例,展示了MultiMap.remove()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MultiMap.remove()方法的具体详情如下:
包路径:com.hazelcast.core.MultiMap
类名称:MultiMap
方法名:remove

MultiMap.remove介绍

[英]Removes all the entries with the given key.

Warning 1: This method uses hashCode and equals of the binary form of the key, not the actual implementations of hashCode and equals defined in the key's class.

Warning 2: The collection is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.
[中]删除具有给定密钥的所有条目。
警告1:此方法使用密钥二进制形式的hashCode和equals,而不是密钥类中定义的hashCode和equals的实际实现。
警告2:集合不受映射支持,因此对映射的更改不会反映在集合中,反之亦然。

代码示例

代码示例来源:origin: org.apache.camel/camel-hazelcast

private void delete(Object oid) {
  this.cache.remove(oid);
}

代码示例来源:origin: jclawson/hazeltask

public Collection<V> remove(Object key) {
  return hcMultiMap.remove(key);
}

代码示例来源:origin: org.apache.camel/camel-hazelcast

private void removevalue(Object oid, Exchange exchange) {
  this.cache.remove(oid, exchange.getIn().getBody());
}

代码示例来源:origin: jclawson/hazeltask

public boolean remove(Object key, Object value) {
  if(guavaMultiMap != null)
    return guavaMultiMap.remove(key, value);
  return hcMultiMap.remove(key, value);
}

代码示例来源:origin: dCache/nfs4j

@Override
protected boolean remove(byte[] objId, NlmLock lock) {
  String key = objIdToKey(objId);
  return locks.remove(key, lock);
}

代码示例来源:origin: dCache/nfs4j

@Override
protected void removeAll(byte[] objId, Collection<NlmLock> locks) {
  String key = objIdToKey(objId);
  locks.forEach(l -> this.locks.remove(key, l));
}

代码示例来源:origin: org.vert-x/vertx-core

public Boolean action() throws Exception {
  return map.remove(subName, new HazelcastServerID(serverID));
 }
}.run();

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

static void refreshGroups( HazelcastInstance hazelcastInstance, String memberId, List<String> groups )
{
  MultiMap<String,String> groupsMap = hazelcastInstance.getMultiMap( SERVER_GROUPS_MULTIMAP );
  Collection<String> existing = groupsMap.get( memberId );
  Set<String> superfluous = existing.stream().filter( t -> !groups.contains( t ) ).collect( Collectors.toSet() );
  Set<String> missing = groups.stream().filter( t -> !existing.contains( t ) ).collect( Collectors.toSet() );
  missing.forEach( group -> groupsMap.put( memberId, group ) );
  superfluous.forEach( group -> groupsMap.remove( memberId, group ) );
}

代码示例来源:origin: jclawson/hazeltask

public int removeAll(Object key, Collection<Object> values) {
  int totalRemoved = 0;
  if(guavaMultiMap != null) {
    synchronized (guavaMultiMap) {
      for(Object o : values) {
        if(guavaMultiMap.remove(key, o))
          totalRemoved ++;
      }
    } 
  } else {
    for(Object o : values) {
      if(hcMultiMap.remove(key, o))
        totalRemoved ++;
    }
  }
  return totalRemoved;
}

代码示例来源: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();

代码示例来源:origin: hazelcast/hazelcast-code-samples

public void run() {
    while (true) {
      int key = (int) (RANDOM.nextFloat() * entryCount);
      int operation = ((int) (RANDOM.nextFloat() * 100));
      if (operation < getPercentage) {
        map.get(String.valueOf(key));
        gets.incrementAndGet();
      } else if (operation < getPercentage + putPercentage) {
        map.put(String.valueOf(key), new byte[valueSize]);
        puts.incrementAndGet();
      } else {
        map.remove(String.valueOf(key));
        removes.incrementAndGet();
      }
    }
  }
});

代码示例来源:origin: hazelcast/hazelcast-jet

protected void handleMultiMapRemove(String[] args) {
  println(getMultiMap().remove(args[1]));
}

代码示例来源:origin: hazelcast/hazelcast-jet

protected void handleMultiMapRemove(String[] args) {
  println(getMultiMap().remove(args[1]));
}

代码示例来源:origin: com.hazelcast/hazelcast-all

protected void handleMultiMapRemove(String[] args) {
  println(getMultiMap().remove(args[1]));
}

代码示例来源:origin: com.hazelcast/hazelcast-all

protected void handleMultiMapRemove(String[] args) {
  println(getMultiMap().remove(args[1]));
}

代码示例来源: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) {
    // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1
    HazelcastInstance hz = HazelcastClient.newHazelcastClient();
    // 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 this Hazelcast Client
    hz.shutdown();
  }
}

代码示例来源:origin: FlavioF/quartz-scheduler-hazelcast-jobstore

@Override
public boolean removeJob(final JobKey jobKey)
 throws JobPersistenceException {
 boolean removed = false;
 if (jobsByKey.containsKey(jobKey)) {
  final List<OperableTrigger> triggersForJob = getTriggersForJob(jobKey);
  for (final OperableTrigger trigger : triggersForJob) {
   if (!removeTrigger(trigger.getKey(), false)) {
    LOG.warn("Error deleting trigger [{}] of job [{}] .", trigger, jobKey);
    return false;
   }
  }
  jobsByKey.lock(jobKey, 5, TimeUnit.MILLISECONDS);
  try {
   jobsByGroup.remove(jobKey.getGroup(), jobKey);
   removed = jobsByKey.remove(jobKey) != null;
  } finally {
   try {
    jobsByKey.unlock(jobKey);
   } catch (IllegalMonitorStateException ex) {
    LOG.warn("Error unlocking since it is already released.", ex);
   }
  }
 }
 return removed;
}

代码示例来源:origin: FlavioF/quartz-scheduler-hazelcast-jobstore

if (removed) {
 triggersByGroup.remove(key.getGroup(), key);

代码示例来源: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);
}

相关文章