Created
October 5, 2013 16:10
-
-
Save giastfader/6842734 to your computer and use it in GitHub Desktop.
OrientDB: retry edge creation in case of vertex stealing
This file contains hidden or 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
| int maxRetries=MVCC_MAX_RETRIES; | |
| boolean done=false; | |
| OConcurrentModificationException e =null; | |
| for (int i=1;i<=maxRetries;i++){ | |
| try { | |
| Logger.debug("Creation of the edge. Attempt n. " + i); | |
| db.createEdge((ODocument)vertex1.reload().getRecord(),vertex2).save(); | |
| done=true; | |
| Logger.debug("Edge created successfully after " + i + " attempts"); | |
| break; | |
| }catch (OConcurrentModificationException ex){ | |
| e=ex; | |
| Logger.debug ("+++ vertex1 was modified by another thread. Let's retry. This was the attempt n. " + i); | |
| Thread.sleep(1); | |
| } | |
| } | |
| if (!done) throw e; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment