From bdec440ecc0854529c60659683cd3acd4696fd1c Mon Sep 17 00:00:00 2001 From: Arthur Martella Date: Tue, 25 Jun 2019 16:27:00 -0400 Subject: Add retry to Music get calls Add 3 retries to Music get calls. Ideally, should allow configuration of number of retries. Issue-ID: MUSIC-416 Signed-off-by: Martella, Arthur Change-Id: Ibdbc8c91da103b8058e46f8995f54e349a41afbd --- .../org/onap/music/mdbc/mixins/MusicMixin.java | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'mdbc-server/src/main') diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java index 71302dd..1bdb022 100644 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java @@ -2270,25 +2270,29 @@ public class MusicMixin implements MusicInterface { private static Row executeMusicLockedGet(String keyspace, String table, PreparedQueryObject cqlObject, String primaryKey, String lock) throws MDBCServiceException{ - ResultSet result; - if(lock != null && !lock.isEmpty()) { - try { - result = MusicCore.criticalGet(keyspace, table, primaryKey, cqlObject, lock); - } catch (MusicServiceException e) { - e.printStackTrace(); - throw new MDBCServiceException("Error executing critical get", e); + ResultSet result = null; + int triesRemaining = 3; + while (result==null && triesRemaining>0) { + if(lock != null && !lock.isEmpty()) { + try { + result = MusicCore.criticalGet(keyspace, table, primaryKey, cqlObject, lock); + } catch (MusicServiceException e) { + e.printStackTrace(); + throw new MDBCServiceException("Error executing critical get", e); + } } - } - else{ - try { - result = MusicCore.atomicGet(keyspace,table,primaryKey,cqlObject); - } catch (MusicServiceException|MusicLockingException|MusicQueryException e) { - e.printStackTrace(); - throw new MDBCServiceException("Error executing atomic get", e); + else{ + try { + result = MusicCore.atomicGet(keyspace,table,primaryKey,cqlObject); + } catch (MusicServiceException|MusicLockingException|MusicQueryException e) { + e.printStackTrace(); + throw new MDBCServiceException("Error executing atomic get", e); + } } + triesRemaining--; } if(result==null){ - throw new MDBCServiceException("Error executing atomic get for primary key: "+primaryKey); + throw new MDBCServiceException("Error executing atomic get for primary key: " + primaryKey + " and lock: " + lock); } if(result.isExhausted()){ return null; -- cgit 1.2.3-korg