static bool RendezvousWithParent(string processUri, string fileUri, string directory, ILogger logger) { if (parentAddress == null) { // we weren't started from Peloponnese so do nothing return(true); } NotHttpClient httpClient = new NotHttpClient(false, 1, 10000, logger); string status; try { var processDetails = new XElement("ProcessUri"); processDetails.Value = processUri; var fileDetails = new XElement("FileUri"); fileDetails.Value = fileUri; var dirDetails = new XElement("LocalDirectory"); dirDetails.Value = directory; var details = new XElement("ProcessDetails"); details.SetAttributeValue("hostname", hostName); details.SetAttributeValue("rackname", rackName); details.Add(processDetails); details.Add(fileDetails); details.Add(dirDetails); status = details.ToString(); } catch (Exception e) { logger.Log("malformed xml: " + e.ToString()); return(false); } string registration = String.Format("{0}register?guid={1}&group={2}&identifier={3}", parentAddress, jobGuid.ToString(), groupName, identifier); IHttpRequest request = httpClient.CreateRequest(registration); request.Timeout = 30 * 1000; // if it doesn't respond in 30 seconds we'll throw an exception and quit request.Method = "POST"; try { using (Stream upload = request.GetRequestStream()) { using (StreamWriter sw = new StreamWriter(upload)) { sw.Write(status); } } using (IHttpResponse response = request.GetResponse()) { logger.Log("Server registration succeeded"); return(true); } } catch (NotHttpException e) { // if this failed, there's nothing much more we can do logger.Log("Command put failed message " + e.Message + " status " + e.Response.StatusCode + " " + e.Response.StatusDescription); } catch (Exception e) { logger.Log("Command put failed message " + e.Message); } return(false); }
public static IHttpRequest Create(string uri) { return(s_client.CreateRequest(uri)); }
static bool RendezvousWithParent(string processUri, string fileUri, string directory, ILogger logger) { if (parentAddress == null) { // we weren't started from Peloponnese so do nothing return true; } NotHttpClient httpClient = new NotHttpClient(false, 1, 10000, logger); string status; try { var processDetails = new XElement("ProcessUri"); processDetails.Value = processUri; var fileDetails = new XElement("FileUri"); fileDetails.Value = fileUri; var dirDetails = new XElement("LocalDirectory"); dirDetails.Value = directory; var details = new XElement("ProcessDetails"); details.SetAttributeValue("hostname", hostName); details.SetAttributeValue("rackname", rackName); details.Add(processDetails); details.Add(fileDetails); details.Add(dirDetails); status = details.ToString(); } catch (Exception e) { logger.Log("malformed xml: " + e.ToString()); return false; } string registration = String.Format("{0}register?guid={1}&group={2}&identifier={3}", parentAddress, jobGuid.ToString(), groupName, identifier); IHttpRequest request = httpClient.CreateRequest(registration); request.Timeout = 30 * 1000; // if it doesn't respond in 30 seconds we'll throw an exception and quit request.Method = "POST"; try { using (Stream upload = request.GetRequestStream()) { using (StreamWriter sw = new StreamWriter(upload)) { sw.Write(status); } } using (IHttpResponse response = request.GetResponse()) { logger.Log("Server registration succeeded"); return true; } } catch (NotHttpException e) { // if this failed, there's nothing much more we can do logger.Log("Command put failed message " + e.Message + " status " + e.Response.StatusCode + " " + e.Response.StatusDescription); } catch (Exception e) { logger.Log("Command put failed message " + e.Message); } return false; }