internal void DeregisterContext(string context) { context = GetRootedContextPath(context); try { McmpResponse disableresult = ClientConfig.ExecuteCommand(ClusterUri, Constants.Commands.DisableApp, "Context", context); if (log != null && log.IsInfoEnabled) { log.Info("DeregisterContext(" + context + ") Result: " + disableresult.ToString()); } McmpResponse stopresult = ClientConfig.ExecuteCommand(ClusterUri, Constants.Commands.StopApp, "Context", context); if (log != null && log.IsInfoEnabled) { log.Info("DeregisterContext(" + context + ") Result: " + stopresult.ToString()); } McmpResponse removeresult = ClientConfig.ExecuteCommand(ClusterUri, Constants.Commands.RemoveApp, "Context", context); if (log != null && log.IsInfoEnabled) { log.Info("DeregisterContext(" + context + ") Result: " + removeresult.ToString()); } if (disableresult.HttpStatusCode == HttpStatusCode.OK && removeresult.HttpStatusCode == HttpStatusCode.OK) { RegisteredContexts.Remove(context); } } catch (Exception ex) { if (log != null && log.IsErrorEnabled) { log.Error("DeregisterContext(" + context + ") fail", ex); } throw; } }
private void RegistrationTimerCallback(object state) { if (disposed) { return; } try { StopRegistrationTimer(); if (!RouteRegistered) { try { RegisterRoute(RegisteredContexts.Union(contextsToRegister.ToList())); } catch (Exceptions.CommandFailureException ex) { if (ex.InnerException is WebException && ( (ex.InnerException as WebException).Status == WebExceptionStatus.ConnectFailure || (ex.InnerException as WebException).Status == WebExceptionStatus.Timeout )) { if (log != null && log.IsErrorEnabled) { log.Error("RegistrationTimerCallback() Could not connect to mod_cluster for STATUS command - " + ex.Message + " on " + ClusterUri); } return; } else if (log != null && log.IsErrorEnabled) { log.Error("RegistrationTimerCallback() CommandFailureException on " + ClusterUri, ex); } return; } catch (Exception ex) { if (log != null && log.IsErrorEnabled) { log.Error("RegistrationTimerCallback() failed to RegisterRoute, wait til next timer callback"); } return; } } while (RouteRegistered && contextsToRegister.Count > 0) { try { string context = null; if (!contextsToRegister.TryDequeue(out context)) { return; } if (log != null && log.IsDebugEnabled) { log.Debug("RegistrationTimerCallback() trying to register context " + context); } RegisterContextPath(context); } catch (Exception ex) { if (log != null && log.IsErrorEnabled) { log.Error("RegistrationTimerCallback() failed to add context, wait til next timer callback"); } return; } } } finally { StartRegistrationTimer(); } }
internal void RegisterContextPath(string context) { // Root if necessary context = GetRootedContextPath(context); if (RegisteredContexts.Contains(context)) { return; } McmpResponse result = null; try { // If route not reigstered, we will wait if (!RouteRegistered) { // Queue up context if (!contextsToRegister.Contains(context)) { contextsToRegister.Enqueue(context); } return; } // Register individual context on route result = ClientConfig.ExecuteCommand(ClusterUri, Constants.Commands.EnableApp, "Context", context); if (log != null && log.IsInfoEnabled) { log.Info("RegisterContextPath(" + context + ") Result: " + result.ToString()); } } catch (Exceptions.CommandFailureException ex) { if (ex.McmpResponse.ErrorMessage == "MEM: Can't read node") { log.Error("Cannot register context to cluster because this node does not exist?", ex); } else if (log != null && log.IsErrorEnabled) { log.Error("RegisterContextPath(" + context + ") Result: " + ex.McmpResponse, ex); } // Queue up context if (!contextsToRegister.Contains(context)) { contextsToRegister.Enqueue(context); } throw; } catch (Exception ex) { if (log != null && log.IsErrorEnabled) { log.Error("RegisterContextPath(" + context + ") Result: " + result, ex); } // Queue up context if (!contextsToRegister.Contains(context)) { contextsToRegister.Enqueue(context); } throw; } // Store context in our list RegisteredContexts.Add(context); }