Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made
PULL_ALL
and DISCARD_ALL
response return bookmark for auto t…
…x only On the other hand, bookmark will only return in response of `COMMIT` for explicit tx
- Loading branch information
Showing
11 changed files
with
359 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
community/bolt/src/main/java/org/neo4j/bolt/v3/runtime/AbstractStreamingState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.bolt.v3.runtime; | ||
|
||
import org.neo4j.bolt.messaging.RequestMessage; | ||
import org.neo4j.bolt.runtime.BoltConnectionFatality; | ||
import org.neo4j.bolt.runtime.BoltStateMachineState; | ||
import org.neo4j.bolt.runtime.StateMachineContext; | ||
import org.neo4j.bolt.v1.messaging.request.DiscardAllMessage; | ||
import org.neo4j.bolt.v1.messaging.request.InterruptSignal; | ||
import org.neo4j.bolt.v1.messaging.request.PullAllMessage; | ||
|
||
import static org.neo4j.util.Preconditions.checkState; | ||
|
||
/** | ||
* When STREAMING, a result is available as a stream of records. | ||
* These must be PULLed or DISCARDed before any further statements | ||
* can be executed. | ||
*/ | ||
public abstract class AbstractStreamingState extends FailSafeBoltStateMachineState | ||
{ | ||
protected BoltStateMachineState readyState; | ||
private BoltStateMachineState interruptedState; | ||
|
||
@Override | ||
public BoltStateMachineState process( RequestMessage message, StateMachineContext context ) throws BoltConnectionFatality | ||
{ | ||
assertInitialized(); | ||
if ( message instanceof PullAllMessage ) | ||
{ | ||
return processPullAllMessage( context ); | ||
} | ||
if ( message instanceof DiscardAllMessage ) | ||
{ | ||
return processDiscardAllMessage( context ); | ||
} | ||
if ( message instanceof InterruptSignal ) | ||
{ | ||
return interruptedState; | ||
} | ||
return null; | ||
} | ||
|
||
public void setReadyState( BoltStateMachineState readyState ) | ||
{ | ||
this.readyState = readyState; | ||
} | ||
|
||
public void setInterruptedState( BoltStateMachineState interruptedState ) | ||
{ | ||
this.interruptedState = interruptedState; | ||
} | ||
|
||
private BoltStateMachineState processPullAllMessage( StateMachineContext context ) throws BoltConnectionFatality | ||
{ | ||
return processMessage( context, () -> processStreamResultMessage( true, context ) ); | ||
} | ||
|
||
private BoltStateMachineState processDiscardAllMessage( StateMachineContext context ) throws BoltConnectionFatality | ||
{ | ||
return processMessage( context, () -> processStreamResultMessage( false, context ) ); | ||
} | ||
|
||
abstract BoltStateMachineState processStreamResultMessage( boolean pull, StateMachineContext context ) throws Throwable; | ||
|
||
private void assertInitialized() | ||
{ | ||
checkState( readyState != null, "Ready state not set" ); | ||
checkState( interruptedState != null, "Interrupted state not set" ); | ||
checkState( failedState != null, "Failed state not set" ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
community/bolt/src/main/java/org/neo4j/bolt/v3/runtime/TransactionStreamingState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2002-2018 "Neo4j," | ||
* Neo4j Sweden AB [http://neo4j.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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.neo4j.bolt.v3.runtime; | ||
|
||
import org.neo4j.bolt.runtime.BoltStateMachineState; | ||
import org.neo4j.bolt.runtime.StateMachineContext; | ||
|
||
public class TransactionStreamingState extends AbstractStreamingState | ||
{ | ||
@Override | ||
public String name() | ||
{ | ||
return "TX_STREAMING"; | ||
} | ||
|
||
protected BoltStateMachineState processStreamResultMessage( boolean pull, StateMachineContext context ) throws Throwable | ||
{ | ||
context.connectionState().getStatementProcessor().streamResult( | ||
recordStream -> context.connectionState().getResponseHandler().onRecords( recordStream, pull ) ); | ||
return readyState; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.