private bool validate_Contracts(ValidationContext ctx) { var output = ctx.Output; try { var instance = SkyApp.GetServiceClientHub(); } catch (Exception error) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, null, null, StringConsts.METABASE_CONTRACTS_SERVICE_HUB_ERROR + error.ToMessageWithType())); return(false); } foreach (var mapping in SkyApp.GetServiceClientHub().CachedMap) { if (mapping.Local.Service.IsNullOrWhiteSpace()) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Warning, null, null, " Contract mapping '{0}' does not specify local service name".Args(mapping))); } if (mapping.Global.Service.IsNullOrWhiteSpace()) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Warning, null, null, " Contract mapping '{0}' does not specify global service name".Args(mapping))); } } return(true); }
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 = SkyApp.GetServiceClientHub().MakeNew <Contracts.IZoneHostRegistryClient>(hzgov)) { cl.TimeoutMs = this.m_ResolveDynamicHostNetSvcTimeoutMs; hinfo = cl.GetSubordinateHost(fullHostName); break; } } catch (Exception error) { //todo Perf counter WriteLog(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 (Text.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)); }
private void validate_GDIDAuthorities(ValidationContext ctx) { var output = ctx.Output; var authorities = GDIDAuthorities; if (!authorities.Any()) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Warning, null, null, StringConsts.METABASE_GDID_AUTHORITIES_NONE_DEFINED_WARNING)); return; } if (authorities.Count() != authorities.Distinct().Count()) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, null, null, StringConsts.METABASE_GDID_AUTHORITIES_DUPLICATION_ERROR)); } foreach (var authority in authorities) { var host = CatalogReg[authority.Name] as SectionHost; if (host == null) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, null, null, StringConsts.METABASE_GDID_AUTHORITY_BAD_HOST_ERROR.Args(authority.Name))); continue; } if (!host.Role.AppNames.Any(n => INVSTRCMP.Equals(n, SysConsts.APP_NAME_GDIDA))) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, null, null, StringConsts.METABASE_GDID_AUTHORITY_HOST_NOT_AGDIDA_ERROR.Args(authority.Name, host.Role))); } try { SkyApp.GetServiceClientHub().RunTestSetupOf <Contracts.IGdidAuthorityClient>(host.RegionPath); } catch (Exception error) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, null, null, StringConsts.METABASE_GDID_AUTHORITY_SVC_RESOLUTION_ERROR.Args(authority.Name, error.ToMessageWithType()))); } } }