@Test public void testPrepareWithRegionsWithReference() throws IOException { HStore storeMock = Mockito.mock(HStore.class); when(storeMock.hasReferences()).thenReturn(true); when(storeMock.getFamily()).thenReturn(new HColumnDescriptor("cf")); when(storeMock.close()).thenReturn(ImmutableList.<StoreFile>of()); this.parent.stores.put(Bytes.toBytes(""), storeMock); SplitTransaction st = new SplitTransaction(this.parent, GOOD_SPLIT_ROW); assertFalse("a region should not be splittable if it has instances of store file references", st.prepare()); }
public boolean prepare() { LOG.info("Shen Li: SplitTransaction.prepare()"); if (!this.parent.isSplittable()) return false; if (this.splitrow == null && !reuseFile) return false; HRegionInfo hri = this.parent.getRegionInfo(); parent.prepareToSplit(); long rid = getDaughterRegionIdTimestamp(hri); if (reuseFile) { byte [][] allKeys = hri.getAllKeys(); if (null == allKeys || allKeys.length <= 2) { int length = (null == allKeys) ? 0: allKeys.length; throw new IllegalStateException("Shen Li: allKeys length = " + length + ", not able to further split"); } if (null == destA || null == destB) { throw new IllegalStateException("Shen Li: In SplitTransaction " + "destA and destB must not be null when reuseFile is true"); } LOG.info("Shen Li: init daughter regions with reuseFile = true"); int midIndex = allKeys.length >> 1; this.hri_a = new HRegionInfo(hri.getTable(), allKeys, 0, midIndex, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(true)); this.hri_b = new HRegionInfo(hri.getTable(), allKeys, midIndex, allKeys.length - 1, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(false)); hri_a.setDestHostname(destA); hri_b.setDestHostname(destB); } else { byte [] startKey = hri.getStartKey(); byte [] endKey = hri.getEndKey(); if (Bytes.equals(startKey, splitrow) || !this.parent.getRegionInfo().containsRow(splitrow)) { LOG.info("Split row is not inside region key range or is equal to " + "startkey: " + Bytes.toStringBinary(this.splitrow)); return false; } this.hri_a = new HRegionInfo(hri.getTable(), startKey, this.splitrow, false, rid); this.hri_b = new HRegionInfo(hri.getTable(), this.splitrow, endKey, false, rid); } return true; }
SplitTransaction { public boolean prepare() { LOG.info("Shen Li: SplitTransaction.prepare()"); if (!this.parent.isSplittable()) return false; if (this.splitrow == null && !reuseFile) return false; HRegionInfo hri = this.parent.getRegionInfo(); parent.prepareToSplit(); long rid = getDaughterRegionIdTimestamp(hri); if (reuseFile) { byte [][] allKeys = hri.getAllKeys(); if (null == allKeys || allKeys.length <= 2) { int length = (null == allKeys) ? 0: allKeys.length; throw new IllegalStateException("Shen Li: allKeys length = " + length + ", not able to further split"); } if (null == destA || null == destB) { throw new IllegalStateException("Shen Li: In SplitTransaction " + "destA and destB must not be null when reuseFile is true"); } LOG.info("Shen Li: init daughter regions with reuseFile = true"); int midIndex = allKeys.length >> 1; this.hri_a = new HRegionInfo(hri.getTable(), allKeys, 0, midIndex, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(true)); this.hri_b = new HRegionInfo(hri.getTable(), allKeys, midIndex, allKeys.length - 1, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(false)); hri_a.setDestHostname(destA); hri_b.setDestHostname(destB); } else { byte [] startKey = hri.getStartKey(); byte [] endKey = hri.getEndKey(); if (Bytes.equals(startKey, splitrow) || !this.parent.getRegionInfo().containsRow(splitrow)) { LOG.info("Split row is not inside region key range or is equal to " + "startkey: " + Bytes.toStringBinary(this.splitrow)); return false; } this.hri_a = new HRegionInfo(hri.getTable(), startKey, this.splitrow, false, rid); this.hri_b = new HRegionInfo(hri.getTable(), this.splitrow, endKey, false, rid); } return true; } }
SplitTransaction { public boolean prepare() { LOG.info("Shen Li: SplitTransaction.prepare()"); if (!this.parent.isSplittable()) return false; if (this.splitrow == null && !reuseFile) return false; HRegionInfo hri = this.parent.getRegionInfo(); parent.prepareToSplit(); long rid = getDaughterRegionIdTimestamp(hri); if (reuseFile) { byte [][] allKeys = hri.getAllKeys(); if (null == allKeys || allKeys.length <= 2) { int length = (null == allKeys) ? 0: allKeys.length; throw new IllegalStateException("Shen Li: allKeys length = " + length + ", not able to further split"); } if (null == destA || null == destB) { throw new IllegalStateException("Shen Li: In SplitTransaction " + "destA and destB must not be null when reuseFile is true"); } LOG.info("Shen Li: init daughter regions with reuseFile = true"); int midIndex = allKeys.length >> 1; this.hri_a = new HRegionInfo(hri.getTable(), allKeys, 0, midIndex, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(true)); this.hri_b = new HRegionInfo(hri.getTable(), allKeys, midIndex, allKeys.length - 1, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(false)); hri_a.setDestHostname(destA); hri_b.setDestHostname(destB); } else { byte [] startKey = hri.getStartKey(); byte [] endKey = hri.getEndKey(); if (Bytes.equals(startKey, splitrow) || !this.parent.getRegionInfo().containsRow(splitrow)) { LOG.info("Split row is not inside region key range or is equal to " + "startkey: " + Bytes.toStringBinary(this.splitrow)); return false; } this.hri_a = new HRegionInfo(hri.getTable(), startKey, this.splitrow, false, rid); this.hri_b = new HRegionInfo(hri.getTable(), this.splitrow, endKey, false, rid); } return true; } SplitTransaction(final HRegion r, final byte [] splitrow);  SplitTransaction(final HRegion r, final byte [] splitrow, 
                          boolean reuseFile, String destA, String destB); }
