Beispiel #1
0
                                      public override void Validate(ValidationContext ctx)
                                      {
                                          var output = ctx.Output;

                                          base.Validate(ctx);

                                          SectionZone pnz = null;

                                          try
                                          {
                                              pnz = this.ParentNOCZone;//throws
                                          }
                                          catch (Exception error)
                                          {
                                              output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, Catalog, this,
                                                                                   "Invalid '{0}' specified: {1}".Args(CONFIG_PARENT_NOC_ZONE_ATTR, error.ToMessageWithType())));
                                          }

                                          if (pnz == null && ParentSectionsOnPath.Count() > 1)
                                          {
                                              output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Warning, Catalog, this,
                                                                                   "This NOC is not top-level but it does not have any '{0}' specified".Args(CONFIG_PARENT_NOC_ZONE_ATTR)));
                                          }

                                          if (pnz != null && !pnz.ZoneGovernorHosts.Any())
                                          {
                                              output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, Catalog, this,
                                                                                   "ParenNOCZone '{0}' pointed to by this NOC does not have any hosts that run zone governor application".Args(pnz.RegionPath)));
                                          }

                                          foreach (var szone in this.ZoneNames)
                                          {
                                              this.GetZone(szone).Validate(ctx);
                                          }
                                      }
Beispiel #2
0
                              private NetSvcPeer resolveDynamicHostAddress(string fullHostName, string net, string svc, SectionHost fromh, SectionHost toh, NetSvcPeer toPeer)
                              {
                                  Contracts.HostInfo hinfo = null;

                                  SectionZone zone = toh.ParentZone;

                                  while (zone != null)
                                  {
                                      var hzgovs = zone.ZoneGovernorHosts.Where(h => !h.Dynamic);//Where for safeguard check, as dynamic host can not be zonegov, but in case someone ignores AMM error
                                      foreach (var hzgov in hzgovs)
                                      {
                                          try
                                          {
                                              using (var cl = Contracts.ServiceClientHub.New <Contracts.IZoneHostRegistryClient>(hzgov))
                                              {
                                                  cl.TimeoutMs = this.m_ResolveDynamicHostNetSvcTimeoutMs;
                                                  hinfo        = cl.GetSubordinateHost(fullHostName);
                                                  break;
                                              }
                                          }
                                          catch (Exception error)
                                          {
                                              //todo Perf counter
                                              log(MessageType.Error,
                                                  "resolveDynamicHostAddress()",
                                                  "Error resolving net svc on dynamic host '{0}' while contacting zgov on '{1}': {2}".Args(fullHostName, hzgov.RegionPath, error.ToMessageWithType()),
                                                  error);
                                          }
                                      } //foreach
                                      zone = zone.ParentZone; //loop only WITHIN the NOC
                                  }     //while

                                  if (hinfo == null)
                                  {
                                      throw new MetabaseException(StringConsts.METABASE_NET_SVC_RESOLVER_DYN_HOST_UNKNOWN_ERROR.Args(svc, fromh.RegionPath, toh.RegionPath, net));
                                  }

                                  var pattern = toPeer.Address + "*";

                                  foreach (var nic in hinfo.NetInfo.Adapters)
                                  {
                                      foreach (var addr in nic.Addresses.Where(a => a.Unicast))
                                      {
                                          if (NFX.Parsing.Utils.MatchPattern(addr.Name, pattern))
                                          {
                                              return(new NetSvcPeer(addr.Name, toPeer.Port, toPeer.Group));
                                          }
                                      }
                                  }

                                  throw new MetabaseException(StringConsts.METABASE_NET_SVC_RESOLVER_DYN_HOST_NO_ADDR_MATCH_ERROR.Args(svc, fromh.RegionPath, toh.RegionPath, net, toPeer.Address));
                              }
 internal SectionZone(SectionNOC noc, SectionZone parentZone, string name, string path, FileSystemSession session)
     : base(noc.Catalog, (SectionRegionBase)parentZone ?? (SectionRegionBase)noc, name, path, session)
 {
     m_NOC        = noc;
     m_ParentZone = parentZone;
 }
 internal SectionHost(SectionZone parentZone, string name, string path, FileSystemSession session) : base(parentZone.Catalog, parentZone, name, path, session)
 {
     m_ParentZone = parentZone;
 }