diff options
author | Tschaen, Brendan <ctschaen@att.com> | 2019-04-16 09:51:58 -0400 |
---|---|---|
committer | Tschaen, Brendan <ctschaen@att.com> | 2019-04-16 09:51:58 -0400 |
commit | eff522e4e38b11432f518d1b43fda01d8d387ca4 (patch) | |
tree | e6a1d44ec07874cb40b40788563ea51b7c6669f6 /mdbc-server | |
parent | 1ec38875f207407ad8f4dc5b428e5ca47f016d5f (diff) |
Row re-use fix
This prevents rows from being split properly, will follow up on issue
Change-Id: I6d9ebbf8cf9abd2cac4992be407fb6cb44cb318b
Issue-ID: MUSIC-326
Signed-off-by: Tschaen, Brendan <ctschaen@att.com>
Diffstat (limited to 'mdbc-server')
3 files changed, 23 insertions, 8 deletions
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java index 4204960..c8cad47 100755 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java @@ -195,4 +195,18 @@ public class DatabasePartition { } return false; } + + /** + * Checks if the database partition contains all of the ranges + * @param ranges + * @return + */ + public synchronized boolean contains(List<Range> ranges) { + for (Range range: ranges) { + if (!isContained(range)) { + return false; + } + } + return true; + } }
\ No newline at end of file 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 e41b7c0..cb37a55 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 @@ -2124,7 +2124,8 @@ public class MusicMixin implements MusicInterface { 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) { + + if (latestRows.size()==1 && latestRows.get(0).getDBPartition().contains(ranges)) { //reuse current row if possible MusicRangeInformationRow row = latestRows.get(0); LockResult lockresult = locks.get(row.getPartitionIndex()); 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 8823b81..110cc80 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 @@ -293,8 +293,8 @@ public class OwnershipAndCheckpoint{ //Find Map<UUID,LockResult> newLocks = new HashMap<>(); List<Range> rangesToOwn = mi.getRangeDependencies(ranges); - List<MusicRangeInformationRow> rows = extractRowsForRange(mi,rangesToOwn, false); - Dag toOwn = Dag.getDag(rows,rangesToOwn); + List<MusicRangeInformationRow> rangesToOwnRows = extractRowsForRange(mi,rangesToOwn, false); + Dag toOwn = Dag.getDag(rangesToOwnRows,rangesToOwn); Dag currentlyOwn = new Dag(); while ( (toOwn.isDifferent(currentlyOwn) || !currentlyOwn.isOwned() ) && !timeout(opId) @@ -302,8 +302,8 @@ public class OwnershipAndCheckpoint{ takeOwnershipOfDag(mi, currPartition, opId, newLocks, toOwn); currentlyOwn=toOwn; //TODO instead of comparing dags, compare rows - rows = extractRowsForRange(mi, rangesToOwn, false); - toOwn = Dag.getDag(rows,rangesToOwn); + rangesToOwnRows = extractRowsForRange(mi, rangesToOwn, false); + toOwn = Dag.getDag(rangesToOwnRows,rangesToOwn); } if (!currentlyOwn.isOwned() || toOwn.isDifferent(currentlyOwn)) { //hold on to previous partition @@ -314,9 +314,9 @@ public class OwnershipAndCheckpoint{ throw new MDBCServiceException("Ownership timeout"); } Set<Range> allRanges = currentlyOwn.getAllRanges(); - List<MusicRangeInformationRow> isLatestRows = extractRowsForRange(mi, new ArrayList<>(allRanges), true); - currentlyOwn.setRowsPerLatestRange(getIsLatestPerRange(toOwn,isLatestRows)); - return mi.mergeLatestRowsIfNecessary(currentlyOwn,rows,ranges,newLocks,opId); + List<MusicRangeInformationRow> latestRows = extractRowsForRange(mi, new ArrayList<>(allRanges), true); + currentlyOwn.setRowsPerLatestRange(getIsLatestPerRange(toOwn,latestRows)); + return mi.mergeLatestRowsIfNecessary(currentlyOwn,latestRows,ranges,newLocks,opId); } /** |