public StreamState ReadStreamState(String topic, String group, List<Int32> partitions)
{
if (partitions == null || partitions.Count == 0)
throw new ArgumentException("Empty partitions set not allowed");
Dictionary<Int32, Int32> offsetByPartition = new Dictionary<Int32, Int32>(partitions.Count);
foreach (var partition in partitions)
{
var stateFilePath = GetPartitionStateFilePath(topic, group, partition);
if (!File.Exists(stateFilePath))
{
var dir = GetPartitionDirectoryPath(topic, group, partition);
Directory.CreateDirectory(dir);
using (File.Create(stateFilePath)) { }
}
var offset = File.ReadAllText(stateFilePath);
offsetByPartition[partition] = String.IsNullOrWhiteSpace(offset) ? 0 :
Int32.Parse(offset, CultureInfo.InvariantCulture);
}
return new StreamState(topic, group, offsetByPartition);
}