Package voldemort.versioning

Examples of voldemort.versioning.ObsoleteVersionException


                int httpErrorStatus = exception.getResponse().getStatus();
                if(httpErrorStatus == BAD_REQUEST.getCode()) {
                    throw new VoldemortException("Bad request: " + e.getMessage(), e);
                } else if(httpErrorStatus == PRECONDITION_FAILED.getCode()) {
                    throw new ObsoleteVersionException(e.getMessage());
                } else if(httpErrorStatus == REQUEST_TIMEOUT.getCode()
                          || httpErrorStatus == INTERNAL_SERVER_ERROR.getCode()) {
                    throw new InsufficientOperationalNodesException(e.getMessage());
                }
            }
View Full Code Here


                // Update the value
                List<Versioned<byte[]>> removedValueList = new ArrayList<Versioned<byte[]>>();
                for(Versioned<byte[]> versioned: existingValuesList) {
                    Occurred occurred = value.getVersion().compare(versioned.getVersion());
                    if(occurred == Occurred.BEFORE)
                        throw new ObsoleteVersionException("Obsolete version for key '" + key
                                                           + "': " + value.getVersion());
                    else if(occurred == Occurred.AFTER)
                        removedValueList.add(versioned);
                }
                existingValuesList.removeAll(removedValueList);
View Full Code Here

        {
            Versioned<VListNode<E>> firstNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(firstNodeMap.getValue()),
                                                                            firstNodeMap.getVersion());

            if(!firstNode.getValue().isStable()) {
                throw new ObsoleteVersionException("cannot add when list node is not stable");
            }

            // set stable flag to false
            Map<String, Object> tmpMap = new HashMap<String, Object>(firstNodeMap.getValue());
            tmpMap.put(VListNode.STABLE, false);
            storeClient.put(newKey.mapValue(),
                            new Versioned<Map<String, Object>>(tmpMap, firstNodeMap.getVersion()));
            _rollback.put(0, firstNodeMap.getValue());

            int newId;
            int nextId = firstNode.getValue().getNextId();
            newId = (nextId == VStack.NULL_ID) ? 1 : nextId + 1;
            if(newId == Integer.MAX_VALUE)
                throw new ArrayIndexOutOfBoundsException(newId + " out of bounds");

            Versioned<VListNode<E>> nextNode = null;
            VListKey<K> nextKey = new VListKey<K>(_key, nextId);
            if(nextId != VStack.NULL_ID) {
                Versioned<Map<String, Object>> nextNodeMap = storeClient.get(nextKey.mapValue());
                if(nextNodeMap == null)
                    throw new ObsoleteVersionException("possible concurrent modification");
                nextNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()),
                                                       nextNodeMap.getVersion());
                if(!nextNode.getValue().isStable()) {
                    throw new ObsoleteVersionException("cannot add when list node is not stable");
                }

                // set stable flag to false
                tmpMap = new HashMap<String, Object>(nextNode.getValue().mapValue());
                tmpMap.put(VListNode.STABLE, false);
                storeClient.put(nextKey.mapValue(),
                                new Versioned<Map<String, Object>>(tmpMap, nextNode.getVersion()));
                _rollback.put(nextId, nextNode.getValue().mapValue());
            }

            // insert new node
            Map<String, Object> newNode = (new VListNode<E>(_value, 0, VStack.NULL_ID, newId, true)).mapValue();
            // don't need to specify versioned because node is already "locked"
            storeClient.put(newKey.mapValue(), newNode);

            // move first node to next index
            VListKey<K> firstKey = new VListKey<K>(_key, newId);
            firstNode = new Versioned<VListNode<E>>(new VListNode<E>(firstNode.getValue()
                                                                              .getValue(),
                                                                     newId,
                                                                     0,
                                                                     firstNode.getValue()
                                                                              .getNextId(),
                                                                     true));
            // don't need to specify versioned because node is already "locked"
            storeClient.put(firstKey.mapValue(), firstNode.getValue().mapValue());

            // redefine previous pointer on next node
            if(nextNode != null) {
                if(!storeClient.applyUpdate(new UpdateNextNode<K, E>(nextNode, nextKey, newId)))
                    throw new ObsoleteVersionException("unable to update node");
            }
        }
    }
