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

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

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

MultiMap.put介绍

[英]Stores a key-value pair in the multimap.

Warning: 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.
[中]在多重映射中存储键值对。
警告:此方法使用密钥二进制形式的hashCode和equals,而不是密钥类中定义的hashCode和equals的实际实现。

代码示例

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

public void run() {
    map.put(key, new byte[valueSize]);
  }
});

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

public boolean put(K key, V value) {
  if(guavaMultiMap != null)
    return guavaMultiMap.put(key, value);
  return hcMultiMap.put(key, value);
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.spark.core

public void addTableName(int tenantId, String tableName) {
  if (isClustered) {
    this.sparkTableNames.put(tenantId, tableName);
  } else {
    this.inMemSparkTableNames.put(tenantId, tableName);
  }
}

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

public static void main(String[] args) {
    HazelcastInstance hz = Hazelcast.newHazelcastInstance();
    MultiMap<String, String> map = hz.getMultiMap("map");

    map.put("a", "1");
    map.put("a", "2");
    map.put("b", "3");
    System.out.println("PutMember:Done");
  }
}

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

private void put(Object oid, Exchange exchange) {
  Object body = exchange.getIn().getBody();
  this.cache.put(oid, body);
}

代码示例来源: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: dCache/nfs4j

@Override
protected void add(byte[] objId, NlmLock lock) {
  String key = objIdToKey(objId);
  locks.put(key, lock);
}

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

public Void action() throws Exception {
  map.put(subName, new HazelcastServerID(serverID));
  return null;
 }
}.run();

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

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

代码示例来源: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: 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 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: org.opendaylight.nic/intent-mapping-hazelcast

@Override
public void add(String key, Map<String, String> objs) {
  delete(key);
  if (objs != null) {
    for (String s : objs.values()) {
      getMultiMap().put(key, s);
    }
  }
}

代码示例来源: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: hazelcast/hazelcast-jet

protected void handleMultiMapPut(String[] args) {
  println(getMultiMap().put(args[1], args[2]));
}

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

protected void handleMultiMapPut(String[] args) {
  println(getMultiMap().put(args[1], args[2]));
}

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

protected void handleMultiMapPut(String[] args) {
  println(getMultiMap().put(args[1], args[2]));
}

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

protected void handleMultiMapPut(String[] args) {
  println(getMultiMap().put(args[1], args[2]));
}

代码示例来源: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: FlavioF/quartz-scheduler-hazelcast-jobstore

@Override
public void storeJob(final JobDetail job, boolean replaceExisting)
 throws ObjectAlreadyExistsException, JobPersistenceException {
 final JobDetail newJob = (JobDetail) job.clone();
 final JobKey newJobKey = newJob.getKey();
 if (jobsByKey.containsKey(newJobKey) && !replaceExisting) {
  throw new ObjectAlreadyExistsException(newJob);
 }
 jobsByKey.lock(newJobKey, 5, TimeUnit.SECONDS);
 try {
  jobsByKey.set(newJobKey, newJob);
  jobsByGroup.put(newJobKey.getGroup(), newJobKey);
 } finally {
  try {
   jobsByKey.unlock(newJobKey);
  } catch (IllegalMonitorStateException ex) {
   LOG.warn("Error unlocking since it is already released.", ex);
  }
 }
}

相关文章