// ASYNCHRONOUS MODE NO ANSWER
iMode = 2;
final OPhysicalPosition ppos = new OPhysicalPosition(iRecordType);
OChannelBinaryAsynchClient lastNetworkUsed = null;
do {
try {
final OChannelBinaryAsynchClient network = beginRequest(OChannelBinaryProtocol.REQUEST_RECORD_CREATE);
lastNetworkUsed = network;
try {
network.writeShort((short) iRid.clusterId);
network.writeBytes(iContent);
network.writeByte(iRecordType);
network.writeByte((byte) iMode);
} finally {
endRequest(network);
}
switch (iMode) {
case 0:
// SYNCHRONOUS
try {
beginResponse(network);
iRid.clusterPosition = network.readClusterPosition();
ppos.clusterPosition = iRid.clusterPosition;
if (network.getSrvProtocolVersion() >= 11) {
ppos.recordVersion = network.readVersion();
} else
ppos.recordVersion = OVersionFactory.instance().createVersion();
if (network.getSrvProtocolVersion() >= 20)
readCollectionChanges(network, ODatabaseRecordThreadLocal.INSTANCE.get().getSbTreeCollectionManager());
return new OStorageOperationResult<OPhysicalPosition>(ppos);
} finally {
endResponse(network);
}
case 1:
// ASYNCHRONOUS
if (iCallback != null) {
final int sessionId = getSessionId();
final OSBTreeCollectionManager collectionManager = ODatabaseRecordThreadLocal.INSTANCE.get()
.getSbTreeCollectionManager();
Callable<Object> response = new Callable<Object>() {
public Object call() throws Exception {
final OClusterPosition result;
try {
OStorageRemoteThreadLocal.INSTANCE.get().sessionId = sessionId;
beginResponse(network);
result = network.readClusterPosition();
if (network.getSrvProtocolVersion() >= 11)
network.readVersion();
if (network.getSrvProtocolVersion() >= 20)
readCollectionChanges(network, collectionManager);
} finally {
endResponse(network);
OStorageRemoteThreadLocal.INSTANCE.get().sessionId = -1;
}