public ServiceClientWrapper() { this.EndpointUri = UriProvider.GetNextUri(); // var binding = new BasicHttpBinding("BasicHttpBinding_IRemoteWorkerService"); var binding = new BasicHttpBinding(); this.client = new WSClient.RemoteWorkerServiceClient(binding, new EndpointAddress(this.EndpointUri)); }
public ActionResult PerformanceStatistics(Uri uri) { try { if (uri == null) { return this.Json("incorrect uri"); } var binding = new BasicHttpBinding(); using (var client = new WSClient.RemoteWorkerServiceClient(binding, new EndpointAddress(uri))) { var statistics = client.GetPerformanceStatistics(); var driveStatistics = statistics.DriveStatistics.First(); return this.Json( new { CPU = statistics.LoadStatistics.TotalProcessorTimeCounterPercent.ToString("f2"), Memory = statistics.LoadStatistics.UsedRamCounterPercent.ToString("f2"), Disk = (100 * Convert.ToDouble(driveStatistics.FreeSpace) / Convert.ToDouble(driveStatistics.TotalSize)).ToString("f2") }, JsonRequestBehavior.AllowGet); } } catch (EndpointNotFoundException) { return this.Json(new { CPU = string.Empty, Memory = string.Empty, Disk = string.Empty }, JsonRequestBehavior.AllowGet); } catch (CommunicationException) { return this.Json(new { CPU = string.Empty, Memory = string.Empty, Disk = string.Empty }, JsonRequestBehavior.AllowGet); } }
private static Task<Uri> PushFileToReducer(Dictionary<string, Uri> keysAndUris, IStorage workerStorage, string fileName, string key) { var reducerUri = keysAndUris[key]; var reducerWorkerId = GetWorkerId(reducerUri); var reducerEndpointUri = GetWorkerEndpointUri(reducerUri); var binding = new BasicHttpBinding();//new BasicHttpBinding("BasicHttpBinding_IRemoteWorkerService"); using (var client = new WSClient.RemoteWorkerServiceClient(binding, new EndpointAddress(reducerEndpointUri))) { return client.PushFileAsync(reducerWorkerId, fileName, workerStorage.Read(fileName)); } }