use of com.orientechnologies.orient.core.fetch.remote.ORemoteFetchListener in project orientdb by orientechnologies.
the class OAsyncCommandResultListener method result.
@Override
public boolean result(final Object iRecord) {
if (empty.compareAndSet(true, false))
try {
protocol.sendOk(connection, txId);
} catch (IOException ignored) {
}
try {
fetchRecord(iRecord, new ORemoteFetchListener() {
@Override
protected void sendRecord(ORecord iLinked) {
if (!alreadySent.contains(iLinked.getIdentity())) {
alreadySent.add(iLinked.getIdentity());
try {
// CACHE IT ON THE CLIENT
protocol.channel.writeByte((byte) 2);
protocol.writeIdentifiable(connection, iLinked);
} catch (IOException e) {
OLogManager.instance().error(this, "Cannot write against channel", e);
}
}
}
});
alreadySent.add(((OIdentifiable) iRecord).getIdentity());
// ONE MORE RECORD
protocol.channel.writeByte((byte) 1);
protocol.writeIdentifiable(connection, ((OIdentifiable) iRecord).getRecord());
// TODO review this flush... it's for non blocking...
protocol.channel.flush();
if (wrappedResultListener != null)
// NOTIFY THE WRAPPED LISTENER
wrappedResultListener.result(iRecord);
} catch (IOException e) {
return false;
}
return true;
}
use of com.orientechnologies.orient.core.fetch.remote.ORemoteFetchListener in project orientdb by orientechnologies.
the class OSyncCommandResultListener method linkdedBySimpleValue.
@Override
public void linkdedBySimpleValue(ODocument doc) {
ORemoteFetchListener listener = new ORemoteFetchListener() {
@Override
protected void sendRecord(ORecord iLinked) {
if (!alreadySent.contains(iLinked))
fetchedRecordsToSend.add(iLinked);
}
@Override
public void parseLinked(ODocument iRootRecord, OIdentifiable iLinked, Object iUserObject, String iFieldName, OFetchContext iContext) throws OFetchException {
if (!(iLinked instanceof ORecordId)) {
sendRecord(iLinked.getRecord());
}
}
@Override
public void parseLinkedCollectionValue(ODocument iRootRecord, OIdentifiable iLinked, Object iUserObject, String iFieldName, OFetchContext iContext) throws OFetchException {
if (!(iLinked instanceof ORecordId)) {
sendRecord(iLinked.getRecord());
}
}
};
final OFetchContext context = new ORemoteFetchContext();
OFetchHelper.fetch(doc, doc, OFetchHelper.buildFetchPlan(""), listener, context, "");
}
Aggregations