Esempio n. 1
0
        public void SetOffset(string topic, string clientId, int partitionId, long msgOffset)
        {
            var key = String.Format("/lt/offset/{0}/{1}/{2}", topic, clientId, partitionId);

            var offset = new OffsetManagerItem(topic, clientId, partitionId, msgOffset);

            zkClient.WriteData(key, offset);
        }
Esempio n. 2
0
        public long GetOffset(string topic, string clientId, int partitionId)
        {
            var key = String.Format("/lt/offset/{0}/{1}/{2}", topic, clientId, partitionId);

            zkClient.MakeSurePersistentPathExists(key);
            var offset = zkClient.ReadData <OffsetManagerItem>(key);

            if (offset != null)
            {
                return(offset.Offset);
            }

            long primero;
            long ultimo;
            long msgOffset;

            GetAdjustedOffset(topic, _manager, partitionId, KafkaOffsetType.Earliest, 0, 0, out primero,
                              out ultimo, out msgOffset);
            offset = new OffsetManagerItem(topic, clientId, partitionId, msgOffset);
            zkClient.WriteData(key, offset);

            return(offset.Offset);
        }