View Full Code Here

        public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) {
            if(numCalls > 0) {
                // TODO jko maybe delete this if unnecessary
                Versioned<Map<String, Object>> nextNodeMap = storeClient.get(_key.mapValue());
                if(nextNodeMap == null)
                    throw new ObsoleteVersionException("possible concurrent modification");
                _listNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()),
                                                        nextNodeMap.getVersion());
            }

            VListNode<E> nodeValue = _listNode.getValue();
View Full Code Here

        // Validate the Vector clock
        VectorClock clock = readVersion();
        if(clock != null) {
            if(value.getVersion().compare(clock) == Occurred.BEFORE) {
                throw new ObsoleteVersionException("A successor version " + clock + "  to this "
                                                   + value.getVersion()
                                                   + " exists for the current file : " + getName());
            } else if(value.getVersion().compare(clock) == Occurred.CONCURRENTLY) {
                throw new ObsoleteVersionException("Concurrent Operation not allowed on Metadata.");
            }
        }

        // Update the cache copy
        this.metadataMap.put(new String(key.get()), new String(value.getValue()));
View Full Code Here

        // remove in case of success
        List<Versioned<V>> itemsToRemove = new ArrayList<Versioned<V>>(items.size());
        for(Versioned<V> versioned: items) {
            Occurred occurred = value.getVersion().compare(versioned.getVersion());
            if(occurred == Occurred.BEFORE) {
                throw new ObsoleteVersionException("Obsolete version for key '" + key + "': "
                                                   + value.getVersion());
            } else if(occurred == Occurred.AFTER) {
                itemsToRemove.add(versioned);
            }
        }
View Full Code Here

            if(file.getName().equals(key)) {
                VectorClock clock = readVersion(key);
                if(value.getVersion().compare(clock) == Occurred.AFTER) {
                    // continue
                } else if(value.getVersion().compare(clock) == Occurred.BEFORE) {
                    throw new ObsoleteVersionException("A successor version " + clock
                                                       + "  to this " + value.getVersion()
                                                       + " exists for key " + key);
                } else if(value.getVersion().compare(clock) == Occurred.CONCURRENTLY) {
                    throw new ObsoleteVersionException("Concurrent Operation not allowed on Metadata.");
                }
            }
        }

        File keyFile = new File(getDirectory(key), key);
View Full Code Here

    public E setById(final int id, final E element) {
        VListKey<K> key = new VListKey<K>(_key, id);
        UpdateElementById<K, E> updateElementAction = new UpdateElementById<K, E>(key, element);

        if(!_storeClient.applyUpdate(updateElementAction))
            throw new ObsoleteVersionException("update failed");

        return updateElementAction.getResult();
    }
View Full Code Here

    public E setById(int id, Versioned<E> element) {
        VListKey<K> key = new VListKey<K>(_key, id);
        UpdateElementById<K, E> updateElementAction = new UpdateElementById<K, E>(key, element);

        if(!_storeClient.applyUpdate(updateElementAction))
            throw new ObsoleteVersionException("update failed");

        return updateElementAction.getResult();
    }
View Full Code Here

        if(nodeMap == null)
            throw new IndexOutOfBoundsException("invalid id " + _key.getId());
        Version version = (_version != null) ? _version : nodeMap.getVersion();
        VListNode<E> listNode = VListNode.valueOf(nodeMap.getValue());
        if(!listNode.isStable()) {
            throw new ObsoleteVersionException("node " + _key.getId() + " not stable.");
        }
        _result = listNode.getValue();
        VListNode<E> newNode = new VListNode<E>(_element,
                                                listNode.getId(),
                                                listNode.getPreviousId(),
View Full Code Here

TOP

Related Classes of voldemort.versioning.ObsoleteVersionException

Copyright © 2018 www.massapicom. 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.