@Override public V putIfAbsent(K key, V value) { return map.putIfAbsent(key, value); }
@Override public V putIfAbsent(K key, V value, long ttl, TimeUnit ttlUnit, long maxIdle, TimeUnit maxIdleUnit) { return map.putIfAbsent(key, value, ttl, ttlUnit, maxIdle, maxIdleUnit); }
@Override public boolean putIfAbsent(K key, V value) { return map.putIfAbsent(key, value) == null; }
@Override public Object putIfAbsent(String mapName, String key, Object value, int ttlSeconds) { return hazelcast.getMap(mapName).putIfAbsent(key, value, ttlSeconds, TimeUnit.SECONDS); }
/** * Puts an entry into this map with a given ttl (time to live) value if the specified key is not already associated with a value. */ private void putIfAbsent(Object oid, Object ttl, Object ttlUnit, Exchange exchange) { Object body = exchange.getIn().getBody(); this.cache.putIfAbsent(oid, body, (long) ttl, (TimeUnit) ttlUnit); }
@Override public String putIfAbsent(String key, String value) { Assert.notNull(key, "'key' must not be null."); Assert.notNull(value, "'value' must not be null."); return this.map.putIfAbsent(key, value); }
/** * if the specified key is not already associated with a value, associate it with the given value. */ private void putIfAbsent(Object oid, Exchange exchange) { Object body = exchange.getIn().getBody(); this.cache.putIfAbsent(oid, body); }
public void run() { IMap map = hazelcast.getMap("myMap"); map.putIfAbsent(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))), 10, TimeUnit.MILLISECONDS); } }, 5);
private long newJobId() { long jobId; do { jobId = Util.secureRandomNextLong(); } while (randomIds.putIfAbsent(jobId, jobId) != null); return jobId; }
/** * Generates a new execution id for the given job id, guaranteed to be unique across the cluster */ long newExecutionId(long jobId) { long executionId; do { executionId = Util.secureRandomNextLong(); } while (randomIds.putIfAbsent(executionId, jobId) != null); return executionId; }
public void run() { IMap map = hazelcast.getMap("myMap"); map.putIfAbsent(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000)))); } }, 5);
@Override public Object putIfAbsent(String key, Object value, long ttl, TimeUnit timeunit) { return delegate().putIfAbsent(key, value, ttl, timeunit); }
@Override public V putIfAbsent(@Nonnull K key, @Nonnull V value) { return unwrap(map.putIfAbsent(checkNotNull(key, "key"), wrap(checkNotNull(value, "value")))); }
static boolean casClusterId( HazelcastInstance hazelcastInstance, ClusterId clusterId, String dbName ) { IMap<String, UUID> uuidPerDbCluster = hazelcastInstance.getMap( CLUSTER_UUID_DB_NAME_MAP ); UUID uuid = uuidPerDbCluster.putIfAbsent( dbName, clusterId.uuid() ); return uuid == null || clusterId.uuid().equals( uuid ); }
private boolean isSelected(Selection selection, TestContext testContext) { switch (selection) { case ALL: return true; case ONE_PER_NODE: return (getMap(testContext).putIfAbsent(testContext.getPublicIpAddress(), true) == null); case ONE_PER_CLUSTER: return (getMap(testContext).putIfAbsent(testContext.getTestId(), true) == null); default: throw new UnsupportedOperationException("Unknown selection type"); } }
@Override public boolean add(String key) { repo.lock(key); try { return repo.putIfAbsent(key, false) == null; } finally { repo.unlock(key); } }
/** * Puts the given job record into the jobRecords map. * If another job record is already put, it checks if it has the same DAG. * If it has a different DAG, then the call fails with {@link IllegalStateException} */ void putNewJobRecord(JobRecord jobRecord) { long jobId = jobRecord.getJobId(); JobRecord prev = jobRecords.putIfAbsent(jobId, jobRecord); if (prev != null && !prev.getDag().equals(jobRecord.getDag())) { throw new IllegalStateException("Cannot put job record for job " + idToString(jobId) + " because it already exists with a different DAG"); } }
/** * Add to the write ahead log (hazelcast IMap) that tracks all the outstanding tasks */ public boolean addPendingTask(HazeltaskTask<GROUP> task, boolean replaceIfExists) { if(!replaceIfExists) return pendingTask.putIfAbsent(task.getId(), task) == null; pendingTask.put(task.getId(), task); return true; }
public ValueWrapper putIfAbsent(Object key, Object value) { Object result = map.putIfAbsent(key, toStoreValue(value)); return result != null ? new SimpleValueWrapper(fromStoreValue(result)) : null; }
public void onOperationMessage(ConsumerRecord<String, Serializable> record, Operation operation) { try { log.info("Operation:" + record.key() + " - " + operation.toString()); operationsMap.putIfAbsent(record.key(), new Topology(record.key(), operation.getParentId()), calculateTimeout(operation.getContext()), TimeUnit.MILLISECONDS); operationsMap.executeOnKey(record.key(), new OperationTopologyUpdater(operation)); } catch (Exception e) { log.error("Error While Handling Event:" + e.getMessage(), e); } }