Skip to content

Kill queries #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ public StatementResult run( Statement statement )
return cursor;
}

public void kill()
{
ensureNoUnrecoverableError();
ensureConnectionIsOpen();

connection.resetAndFlushAsync();
}

@Override
public boolean isOpen()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ public boolean hasUnrecoverableErrors()
return delegate.hasUnrecoverableErrors();
}

@Override
public void resetAndFlushAsync()
{
delegate.resetAndFlushAsync();
}

private void markAsAvailable()
{
inUse.set( false );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,11 @@ public boolean hasUnrecoverableErrors()
{
throw new UnsupportedOperationException( "Unrecoverable error detection is not supported on SocketConnection." );
}

@Override
public void resetAndFlushAsync()
{
reset();
flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ public boolean hasUnrecoverableErrors()
return unrecoverableErrorsOccurred;
}

@Override
public void resetAndFlushAsync()
{
try
{
delegate.resetAndFlushAsync();
}
catch( RuntimeException e )
{
onDelegateException( e );
}
}

public void dispose()
{
delegate.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,9 @@ public interface Connection extends AutoCloseable


boolean hasUnrecoverableErrors();

/**
* Asynchronously sending reset and flush to the socket output channel.
*/
void resetAndFlushAsync();
}
5 changes: 4 additions & 1 deletion driver/src/main/java/org/neo4j/driver/v1/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ public interface Session extends Resource, StatementRunner
*/
Transaction beginTransaction();


/**
* Stop running more statements in this session and rest the session to a clean state.
*/
void kill();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per earlier conversation, this should be named reset and could be described as follows:

/**
 * Reset the current session. This sends an immediate RESET signal to the server which both interrupts
 * any statement that is currently executing and ignores any subsequently queued statements. Following
 * the reset, the current transaction will have been rolled back and any outstanding failures will
 * have been acknowledged.
 */
void reset();

/**
* Signal that you are done using this session. In the default driver usage, closing
* and accessing sessions is very low cost, because sessions are pooled by {@link Driver}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ public Transaction beginTransaction()
return realSession.beginTransaction();
}

@Override
public void kill()
{
realSession.kill();
}

@Override
public StatementResult run( String statementText, Map<String,Object> statementParameters )
{
Expand Down