aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Martella <arthur.martella.1@att.com>2019-06-25 16:27:00 -0400
committerTschaen, Brendan <ctschaen@att.com>2019-06-25 16:57:17 -0400
commitbdec440ecc0854529c60659683cd3acd4696fd1c (patch)
treeb5070e6c9d9e904668736615b875eae8295b1cc3
parentdcdded9d153295c176053c245772a67eef222aa8 (diff)
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 <arthur.martella.1@att.com> Change-Id: Ibdbc8c91da103b8058e46f8995f54e349a41afbd
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java34
1 files changed, 19 insertions, 15 deletions
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;