Package com.hazelcast.map.impl

Examples of com.hazelcast.map.impl.MapServiceContext.toObject()


    protected Object reduce(Map<Integer, Object> map) {
        int total = 0;
        MapService mapService = getService();
        final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
        for (Object result : map.values()) {
            Integer size = (Integer) mapServiceContext.toObject(result);
            total += size;
        }
        final Address thisAddress = mapServiceContext.getNodeEngine().getThisAddress();
        if (total > 0) {
            mapServiceContext.getMapEventPublisher().publishMapEvent(thisAddress, name, EntryEventType.EVICT_ALL, total);
View Full Code Here


    }


    protected Object toObject(Object data) {
        final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
        return mapServiceContext.toObject(data);
    }

    protected Data toData(Object obj) {
        final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
        return mapServiceContext.toData(obj);
View Full Code Here

        if (currentValue != null) {
            return checkIfRemoved(currentValue);
        }
        final MapService service = getService();
        final MapServiceContext mapServiceContext = service.getMapServiceContext();
        return mapServiceContext.toObject(getInternal(mapServiceContext.toData(key, partitionStrategy)));
    }

    public Object getForUpdate(Object key) {
        checkTransactionState();
        TxnValueWrapper currentValue = txMap.get(key);
View Full Code Here

            return checkIfRemoved(currentValue);
        }
        final MapService service = getService();
        final MapServiceContext mapServiceContext = service.getMapServiceContext();
        Data dataKey = mapServiceContext.toData(key, partitionStrategy);
        return mapServiceContext.toObject(getForUpdateInternal(dataKey));
    }

    private Object checkIfRemoved(TxnValueWrapper wrapper) {
        checkTransactionState();
        return wrapper == null || wrapper.type == TxnValueWrapper.Type.REMOVED ? null : wrapper.value;
View Full Code Here

    public Object put(Object key, Object value) {
        checkTransactionState();
        MapService service = getService();
        final MapServiceContext mapServiceContext = service.getMapServiceContext();
        final Object valueBeforeTxn = mapServiceContext.toObject(putInternal(mapServiceContext.toData(key, partitionStrategy),
                mapServiceContext.toData(value)));
        TxnValueWrapper currentValue = txMap.get(key);
        if (value != null) {
            TxnValueWrapper wrapper = valueBeforeTxn == null
                    ? new TxnValueWrapper(value, TxnValueWrapper.Type.NEW)
View Full Code Here

    public Object put(Object key, Object value, long ttl, TimeUnit timeUnit) {
        checkTransactionState();
        MapService service = getService();
        final MapServiceContext mapServiceContext = service.getMapServiceContext();
        final Object valueBeforeTxn = mapServiceContext.toObject(putInternal(mapServiceContext.toData(key, partitionStrategy),
                mapServiceContext.toData(value), ttl, timeUnit));
        TxnValueWrapper currentValue = txMap.get(key);
        if (value != null) {
            TxnValueWrapper wrapper = valueBeforeTxn == null
                    ? new TxnValueWrapper(value, TxnValueWrapper.Type.NEW)
View Full Code Here

                    = putIfAbsentInternal(mapServiceContext.toData(key, partitionStrategy),
                    mapServiceContext.toData(value));
            if (oldValue == null) {
                txMap.put(key, new TxnValueWrapper(value, TxnValueWrapper.Type.NEW));
            }
            return mapServiceContext.toObject(oldValue);
        }
    }

    public Object replace(Object key, Object value) {
        checkTransactionState();
View Full Code Here

        } else {
            Data oldValue = replaceInternal(mapServiceContext.toData(key, partitionStrategy), mapServiceContext.toData(value));
            if (oldValue != null) {
                txMap.put(key, new TxnValueWrapper(value, TxnValueWrapper.Type.UPDATED));
            }
            return mapServiceContext.toObject(oldValue);
        }
    }

    public boolean replace(Object key, Object oldValue, Object newValue) {
        checkTransactionState();
View Full Code Here

    public Object remove(Object key) {
        checkTransactionState();
        MapService service = getService();
        final MapServiceContext mapServiceContext = service.getMapServiceContext();
        final Object valueBeforeTxn
                = mapServiceContext.toObject(removeInternal(mapServiceContext.toData(key, partitionStrategy)));
        TxnValueWrapper wrapper = null;
        if (valueBeforeTxn != null || txMap.containsKey(key)) {
            wrapper = txMap.put(key, new TxnValueWrapper(valueBeforeTxn, TxnValueWrapper.Type.REMOVED));
        }
        return wrapper == null ? valueBeforeTxn : checkIfRemoved(wrapper);
View Full Code Here

        checkTransactionState();
        MapService service = getService();
        final MapServiceContext mapServiceContext = service.getMapServiceContext();
        Data data = removeInternal(mapServiceContext.toData(key, partitionStrategy));
        if (data != null || txMap.containsKey(key)) {
            txMap.put(key, new TxnValueWrapper(mapServiceContext.toObject(data), TxnValueWrapper.Type.REMOVED));
        }
    }

    public Set<Object> keySet() {
        checkTransactionState();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.