@Override public Long startCacheFlush(byte[] encodedRegionName, Set<byte[]> families) { return this.sequenceIdAccounting.startCacheFlush(encodedRegionName, families); }
@Override public Long startCacheFlush(byte[] encodedRegionName, Map<byte[], Long> familyToSeq) { return this.sequenceIdAccounting.startCacheFlush(encodedRegionName, familyToSeq); }
/** * @param encodedRegionName Region to flush. * @param families Families to flush. May be a subset of all families in the region. * @return Returns {@link HConstants#NO_SEQNUM} if we are flushing the whole region OR if * we are flushing a subset of all families but there are no edits in those families not * being flushed; in other words, this is effectively same as a flush of all of the region * though we were passed a subset of regions. Otherwise, it returns the sequence id of the * oldest/lowest outstanding edit. */ Long startCacheFlush(final byte[] encodedRegionName, final Set<byte[]> families) { Map<byte[],Long> familytoSeq = new HashMap<>(); for (byte[] familyName : families){ familytoSeq.put(familyName,HConstants.NO_SEQNUM); } return startCacheFlush(encodedRegionName,familytoSeq); }
@Test public void testStartCacheFlush() { SequenceIdAccounting sida = new SequenceIdAccounting(); sida.getOrCreateLowestSequenceIds(ENCODED_REGION_NAME); Map<byte[], Long> m = new HashMap<>(); m.put(ENCODED_REGION_NAME, HConstants.NO_SEQNUM); assertEquals(HConstants.NO_SEQNUM, (long)sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES)); sida.completeCacheFlush(ENCODED_REGION_NAME); long sequenceid = 1; sida.update(ENCODED_REGION_NAME, FAMILIES, sequenceid, true); // Only one family so should return NO_SEQNUM still. assertEquals(HConstants.NO_SEQNUM, (long)sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES)); sida.completeCacheFlush(ENCODED_REGION_NAME); long currentSequenceId = sequenceid; sida.update(ENCODED_REGION_NAME, FAMILIES, sequenceid, true); final Set<byte[]> otherFamily = new HashSet<>(1); otherFamily.add(Bytes.toBytes("otherCf")); sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true); // Should return oldest sequence id in the region. assertEquals(currentSequenceId, (long)sida.startCacheFlush(ENCODED_REGION_NAME, otherFamily)); sida.completeCacheFlush(ENCODED_REGION_NAME); }
assertFalse(sida.areAllLower(m, null)); sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES); assertFalse(sida.areAllLower(m, null)); m.put(ENCODED_REGION_NAME, HConstants.NO_SEQNUM); m.put(ENCODED_REGION_NAME, lowest); assertFalse(sida.areAllLower(m, null)); sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES);
@Override public Long startCacheFlush(final byte[] encodedRegionName, Set<byte[]> families) { if (!closeBarrier.beginOp()) { LOG.info("Flush not started for " + Bytes.toString(encodedRegionName) + "; server closing."); return null; } return this.sequenceIdAccounting.startCacheFlush(encodedRegionName, families); }
@Test public void testStartCacheFlush() { SequenceIdAccounting sida = new SequenceIdAccounting(); sida.getOrCreateLowestSequenceIds(ENCODED_REGION_NAME); Map<byte[], Long> m = new HashMap<>(); m.put(ENCODED_REGION_NAME, HConstants.NO_SEQNUM); assertEquals(HConstants.NO_SEQNUM, (long)sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES)); sida.completeCacheFlush(ENCODED_REGION_NAME); long sequenceid = 1; sida.update(ENCODED_REGION_NAME, FAMILIES, sequenceid, true); // Only one family so should return NO_SEQNUM still. assertEquals(HConstants.NO_SEQNUM, (long)sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES)); sida.completeCacheFlush(ENCODED_REGION_NAME); long currentSequenceId = sequenceid; sida.update(ENCODED_REGION_NAME, FAMILIES, sequenceid, true); final Set<byte[]> otherFamily = new HashSet<>(1); otherFamily.add(Bytes.toBytes("otherCf")); sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true); // Should return oldest sequence id in the region. assertEquals(currentSequenceId, (long)sida.startCacheFlush(ENCODED_REGION_NAME, otherFamily)); sida.completeCacheFlush(ENCODED_REGION_NAME); }
assertFalse(sida.areAllLower(m)); sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES); assertFalse(sida.areAllLower(m)); m.put(ENCODED_REGION_NAME, HConstants.NO_SEQNUM); m.put(ENCODED_REGION_NAME, lowest); assertFalse(sida.areAllLower(m)); sida.startCacheFlush(ENCODED_REGION_NAME, FAMILIES);