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);
}
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()));
}
}
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;
}
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);
}
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);
}
}
Aggregations