Ejemplo n.º 1
0
 public static CommandRequest FromWire(Wire.Raft.CommandRequest wire)
 {
     return(new CommandRequest
     {
         Tag = CommandTag.FromWire(wire.Tag),
         Event = Uid.FromWire(wire.Event)
     });
 }
Ejemplo n.º 2
0
 public static CommandTag FromWire(Wire.Raft.CommandTag wire)
 {
     return(new CommandTag
     {
         Uid = Uid.FromWire(wire.Uid),
         Type = (CommandType)wire.Type
     });
 }
Ejemplo n.º 3
0
 public static LogResponse FromWire(Wire.Raft.LogResponse wire)
 {
     return(new LogResponse
     {
         Success = wire.Success,
         Leader = Uid.FromWire(wire.Leader),
         Entries = wire.Entries.Select(entryWire => Entry.FromWire(entryWire)).ToList()
     });
 }
Ejemplo n.º 4
0
 public static Peer FromWire(Wire.Sgx.SgxConfig.Types.Peer wire)
 {
     return(new Peer
     {
         Uid = Uid.FromWire(wire.Uid),
         Event = Uid.FromWire(wire.Event),
         Addr = Addr.FromWire(wire.Addr)
     });
 }
Ejemplo n.º 5
0
 public static SgxConfig FromWire(Wire.Sgx.SgxConfig wire)
 {
     return(new SgxConfig
     {
         Self = Uid.FromWire(wire.Self),
         Workflow = Workflow.FromWire(wire.Workflow),
         Peers = wire.Peers.Select(Peer.FromWire).ToArray()
     });
 }
Ejemplo n.º 6
0
 public static CommandReponse FromWire(Wire.Raft.CommandResponse wire)
 {
     return(new CommandReponse
     {
         Tag = CommandTag.FromWire(wire.Tag),
         Success = wire.Success,
         Leader = Uid.FromWire(wire.Leader)
     });
 }
Ejemplo n.º 7
0
 public static Entry FromWire(Wire.Raft.Entry wire)
 {
     return(new Entry
     {
         Event = Uid.FromWire(wire.Event),
         Index = wire.Index,
         Term = wire.Term,
         Tag = CommandTag.FromWire(wire.Tag)
     });
 }
Ejemplo n.º 8
0
        public void TestUid()
        {
            Uid uid = new Uid
            {
                Part1 = ulong.MaxValue,
                Part2 = ulong.MinValue
            };

            Assert.That(Uid.FromWire(uid.ToWire()), Is.EqualTo(uid));
        }
Ejemplo n.º 9
0
        public static void CollectGlobalHistory(CollectGlobalHistoryOptions opts)
        {
            CoreLib.Messages.Config.SgxConfig config = null;
            if (!string.IsNullOrEmpty(opts.ConfigPath) && !TryReadConfig(opts.ConfigPath, out config))
            {
                return;
            }

            if (!TryConnectRpc(opts, out SgxDaemon.SgxDaemonClient client))
            {
                return;
            }

            System.Console.WriteLine("Collecting history...");
            Snapshot snapshot;

            try
            {
                snapshot = client.History(new Empty(), new CallOptions(deadline: DateTime.MaxValue));
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"Error while collecting history: {ex.Message}");
                return;
            }

            // Convert snapshot data structure
            var result = new List <Tuple <Uid, Entry[]> >();

            foreach (var part in snapshot.Parts)
            {
                var local = new Tuple <Uid, Entry[]>(
                    Uid.FromWire(part.Cluster),
                    part.Entries.Select(Entry.FromWire).ToArray());

                result.Add(local);
            }

            var cs = new CheapShot(result);

            foreach (EventExecution exec in cs.GlobalHistory)
            {
                string eventName = config?.Workflow.Events.First(e => e.Uid == exec.Event).Name;

                System.Console.WriteLine();
                System.Console.ForegroundColor = ConsoleColor.DarkGreen;
                System.Console.WriteLine($"exec  {exec.ExecutionID}");
                System.Console.ResetColor();
                System.Console.WriteLine($"euid  {exec.Event}");
                if (eventName != null)
                {
                    System.Console.WriteLine($"event {eventName}");
                }
            }
        }