示例#1
0
 public static CommandRequest FromWire(Wire.Raft.CommandRequest wire)
 {
     return(new CommandRequest
     {
         Tag = CommandTag.FromWire(wire.Tag),
         Event = Uid.FromWire(wire.Event)
     });
 }
示例#2
0
 public static CommandTag FromWire(Wire.Raft.CommandTag wire)
 {
     return(new CommandTag
     {
         Uid = Uid.FromWire(wire.Uid),
         Type = (CommandType)wire.Type
     });
 }
示例#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()
     });
 }
示例#4
0
文件: Peer.cs 项目: trusted-dcr/tdcr
 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)
     });
 }
示例#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()
     });
 }
示例#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)
     });
 }
示例#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)
     });
 }
示例#8
0
        public void TestUid()
        {
            Uid uid = new Uid
            {
                Part1 = ulong.MaxValue,
                Part2 = ulong.MinValue
            };

            Assert.That(Uid.FromWire(uid.ToWire()), Is.EqualTo(uid));
        }
示例#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}");
                }
            }
        }