-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For write sessions we throw a SessionExpiredException on connection failures
- Loading branch information
1 parent
d85a610
commit 83afe65
Showing
4 changed files
with
108 additions
and
6 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
50 changes: 50 additions & 0 deletions
50
driver/src/main/java/org/neo4j/driver/internal/WriteNetworkSession.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,50 @@ | ||
/** | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed 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.neo4j.driver.internal; | ||
|
||
|
||
import org.neo4j.driver.internal.spi.Connection; | ||
import org.neo4j.driver.v1.Logger; | ||
import org.neo4j.driver.v1.Statement; | ||
import org.neo4j.driver.v1.StatementResult; | ||
import org.neo4j.driver.v1.exceptions.ConnectionFailureException; | ||
import org.neo4j.driver.v1.exceptions.SessionExpiredException; | ||
|
||
public class WriteNetworkSession extends NetworkSession | ||
{ | ||
|
||
WriteNetworkSession(Connection connection, ClusterSettings clusterSettings, Logger logger ) | ||
{ | ||
super(connection, logger); | ||
} | ||
|
||
@Override | ||
public StatementResult run( Statement statement ) | ||
{ | ||
try | ||
{ | ||
return super.run( statement ); | ||
}//TODO we need to catch exceptions due to leader switches etc here | ||
catch ( ConnectionFailureException e ) | ||
{ | ||
throw new SessionExpiredException( "Failed to perform write load to server", e ); | ||
} | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
driver/src/main/java/org/neo4j/driver/v1/exceptions/SessionExpiredException.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,33 @@ | ||
/** | ||
* Copyright (c) 2002-2016 "Neo Technology," | ||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed 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.neo4j.driver.v1.exceptions; | ||
|
||
/** | ||
* A <em>SessionExpiredException</em> indicates that the session can no longer satisfy the criteria under which it | ||
* was acquired, e.g. a server no longer accepts write requests. A new session needs to be acquired from the driver | ||
* and all actions taken on the expired session must be replayed. | ||
* @since 1.1 | ||
*/ | ||
public class SessionExpiredException extends Neo4jException | ||
{ | ||
public SessionExpiredException( String message, Throwable throwable ) | ||
{ | ||
super( message, throwable ); | ||
} | ||
} |
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