private void InnerUpdateUrlsForClient(GridRegistrationURLs urls) { if (urls != null) { urls.Expiration = DateTime.UtcNow.AddMinutes (m_timeBeforeTimeout * 60); m_genericsConnector.AddGeneric(UUID.Zero, "GridRegistrationUrls", urls.SessionID, urls.ToOSD()); MainConsole.Instance.DebugFormat ("[GridRegistrationService]: Updated URLs for {0}", urls.SessionID); } else MainConsole.Instance.ErrorFormat ("[GridRegistrationService]: Failed to find URLs to update for {0}", "unknown"); }
public OSDMap GetUrlForRegisteringClient(string SessionID) { GridRegistrationURLs urls = m_genericsConnector.GetGeneric<GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", SessionID); OSDMap retVal = new OSDMap(); if (urls != null) { if(urls.HostNames == null || urls.Ports == null || urls.URLS == null || urls.SessionID != SessionID || !CheckModuleNames(urls) || urls.VersionNumber < GridRegistrationURLs.CurrentVersionNumber) { if (urls.VersionNumber == GridRegistrationURLs.CurrentVersionNumber) { if (CheckModuleNames(urls)) { MainConsole.Instance.Warn("[GridRegService]: Null stuff in GetUrls, HostNames " + (urls.HostNames == null) + ", Ports " + (urls.Ports == null) + ", URLS " + (urls.URLS == null) + ", SessionID 1 " + SessionID + ", SessionID 2 " + urls.SessionID + ", checkModuleNames: " + CheckModuleNames(urls)); } } RemoveUrlsForClient(urls.SessionID); } else { urls.Expiration = DateTime.UtcNow.AddMinutes (m_timeBeforeTimeout * 60); urls.SessionID = SessionID; InnerUpdateUrlsForClient (urls); foreach (KeyValuePair<string, OSD> module in urls.URLS) { //Build the URL retVal[module.Key] = urls.HostNames[module.Key] + ":" + urls.Ports[module.Key] + module.Value.AsString (); } return retVal; } } OSDMap databaseSave = new OSDMap(); OSDMap ports = new OSDMap(); OSDMap hostnames = new OSDMap(); //Get the URLs from all the modules that have registered with us foreach (IGridRegistrationUrlModule module in m_modules.Values) { uint port; string hostName; string innerURL; m_loadBalancer.GetHost (module.UrlName, module, SessionID, out port, out hostName, out innerURL); ports[module.UrlName] = port; hostnames[module.UrlName] = hostName; databaseSave[module.UrlName] = innerURL; } foreach (KeyValuePair<string, OSD> module in databaseSave) { //Build the URL if (module.Value.AsString().StartsWith("http://") || module.Value.AsString().StartsWith("https://")) retVal[module.Key] = module.Value.AsString(); else retVal[module.Key] = hostnames[module.Key] + ":" + ports[module.Key] + module.Value.AsString (); } //Save into the database so that we can rebuild later if the server goes offline urls = new GridRegistrationURLs { URLS = databaseSave, SessionID = SessionID, Ports = ports, HostNames = hostnames, Expiration = DateTime.UtcNow.AddMinutes(m_timeBeforeTimeout*60) }; m_genericsConnector.AddGeneric (UUID.Zero, "GridRegistrationUrls", SessionID, urls.ToOSD ()); return retVal; }
public OSDMap GetUrlForRegisteringClient(string SessionID) { if (!m_useRegistrationService) return null; GridRegistrationURLs urls = m_genericsConnector.GetGeneric<GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", SessionID); OSDMap retVal = new OSDMap(); if (urls != null) { if(urls.HostNames == null || urls.Ports == null || urls.URLS == null || urls.SessionID != SessionID || MainServer.Instance.HostName != urls._ParentHostName || !CheckModuleNames(urls) || urls.VersionNumber < GridRegistrationURLs.CurrentVersionNumber) { if (urls.VersionNumber == GridRegistrationURLs.CurrentVersionNumber) { if (CheckModuleNames(urls)) { MainConsole.Instance.Warn("[GridRegService]: Null stuff in GetUrls, HostNames " + (urls.HostNames == null) + ", Ports " + (urls.Ports == null) + ", URLS " + (urls.URLS == null) + ", SessionID 1 " + SessionID + ", SessionID 2 " + urls.SessionID + ", checkModuleNames: " + CheckModuleNames(urls)); } } RemoveUrlsForClient(urls.SessionID); } else { urls.Expiration = DateTime.UtcNow.AddMinutes (m_timeBeforeTimeout * 60); urls.SessionID = SessionID; InnerUpdateUrlsForClient (urls); foreach (KeyValuePair<string, OSD> module in urls.URLS) { if (module.Value.Type == OSDType.Array) { OSDArray array = new OSDArray(); int i = 0; foreach (OSD o in (OSDArray)module.Value) { //Build the URL if (o.AsString().StartsWith("http://") || o.AsString().StartsWith("https://")) array.Add(o.AsString()); else array.Add(((OSDArray)urls.HostNames[module.Key])[i] + ":" + (int)((OSDArray)urls.Ports[module.Key])[i].AsUInteger() + o.AsString()); i++; } retVal[module.Key] = array; } else { //Build the URL if (module.Value.AsString().StartsWith("http://") || module.Value.AsString().StartsWith("https://")) retVal[module.Key] = module.Value.AsString(); else retVal[module.Key] = urls.HostNames[module.Key] + ":" + urls.Ports[module.Key] + module.Value.AsString(); } } return retVal; } } OSDMap databaseSave = new OSDMap(); OSDMap ports = new OSDMap(); OSDMap hostnames = new OSDMap(); //Get the URLs from all the modules that have registered with us foreach (IGridRegistrationUrlModule module in m_modules.Values) { List<uint> port; List<string> hostName; List<string> innerURL; m_loadBalancer.GetHost (module.UrlName, module, SessionID, out port, out hostName, out innerURL); ports[module.UrlName] = port.Count == 1 ? (OSD)port[0] : (OSD)port.ToOSDArray(); hostnames[module.UrlName] = hostName.Count == 1 ? (OSD)hostName[0] : (OSD)hostName.ToOSDArray(); databaseSave[module.UrlName] = innerURL.Count == 1 ? (OSD)innerURL[0] : (OSD)innerURL.ToOSDArray(); } foreach (KeyValuePair<string, OSD> module in databaseSave) { if (module.Value.Type == OSDType.Array) { OSDArray array = new OSDArray(); int i = 0; foreach (OSD o in (OSDArray)module.Value) { //Build the URL if (o.AsString().StartsWith("http://") || o.AsString().StartsWith("https://")) array.Add(o.AsString()); else array.Add(((OSDArray)hostnames[module.Key])[i] + ":" + (int)((OSDArray)ports[module.Key])[i].AsUInteger() + o.AsString()); i++; } retVal[module.Key] = array; } else { //Build the URL if (module.Value.AsString().StartsWith("http://") || module.Value.AsString().StartsWith("https://")) retVal[module.Key] = module.Value.AsString(); else retVal[module.Key] = hostnames[module.Key] + ":" + ports[module.Key] + module.Value.AsString(); } } //Save into the database so that we can rebuild later if the server goes offline urls = new GridRegistrationURLs { URLS = databaseSave, SessionID = SessionID, Ports = ports, HostNames = hostnames, Expiration = DateTime.UtcNow.AddMinutes(m_timeBeforeTimeout*60), _ParentHostName = MainServer.Instance.HostName }; m_genericsConnector.AddGeneric (UUID.Zero, "GridRegistrationUrls", SessionID, urls.ToOSD ()); return retVal; }
public OSDMap GetUrlForRegisteringClient(string SessionID, ulong RegionHandle) { GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", RegionHandle.ToString(), new GridRegistrationURLs()); OSDMap retVal = new OSDMap(); if (urls != null) { urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); urls.SessionID = SessionID; urls.RegionHandle = RegionHandle; foreach (KeyValuePair <string, OSD> module in urls.URLS) { //Build the URL retVal[module.Key] = m_loadBalancer.GetHost() + ":" + m_modules[module.Key].Port + module.Value.AsString(); } return(retVal); } OSDMap databaseSave = new OSDMap(); //Get the URLs from all the modules that have registered with us foreach (IGridRegistrationUrlModule module in m_modules.Values) { //Build the URL databaseSave[module.UrlName] = module.GetUrlForRegisteringClient(SessionID, RegionHandle); } foreach (KeyValuePair <string, OSD> module in databaseSave) { //Build the URL retVal[module.Key] = m_loadBalancer.GetHost() + ":" + m_modules[module.Key].Port + module.Value.AsString(); } //Save into the database so that we can rebuild later if the server goes offline urls = new GridRegistrationURLs(); urls.URLS = databaseSave; urls.RegionHandle = RegionHandle; urls.SessionID = SessionID; urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); m_genericsConnector.AddGeneric(UUID.Zero, "GridRegistrationUrls", RegionHandle.ToString(), urls.ToOSD()); return(retVal); }
public void UpdateUrlsForClient(ulong RegionHandle) { GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", RegionHandle.ToString(), new GridRegistrationURLs()); if (urls != null) { urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); m_genericsConnector.AddGeneric(UUID.Zero, "GridRegistrationUrls", RegionHandle.ToString(), urls.ToOSD()); m_log.WarnFormat("[GridRegistrationService]: Updated URLs for {0}", RegionHandle); } else { m_log.ErrorFormat("[GridRegistrationService]: Failed to find URLs to update for {0}", RegionHandle); } }
private void InnerUpdateUrlsForClient(GridRegistrationURLs urls) { if (urls != null) { urls.Expiration = DateTime.UtcNow.AddMinutes (m_timeBeforeTimeout * 60); //Remove it first just to make sure it is replaced m_genericsConnector.RemoveGeneric (UUID.Zero, "GridRegistrationUrls", urls.SessionID.ToString ()); m_genericsConnector.AddGeneric (UUID.Zero, "GridRegistrationUrls", urls.SessionID.ToString (), urls.ToOSD ()); m_log.WarnFormat ("[GridRegistrationService]: Updated URLs for {0}", urls.SessionID); } else m_log.ErrorFormat ("[GridRegistrationService]: Failed to find URLs to update for {0}", urls.SessionID); }
public OSDMap GetUrlForRegisteringClient(string SessionID, ulong RegionHandle) { GridRegistrationURLs urls = m_genericsConnector.GetGeneric<GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", RegionHandle.ToString(), new GridRegistrationURLs()); OSDMap retVal = new OSDMap(); if (urls != null) { urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); urls.SessionID = SessionID; urls.RegionHandle = RegionHandle; foreach (KeyValuePair<string, OSD> module in urls.URLS) { //Build the URL retVal[module.Key] = m_loadBalancer.GetHost() + ":" + m_modules[module.Key].Port + module.Value.AsString(); } return retVal; } OSDMap databaseSave = new OSDMap(); //Get the URLs from all the modules that have registered with us foreach (IGridRegistrationUrlModule module in m_modules.Values) { //Build the URL databaseSave[module.UrlName] = module.GetUrlForRegisteringClient(SessionID, RegionHandle); } foreach (KeyValuePair<string, OSD> module in databaseSave) { //Build the URL retVal[module.Key] = m_loadBalancer.GetHost() + ":" + m_modules[module.Key].Port + module.Value.AsString(); } //Save into the database so that we can rebuild later if the server goes offline urls = new GridRegistrationURLs(); urls.URLS = databaseSave; urls.RegionHandle = RegionHandle; urls.SessionID = SessionID; urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); m_genericsConnector.AddGeneric(UUID.Zero, "GridRegistrationUrls", RegionHandle.ToString(), urls.ToOSD()); return retVal; }
private void InnerUpdateUrlsForClient(GridRegistrationURLs urls) { if (urls != null) { urls.Expiration = DateTime.UtcNow.AddMinutes(m_timeBeforeTimeout * 60); m_genericsConnector.AddGeneric(UUID.Zero, "GridRegistrationUrls", urls.SessionID, urls.ToOSD()); MainConsole.Instance.DebugFormat("[GridRegistrationService]: Updated URLs for {0}", urls.SessionID); } else { MainConsole.Instance.ErrorFormat("[GridRegistrationService]: Failed to find URLs to update for {0}", "unknown"); } }
public OSDMap GetUrlForRegisteringClient(string SessionID) { if (!m_useRegistrationService) { return(null); } GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", SessionID); OSDMap retVal = new OSDMap(); if (urls != null) { if (urls.HostNames == null || urls.Ports == null || urls.URLS == null || urls.SessionID != SessionID || MainServer.Instance.HostName != urls._ParentHostName || !CheckModuleNames(urls) || urls.VersionNumber < GridRegistrationURLs.CurrentVersionNumber) { if (urls.VersionNumber == GridRegistrationURLs.CurrentVersionNumber) { if (CheckModuleNames(urls)) { MainConsole.Instance.Warn("[GridRegService]: Null stuff in GetUrls, HostNames " + (urls.HostNames == null) + ", Ports " + (urls.Ports == null) + ", URLS " + (urls.URLS == null) + ", SessionID 1 " + SessionID + ", SessionID 2 " + urls.SessionID + ", checkModuleNames: " + CheckModuleNames(urls)); } } RemoveUrlsForClient(urls.SessionID); } else { urls.Expiration = DateTime.UtcNow.AddMinutes(m_timeBeforeTimeout * 60); urls.SessionID = SessionID; InnerUpdateUrlsForClient(urls); foreach (KeyValuePair <string, OSD> module in urls.URLS) { if (module.Value.Type == OSDType.Array) { OSDArray array = new OSDArray(); int i = 0; foreach (OSD o in (OSDArray)module.Value) { //Build the URL if (o.AsString().StartsWith("http://") || o.AsString().StartsWith("https://")) { array.Add(o.AsString()); } else { array.Add(((OSDArray)urls.HostNames[module.Key])[i] + ":" + (int)((OSDArray)urls.Ports[module.Key])[i].AsUInteger() + o.AsString()); } i++; } retVal[module.Key] = array; } else { //Build the URL if (module.Value.AsString().StartsWith("http://") || module.Value.AsString().StartsWith("https://")) { retVal[module.Key] = module.Value.AsString(); } else { retVal[module.Key] = urls.HostNames[module.Key] + ":" + urls.Ports[module.Key] + module.Value.AsString(); } } } return(retVal); } } OSDMap databaseSave = new OSDMap(); OSDMap ports = new OSDMap(); OSDMap hostnames = new OSDMap(); //Get the URLs from all the modules that have registered with us foreach (IGridRegistrationUrlModule module in m_modules.Values) { List <uint> port; List <string> hostName; List <string> innerURL; m_loadBalancer.GetHost(module.UrlName, module, SessionID, out port, out hostName, out innerURL); ports[module.UrlName] = port.Count == 1 ? (OSD)port[0] : (OSD)port.ToOSDArray(); hostnames[module.UrlName] = hostName.Count == 1 ? (OSD)hostName[0] : (OSD)hostName.ToOSDArray(); databaseSave[module.UrlName] = innerURL.Count == 1 ? (OSD)innerURL[0] : (OSD)innerURL.ToOSDArray(); } foreach (KeyValuePair <string, OSD> module in databaseSave) { if (module.Value.Type == OSDType.Array) { OSDArray array = new OSDArray(); int i = 0; foreach (OSD o in (OSDArray)module.Value) { //Build the URL if (o.AsString().StartsWith("http://") || o.AsString().StartsWith("https://")) { array.Add(o.AsString()); } else { array.Add(((OSDArray)hostnames[module.Key])[i] + ":" + (int)((OSDArray)ports[module.Key])[i].AsUInteger() + o.AsString()); } i++; } retVal[module.Key] = array; } else { //Build the URL if (module.Value.AsString().StartsWith("http://") || module.Value.AsString().StartsWith("https://")) { retVal[module.Key] = module.Value.AsString(); } else { retVal[module.Key] = hostnames[module.Key] + ":" + ports[module.Key] + module.Value.AsString(); } } } //Save into the database so that we can rebuild later if the server goes offline urls = new GridRegistrationURLs { URLS = databaseSave, SessionID = SessionID, Ports = ports, HostNames = hostnames, Expiration = DateTime.UtcNow.AddMinutes(m_timeBeforeTimeout * 60), _ParentHostName = MainServer.Instance.HostName }; m_genericsConnector.AddGeneric(UUID.Zero, "GridRegistrationUrls", SessionID, urls.ToOSD()); return(retVal); }
public OSDMap GetUrlForRegisteringClient(string SessionID) { GridRegistrationURLs urls = m_genericsConnector.GetGeneric <GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", SessionID); OSDMap retVal = new OSDMap(); if (urls != null) { if (urls.HostNames == null || urls.Ports == null || urls.URLS == null || urls.SessionID != SessionID || !CheckModuleNames(urls) || urls.VersionNumber < GridRegistrationURLs.CurrentVersionNumber) { if (urls.VersionNumber == GridRegistrationURLs.CurrentVersionNumber) { if (CheckModuleNames(urls)) { MainConsole.Instance.Warn("[GridRegService]: Null stuff in GetUrls, HostNames " + (urls.HostNames == null) + ", Ports " + (urls.Ports == null) + ", URLS " + (urls.URLS == null) + ", SessionID 1 " + SessionID + ", SessionID 2 " + urls.SessionID + ", checkModuleNames: " + CheckModuleNames(urls)); } } RemoveUrlsForClient(urls.SessionID); } else { urls.Expiration = DateTime.UtcNow.AddMinutes(m_timeBeforeTimeout * 60); urls.SessionID = SessionID; InnerUpdateUrlsForClient(urls); foreach (KeyValuePair <string, OSD> module in urls.URLS) { //Build the URL retVal[module.Key] = urls.HostNames[module.Key] + ":" + urls.Ports[module.Key] + module.Value.AsString(); } return(retVal); } } OSDMap databaseSave = new OSDMap(); OSDMap ports = new OSDMap(); OSDMap hostnames = new OSDMap(); //Get the URLs from all the modules that have registered with us foreach (IGridRegistrationUrlModule module in m_modules.Values) { uint port; string hostName; string innerURL; m_loadBalancer.GetHost(module.UrlName, module, SessionID, out port, out hostName, out innerURL); ports[module.UrlName] = port; hostnames[module.UrlName] = hostName; databaseSave[module.UrlName] = innerURL; } foreach (KeyValuePair <string, OSD> module in databaseSave) { //Build the URL if (module.Value.AsString().StartsWith("http://") || module.Value.AsString().StartsWith("https://")) { retVal[module.Key] = module.Value.AsString(); } else { retVal[module.Key] = hostnames[module.Key] + ":" + ports[module.Key] + module.Value.AsString(); } } //Save into the database so that we can rebuild later if the server goes offline urls = new GridRegistrationURLs { URLS = databaseSave, SessionID = SessionID, Ports = ports, HostNames = hostnames, Expiration = DateTime.UtcNow.AddMinutes(m_timeBeforeTimeout * 60) }; m_genericsConnector.AddGeneric(UUID.Zero, "GridRegistrationUrls", SessionID, urls.ToOSD()); return(retVal); }
private void InnerUpdateUrlsForClient(GridRegistrationURLs urls) { if (urls != null) { urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); m_genericsConnector.AddGeneric (UUID.Zero, "GridRegistrationUrls", urls.SessionID.ToString (), urls.ToOSD ()); m_log.WarnFormat ("[GridRegistrationService]: Updated URLs for {0}", urls.SessionID); } else m_log.ErrorFormat ("[GridRegistrationService]: Failed to find URLs to update for {0}", urls.SessionID); }
public OSDMap GetUrlForRegisteringClient(string SessionID) { GridRegistrationURLs urls = m_genericsConnector.GetGeneric<GridRegistrationURLs>(UUID.Zero, "GridRegistrationUrls", SessionID.ToString (), new GridRegistrationURLs ()); OSDMap retVal = new OSDMap(); if (urls != null) { if(urls.HostNames == null || urls.Ports == null || urls.URLS == null || urls.SessionID != SessionID) { RemoveUrlsForClient(SessionID.ToString()); } else { urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); urls.SessionID = SessionID; foreach (KeyValuePair<string, OSD> module in urls.URLS) { //Build the URL retVal[module.Key] = urls.HostNames[module.Key] + ":" + urls.Ports[module.Key] + module.Value.AsString (); } return retVal; } } OSDMap databaseSave = new OSDMap(); OSDMap ports = new OSDMap(); OSDMap hostnames = new OSDMap(); //Get the URLs from all the modules that have registered with us foreach (IGridRegistrationUrlModule module in m_modules.Values) { ports[module.UrlName] = m_loadBalancer.GetPort (module.UrlName); hostnames[module.UrlName] = m_loadBalancer.GetHost (module.UrlName); //Build the URL databaseSave[module.UrlName] = module.GetUrlForRegisteringClient (SessionID, ports[module.UrlName]); } foreach (KeyValuePair<string, OSD> module in databaseSave) { //Build the URL retVal[module.Key] = hostnames[module.Key] + ":" + ports[module.Key] + module.Value.AsString (); } //Save into the database so that we can rebuild later if the server goes offline urls = new GridRegistrationURLs(); urls.URLS = databaseSave; urls.SessionID = SessionID; urls.Ports = ports; urls.HostNames = hostnames; urls.Expiration = DateTime.Now.AddHours(m_timeBeforeTimeout); m_genericsConnector.AddGeneric (UUID.Zero, "GridRegistrationUrls", SessionID.ToString (), urls.ToOSD ()); return retVal; }