Construct {@link KernelStatement} when {@link KernelTransactionImplementation} is constructed
*
For every transaction...
- *
Call {@link #initialize(StatementLocks)} which makes this instance
+ *
Call {@link #initialize(StatementLocks, StatementOperationParts)} which makes this instance
* full available and ready to use. Call when the {@link KernelTransactionImplementation} is initialized.
*
Alternate {@link #acquire()} / {@link #close()} when acquiring / closing a statement for the transaction...
* Temporarily asymmetric number of calls to {@link #acquire()} / {@link #close()} is supported, although in
* the end an equal number of calls must have been issued.
*
To be safe call {@link #forceClose()} at the end of a transaction to force a close of the statement,
* even if there are more than one current call to {@link #acquire()}. This instance is now again ready
- * to be {@link #initialize(StatementLocks) initialized} and used for the transaction
+ * to be {@link #initialize(StatementLocks, StatementOperationParts) initialized} and used for the transaction
* instance again, when it's initialized.
*
*/
@@ -66,18 +66,13 @@ public class KernelStatement implements TxStateHolder, Statement
private int referenceCount;
private volatile ExecutingQueryList executingQueryList;
- public KernelStatement(
- KernelTransactionImplementation transaction,
- TxStateHolder txStateHolder,
- StatementOperationParts operations,
- StorageStatement storeStatement,
- Procedures procedures
- )
+ public KernelStatement( KernelTransactionImplementation transaction,
+ TxStateHolder txStateHolder, StorageStatement storeStatement, Procedures procedures )
{
this.transaction = transaction;
this.txStateHolder = txStateHolder;
this.storeStatement = storeStatement;
- this.facade = new OperationsFacade( transaction, this, operations, procedures );
+ this.facade = new OperationsFacade( transaction, this, procedures );
this.executingQueryList = ExecutingQueryList.EMPTY;
}
@@ -173,9 +168,10 @@ void assertOpen()
}
}
- void initialize( StatementLocks statementLocks )
+ void initialize( StatementLocks statementLocks, StatementOperationParts operationParts )
{
this.statementLocks = statementLocks;
+ facade.initialize( operationParts );
}
public StatementLocks locks()
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactionImplementation.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactionImplementation.java
index 55c03ae08202..b755fc8b3c01 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactionImplementation.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactionImplementation.java
@@ -127,7 +127,7 @@ TransactionWriteState upgradeToSchemaWrites() throws InvalidTransactionTypeKerne
private final SchemaWriteGuard schemaWriteGuard;
private final TransactionHooks hooks;
private final ConstraintIndexCreator constraintIndexCreator;
- private final StatementOperationParts operations;
+ private final StatementOperationContainer operationContainer;
private final StorageEngine storageEngine;
private final TransactionTracer tracer;
private final Pool pool;
@@ -146,6 +146,7 @@ TransactionWriteState upgradeToSchemaWrites() throws InvalidTransactionTypeKerne
private LegacyIndexTransactionState legacyIndexTransactionState;
private TransactionWriteState writeState;
private TransactionHooks.TransactionHooksState hooksState;
+ private StatementOperationParts currentTransactionOperations;
private final KernelStatement currentStatement;
private final StorageStatement storageStatement;
private final List closeListeners = new ArrayList<>( 2 );
@@ -174,7 +175,7 @@ TransactionWriteState upgradeToSchemaWrites() throws InvalidTransactionTypeKerne
*/
private final Lock terminationReleaseLock = new ReentrantLock();
- public KernelTransactionImplementation( StatementOperationParts operations,
+ public KernelTransactionImplementation( StatementOperationContainer operationContainer,
SchemaWriteGuard schemaWriteGuard,
TransactionHooks hooks,
ConstraintIndexCreator constraintIndexCreator,
@@ -188,7 +189,7 @@ public KernelTransactionImplementation( StatementOperationParts operations,
TransactionTracer tracer,
StorageEngine storageEngine )
{
- this.operations = operations;
+ this.operationContainer = operationContainer;
this.schemaWriteGuard = schemaWriteGuard;
this.hooks = hooks;
this.constraintIndexCreator = constraintIndexCreator;
@@ -202,7 +203,7 @@ public KernelTransactionImplementation( StatementOperationParts operations,
this.clock = clock;
this.tracer = tracer;
this.storageStatement = storeLayer.newStatement();
- this.currentStatement = new KernelStatement( this, this, operations, storageStatement, procedures );
+ this.currentStatement = new KernelStatement( this, this, storageStatement, procedures );
}
/**
@@ -226,7 +227,8 @@ public KernelTransactionImplementation initialize(
this.accessMode = accessMode;
this.transactionId = NOT_COMMITTED_TRANSACTION_ID;
this.commitTime = NOT_COMMITTED_TRANSACTION_COMMIT_TIME;
- this.currentStatement.initialize( statementLocks );
+ this.currentTransactionOperations = timeoutMillis > 0 ? operationContainer.guardedParts() : operationContainer.nonGuarderParts();
+ this.currentStatement.initialize( statementLocks, currentTransactionOperations );
return this;
}
@@ -605,7 +607,7 @@ private long commit() throws TransactionFailureException
catch ( ConstraintValidationKernelException | CreateConstraintFailureException e )
{
throw new ConstraintViolationTransactionFailureException(
- e.getUserMessage( new KeyReadTokenNameLookup( operations.keyReadOperations() ) ), e );
+ e.getUserMessage( new KeyReadTokenNameLookup( currentTransactionOperations.keyReadOperations() ) ), e );
}
finally
{
@@ -718,6 +720,7 @@ private void release()
legacyIndexTransactionState = null;
txState = null;
hooksState = null;
+ currentTransactionOperations = null;
closeListeners.clear();
reuseCount++;
pool.release( this );
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactions.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactions.java
index 9321aae31dc6..3a98d9bd509a 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactions.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/KernelTransactions.java
@@ -68,7 +68,7 @@ public class KernelTransactions extends LifecycleAdapter
private final StatementLocksFactory statementLocksFactory;
private final ConstraintIndexCreator constraintIndexCreator;
- private final StatementOperationParts statementOperations;
+ private final StatementOperationContainer statementOperations;
private final SchemaWriteGuard schemaWriteGuard;
private final TransactionHeaderInformationFactory transactionHeaderInformationFactory;
private final TransactionCommitProcess transactionCommitProcess;
@@ -100,7 +100,7 @@ public class KernelTransactions extends LifecycleAdapter
public KernelTransactions( StatementLocksFactory statementLocksFactory,
ConstraintIndexCreator constraintIndexCreator,
- StatementOperationParts statementOperations,
+ StatementOperationContainer statementOperationContainer,
SchemaWriteGuard schemaWriteGuard,
TransactionHeaderInformationFactory txHeaderFactory,
TransactionCommitProcess transactionCommitProcess,
@@ -117,7 +117,7 @@ public KernelTransactions( StatementLocksFactory statementLocksFactory,
{
this.statementLocksFactory = statementLocksFactory;
this.constraintIndexCreator = constraintIndexCreator;
- this.statementOperations = statementOperations;
+ this.statementOperations = statementOperationContainer;
this.schemaWriteGuard = schemaWriteGuard;
this.transactionHeaderInformationFactory = txHeaderFactory;
this.transactionCommitProcess = transactionCommitProcess;
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java
index d9fe54afdbdf..b6152a86c88a 100644
--- a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/OperationsFacade.java
@@ -101,18 +101,22 @@ public class OperationsFacade
{
private final KernelTransaction tx;
private final KernelStatement statement;
- private final StatementOperationParts operations;
private final Procedures procedures;
+ private StatementOperationParts operations;
OperationsFacade( KernelTransaction tx, KernelStatement statement,
- StatementOperationParts operations, Procedures procedures )
+ Procedures procedures )
{
this.tx = tx;
this.statement = statement;
- this.operations = operations;
this.procedures = procedures;
}
+ public void initialize( StatementOperationParts operationParts )
+ {
+ this.operations = operationParts;
+ }
+
final KeyReadOperations tokenRead()
{
return operations.keyReadOperations();
diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StatementOperationContainer.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StatementOperationContainer.java
new file mode 100644
index 000000000000..b064f74d7302
--- /dev/null
+++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/api/StatementOperationContainer.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2002-2016 "Neo Technology,"
+ * Network Engine for Objects in Lund AB [http://neotechnology.com]
+ *
+ * This file is part of Neo4j.
+ *
+ * Neo4j is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.neo4j.kernel.impl.api;
+
+/**
+ * Container for different version of operation parts.
+ * To allow dynamic parts switching depending of transaction nature.
+ *
+ * Currently supported only 2 different kinds of parts:
+ *