/** {@inheritDoc} */
  @Override
  protected void processInStreamOutStream(
      int type, BinaryRawReaderEx reader, BinaryRawWriterEx writer) throws IgniteCheckedException {
    switch (type) {
      case OP_START:
        {
          TransactionConcurrency txConcurrency =
              TransactionConcurrency.fromOrdinal(reader.readInt());

          assert txConcurrency != null;

          TransactionIsolation txIsolation = TransactionIsolation.fromOrdinal(reader.readInt());

          assert txIsolation != null;

          Transaction tx =
              txs.txStart(txConcurrency, txIsolation, reader.readLong(), reader.readInt());

          long id = registerTx(tx);

          writer.writeLong(id);

          return;
        }
    }

    super.processInStreamOutStream(type, reader, writer);
  }
  /** {@inheritDoc} */
  @Override
  protected void processOutStream(int type, BinaryRawWriterEx writer)
      throws IgniteCheckedException {
    switch (type) {
      case OP_CACHE_CONFIG_PARAMETERS:
        TransactionConfiguration txCfg =
            platformCtx.kernalContext().config().getTransactionConfiguration();

        writer.writeInt(txCfg.getDefaultTxConcurrency().ordinal());
        writer.writeInt(txCfg.getDefaultTxIsolation().ordinal());
        writer.writeLong(txCfg.getDefaultTxTimeout());

        break;

      case OP_METRICS:
        TransactionMetrics metrics = txs.metrics();

        writer.writeTimestamp(new Timestamp(metrics.commitTime()));
        writer.writeTimestamp(new Timestamp(metrics.rollbackTime()));
        writer.writeInt(metrics.txCommits());
        writer.writeInt(metrics.txRollbacks());

        break;

      default:
        super.processOutStream(type, writer);
    }
  }
  /** {@inheritDoc} */
  @Override
  protected void processOutStream(int type, final BinaryRawWriterEx writer)
      throws IgniteCheckedException {
    switch (type) {
      case OP_GET_BATCH:
        {
          assert iter != null : "iterator() has not been called";

          try {
            int cntPos = writer.reserveInt();

            int cnt;

            for (cnt = 0; cnt < batchSize; cnt++) {
              if (iter.hasNext()) write(writer, iter.next());
              else break;
            }

            writer.writeInt(cntPos, cnt);
          } catch (Exception err) {
            throw PlatformUtils.unwrapQueryException(err);
          }

          break;
        }

      case OP_GET_SINGLE:
        {
          assert iter != null : "iterator() has not been called";

          try {
            if (iter.hasNext()) {
              write(writer, iter.next());

              return;
            }
          } catch (Exception err) {
            throw PlatformUtils.unwrapQueryException(err);
          }

          throw new IgniteCheckedException("No more data available.");
        }

      case OP_GET_ALL:
        {
          try {
            int pos = writer.reserveInt();

            Consumer<T> consumer = new Consumer<>(this, writer);

            cursor.getAll(consumer);

            writer.writeInt(pos, consumer.cnt);
          } catch (Exception err) {
            throw PlatformUtils.unwrapQueryException(err);
          }

          break;
        }

      default:
        super.processOutStream(type, writer);
    }
  }