예제 #1
0
 public void interceptAfterRemove(String mapName, Object value) {
   List<MapInterceptor> interceptors = getMapContainer(mapName).getInterceptors();
   if (!interceptors.isEmpty()) {
     for (MapInterceptor interceptor : interceptors) {
       value = toObject(value);
       interceptor.afterRemove(value);
     }
   }
 }
예제 #2
0
 public void interceptAfterPut(String mapName, Object newValue) {
   List<MapInterceptor> interceptors = getMapContainer(mapName).getInterceptors();
   if (!interceptors.isEmpty()) {
     newValue = toObject(newValue);
     for (MapInterceptor interceptor : interceptors) {
       interceptor.afterPut(newValue);
     }
   }
 }
 private Collection<E> getAll() {
   final CollectionGetAllOperation operation = new CollectionGetAllOperation(name);
   final SerializableCollection result = invoke(operation);
   final Collection<Data> collection = result.getCollection();
   final List<E> list = new ArrayList<E>(collection.size());
   final NodeEngine nodeEngine = getNodeEngine();
   for (Data data : collection) {
     list.add(nodeEngine.<E>toObject(data));
   }
   return list;
 }
 public boolean addAll(Collection<? extends E> c) {
   throwExceptionIfNull(c);
   List<Data> valueList = new ArrayList<Data>(c.size());
   final NodeEngine nodeEngine = getNodeEngine();
   for (E e : c) {
     throwExceptionIfNull(e);
     valueList.add(nodeEngine.toData(e));
   }
   final CollectionAddAllOperation operation = new CollectionAddAllOperation(name, valueList);
   final Boolean result = invoke(operation);
   return result;
 }
예제 #5
0
 public Object interceptRemove(String mapName, Object value) {
   List<MapInterceptor> interceptors = getMapContainer(mapName).getInterceptors();
   Object result = null;
   if (!interceptors.isEmpty()) {
     result = toObject(value);
     for (MapInterceptor interceptor : interceptors) {
       Object temp = interceptor.interceptRemove(result);
       if (temp != null) {
         result = temp;
       }
     }
   }
   return result == null ? value : result;
 }
예제 #6
0
 public Object interceptPut(String mapName, Object oldValue, Object newValue) {
   List<MapInterceptor> interceptors = getMapContainer(mapName).getInterceptors();
   Object result = null;
   if (!interceptors.isEmpty()) {
     result = toObject(newValue);
     oldValue = toObject(oldValue);
     for (MapInterceptor interceptor : interceptors) {
       Object temp = interceptor.interceptPut(oldValue, result);
       if (temp != null) {
         result = temp;
       }
     }
   }
   return result == null ? newValue : result;
 }
예제 #7
0
 public QueryResult queryOnPartition(String mapName, Predicate predicate, int partitionId) {
   final QueryResult result = new QueryResult();
   List<QueryEntry> list = new LinkedList<QueryEntry>();
   PartitionContainer container = getPartitionContainer(partitionId);
   RecordStore recordStore = container.getRecordStore(mapName);
   Map<Data, Record> records = recordStore.getReadonlyRecordMap();
   SerializationService serializationService = nodeEngine.getSerializationService();
   final PagingPredicate pagingPredicate =
       predicate instanceof PagingPredicate ? (PagingPredicate) predicate : null;
   Comparator<Map.Entry> wrapperComparator = SortingUtil.newComparator(pagingPredicate);
   for (Record record : records.values()) {
     Data key = record.getKey();
     Object value = record.getValue();
     if (value == null) {
       continue;
     }
     QueryEntry queryEntry = new QueryEntry(serializationService, key, key, value);
     if (predicate.apply(queryEntry)) {
       if (pagingPredicate != null) {
         Map.Entry anchor = pagingPredicate.getAnchor();
         if (anchor != null
             && SortingUtil.compare(
                     pagingPredicate.getComparator(),
                     pagingPredicate.getIterationType(),
                     anchor,
                     queryEntry)
                 >= 0) {
           continue;
         }
       }
       list.add(queryEntry);
     }
   }
   if (pagingPredicate != null) {
     Collections.sort(list, wrapperComparator);
     if (list.size() > pagingPredicate.getPageSize()) {
       list = list.subList(0, pagingPredicate.getPageSize());
     }
   }
   for (QueryEntry entry : list) {
     result.add(
         new QueryResultEntryImpl(entry.getKeyData(), entry.getKeyData(), entry.getValueData()));
   }
   return result;
 }