Repository: ignite
Updated Branches:
  refs/heads/ignite-8446 6cfb715cb -> b62054101


8446

Signed-off-by: Anton Vinogradov <a...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b6205410
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b6205410
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b6205410

Branch: refs/heads/ignite-8446
Commit: b6205410196a11817162de2349ddcdbf47d238d9
Parents: 6cfb715
Author: Anton Vinogradov <a...@apache.org>
Authored: Wed Jun 27 15:42:40 2018 +0300
Committer: Anton Vinogradov <a...@apache.org>
Committed: Wed Jun 27 15:42:40 2018 +0300

----------------------------------------------------------------------
 .../cache/transactions/IgniteTxAdapter.java     |   2 +-
 .../transactions/TransactionEventProxyImpl.java | 209 +++++++++++++++++++
 2 files changed, 210 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b6205410/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index c455466..d9eff2d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1211,7 +1211,7 @@ public abstract class IgniteTxAdapter extends 
GridMetadataAwareAdapter implement
 
         if (!system() /* ignoring system tx */ && evtMgr.isRecordable(type))
             evtMgr.record(new TransactionStateChangedEvent(
-                cctx.discovery().localNode(), null, type, 
((GridNearTxLocal)this).proxy()));
+                cctx.discovery().localNode(), null, type, 
((GridNearTxLocal)this).rollbackOnlyProxy()));
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/b6205410/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionEventProxyImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionEventProxyImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionEventProxyImpl.java
new file mode 100644
index 0000000..55ec513
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TransactionEventProxyImpl.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.transactions;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.events.TransactionStateChangedEvent;
+import org.apache.ignite.lang.IgniteAsyncSupport;
+import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.apache.ignite.transactions.TransactionState;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Transaction proxy used at tx events.
+ *
+ * @see TransactionStateChangedEvent
+ */
+public class TransactionEventProxyImpl implements TransactionProxy, 
Externalizable {
+    /** Xid. */
+    private IgniteUuid xid;
+
+    /** Tx proxy. */
+    private TransactionProxy tx;
+
+    /**
+     * Default constructor (required by Externalizable).
+     */
+    public TransactionEventProxyImpl() {
+    }
+
+    /**
+     * @param xid Xid.
+     * @param tx Tx proxy.
+     */
+    public TransactionEventProxyImpl(IgniteUuid xid, TransactionProxy tx) {
+        assert xid != null;
+        assert tx != null;
+
+        this.xid = xid;
+        this.tx = tx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteUuid xid() {
+        return xid;
+    }
+
+    /** {@inheritDoc} */
+    @Override public UUID nodeId() {
+        return tx().nodeId();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long threadId() {
+        return tx().threadId();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long startTime() {
+        return tx().startTime();
+    }
+
+    /** {@inheritDoc} */
+    @Override public TransactionIsolation isolation() {
+        return tx().isolation();
+    }
+
+    /** {@inheritDoc} */
+    @Override public TransactionConcurrency concurrency() {
+        return tx().concurrency();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean implicit() {
+        return tx().implicit();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isInvalidate() {
+        return tx().isInvalidate();
+    }
+
+    /** {@inheritDoc} */
+    @Override public TransactionState state() {
+        return tx().state();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long timeout() {
+        return tx().timeout();
+    }
+
+    /** {@inheritDoc} */
+    @Override public long timeout(long timeout) {
+        return tx().timeout(timeout);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean setRollbackOnly() {
+        return tx().setRollbackOnly();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isRollbackOnly() {
+        return tx().isRollbackOnly();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void commit() throws IgniteException {
+        tx().commit();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> commitAsync() throws IgniteException {
+        return tx().commitAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void close() throws IgniteException {
+        tx().close();
+        ;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void rollback() throws IgniteException {
+        tx().rollback();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteFuture<Void> rollbackAsync() throws IgniteException 
{
+        return tx().rollbackAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void resume() throws IgniteException {
+        tx().resume();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void suspend() throws IgniteException {
+        tx().suspend();
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public String label() {
+        return tx().label();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteAsyncSupport withAsync() {
+        return tx().withAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isAsync() {
+        return tx().isAsync();
+    }
+
+    /** {@inheritDoc} */
+    @Override public <R> IgniteFuture<R> future() {
+        return tx().future();
+    }
+
+    /**
+     * @return local transaction
+     * @throws IgniteException in case tx was not found.
+     */
+    private Transaction tx() throws IgniteException {
+        if (tx == null)
+            throw new IgniteException("Operation allowed only inside remote 
listener or " +
+                "inside local listener registered on originating node. " +
+                "Only xid() operation allowed in other cases. ");
+
+        return tx;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeObject(xid);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+        xid = (IgniteUuid)in.readObject();
+    }
+}

Reply via email to