public void GetStatus() { Console.WriteLine("--------------------"); Console.WriteLine(">>> Printing status..."); Console.WriteLine("--------------------"); List <Partition> partitions = server.getPartitions(); List <string> partitionsString = new List <string>(); List <string> masterOfPartitions = new List <string>(); foreach (Partition partition in partitions) { if (partition.getMasterID() == serverId) { masterOfPartitions.Add(partition.getName()); } partitionsString.Add(partition.getName()); } Console.WriteLine(">>> Role: server. ID: " + serverId + ", Frozen: " + _isFrozen); Console.WriteLine(">>> Partitions: " + string.Join(", ", partitionsString.ToArray()) + ", Num of partitions: " + server.getNumberOfPartitions()); if (masterOfPartitions.Count > 0) { Console.WriteLine(">>> I am Master of: " + string.Join(", ", masterOfPartitions.ToArray())); } else { Console.WriteLine(">>> I am Replica in every partition"); } Console.WriteLine("--------------------"); }
public ListServerReply ListServerHandler(ListServerRequest request) { ListServerReply reply = null; List <DataStorePartitionDto> partitionList = new List <DataStorePartitionDto>(); foreach (Partition p in server.getPartitions()) { List <DataStoreObjectDto> objectList = new List <DataStoreObjectDto>(); DataStore store = p.getDataStore(); foreach (DataStoreKey key in store.getKeys()) { Shared.GrpcDataStore.DataStoreObjectDto dto_obj = new Shared.GrpcDataStore.DataStoreObjectDto { Key = DataStoreServer.Util.Utilities.ConvertKeyDomainToDto(key), Value = DataStoreServer.Util.Utilities.ConvertValueDomainToDto(store.getObject(key)) }; objectList.Add(dto_obj); } Shared.GrpcDataStore.DataStorePartitionDto dto_part = new Shared.GrpcDataStore.DataStorePartitionDto { PartitionId = p.getName(), IsMaster = p.is_master, ObjectList = { objectList } }; partitionList.Add(dto_part); } reply = new ListServerReply { PartitionList = { partitionList } }; return(reply); }