Example #1
0
 public int Compare(EditLogInputStream elis1, EditLogInputStream elis2)
 {
     // we want local logs to be ordered earlier in the collection, and true
     // is considered larger than false, so we want to invert the booleans here
     return(ComparisonChain.Start().Compare(!elis1.IsLocalLog(), !elis2.IsLocalLog()).
            Result());
 }
Example #2
0
 //
 // Comparable interface
 //
 public virtual int CompareTo(Org.Apache.Hadoop.Hdfs.Server.Namenode.CheckpointSignature
                              o)
 {
     return(ComparisonChain.Start().Compare(layoutVersion, o.layoutVersion).Compare(namespaceID
                                                                                    , o.namespaceID).Compare(cTime, o.cTime).Compare(mostRecentCheckpointTxId, o.mostRecentCheckpointTxId
                                                                                                                                     ).Compare(curSegmentTxId, o.curSegmentTxId).Compare(clusterID, o.clusterID).Compare
                (blockpoolID, o.blockpoolID).Result());
 }
Example #3
0
 public int Compare(AclEntry entry1, AclEntry entry2)
 {
     return(ComparisonChain.Start().Compare(entry1.GetScope(), entry2.GetScope(), Ordering
                                            .Explicit(AclEntryScope.Access, AclEntryScope.Default)).Compare(entry1.GetType()
                                                                                                            , entry2.GetType(), Ordering.Explicit(AclEntryType.User, AclEntryType.Group, AclEntryType
                                                                                                                                                  .Mask, AclEntryType.Other)).Compare(entry1.GetName(), entry2.GetName(), Ordering
                                                                                                                                                                                      .Natural().NullsFirst()).Result());
 }
        public virtual int Compare(KeyValuePair <AsyncLogger, QJournalProtocolProtos.PrepareRecoveryResponseProto
                                                 > a, KeyValuePair <AsyncLogger, QJournalProtocolProtos.PrepareRecoveryResponseProto
                                                                    > b)
        {
            QJournalProtocolProtos.PrepareRecoveryResponseProto r1 = a.Value;
            QJournalProtocolProtos.PrepareRecoveryResponseProto r2 = b.Value;
            // A response that has data for a segment is always better than one
            // that doesn't.
            if (r1.HasSegmentState() != r2.HasSegmentState())
            {
                return(Booleans.Compare(r1.HasSegmentState(), r2.HasSegmentState()));
            }
            if (!r1.HasSegmentState())
            {
                // Neither has a segment, so neither can be used for recover.
                // Call them equal.
                return(0);
            }
            // They both have a segment.
            QJournalProtocolProtos.SegmentStateProto r1Seg = r1.GetSegmentState();
            QJournalProtocolProtos.SegmentStateProto r2Seg = r2.GetSegmentState();
            Preconditions.CheckArgument(r1Seg.GetStartTxId() == r2Seg.GetStartTxId(), "Should only be called with responses for corresponding segments: "
                                        + "%s and %s do not have the same start txid.", r1, r2);
            // If one is in-progress but the other is finalized,
            // the finalized one is greater.
            if (r1Seg.GetIsInProgress() != r2Seg.GetIsInProgress())
            {
                return(Booleans.Compare(!r1Seg.GetIsInProgress(), !r2Seg.GetIsInProgress()));
            }
            if (!r1Seg.GetIsInProgress())
            {
                // If both are finalized, they should match lengths
                if (r1Seg.GetEndTxId() != r2Seg.GetEndTxId())
                {
                    throw new Exception("finalized segs with different lengths: " + r1 + ", " + r2);
                }
                return(0);
            }
            // Both are in-progress.
            long r1SeenEpoch = Math.Max(r1.GetAcceptedInEpoch(), r1.GetLastWriterEpoch());
            long r2SeenEpoch = Math.Max(r2.GetAcceptedInEpoch(), r2.GetLastWriterEpoch());

            return(ComparisonChain.Start().Compare(r1SeenEpoch, r2SeenEpoch).Compare(r1.GetSegmentState
                                                                                         ().GetEndTxId(), r2.GetSegmentState().GetEndTxId()).Result());
        }
Example #5
0
 public int Compare(EditLogInputStream a, EditLogInputStream b)
 {
     return(ComparisonChain.Start().Compare(a.GetFirstTxId(), b.GetFirstTxId()).Compare
                (b.GetLastTxId(), a.GetLastTxId()).Result());
 }
Example #6
0
 public virtual int CompareTo(Org.Apache.Hadoop.Hdfs.Server.Protocol.RemoteEditLog
                              log)
 {
     return(ComparisonChain.Start().Compare(startTxId, log.startTxId).Compare(endTxId,
                                                                              log.endTxId).Result());
 }
 public int Compare(FileJournalManager.EditLogFile a, FileJournalManager.EditLogFile
                    b)
 {
     return(ComparisonChain.Start().Compare(a.GetFirstTxId(), b.GetFirstTxId()).Compare
                (a.GetLastTxId(), b.GetLastTxId()).Result());
 }
Example #8
0
 public virtual int CompareTo(Org.Apache.Hadoop.Metrics2.Util.Quantile other)
 {
     return(ComparisonChain.Start().Compare(quantile, other.quantile).Compare(error, other
                                                                              .error).Result());
 }
Example #9
0
 public int CompareTo(ElasticByteBufferPool.Key other)
 {
     return(ComparisonChain.Start().Compare(capacity, other.capacity).Compare(insertionTime
                                                                              , other.insertionTime).Result());
 }
Example #10
0
 public virtual int CompareTo(ShortCircuitShm.ShmId other)
 {
     return(ComparisonChain.Start().Compare(hi, other.hi).Compare(lo, other.lo).Result
                ());
 }