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);
        }
        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);
        }
Beispiel #3
0
 public Interfaces.Results.SurgeonOperatingRoomAssignments.Iy GetElementsAt(
     IyResultElementFactory yResultElementFactory,
     IyFactory yFactory,
     Isr sr)
 {
     return(yFactory.Create(
                sr.Value
                .Select(
                    i => yResultElementFactory.Create(
                        i.sIndexElement,
                        i.rIndexElement,
                        this.GetElementAt(
                            i.sIndexElement,
                            i.rIndexElement)))
                .ToImmutableList()));
 }
        public ObjectiveFunction001(
            IObjectiveFactory objectiveFactory,
            Isr sr,
            Iy y)
        {
            Expression expression = Expression.Sum(
                sr.Value
                .Select(
                    x => y.Value[x.sIndexElement, x.rIndexElement]));

            Objective objective = objectiveFactory.Create(
                expression,
                ObjectiveSense.Minimize);

            this.Value = objective;
        }
Beispiel #5
0
        public Isr Create(
            ImmutableList <IsrCrossJoinElement> value)
        {
            Isr crossJoin = null;

            try
            {
                crossJoin = new sr(
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error("Exception message: " + exception.Message + " and stacktrace " + exception.StackTrace);
            }

            return(crossJoin);
        }
Beispiel #6
0
        public Isr Create(
            ImmutableList <IsrCrossJoinElement> value)
        {
            Isr crossJoin = null;

            try
            {
                crossJoin = new sr(
                    value);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(crossJoin);
        }
Beispiel #7
0
        public IObjectiveFunction001 Create(
            IObjectiveFactory objectiveFactory,
            Isr sr,
            Iy y)
        {
            IObjectiveFunction001 objectiveFunction = null;

            try
            {
                objectiveFunction = new ObjectiveFunction001(
                    objectiveFactory,
                    sr,
                    y);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(objectiveFunction);
        }