/** * Increases the reference counter for the given entry so that it is not * accidentally removed. * * @param node id of the entry */ public void lockNode(final NodeId node) { Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node); if (sharedBufferNode != null) { sharedBufferNode.lock(); sharedBuffer.upsertEntry(node, sharedBufferNode); } }
/** * Decreases the reference counter for the given entry so that it can be * removed once the reference counter reaches 0. * * @param node id of the entry * @throws Exception Thrown if the system cannot access the state. */ public void releaseNode(final NodeId node) throws Exception { Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node); if (sharedBufferNode != null) { if (sharedBufferNode.release()) { removeNode(node, sharedBufferNode.getElement()); } else { sharedBuffer.upsertEntry(node, sharedBufferNode); } } }
/** * Stores given value (value + timestamp) under the given state. It assigns a preceding element * relation to the previous entry. * * @param stateName name of the state that the event should be assigned to * @param eventId unique id of event assigned by this SharedBuffer * @param previousNodeId id of previous entry (might be null if start of new run) * @param version Version of the previous relation * @return assigned id of this element */ public NodeId put( final String stateName, final EventId eventId, @Nullable final NodeId previousNodeId, final DeweyNumber version) { if (previousNodeId != null) { lockNode(previousNodeId); } NodeId currentNodeId = new NodeId(eventId, getOriginalNameFromInternal(stateName)); Lockable<SharedBufferNode> currentNode = sharedBuffer.getEntry(currentNodeId); if (currentNode == null) { currentNode = new Lockable<>(new SharedBufferNode(), 0); lockEvent(eventId); } currentNode.getElement().addEdge(new SharedBufferEdge( previousNodeId, version)); sharedBuffer.upsertEntry(currentNodeId, currentNode); return currentNodeId; }
/** * Increases the reference counter for the given entry so that it is not * accidentally removed. * * @param node id of the entry */ public void lockNode(final NodeId node) { Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node); if (sharedBufferNode != null) { sharedBufferNode.lock(); sharedBuffer.upsertEntry(node, sharedBufferNode); } }
/** * Increases the reference counter for the given entry so that it is not * accidentally removed. * * @param node id of the entry */ public void lockNode(final NodeId node) { Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node); if (sharedBufferNode != null) { sharedBufferNode.lock(); sharedBuffer.upsertEntry(node, sharedBufferNode); } }
/** * Decreases the reference counter for the given entry so that it can be * removed once the reference counter reaches 0. * * @param node id of the entry * @throws Exception Thrown if the system cannot access the state. */ public void releaseNode(final NodeId node) throws Exception { Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node); if (sharedBufferNode != null) { if (sharedBufferNode.release()) { removeNode(node, sharedBufferNode.getElement()); } else { sharedBuffer.upsertEntry(node, sharedBufferNode); } } }
/** * Decreases the reference counter for the given entry so that it can be * removed once the reference counter reaches 0. * * @param node id of the entry * @throws Exception Thrown if the system cannot access the state. */ public void releaseNode(final NodeId node) throws Exception { Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node); if (sharedBufferNode != null) { if (sharedBufferNode.release()) { removeNode(node, sharedBufferNode.getElement()); } else { sharedBuffer.upsertEntry(node, sharedBufferNode); } } }
/** * Stores given value (value + timestamp) under the given state. It assigns a preceding element * relation to the previous entry. * * @param stateName name of the state that the event should be assigned to * @param eventId unique id of event assigned by this SharedBuffer * @param previousNodeId id of previous entry (might be null if start of new run) * @param version Version of the previous relation * @return assigned id of this element */ public NodeId put( final String stateName, final EventId eventId, @Nullable final NodeId previousNodeId, final DeweyNumber version) { if (previousNodeId != null) { lockNode(previousNodeId); } NodeId currentNodeId = new NodeId(eventId, getOriginalNameFromInternal(stateName)); Lockable<SharedBufferNode> currentNode = sharedBuffer.getEntry(currentNodeId); if (currentNode == null) { currentNode = new Lockable<>(new SharedBufferNode(), 0); lockEvent(eventId); } currentNode.getElement().addEdge(new SharedBufferEdge( previousNodeId, version)); sharedBuffer.upsertEntry(currentNodeId, currentNode); return currentNodeId; }
/** * Stores given value (value + timestamp) under the given state. It assigns a preceding element * relation to the previous entry. * * @param stateName name of the state that the event should be assigned to * @param eventId unique id of event assigned by this SharedBuffer * @param previousNodeId id of previous entry (might be null if start of new run) * @param version Version of the previous relation * @return assigned id of this element */ public NodeId put( final String stateName, final EventId eventId, @Nullable final NodeId previousNodeId, final DeweyNumber version) { if (previousNodeId != null) { lockNode(previousNodeId); } NodeId currentNodeId = new NodeId(eventId, getOriginalNameFromInternal(stateName)); Lockable<SharedBufferNode> currentNode = sharedBuffer.getEntry(currentNodeId); if (currentNode == null) { currentNode = new Lockable<>(new SharedBufferNode(), 0); lockEvent(eventId); } currentNode.getElement().addEdge(new SharedBufferEdge( previousNodeId, version)); sharedBuffer.upsertEntry(currentNodeId, currentNode); return currentNodeId; }