} else if (!lastKey.equals(entry.getKey())) { if (lastKey.getRevision() <= entry.getKey().getRevision()) { if (txStart > TX_NO && tx.getTxIsolation().ordinal() > TransactionIsolation.readCommited.ordinal()) { return new BagriException("Document with key: " + entry.getKey() + ", uri: " + uri + " has been concurrently inserted; latest key is: " + lastKey, BagriException.ecDocument); if (lastKey != null && !lastKey.equals(entry.getKey())) { if (lastKey.getVersion() > entry.getKey().getVersion()) { if (txStart > TX_NO && tx.getTxIsolation().ordinal() > TransactionIsolation.readCommited.ordinal()) { return new BagriException("Document with key: " + entry.getKey() + ", uri: " + uri + " has been concurrently updated; latest key is: " + lastKey, BagriException.ecDocument);
@Override public Object process(Map.Entry<DocumentKey, Document> entry) { doc = entry.getValue(); long txStart = tx == null ? TX_NO : tx.getTxId(); DocumentKey lastKey = ddSvc.getLastKeyForUri(doc.getUri()); if (lastKey == null) { return new BagriException("Document with key: " + entry.getKey() + ", uri: " + doc.getUri() + " has been concurrently removed", BagriException.ecDocument); } else if (lastKey.getVersion() > entry.getKey().getVersion()) { if (txStart > TX_NO && tx.getTxIsolation().ordinal() > TransactionIsolation.readCommited.ordinal()) { return new BagriException("Document with key: " + entry.getKey() + ", uri: " + doc.getUri() + " has been concurrently updated; latest key is: " + lastKey, BagriException.ecDocument); } doc = docMgr.getDocument(lastKey); } try { return docMgr.processDocumentRemoval(entry, properties, txStart, doc); } catch (BagriException ex) { return ex; } }
private void writeTx(Transaction xtx) { buff.put((byte) xtx.getTxState().ordinal()); buff.putLong(xtx.getTxId()); buff.putLong(xtx.getStartedAt()); buff.putLong(xtx.getFinishedAt()); buff.put((byte) xtx.getTxIsolation().ordinal()); buff.putInt(xtx.getDocsCreated()); buff.putInt(xtx.getDocsUpdated()); buff.putInt(xtx.getDocsDeleted()); byte[] by = xtx.getStartedBy().getBytes(); byte[] by26 = new byte[byLen]; for (int i=0; i < by.length; i++) { by26[i] = by[i]; } buff.put(by26); //buff.force(); }
@Override public void write(ObjectDataOutput out, Transaction xTrans) throws IOException { out.writeLong(xTrans.getTxId()); out.writeLong(xTrans.getStartedAt()); out.writeLong(xTrans.getFinishedAt()); out.writeUTF(xTrans.getStartedBy()); out.writeInt(xTrans.getTxIsolation().ordinal()); out.writeInt(xTrans.getTxState().ordinal()); out.writeInt(xTrans.getDocsCreated()); out.writeInt(xTrans.getDocsUpdated()); out.writeInt(xTrans.getDocsDeleted()); }