SplitTransaction { public boolean prepare() { LOG.info("Shen Li: SplitTransaction.prepare()"); if (!this.parent.isSplittable()) return false; if (this.splitrow == null && !reuseFile) return false; HRegionInfo hri = this.parent.getRegionInfo(); parent.prepareToSplit(); long rid = getDaughterRegionIdTimestamp(hri); if (reuseFile) { byte [][] allKeys = hri.getAllKeys(); if (null == allKeys || allKeys.length <= 2) { int length = (null == allKeys) ? 0: allKeys.length; throw new IllegalStateException("Shen Li: allKeys length = " + length + ", not able to further split"); } if (null == destA || null == destB) { throw new IllegalStateException("Shen Li: In SplitTransaction " + "destA and destB must not be null when reuseFile is true"); } LOG.info("Shen Li: init daughter regions with reuseFile = true"); int midIndex = allKeys.length >> 1; this.hri_a = new HRegionInfo(hri.getTable(), allKeys, 0, midIndex, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(true)); this.hri_b = new HRegionInfo(hri.getTable(), allKeys, midIndex, allKeys.length - 1, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(false)); hri_a.setDestHostname(destA); hri_b.setDestHostname(destB); } else { byte [] startKey = hri.getStartKey(); byte [] endKey = hri.getEndKey(); if (Bytes.equals(startKey, splitrow) || !this.parent.getRegionInfo().containsRow(splitrow)) { LOG.info("Split row is not inside region key range or is equal to " + "startkey: " + Bytes.toStringBinary(this.splitrow)); return false; } this.hri_a = new HRegionInfo(hri.getTable(), startKey, this.splitrow, false, rid); this.hri_b = new HRegionInfo(hri.getTable(), this.splitrow, endKey, false, rid); } return true; } SplitTransaction(final HRegion r, final byte [] splitrow);  SplitTransaction(final HRegion r, final byte [] splitrow, 
                          boolean reuseFile, String destA, String destB); boolean prepare(); PairOfSameType<HRegion> stepsBeforePONR(final Server server,
      final RegionServerServices services, boolean testing); PairOfSameType<HRegion> execute(final Server server,
      final RegionServerServices services); PairOfSameType<HRegion> stepsAfterPONR(final Server server,
      final RegionServerServices services, PairOfSameType<HRegion> regions); Put addLocation(final Put p, final ServerName sn, long openSeqNum); @SuppressWarnings("deprecation") boolean rollback(final Server server, final RegionServerServices services); static void createNodeSplitting(final ZooKeeperWatcher zkw, final HRegionInfo region,
      final ServerName serverName, final HRegionInfo a,
      final HRegionInfo b); static int transitionSplittingNode(ZooKeeperWatcher zkw,
      HRegionInfo parent, HRegionInfo a, HRegionInfo b, ServerName serverName,
      final int znodeVersion, final EventType beginState,
      final EventType endState); static int transitionSplittingNode(ZooKeeperWatcher zkw,
      HRegionInfo parent, HRegionInfo a, HRegionInfo b, ServerName serverName,
      final int znodeVersion, final EventType beginState,
      final EventType endState, boolean reuseFile); }
