Search in sources :

Example 6 with PseudoTime

use of org.structr.net.data.time.PseudoTime in project structr by structr.

the class Set method deserialize.

@Override
public void deserialize(final DataInputStream dis) throws IOException {
    super.deserialize(dis);
    // dis.readUTF();
    this.recipient = deserializeUUID(dis);
    // dis.readUTF();
    this.objectId = deserializeUUID(dis);
    // dis.readUTF();
    this.transactionId = deserializeUUID(dis);
    this.key = dis.readUTF();
    this.value = deserializeObject(dis);
    this.time = new PseudoTime();
    time.deserialize(dis);
}
Also used : PseudoTime(org.structr.net.data.time.PseudoTime)

Example 7 with PseudoTime

use of org.structr.net.data.time.PseudoTime in project structr by structr.

the class DefaultRepositoryObject method printHistory.

public void printHistory() {
    for (final PseudoTime time : history.keySet()) {
        System.out.println("            " + time + ": " + history.get(time));
    }
    if (!history.isEmpty()) {
        System.out.println("            " + history.firstKey() + ": " + getProperties(history.firstKey()));
        System.out.println("            " + history.lastKey() + ": " + getProperties(history.lastKey()));
    }
}
Also used : PseudoTime(org.structr.net.data.time.PseudoTime)

Example 8 with PseudoTime

use of org.structr.net.data.time.PseudoTime in project structr by structr.

the class DefaultRepositoryObject method getProperty.

@Override
public Object getProperty(final PseudoTime instant, final String transactionId, final String key) {
    PossibleValue value = history.get(instant);
    // optimistic best cas first
    if (value != null && value.isComplete(transactionId) && value.hasValue(key)) {
        return value.get(key);
    } else {
        // do backwards search
        final List<PseudoTime> times = new LinkedList<>(history.keySet());
        Collections.reverse(times);
        for (final PseudoTime time : times) {
            if (time.equals(instant) || time.before(instant)) {
                final PossibleValue val = history.get(time);
                if (val.isComplete(transactionId) && val.hasValue(key)) {
                    return val.get(key);
                } else if (val.isAborted()) {
                    history.remove(time);
                }
            }
        }
    }
    // nothing found, no values committed yet
    return null;
}
Also used : PseudoTime(org.structr.net.data.time.PseudoTime) LinkedList(java.util.LinkedList)

Example 9 with PseudoTime

use of org.structr.net.data.time.PseudoTime in project structr by structr.

the class PeerToPeerService method delete.

public void delete(final String uuid) {
    final PseudoTime time = peer.getPseudoTemporalEnvironment().current();
    logger.info("Shared node with UUID {} DELETED in Structr at {}", new Object[] { uuid, time });
    repository.delete(uuid, time);
}
Also used : PseudoTime(org.structr.net.data.time.PseudoTime)

Example 10 with PseudoTime

use of org.structr.net.data.time.PseudoTime in project structr by structr.

the class PeerToPeerService method update.

public void update(final SharedNodeInterface sharedNode) {
    final RepositoryObject obj = repository.getObject(sharedNode.getUuid());
    if (obj != null) {
        final PseudoTime time = sharedNode.getLastModificationPseudoTime();
        final Map<String, Object> data = sharedNode.getData();
        final String type = sharedNode.getType();
        final String user = sharedNode.getUserId();
        logger.info("Shared node with UUID {} UPDATED in Structr at {}", new Object[] { sharedNode.getUuid(), time.toString() });
        repository.update(obj, type, peer.getUuid(), user, time, data);
    }
}
Also used : PseudoTime(org.structr.net.data.time.PseudoTime) RepositoryObject(org.structr.net.repository.RepositoryObject) RepositoryObject(org.structr.net.repository.RepositoryObject) GraphObject(org.structr.core.GraphObject)

Aggregations

PseudoTime (org.structr.net.data.time.PseudoTime)14 RepositoryObject (org.structr.net.repository.RepositoryObject)4 LinkedList (java.util.LinkedList)2 GraphObject (org.structr.core.GraphObject)2 HashMap (java.util.HashMap)1