/** {@inheritDoc} */ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { readExternalMeta(in); xidVer = (GridCacheVersion)in.readObject(); invalidate = in.readBoolean(); timeout = in.readLong(); threadId = in.readLong(); startTime = in.readLong(); nodeId = U.readUuid(in); isolation = TransactionIsolation.fromOrdinal(in.read()); concurrency = TransactionConcurrency.fromOrdinal(in.read()); state = TransactionState.fromOrdinal(in.read()); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { writeExternalMeta(out); out.writeObject(xidVer); out.writeBoolean(invalidate); out.writeLong(timeout); out.writeLong(threadId); out.writeLong(startTime); U.writeUuid(out, nodeId); out.write(isolation.ordinal()); out.write(concurrency.ordinal()); out.write(state().ordinal()); }
final TransactionState state = txRecord.state(); incrementStat(state.toString(), txRecord, txRecordAct);
/** * Writes {@link TxRecord} to given buffer. * * @param rec TxRecord. * @param buf Byte buffer. */ public void write(TxRecord rec, ByteBuffer buf) { buf.put((byte)rec.state().ordinal()); RecordV1Serializer.putVersion(buf, rec.nearXidVersion(), true); RecordV1Serializer.putVersion(buf, rec.writeVersion(), true); Map<Short, Collection<Short>> participatingNodes = rec.participatingNodes(); if (participatingNodes != null && !participatingNodes.isEmpty()) { buf.putInt(participatingNodes.size()); for (Map.Entry<Short, Collection<Short>> e : participatingNodes.entrySet()) { buf.putShort(e.getKey()); Collection<Short> backupNodes = e.getValue(); buf.putInt(backupNodes.size()); for (short backupNode : backupNodes) buf.putShort(backupNode); } } else buf.putInt(0); // Put zero size of participating nodes. buf.putLong(rec.timestamp()); }
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { op = VisorTxOperation.fromOrdinal(in.readByte()); limit = fixNull(in.readInt()); minDuration = fixNull(in.readLong()); minSize = fixNull(in.readInt()); state = TransactionState.fromOrdinal(in.readByte()); proj = VisorTxProjection.fromOrdinal(in.readByte()); consistentIds = U.readList(in); lbRegex = fixNull(in.readUTF()); xid = fixNull(in.readUTF()); sortOrder = VisorTxSortOrder.fromOrdinal(in.readByte()); }
/** * Writes {@link MvccTxRecord} to given buffer. * * @param rec MvccTxRecord. * @param buf Byte buffer. * @throws IgniteCheckedException In case of fail. */ public void write(MvccTxRecord rec, ByteBuffer buf) throws IgniteCheckedException { buf.put((byte)rec.state().ordinal()); RecordV1Serializer.putVersion(buf, rec.nearXidVersion(), true); RecordV1Serializer.putVersion(buf, rec.writeVersion(), true); putMvccVersion(buf, rec.mvccVersion()); Map<Short, Collection<Short>> participatingNodes = rec.participatingNodes(); if (participatingNodes != null && !participatingNodes.isEmpty()) { buf.putInt(participatingNodes.size()); for (Map.Entry<Short, Collection<Short>> e : participatingNodes.entrySet()) { buf.putShort(e.getKey()); Collection<Short> backupNodes = e.getValue(); buf.putInt(backupNodes.size()); for (short backupNode : backupNodes) buf.putShort(backupNode); } } else buf.putInt(0); // Put zero size of participating nodes. buf.putLong(rec.timestamp()); }
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { xid = U.readGridUuid(in); duration = in.readLong(); isolation = TransactionIsolation.fromOrdinal(in.readByte()); concurrency = TransactionConcurrency.fromOrdinal(in.readByte()); timeout = in.readLong(); lb = U.readString(in); primaryNodes = U.readCollection(in); state = TransactionState.fromOrdinal(in.readByte()); size = in.readInt(); if (protoVer >= V2) { nearXid = U.readGridUuid(in); masterNodeIds = U.readCollection(in); startTime = in.readLong(); } if (protoVer >= V3) { long topVer = in.readLong(); int minorTopVer = in.readInt(); if (topVer != -1) this.topVer = new AffinityTopologyVersion(topVer, minorTopVer); } }
/** * @param id Transaction ID. * @return Transaction state. */ private int txClose(long id) { Transaction tx = tx(id); try { tx.close(); return tx.state().ordinal(); } finally { unregisterTx(id); } }
/** * Reads {@link TxRecord} from given input. * * @param in Input * @return TxRecord. * @throws IOException In case of fail. */ public TxRecord readTx(ByteBufferBackedDataInput in) throws IOException { byte txState = in.readByte(); TransactionState state = TransactionState.fromOrdinal(txState); GridCacheVersion nearXidVer = RecordV1Serializer.readVersion(in, true); GridCacheVersion writeVer = RecordV1Serializer.readVersion(in, true); int participatingNodesSize = in.readInt(); Map<Short, Collection<Short>> participatingNodes = U.newHashMap(participatingNodesSize); for (int i = 0; i < participatingNodesSize; i++) { short primaryNode = in.readShort(); int backupNodesSize = in.readInt(); Collection<Short> backupNodes = new ArrayList<>(backupNodesSize); for (int j = 0; j < backupNodesSize; j++) { short backupNode = in.readShort(); backupNodes.add(backupNode); } participatingNodes.put(primaryNode, backupNodes); } long ts = in.readLong(); return new TxRecord(state, nearXidVer, writeVer, participatingNodes, ts); }
/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_PREPARE: ((TransactionProxyImpl)tx(val)).tx().prepare(true); return TRUE; case OP_COMMIT: tx(val).commit(); return txClose(val); case OP_ROLLBACK: tx(val).rollback(); return txClose(val); case OP_CLOSE: return txClose(val); case OP_SET_ROLLBACK_ONLY: return tx(val).setRollbackOnly() ? TRUE : FALSE; case OP_STATE: return tx(val).state().ordinal(); case OP_RESET_METRICS: txs.resetMetrics(); return TRUE; } return super.processInLongOutLong(type, val); }
/** * Reads {@link MvccTxRecord} from given input. * * @param in Input * @return MvccTxRecord. * @throws IOException In case of fail. */ public MvccTxRecord readMvccTx(ByteBufferBackedDataInput in) throws IOException { byte txState = in.readByte(); TransactionState state = TransactionState.fromOrdinal(txState); GridCacheVersion nearXidVer = RecordV1Serializer.readVersion(in, true); GridCacheVersion writeVer = RecordV1Serializer.readVersion(in, true); MvccVersion mvccVer = readMvccVersion(in); int participatingNodesSize = in.readInt(); Map<Short, Collection<Short>> participatingNodes = U.newHashMap(participatingNodesSize); for (int i = 0; i < participatingNodesSize; i++) { short primaryNode = in.readShort(); int backupNodesSize = in.readInt(); Collection<Short> backupNodes = new ArrayList<>(backupNodesSize); for (int j = 0; j < backupNodesSize; j++) { short backupNode = in.readShort(); backupNodes.add(backupNode); } participatingNodes.put(primaryNode, backupNodes); } long ts = in.readLong(); return new MvccTxRecord(state, nearXidVer, writeVer, participatingNodes, mvccVer, ts); }
/** {@inheritDoc} */ @Override public void writeExternal(ObjectOutput out) throws IOException { writeExternalMeta(out); out.writeObject(xidVer); out.writeBoolean(invalidate); out.writeLong(timeout); out.writeLong(threadId); out.writeLong(startTime); U.writeUuid(out, nodeId); out.write(isolation.ordinal()); out.write(concurrency.ordinal()); out.write(state().ordinal()); }
/** {@inheritDoc} */ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { readExternalMeta(in); xidVer = (GridCacheVersion)in.readObject(); invalidate = in.readBoolean(); timeout = in.readLong(); threadId = in.readLong(); startTime = in.readLong(); nodeId = U.readUuid(in); isolation = TransactionIsolation.fromOrdinal(in.read()); concurrency = TransactionConcurrency.fromOrdinal(in.read()); state = TransactionState.fromOrdinal(in.read()); }
/** * Writes {@link TxRecord} to given buffer. * * @param rec TxRecord. * @param buf Byte buffer. */ public void write(TxRecord rec, ByteBuffer buf) { buf.put((byte)rec.state().ordinal()); RecordV1Serializer.putVersion(buf, rec.nearXidVersion(), true); RecordV1Serializer.putVersion(buf, rec.writeVersion(), true); Map<Short, Collection<Short>> participatingNodes = rec.participatingNodes(); if (participatingNodes != null && !participatingNodes.isEmpty()) { buf.putInt(participatingNodes.size()); for (Map.Entry<Short, Collection<Short>> e : participatingNodes.entrySet()) { buf.putShort(e.getKey()); Collection<Short> backupNodes = e.getValue(); buf.putInt(backupNodes.size()); for (short backupNode : backupNodes) buf.putShort(backupNode); } } else buf.putInt(0); // Put zero size of participating nodes. buf.putLong(rec.timestamp()); }
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { op = VisorTxOperation.fromOrdinal(in.readByte()); limit = fixNull(in.readInt()); minDuration = fixNull(in.readLong()); minSize = fixNull(in.readInt()); state = TransactionState.fromOrdinal(in.readByte()); proj = VisorTxProjection.fromOrdinal(in.readByte()); consistentIds = U.readList(in); lbRegex = fixNull(in.readUTF()); xid = fixNull(in.readUTF()); sortOrder = VisorTxSortOrder.fromOrdinal(in.readByte()); }
/** * Writes {@link MvccTxRecord} to given buffer. * * @param rec MvccTxRecord. * @param buf Byte buffer. * @throws IgniteCheckedException In case of fail. */ public void write(MvccTxRecord rec, ByteBuffer buf) throws IgniteCheckedException { buf.put((byte)rec.state().ordinal()); RecordV1Serializer.putVersion(buf, rec.nearXidVersion(), true); RecordV1Serializer.putVersion(buf, rec.writeVersion(), true); putMvccVersion(buf, rec.mvccVersion()); Map<Short, Collection<Short>> participatingNodes = rec.participatingNodes(); if (participatingNodes != null && !participatingNodes.isEmpty()) { buf.putInt(participatingNodes.size()); for (Map.Entry<Short, Collection<Short>> e : participatingNodes.entrySet()) { buf.putShort(e.getKey()); Collection<Short> backupNodes = e.getValue(); buf.putInt(backupNodes.size()); for (short backupNode : backupNodes) buf.putShort(backupNode); } } else buf.putInt(0); // Put zero size of participating nodes. buf.putLong(rec.timestamp()); }
/** {@inheritDoc} */ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException { xid = U.readGridUuid(in); duration = in.readLong(); isolation = TransactionIsolation.fromOrdinal(in.readByte()); concurrency = TransactionConcurrency.fromOrdinal(in.readByte()); timeout = in.readLong(); lb = U.readString(in); primaryNodes = U.readCollection(in); state = TransactionState.fromOrdinal(in.readByte()); size = in.readInt(); if (protoVer >= V2) { nearXid = U.readGridUuid(in); masterNodeIds = U.readCollection(in); startTime = in.readLong(); } if (protoVer >= V3) { long topVer = in.readLong(); int minorTopVer = in.readInt(); if (topVer != -1) this.topVer = new AffinityTopologyVersion(topVer, minorTopVer); } }
/** * @param id Transaction ID. * @return Transaction state. */ private int txClose(long id) { Transaction tx = tx(id); try { tx.close(); return tx.state().ordinal(); } finally { unregisterTx(id); } }
/** * Reads {@link TxRecord} from given input. * * @param in Input * @return TxRecord. * @throws IOException In case of fail. */ public TxRecord readTx(ByteBufferBackedDataInput in) throws IOException { byte txState = in.readByte(); TransactionState state = TransactionState.fromOrdinal(txState); GridCacheVersion nearXidVer = RecordV1Serializer.readVersion(in, true); GridCacheVersion writeVer = RecordV1Serializer.readVersion(in, true); int participatingNodesSize = in.readInt(); Map<Short, Collection<Short>> participatingNodes = U.newHashMap(participatingNodesSize); for (int i = 0; i < participatingNodesSize; i++) { short primaryNode = in.readShort(); int backupNodesSize = in.readInt(); Collection<Short> backupNodes = new ArrayList<>(backupNodesSize); for (int j = 0; j < backupNodesSize; j++) { short backupNode = in.readShort(); backupNodes.add(backupNode); } participatingNodes.put(primaryNode, backupNodes); } long ts = in.readLong(); return new TxRecord(state, nearXidVer, writeVer, participatingNodes, ts); }
/** {@inheritDoc} */ @Override public long processInLongOutLong(int type, long val) throws IgniteCheckedException { switch (type) { case OP_PREPARE: ((TransactionProxyImpl)tx(val)).tx().prepare(true); return TRUE; case OP_COMMIT: tx(val).commit(); return txClose(val); case OP_ROLLBACK: tx(val).rollback(); return txClose(val); case OP_CLOSE: return txClose(val); case OP_SET_ROLLBACK_ONLY: return tx(val).setRollbackOnly() ? TRUE : FALSE; case OP_STATE: return tx(val).state().ordinal(); case OP_RESET_METRICS: txs.resetMetrics(); return TRUE; } return super.processInLongOutLong(type, val); }