30
30
31
31
import java .time .Duration ;
32
32
import java .util .ArrayList ;
33
+ import java .util .Arrays ;
33
34
import java .util .EnumSet ;
34
35
import java .util .HashMap ;
35
36
import java .util .HashSet ;
51
52
import org .apache .accumulo .core .fate .FateId ;
52
53
import org .apache .accumulo .core .fate .FateInstanceType ;
53
54
import org .apache .accumulo .core .fate .FateKey ;
55
+ import org .apache .accumulo .core .fate .FateKey .FateKeyType ;
54
56
import org .apache .accumulo .core .fate .FateStore ;
55
57
import org .apache .accumulo .core .fate .FateStore .FateTxStore ;
56
58
import org .apache .accumulo .core .fate .ReadOnlyFateStore .FateIdStatus ;
@@ -615,7 +617,9 @@ protected void testConcurrent(FateStore<TestEnv> store, ServerContext sctx) thro
615
617
616
618
assertEquals (1 , idsSeen );
617
619
assertEquals (1 , store .list (FateKey .FateKeyType .SPLIT ).count ());
618
- assertEquals (0 , store .list (FateKey .FateKeyType .COMPACTION_COMMIT ).count ());
620
+ // All other types should be a count of 0
621
+ Arrays .stream (FateKeyType .values ()).filter (t -> !t .equals (FateKey .FateKeyType .SPLIT ))
622
+ .forEach (t -> assertEquals (0 , store .list (t ).count ()));
619
623
620
624
for (var future : futures ) {
621
625
if (future .get ().isPresent ()) {
@@ -628,8 +632,9 @@ protected void testConcurrent(FateStore<TestEnv> store, ServerContext sctx) thro
628
632
}
629
633
}
630
634
631
- assertEquals (0 , store .list (FateKey .FateKeyType .SPLIT ).count ());
632
- assertEquals (0 , store .list (FateKey .FateKeyType .COMPACTION_COMMIT ).count ());
635
+ // All types should be a count of 0
636
+ assertTrue (
637
+ Arrays .stream (FateKeyType .values ()).allMatch (t -> store .list (t ).findAny ().isEmpty ()));
633
638
634
639
} finally {
635
640
executor .shutdown ();
@@ -672,6 +677,7 @@ protected void testListFateKeys(FateStore<TestEnv> store, ServerContext sctx) th
672
677
TableId tid1 = TableId .of ("test" );
673
678
var extent1 = new KeyExtent (tid1 , new Text ("m" ), null );
674
679
var extent2 = new KeyExtent (tid1 , null , new Text ("m" ));
680
+ var extent3 = new KeyExtent (tid1 , new Text ("z" ), new Text ("m" ));
675
681
var fateKey1 = FateKey .forSplit (extent1 );
676
682
var fateKey2 = FateKey .forSplit (extent2 );
677
683
@@ -683,8 +689,12 @@ protected void testListFateKeys(FateStore<TestEnv> store, ServerContext sctx) th
683
689
var fateKey3 = FateKey .forCompactionCommit (cid1 );
684
690
var fateKey4 = FateKey .forCompactionCommit (cid2 );
685
691
692
+ // use one overlapping extent and one different
693
+ var fateKey5 = FateKey .forMerge (extent1 );
694
+ var fateKey6 = FateKey .forMerge (extent3 );
695
+
686
696
Map <FateKey ,FateId > fateKeyIds = new HashMap <>();
687
- for (FateKey fateKey : List .of (fateKey1 , fateKey2 , fateKey3 , fateKey4 )) {
697
+ for (FateKey fateKey : List .of (fateKey1 , fateKey2 , fateKey3 , fateKey4 , fateKey5 , fateKey6 )) {
688
698
var fateId = store .seedTransaction (TEST_FATE_OP , fateKey , new TestRepo (), true ).orElseThrow ();
689
699
fateKeyIds .put (fateKey , fateId );
690
700
}
@@ -693,20 +703,29 @@ protected void testListFateKeys(FateStore<TestEnv> store, ServerContext sctx) th
693
703
allIds .addAll (fateKeyIds .values ());
694
704
allIds .add (id1 );
695
705
assertEquals (allIds , store .list ().map (FateIdStatus ::getFateId ).collect (Collectors .toSet ()));
696
- assertEquals (5 , allIds .size ());
706
+ assertEquals (7 , allIds .size ());
697
707
698
- assertEquals (4 , fateKeyIds .size ());
699
- assertEquals (4 , fateKeyIds .values ().stream ().distinct ().count ());
708
+ assertEquals (6 , fateKeyIds .size ());
709
+ assertEquals (6 , fateKeyIds .values ().stream ().distinct ().count ());
700
710
701
711
HashSet <KeyExtent > seenExtents = new HashSet <>();
702
712
store .list (FateKey .FateKeyType .SPLIT ).forEach (fateKey -> {
703
713
assertEquals (FateKey .FateKeyType .SPLIT , fateKey .getType ());
704
714
assertNotNull (fateKeyIds .remove (fateKey ));
705
715
assertTrue (seenExtents .add (fateKey .getKeyExtent ().orElseThrow ()));
706
716
});
717
+ assertEquals (4 , fateKeyIds .size ());
718
+ assertEquals (Set .of (extent1 , extent2 ), seenExtents );
707
719
720
+ // clear set as one overlaps
721
+ seenExtents .clear ();
722
+ store .list (FateKeyType .MERGE ).forEach (fateKey -> {
723
+ assertEquals (FateKey .FateKeyType .MERGE , fateKey .getType ());
724
+ assertNotNull (fateKeyIds .remove (fateKey ));
725
+ assertTrue (seenExtents .add (fateKey .getKeyExtent ().orElseThrow ()));
726
+ });
708
727
assertEquals (2 , fateKeyIds .size ());
709
- assertEquals (Set .of (extent1 , extent2 ), seenExtents );
728
+ assertEquals (Set .of (extent1 , extent3 ), seenExtents );
710
729
711
730
HashSet <ExternalCompactionId > seenCids = new HashSet <>();
712
731
store .list (FateKey .FateKeyType .COMPACTION_COMMIT ).forEach (fateKey -> {
@@ -717,6 +736,7 @@ protected void testListFateKeys(FateStore<TestEnv> store, ServerContext sctx) th
717
736
718
737
assertEquals (0 , fateKeyIds .size ());
719
738
assertEquals (Set .of (cid1 , cid2 ), seenCids );
739
+
720
740
// Cleanup so we don't interfere with other tests
721
741
store .list ()
722
742
.forEach (fateIdStatus -> store .tryReserve (fateIdStatus .getFateId ()).orElseThrow ().delete ());
0 commit comments