/// <summary> /// Read the storage server health status /// </summary> private async Task <StorageHealthResult> ReadStorageServerHealth(string serverAddress) { StorageHealthResult Result = new StorageHealthResult(); // Raise event to call client storage server ReadStorageHealthRequested?.Invoke(this, new ReadStorageHealthEventArgs(serverAddress)); if (await _signal.WaitAsync(WAIT_TIME)) { lock (_lock) { if (_storageHealth != null) { Result.StorageInfo = new StorageSpaceInfo { FreeDiskSpace = _storageHealth.StorageInfo.FreeDiskSpace, UsedDiskSpace = _storageHealth.StorageInfo.UsedDiskSpace }; } else { _logger.LogError("No record found for the server: " + serverAddress); Result.ErrorContent = new ErrorContent("No record found, please try again.", ErrorOrigin.Server); } } } else { _logger.LogError("Response timed out for server: " + serverAddress); Result.ErrorContent = new ErrorContent("Timeout: Response not received, please check that the server is up and running.", ErrorOrigin.Server); } return(Result); }
/// <summary> /// Sets the storage server health status /// </summary> public void SetStorageHealthStatus(StorageHealthResult storageHealth, string callerAddress) { lock (_lock) { _storageHealth = storageHealth; } _signal.Release(); }