public void WriteTo(KafkaBinaryWriter writer) { Guard.NotNull(writer, "writer"); // if leader exists writer.Write(PartitionId); if (Leader != null) { writer.Write((byte)1); Leader.WriteTo(writer); } else { writer.Write((byte)0); } // number of replicas writer.Write((short)Replicas.Count()); foreach (var replica in Replicas) { replica.WriteTo(writer); } // number of in-sync replicas writer.Write((short)Isr.Count()); foreach (var isr in Isr) { isr.WriteTo(writer); } writer.Write((byte)0); }
public override string ToString() { var sb = new StringBuilder(4096); sb.AppendFormat( "PartitionMetadata.ParitionId:{0},Leader:{1},Replicas Count:{2},Isr Count:{3}", PartitionId, Leader == null ? "null" : Leader.ToString(), Replicas.Count(), Isr.Count()); var i = 0; foreach (var r in Replicas) { sb.AppendFormat(",Replicas[{0}]:{1}", i, r); i++; } i = 0; foreach (var sr in Isr) { sb.AppendFormat(",Isr[{0}]:{1}", i, sr); i++; } var s = sb.ToString(); sb.Length = 0; return(s); }