Esempio n. 1
0
        public OffsetRequest(String topic, Int32[] partitions, OffsetOption offsetOption)
            : base(ApiKey.OffsetRequest)
        {
            if (partitions == null || partitions.Length == 0)
            {
                throw new ArgumentOutOfRangeException("partitions");
            }

            var details = new List <OffsetsRequestTopicPartitionDetail>();

            foreach (var partition in partitions)
            {
                details.Add(new OffsetsRequestTopicPartitionDetail()
                {
                    Partition          = partition,
                    Time               = (Int64)offsetOption,
                    MaxNumberOfOffsets = 1
                });
            }

            ReplicaId       = -1;
            TopicPartitions = new[] {
                new OffsetsRequestTopicPartition {
                    TopicName = topic,
                    Details   = details
                }
            };
        }
Esempio n. 2
0
        public void SetActiveValue(double offset, bool legacy)
        {
            OffsetOption.SetActiveValue(offset);

            VelocityGainOffsetCheck.Checked = !legacy;
            LegacyOffsetCheck.Checked       = legacy;
        }
Esempio n. 3
0
        public Int64[] Offset(String topic, Int32[] partitions, OffsetOption option)
        {
            if (partitions == null || partitions.Length == 0)
            {
                throw new ArgumentOutOfRangeException("partitions");
            }
            var offsets = new Int64[partitions.Length];

            for (int i = 0; i < partitions.Length; i++)
            {
                offsets[i] = Offset(topic, partitions[i], option);
            }
            return(offsets);
        }
Esempio n. 4
0
        public Int64 Offset(String topic, Int32 partition, OffsetOption option)
        {
            EnsureLegalTopicSpelling(topic);
            var broker   = _topicBrokerDispatcher.SelectBroker(topic, partition);
            var request  = new OffsetRequest(topic, new[] { partition }, option);
            var response = (OffsetResponse)SubmitRequest(broker, request);
            var errors   = response.TopicPartitions
                           .SelectMany(r => r.PartitionOffsets)
                           .Where(x => x.ErrorCode != ErrorCode.NoError)
                           .ToList();

            if (errors.Count > 0 && errors.All(e => e.ErrorCode == ErrorCode.UnknownTopicOrPartition))
            {
                return(-1L);
            }
            if (errors.Count > 1)
            {
                throw new ProtocolException(errors.First().ErrorCode);
            }
            return(response.TopicPartitions[0].PartitionOffsets[0].Offsets[0]);
        }
Esempio n. 5
0
 public override void AlignActiveValues()
 {
     OffsetOption.AlignActiveValues();
 }
Esempio n. 6
0
 public override void Show(string name)
 {
     OffsetOption.Show(name);
 }
Esempio n. 7
0
 public void Show()
 {
     OffsetOption.Show();
 }
Esempio n. 8
0
 public override void Hide()
 {
     OffsetOption.Hide();
 }