SplitTransaction { public boolean prepare() { LOG.info("Shen Li: SplitTransaction.prepare()"); if (!this.parent.isSplittable()) return false; if (this.splitrow == null && !reuseFile) return false; HRegionInfo hri = this.parent.getRegionInfo(); parent.prepareToSplit(); long rid = getDaughterRegionIdTimestamp(hri); if (reuseFile) { byte [][] allKeys = hri.getAllKeys(); if (null == allKeys || allKeys.length <= 2) { int length = (null == allKeys) ? 0: allKeys.length; throw new IllegalStateException("Shen Li: allKeys length = " + length + ", not able to further split"); } if (null == destA || null == destB) { throw new IllegalStateException("Shen Li: In SplitTransaction " + "destA and destB must not be null when reuseFile is true"); } LOG.info("Shen Li: init daughter regions with reuseFile = true"); int midIndex = allKeys.length >> 1; this.hri_a = new HRegionInfo(hri.getTable(), allKeys, 0, midIndex, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(true)); this.hri_b = new HRegionInfo(hri.getTable(), allKeys, midIndex, allKeys.length - 1, false, rid, hri.getReplicaNamespace(), hri.getDaughterReplicaGroupIds(false)); hri_a.setDestHostname(destA); hri_b.setDestHostname(destB); } else { byte [] startKey = hri.getStartKey(); byte [] endKey = hri.getEndKey(); if (Bytes.equals(startKey, splitrow) || !this.parent.getRegionInfo().containsRow(splitrow)) { LOG.info("Split row is not inside region key range or is equal to " + "startkey: " + Bytes.toStringBinary(this.splitrow)); return false; } this.hri_a = new HRegionInfo(hri.getTable(), startKey, this.splitrow, false, rid); this.hri_b = new HRegionInfo(hri.getTable(), this.splitrow, endKey, false, rid); } return true; } SplitTransaction(final HRegion r, final byte [] splitrow);  SplitTransaction(final HRegion r, final byte [] splitrow, 
                          boolean reuseFile, String destA, String destB); boolean prepare(); PairOfSameType<HRegion> stepsBeforePONR(final Server server,
      final RegionServerServices services, boolean testing); PairOfSameType<HRegion> execute(final Server server,
      final RegionServerServices services); PairOfSameType<HRegion> stepsAfterPONR(final Server server,
      final RegionServerServices services, PairOfSameType<HRegion> regions); Put addLocation(final Put p, final ServerName sn, long openSeqNum); @SuppressWarnings("deprecation") boolean rollback(final Server server, final RegionServerServices services); static void createNodeSplitting(final ZooKeeperWatcher zkw, final HRegionInfo region,
      final ServerName serverName, final HRegionInfo a,
      final HRegionInfo b); static int transitionSplittingNode(ZooKeeperWatcher zkw,
      HRegionInfo parent, HRegionInfo a, HRegionInfo b, ServerName serverName,
      final int znodeVersion, final EventType beginState,
      final EventType endState); static int transitionSplittingNode(ZooKeeperWatcher zkw,
      HRegionInfo parent, HRegionInfo a, HRegionInfo b, ServerName serverName,
      final int znodeVersion, final EventType beginState,
      final EventType endState, boolean reuseFile);  }