Ejemplo n.º 1
0
        public MatcherInfo FindMatcher(IId partitionId)
        {
            MatcherInfoResponse response = null;

            string path = string.Format("{0}/find/{1}", MatchersPath, partitionId.ToUrlSafe());

            using (WebClient wc = new WebClient {
                BaseAddress = this.BaseAddress
            })
                using (var responseStream = wc.OpenRead(path))
                {
                    var s = new XmlSerializer(typeof(MatcherInfoResponse));
                    response = (MatcherInfoResponse)s.Deserialize(responseStream);
                }

            if (response.Success)
            {
                return(response.Result);
            }
            else
            {
                logger.Error("Error while getting matcher address: {0}.", response.ErrorMessage);
                // TODO: throw an exception?
                return(null);
            }
        }
Ejemplo n.º 2
0
 public INode GetNode(IId id)
 {
     try
     {
         using (WebClient wc = new WebClient {
             BaseAddress = this.baseAddress
         })
             using (var stream = wc.OpenRead(string.Format("{0}/{1}", NodesPath, id.ToUrlSafe())))
             {
                 return(new NodeSerializer(stream).Deserialize());
             }
     }
     catch (WebException ex)
     {
         logger.WarnException("Could not find node in partition.", ex);
         return(null);
     }
 }