Example #1
0
        static string GetWorkSessionTable()
        {
            var sb = new StringBuilder();

            sb.AppendLine("<h2>WorkSessions Table</h2>");
            sb.AppendLine("<table class='log'>");
            var row = string.Format("<tr><th>Work Session ID</th><th>Document ID</th><th>RoleInstance Id</th><th>Created At</th><th>Processed At</th><th>Delay (sec)</th><th>Status</th></tr>");

            sb.AppendLine(row);

            RoutingTable.ForEachWorkSessionServer((id, serverInfo) => {
                foreach (var ws in serverInfo.WorkSessions.Select(v => v.Value))
                {
                    row = string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td></tr>",
                                        ws.WorkSessionID,
                                        ws.DocumentId,
                                        serverInfo.RoleInstanceId,
                                        ws.CreateTime,
                                        ws.ProcessedTime,
                                        (ws.ProcessedTime - ws.CreateTime).Seconds,
                                        Enum.GetName(typeof(WorkSessionStatus), ws.Status)
                                        );
                    sb.AppendLine(row);
                }
            });

            sb.AppendLine("</table>");
            return(sb.ToString());
        }
Example #2
0
        static string GetRoleServers(string roleName, Func <string, string> getHeaderValue)
        {
            var sb = new StringBuilder();

            if (getHeaderValue == null)
            {
                getHeaderValue = (v) => { return(string.Empty); }
            }
            ;
            var row = string.Format("<tr><td colspan='8' class='groupName'>{0}</td></tr>", roleName);

            sb.AppendLine(row);
            RoutingTable.ForEachWorkSessionServer(s => s.RoleName == roleName, (id, serverInfo) => {
                row = string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td><a href='javascript:void(0)' onclick='setCookie(\"ARRAffinity\", \"\"); setCookie(\"ARRAffinity\", \"{7}\");'>{7}</a></td></tr>",
                                    serverInfo.RoleInstanceId,
                                    serverInfo.RoleName,
                                    serverInfo.HostServerName,
                                    serverInfo.HostServerIP,
                                    Enum.GetName(typeof(WorkSessionServerStatus), serverInfo.Status),
                                    serverInfo.RemainingMemory,
                                    serverInfo.LastUpdateTime,
                                    getHeaderValue(serverInfo.HostServerIP)
                                    );
                sb.AppendLine(row);
            });
            return(sb.ToString());
        }
Example #3
0
 private static void OnRoleInstanceNumberChanged(int number)
 {
     if (number < 0)
     {
         List <WorkSessionServerInfo> affectedServers = new List <WorkSessionServerInfo>();
         RoutingTable.ForEachWorkSessionServer((roleInstanceId, serverInfo) => {
             if (serverInfo.IsProbablyShuttingDown())
             {
                 affectedServers.Add(serverInfo);
             }
         });
         WorkSessionMessenger.SendMessage(MessageOperation.ServerNumberDecreased, affectedServers);
     }
 }