Skip to content

Commit

Permalink
Add some javadocs and clarifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaDemianenko committed Aug 22, 2016
1 parent 08cd588 commit 1ee13e4
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 27 deletions.
Expand Up @@ -206,9 +206,6 @@ public abstract class GraphDatabaseSettings
@Description("The maximum time interval of a transaction within which it should be completed.") @Description("The maximum time interval of a transaction within which it should be completed.")
public static final Setting<Long> transaction_timeout = setting( "dbms.transaction.timeout", DURATION, "60s" ); public static final Setting<Long> transaction_timeout = setting( "dbms.transaction.timeout", DURATION, "60s" );


@Description("The maximum time interval of a query within which it should be completed.")
public static final Setting<Long> statement_timeout = setting( "dbms.statement.timeout", DURATION, "10s" );

@Description( "The maximum amount of time to wait for running transactions to complete before allowing " @Description( "The maximum amount of time to wait for running transactions to complete before allowing "
+ "initiated database shutdown to continue" ) + "initiated database shutdown to continue" )
@Internal @Internal
Expand Down
Expand Up @@ -37,13 +37,32 @@
public interface GraphDatabaseQueryService public interface GraphDatabaseQueryService
{ {
DependencyResolver getDependencyResolver(); DependencyResolver getDependencyResolver();

Node createNode(); Node createNode();

Node createNode( Label... labels ); Node createNode( Label... labels );
Node getNodeById(long id);
Relationship getRelationshipById(long id);


Node getNodeById( long id );

Relationship getRelationshipById( long id );

/**
* Begin new internal transaction with with default timeout.
*
* @param type transaction type
* @param accessMode transaction access mode
* @return internal transaction
*/
InternalTransaction beginTransaction( KernelTransaction.Type type, AccessMode accessMode ); InternalTransaction beginTransaction( KernelTransaction.Type type, AccessMode accessMode );


/**
* Begin new internal transaction with specified timeout in milliseconds.
*
* @param type transaction type
* @param accessMode transaction access mode
* @param timeout transaction timeout in milliseconds
* @return internal transaction
*/
InternalTransaction beginTransaction( KernelTransaction.Type type, AccessMode accessMode, long timeout ); InternalTransaction beginTransaction( KernelTransaction.Type type, AccessMode accessMode, long timeout );


URL validateURLAccess( URL url ) throws URLAccessValidationError; URL validateURLAccess( URL url ) throws URLAccessValidationError;
Expand Down
Expand Up @@ -46,11 +46,11 @@ public interface KernelAPI


/** /**
* Creates and returns a new {@link KernelTransaction} capable of modifying the * Creates and returns a new {@link KernelTransaction} capable of modifying the
* underlying graph. * underlying graph with custom timeout in milliseconds.
* *
* @param type the type of the new transaction: implicit (internally created) or explicit (created by the user) * @param type the type of the new transaction: implicit (internally created) or explicit (created by the user)
* @param accessMode transaction access mode * @param accessMode transaction access mode
* @param timeout transaction timeout * @param timeout transaction timeout in millisiseconds
*/ */
KernelTransaction newTransaction( KernelTransaction.Type type, AccessMode accessMode, long timeout ) KernelTransaction newTransaction( KernelTransaction.Type type, AccessMode accessMode, long timeout )
throws TransactionFailureException; throws TransactionFailureException;
Expand Down
Expand Up @@ -21,6 +21,10 @@


import org.neo4j.kernel.impl.api.KernelStatement; import org.neo4j.kernel.impl.api.KernelStatement;


/**
* Guard that check entities for compatibility with some kind of guard criteria.
* As soon as entity do not satisfy that criteria {@link GuardException } will be thrown.
*/
public interface Guard public interface Guard
{ {
void check( KernelStatement statement ); void check( KernelStatement statement );
Expand Down
Expand Up @@ -25,6 +25,10 @@
import org.neo4j.kernel.impl.api.KernelTransactionImplementation; import org.neo4j.kernel.impl.api.KernelTransactionImplementation;
import org.neo4j.logging.Log; import org.neo4j.logging.Log;


/**
* Guard that checks kernel transaction for timeout.
* As soon as transaction timeout time reached {@link GuardTimeoutException } will be thrown.
*/
public class TimeoutGuard implements Guard public class TimeoutGuard implements Guard
{ {
private final Log log; private final Log log;
Expand Down
Expand Up @@ -149,7 +149,7 @@ public interface SPI
KernelTransaction beginTransaction( KernelTransaction.Type type, AccessMode accessMode ); KernelTransaction beginTransaction( KernelTransaction.Type type, AccessMode accessMode );


/** /**
* Begin a new kernel transaction with specified timeout. * Begin a new kernel transaction with specified timeout in milliseconds.
* If a transaction is already associated to the current context * If a transaction is already associated to the current context
* (meaning, non-null is returned from {@link #currentTransaction()}), this should fail. * (meaning, non-null is returned from {@link #currentTransaction()}), this should fail.
* *
Expand Down
Expand Up @@ -51,6 +51,10 @@ public interface TransactionalContext


Statement statement(); Statement statement();


/**
* Check that current context satisfy current execution guard.
* In case if guard criteria is not satisfied {@link org.neo4j.kernel.guard.GuardException} will be thrown.
*/
void check(); void check();


TxStateHolder stateView(); TxStateHolder stateView();
Expand Down
Expand Up @@ -42,7 +42,6 @@
public class TimeoutGuardTest extends KernelTransactionTestBase public class TimeoutGuardTest extends KernelTransactionTestBase
{ {


private static final long STATEMENT_TEST_TIMEOUT = 1000L;
private AssertableLogProvider logProvider = new AssertableLogProvider( true ); private AssertableLogProvider logProvider = new AssertableLogProvider( true );


@Before @Before
Expand All @@ -69,24 +68,7 @@ public void detectTimedTransaction()
} }


@Test @Test
public void detectTimedStatement() public void allowToProceedWhenTransactionTimeoutNotReached()
{
long transactionTimeout = 100000L;
long overtime = 5L;
TimeoutGuard timeoutGuard = buildGuard( logProvider );
initClock();

KernelStatement kernelStatement = getKernelStatement( transactionTimeout );
clock.forward( STATEMENT_TEST_TIMEOUT + overtime, TimeUnit.MILLISECONDS );
String message = "Statement timeout. (Overtime: 5 ms).";

check( timeoutGuard, kernelStatement, overtime, message );

logProvider.assertContainsMessageContaining( message );
}

@Test
public void allowToProceedWhenStatementAndTransactionTimeoutNotReached()
{ {
long transactionTimeout = 100000L; long transactionTimeout = 100000L;
long overtime = 5L; long overtime = 5L;
Expand Down

0 comments on commit 1ee13e4

Please sign in to comment.