Esempio n. 1
0
  /** {@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);
  }
Esempio n. 2
0
  /** {@inheritDoc} */
  @Override
  protected long processInStreamOutLong(int type, BinaryRawReaderEx reader)
      throws IgniteCheckedException {
    long txId = reader.readLong();

    final Transaction asyncTx = (Transaction) tx(txId).withAsync();

    switch (type) {
      case OP_COMMIT_ASYNC:
        asyncTx.commit();

        break;

      case OP_ROLLBACK_ASYNC:
        asyncTx.rollback();

        break;

      default:
        return super.processInStreamOutLong(type, reader);
    }

    // Future result is the tx itself, we do not want to return it to the platform.
    IgniteFuture fut =
        asyncTx
            .future()
            .chain(
                new C1<IgniteFuture, Object>() {
                  private static final long serialVersionUID = 0L;

                  @Override
                  public Object apply(IgniteFuture fut) {
                    return null;
                  }
                });

    readAndListenFuture(reader, fut);

    return TRUE;
  }