public async Task<ActionResult> GetAllGrainTypes() { var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var dashboardCollectorGrain = clusterClient.GetGrain<IDashboardCollectorGrain>(Guid.Empty); var types = await dashboardCollectorGrain.GetGrainTypes(); return Json(types, JsonRequestBehavior.AllowGet); }
public async Task<ActionResult> GetGrainKeyFromType(string type) { var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var grainInfoGrain = clusterClient.GetGrain<IMethodInvocationGrain>(type); var grainKeyType = await grainInfoGrain.GetGrainKeyType(); return Json(grainKeyType, JsonRequestBehavior.AllowGet); }
public async Task<ActionResult> GetGrainInfo(GetGrainInfoRequest grainInfoRequest) { var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var typeFilterGrain = clusterClient.GetGrain<IFilterGrain>(Guid.Empty); var filters = await typeFilterGrain.GetFilters(grainInfoRequest.GrainType, grainInfoRequest.GrainId); return Json(filters); }
public async Task SetSummaryViewLimit(int summaryViewLimit) { var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var dashboardInstanceGrain = clusterClient.GetGrain <IDashboardInstanceGrain>(0); await dashboardInstanceGrain.SetSummaryViewLimit(summaryViewLimit); }
public async Task <DiffModel> GetCurrentSnapshot(AppliedFilter filter, string grainSessionId) { var clusterClient = await GrainClientMultiton.GetAndConnectClient(grainSessionId); var dashboardInstanceGrain = clusterClient.GetGrain <IDashboardInstanceGrain>(0); var diffmodel = await dashboardInstanceGrain.GetAll(filter); return(diffmodel); }
public async Task<ActionResult> GetFilters(GetFiltersRequest filtersRequest) { if (filtersRequest?.Types == null) return null; var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var filterGrain = clusterClient.GetGrain<IFilterGrain>(Guid.Empty); var filters = await filterGrain.GetGroupedFilterValues(filtersRequest.Types); return Json(filters, JsonRequestBehavior.AllowGet); }
private async Task CleanupConnection(ConnectionInfo connection) { if (HttpContext.Request.Cookies.AllKeys.Contains("GrainSessionId")) { var client = GrainClientMultiton.GetClient(GrainSessionId); var gateway = client.Configuration.Gateways.First(); if (gateway.Address.ToString() != connection.Address || gateway.Port != connection.Port) { await CleanupClient(); RemoveCookie("GrainSessionId"); } } }
public async Task<ActionResult> GetDashboardInfo() { var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var dashboardCollectorGrain = clusterClient.GetGrain<IDashboardCollectorGrain>(Guid.Empty); var types = await dashboardCollectorGrain.GetGrainTypes(); var dashboardInfo = new DashboardInfo { Silos = await dashboardCollectorGrain.GetSilos(), AvailableTypes = types }; return Json(dashboardInfo, JsonRequestBehavior.AllowGet); }
public async Task<ActionResult> GetInfoForGrainType(string type) { var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var dashboardCollectorGrain = clusterClient.GetGrain<IDashboardCollectorGrain>(Guid.Empty); var ids = await dashboardCollectorGrain.GetGrainIdsForType(type); var grainInfoGrain = clusterClient.GetGrain<IMethodInvocationGrain>(type); var methods = new List<GrainMethod>(); if (_allowMethodsInvocation) { methods = await grainInfoGrain.GetAvailableMethods(); } var keyType = await grainInfoGrain.GetGrainKeyType(); return Json(new {Methods = methods, Ids = ids, KeyType = keyType}, JsonRequestBehavior.AllowGet); }
public async Task RegisterGrainClient(string grainSessionId) { await _semaphoreSlim.WaitAsync(); try { if (!StreamHandles.ContainsKey(grainSessionId)) { var clusterClient = await GrainClientMultiton.GetAndConnectClient(grainSessionId); var streamprovider = clusterClient.GetStreamProvider(StreamKeys.StreamProvider); var stream = streamprovider.GetStream <DiffModel>(Guid.Empty, StreamKeys.OrniscientClient); StreamHandles.Add(grainSessionId, await stream.SubscribeAsync(this)); } } finally { _semaphoreSlim.Release(); } }
public async Task<ActionResult> InvokeGrainMethod(string type, string id, string methodId, string parametersJson, bool invokeOnNewGrain = false) { if (_allowMethodsInvocation) { try { var clusterClient = await GrainClientMultiton.GetAndConnectClient(GrainSessionId); var methodGrain = clusterClient.GetGrain<IMethodInvocationGrain>(type); var methodReturnData = await methodGrain.InvokeGrainMethod(id, methodId, parametersJson); return Json(methodReturnData, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Error: " + ex.Message); } } return new HttpStatusCodeResult(HttpStatusCode.Forbidden, "Error: This method cannot be invoked"); }
// GET: Dashboard public async Task<ViewResult> Index(ConnectionInfo connection) { try { await CleanupConnection(connection); if(!HttpContext.Request.Cookies.AllKeys.Contains("GrainSessionId")) { var grainSessionIdKey = GrainClientMultiton.RegisterClient(connection.Address, connection.Port); HttpContext.Response.Cookies.Add(new HttpCookie("GrainSessionId", grainSessionIdKey)); } _allowMethodsInvocation = AllowMethodsInvocation(); ViewBag.AllowMethodsInvocation = _allowMethodsInvocation; return View(); } catch (Exception ex) { return View("InitError"); } }
private async Task CleanupConnection(ConnectionInfo connection) { if (HttpContext.Request.Cookies.AllKeys.Contains("GrainSessionId")) { var client = GrainClientMultiton.GetClient(GrainSessionId); if (client == null) { return; } var gateway = client.Configuration.Gateways.First(); if (gateway.Address.ToString() != connection.Address && !Equals(Dns.GetHostEntry(connection.Address).AddressList.FirstOrDefault(ip => ip.AddressFamily == AddressFamily.InterNetwork), gateway.Address)) { if (gateway.Port != connection.Port) { await CleanupClient(); } } } }
private async Task CleanupClient() { await OrniscientObserver.Instance.UnregisterGrainClient(GrainSessionId); GrainClientMultiton.RemoveClient(GrainSessionId); }