Exemplo n.º 1
0
        // Initiate appropriate fetch request following offset update, or retry offset request
        // when nothing has been received.
        private async Task HandleOffsetPartitionResponse(string topic, OffsetPartitionResponse partitionResponse)
        {
            var state = _partitionsStates[topic][partitionResponse.Partition];

            if (!state.Active)
            {
                return;
            }

            // TODO: check size is 0 or 1 only
            if (partitionResponse.Offsets.Length == 0)
            {
                // there was an error, retry
                await Offset(topic, partitionResponse.Partition, state.NextOffsetExpected);
            }
            else
            {
                // start Fetch loop
                var nextOffset = partitionResponse.Offsets[0];
                if (state.StopAt < 0 || nextOffset <= state.StopAt)
                {
                    state.NextOffsetExpected = nextOffset;
                    await Fetch(topic, partitionResponse.Partition, state.NextOffsetExpected);
                }
                else
                {
                    state.Active = false;
                }
            }
        }
Exemplo n.º 2
0
        // Initiate appropriate fetch request following offset update, or retry offset request
        // when nothing has been received.
        private async Task HandleOffsetPartitionResponse(string topic, OffsetPartitionResponse partitionResponse)
        {
            var state = _partitionsStates[topic][partitionResponse.Partition];

            if (!CheckActivity(state, topic, partitionResponse.Partition))
            {
                return;
            }

            // TODO: check size is 0 or 1 only
            if (partitionResponse.Offsets.Length == 0)
            {
                // there was probably an error, in any case retry
                if (partitionResponse.ErrorCode != ErrorCode.NoError)
                {
                    _cluster.Logger.LogError(string.Format(
                                                 "Error on ListOffsets request for topic {0} / partition {1} [{2}].", topic,
                                                 partitionResponse.Partition, partitionResponse.ErrorCode));
                }
                await Offset(topic, partitionResponse.Partition, state.NextOffset);
            }
            else
            {
                // start Fetch loop
                var nextOffset = partitionResponse.Offsets[0];

                if (state.StopAt == Offsets.Never || nextOffset <= state.StopAt)
                {
                    state.NextOffset = nextOffset;
                    await Fetch(topic, partitionResponse.Partition, state.NextOffset);
                }
                else
                {
                    state.Active = false;
                }
            }
        }
Exemplo n.º 3
0
 // Utility function, statically allocated closure
 private static bool IsPartitionOkForClients(OffsetPartitionResponse or)
 {
     return(Error.IsPartitionOkForClients(or.ErrorCode));
 }