static void Main(string[] args) { TrinityConfig.AddServer(new Trinity.Network.ServerInfo("127.0.0.1", 5304, Global.MyAssemblyPath, Trinity.Diagnostics.LogLevel.Error)); if (args.Length < 1) { Console.WriteLine("Please provide a command line parameter (-s|-c)."); Console.WriteLine(" -s Start as a distributed hashtable server."); Console.WriteLine(" -c Start as a distributed hashtable client."); return; } if (args[0].Trim().ToLower().StartsWith("-s")) { DistributedHashtableServer server = new DistributedHashtableServer(); server.Start(); while (true) { Thread.Sleep(1000); } } if (args[0].Trim().ToLower().StartsWith("-c")) { HandlingUserInput(); } }
static void Main(string[] args) { TrinityConfig.AddServer(new Trinity.Network.ServerInfo("127.0.0.1", 5304, Global.MyAssemblyPath, Trinity.Diagnostics.LogLevel.Error)); if (args.Length >= 1 && args[0].StartsWith("-s")) { SSSPServer server = new SSSPServer(); server.Start(); } //SSSP.exe -c startcell if (args.Length >= 2 && args[0].StartsWith("-c")) { TrinityConfig.CurrentRunningMode = RunningMode.Client; for (int i = 0; i < Global.ServerCount; i++) { using (var msg = new StartSSSPMessageWriter(long.Parse(args[1].Trim()))) { Global.CloudStorage.StartSSSPToSSSPServer(i, msg); } } } //SSSP.exe -q cellID if (args.Length >= 2 && args[0].StartsWith("-q")) { TrinityConfig.CurrentRunningMode = RunningMode.Client; var cell = Global.CloudStorage.LoadSSSPCell(int.Parse(args[1])); Console.WriteLine("Current vertex is {0}, the distance to the source vertex is {1}.", cell.CellID, cell.distance); while (cell.distance > 0) { cell = Global.CloudStorage.LoadSSSPCell(cell.parent); Console.WriteLine("Current vertex is {0}, the distance to the source vertex is {1}.", cell.CellID, cell.distance); } } //SSSP.exe -g node count if (args.Length >= 2 && args[0].StartsWith("-g")) { TrinityConfig.CurrentRunningMode = RunningMode.Client; Random rand = new Random(); int nodeCount = int.Parse(args[1].Trim()); for (int i = 0; i < nodeCount; i++) { HashSet <long> neighbors = new HashSet <long>(); for (int j = 0; j < 10; j++) { long neighor = rand.Next(0, nodeCount); if (neighor != i) { neighbors.Add(neighor); } } Global.CloudStorage.SaveSSSPCell(i, distance: int.MaxValue, parent: -1, neighbors: neighbors.ToList()); } } }