Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.hazelcast.map.impl.proxy;
import com.hazelcast.config.MapConfig;
import com.hazelcast.core.EntryListener;
import com.hazelcast.core.EntryView;
import com.hazelcast.core.ExecutionCallback;
import com.hazelcast.core.HazelcastException;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ICompletableFuture;
import com.hazelcast.core.IMap;
import com.hazelcast.map.EntryProcessor;
import com.hazelcast.map.MapInterceptor;
import com.hazelcast.map.impl.MapService;
import com.hazelcast.map.impl.SimpleEntryView;
import com.hazelcast.map.impl.query.MapQueryEngine;
import com.hazelcast.map.impl.query.QueryResult;
import com.hazelcast.map.impl.query.QueryResultCollection;
import com.hazelcast.map.listener.MapListener;
import com.hazelcast.map.listener.MapPartitionLostListener;
import com.hazelcast.mapreduce.Collator;
import com.hazelcast.mapreduce.CombinerFactory;
import com.hazelcast.mapreduce.Job;
import com.hazelcast.mapreduce.JobTracker;
import com.hazelcast.mapreduce.KeyValueSource;
import com.hazelcast.mapreduce.Mapper;
import com.hazelcast.mapreduce.MappingJob;
import com.hazelcast.mapreduce.ReducerFactory;
import com.hazelcast.mapreduce.ReducingSubmittableJob;
import com.hazelcast.mapreduce.aggregation.Aggregation;
import com.hazelcast.mapreduce.aggregation.Supplier;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.query.PagingPredicate;
import com.hazelcast.query.Predicate;
import com.hazelcast.query.TruePredicate;
import com.hazelcast.spi.InitializingObject;
import com.hazelcast.spi.NodeEngine;
import com.hazelcast.spi.Operation;
import com.hazelcast.util.CollectionUtil;
import com.hazelcast.util.IterationType;
import com.hazelcast.util.MapUtil;
import com.hazelcast.util.executor.DelegatingFuture;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static com.hazelcast.map.impl.MapService.SERVICE_NAME;
import static com.hazelcast.util.Preconditions.checkNotNull;
import static com.hazelcast.util.Preconditions.checkPositive;
import static com.hazelcast.util.Preconditions.checkTrue;
import static com.hazelcast.util.Preconditions.isNotNull;
/**
* Proxy implementation of {@link com.hazelcast.core.IMap} interface.
*
* @param the key type of map.
* @param the value type of map.
*/
@SuppressWarnings("checkstyle:classfanoutcomplexity")
public class MapProxyImpl extends MapProxySupport implements IMap, InitializingObject {
public MapProxyImpl(String name, MapService mapService, NodeEngine nodeEngine, MapConfig mapConfig) {
super(name, mapService, nodeEngine, mapConfig);
}
@Override
public V get(Object k) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
return (V) toObject(getInternal(key));
}
@Override
public V put(K k, V v) {
return put(k, v, -1, TimeUnit.MILLISECONDS);
}
@Override
public V put(K k, V v, long ttl, TimeUnit timeunit) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data value = toData(v);
Data result = putInternal(key, value, ttl, timeunit);
return (V) toObject(result);
}
@Override
public boolean tryPut(K k, V v, long timeout, TimeUnit timeunit) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data value = toData(v);
return tryPutInternal(key, value, timeout, timeunit);
}
@Override
public V putIfAbsent(K k, V v) {
return putIfAbsent(k, v, -1, TimeUnit.MILLISECONDS);
}
@Override
public V putIfAbsent(K k, V v, long ttl, TimeUnit timeunit) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data value = toData(v);
Data result = putIfAbsentInternal(key, value, ttl, timeunit);
return (V) toObject(result);
}
@Override
public void putTransient(K k, V v, long ttl, TimeUnit timeunit) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data value = toData(v);
putTransientInternal(key, value, ttl, timeunit);
}
@Override
public boolean replace(K k, V o, V v) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(o, NULL_VALUE_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data oldValue = toData(o);
Data value = toData(v);
return replaceInternal(key, oldValue, value);
}
@Override
public V replace(K k, V v) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data value = toData(v);
return (V) toObject(replaceInternal(key, value));
}
@Override
public void set(K key, V value) {
set(key, value, -1, TimeUnit.MILLISECONDS);
}
@Override
public void set(K k, V v, long ttl, TimeUnit timeunit) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data value = toData(v);
setInternal(key, value, ttl, timeunit);
}
@Override
public V remove(Object k) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data result = removeInternal(key);
return (V) toObject(result);
}
@Override
public boolean remove(Object k, Object v) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
Data value = toData(v);
return removeInternal(key, value);
}
@Override
public void delete(Object k) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
deleteInternal(key);
}
@Override
public boolean containsKey(Object k) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
return containsKeyInternal(key);
}
@Override
public boolean containsValue(Object v) {
checkNotNull(v, NULL_VALUE_IS_NOT_ALLOWED);
Data value = toData(v);
return containsValueInternal(value);
}
@Override
public void lock(K key) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
NodeEngine nodeEngine = getNodeEngine();
Data k = toData(key, partitionStrategy);
lockSupport.lock(nodeEngine, k);
}
@Override
public void lock(Object key, long leaseTime, TimeUnit timeUnit) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
checkPositive(leaseTime, "leaseTime should be positive");
Data k = toData(key, partitionStrategy);
lockSupport.lock(getNodeEngine(), k, timeUnit.toMillis(leaseTime));
}
@Override
public void unlock(K key) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
NodeEngine nodeEngine = getNodeEngine();
Data k = toData(key, partitionStrategy);
lockSupport.unlock(nodeEngine, k);
}
@Override
public boolean tryRemove(K key, long timeout, TimeUnit timeunit) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
Data k = toData(key, partitionStrategy);
return tryRemoveInternal(k, timeout, timeunit);
}
@Override
public Future getAsync(K k) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
NodeEngine nodeEngine = getNodeEngine();
return new DelegatingFuture(getAsyncInternal(key), nodeEngine.getSerializationService());
}
@Override
public boolean isLocked(K k) {
checkNotNull(k, NULL_KEY_IS_NOT_ALLOWED);
Data key = toData(k, partitionStrategy);
NodeEngine nodeEngine = getNodeEngine();
return lockSupport.isLocked(nodeEngine, key);
}
@Override
public Future putAsync(K key, V value) {
return putAsync(key, value, -1, TimeUnit.MILLISECONDS);
}
@Override
public ICompletableFuture putAsync(K key, V value, long ttl, TimeUnit timeunit) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
checkNotNull(value, NULL_VALUE_IS_NOT_ALLOWED);
Data k = toData(key, partitionStrategy);
Data v = toData(value);
return new DelegatingFuture(putAsyncInternal(k, v, ttl, timeunit),
getNodeEngine().getSerializationService());
}
@Override
public ICompletableFuture removeAsync(K key) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
Data k = toData(key, partitionStrategy);
return new DelegatingFuture(removeAsyncInternal(k), getNodeEngine().getSerializationService());
}
@Override
public Map getAll(Set keys) {
if (CollectionUtil.isEmpty(keys)) {
return Collections.emptyMap();
}
List requestedKeys = new ArrayList(keys.size());
for (K key : keys) {
checkNotNull(key, NULL_KEY_IS_NOT_ALLOWED);
Data k = toData(key, partitionStrategy);
requestedKeys.add(k);
}
List resultingKeyValuePairs = new ArrayList(keys.size());
getAllObjectInternal(requestedKeys, resultingKeyValuePairs);
Map