aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Nelson <nelson24@att.com>2019-04-15 18:06:47 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-15 18:06:47 +0000
commitf4152e22bbf9bcde4996ad7a153ace4af99c5f0c (patch)
tree6ffb04fc37d2c3088d4f1a39cc643c01a77e88ea
parent6da3a637d010f0f8d1f06959d39ad91a95ef6c40 (diff)
parent2fdb8fdb419540fee28f8f98a04001979a45f70e (diff)
Merge "Reuse current musicrangeinformation row if possible"
-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 39b1e21..e41b7c0 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
@@ -2121,9 +2121,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);
}
/**