aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTschaen, Brendan <ctschaen@att.com>2019-04-04 16:18:51 -0400
committerTschaen, Brendan <ctschaen@att.com>2019-04-04 16:18:51 -0400
commit2fdb8fdb419540fee28f8f98a04001979a45f70e (patch)
treef9a8ff0c3cb9f753c0987af634381782d5b3f6ba
parenta1c1b4ba47e9c8ef1fa4e7b8a3ea8ab272050bae (diff)
Reuse current musicrangeinformation row if possible
Change-Id: I748a43cefada08df42894968698adcf48a635afb Issue-ID: MUSIC-326 Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
-rwxr-xr-xmdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java15
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java12
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java2
3 files changed, 25 insertions, 4 deletions
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java
index 8b91b28..71f1b8b 100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicInterface.java
@@ -313,7 +313,20 @@ public interface MusicInterface {
void releaseLocks(Map<UUID, LockResult> newLocks) throws MDBCServiceException;
- OwnershipReturn mergeLatestRows(Dag extendedDag, List<MusicRangeInformationRow> latestRows, List<Range> ranges,
+ /**
+ * Combine previous musicrangeinformation rows for new partition, if necessary
+ *
+ * Does not merge rows if a single previous row is sufficient to match new partition needed
+ *
+ * @param extendedDag
+ * @param latestRows
+ * @param ranges
+ * @param locks
+ * @param ownershipId
+ * @return
+ * @throws MDBCServiceException
+ */
+ OwnershipReturn mergeLatestRowsIfNecessary(Dag extendedDag, List<MusicRangeInformationRow> latestRows, List<Range> ranges,
Map<UUID, LockResult> locks, UUID ownershipId) throws MDBCServiceException;
}
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 c176ad9..4e8e08e 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
@@ -2110,9 +2110,17 @@ public class MusicMixin implements MusicInterface {
}
@Override
- public OwnershipReturn mergeLatestRows(Dag extendedDag, List<MusicRangeInformationRow> latestRows, List<Range> ranges,
- Map<UUID,LockResult> locks, UUID ownershipId) throws MDBCServiceException{
+ public OwnershipReturn mergeLatestRowsIfNecessary(Dag extendedDag, List<MusicRangeInformationRow> latestRows,
+ List<Range> ranges, Map<UUID, LockResult> locks, UUID ownershipId) throws MDBCServiceException {
recoverFromFailureAndUpdateDag(extendedDag,latestRows,ranges,locks);
+ if (latestRows.size()==1) {
+ //reuse current row if possible
+ MusicRangeInformationRow row = latestRows.get(0);
+ LockResult lockresult = locks.get(row.getPartitionIndex());
+ if (lockresult!=null) {
+ return new OwnershipReturn(ownershipId, lockresult.getLockId(), row.getPartitionIndex(), ranges, extendedDag);
+ }
+ }
List<MusicRangeInformationRow> changed = setReadOnlyAnyDoubleRow(extendedDag, latestRows,locks);
releaseLocks(changed, locks);
MusicRangeInformationRow row = createAndAssignLock(ranges);
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java
index ef98ebd..8823b81 100644
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java
@@ -316,7 +316,7 @@ public class OwnershipAndCheckpoint{
Set<Range> allRanges = currentlyOwn.getAllRanges();
List<MusicRangeInformationRow> isLatestRows = extractRowsForRange(mi, new ArrayList<>(allRanges), true);
currentlyOwn.setRowsPerLatestRange(getIsLatestPerRange(toOwn,isLatestRows));
- return mi.mergeLatestRows(currentlyOwn,rows,ranges,newLocks,opId);
+ return mi.mergeLatestRowsIfNecessary(currentlyOwn,rows,ranges,newLocks,opId);
}
/**