|
|
@ -516,26 +516,29 @@ namespace ZeroLevel.Network
|
|
|
|
if (discovery_endpoint.Success)
|
|
|
|
if (discovery_endpoint.Success)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var discoveryClient = _cachee.GetClient(discovery_endpoint.Value, true);
|
|
|
|
var discoveryClient = _cachee.GetClient(discovery_endpoint.Value, true);
|
|
|
|
var services = _cachee.ServerList.
|
|
|
|
if (discoveryClient != null)
|
|
|
|
Select(s =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var services = _cachee.ServerList.
|
|
|
|
var info = MessageSerializer.Copy(_owner.ServiceInfo);
|
|
|
|
Select(s =>
|
|
|
|
info.Port = s.LocalEndpoint.Port;
|
|
|
|
{
|
|
|
|
return info;
|
|
|
|
var info = MessageSerializer.Copy(_owner.ServiceInfo);
|
|
|
|
}).
|
|
|
|
info.Port = s.LocalEndpoint.Port;
|
|
|
|
ToList();
|
|
|
|
return info;
|
|
|
|
foreach (var service in services)
|
|
|
|
}).
|
|
|
|
{
|
|
|
|
ToList();
|
|
|
|
var request = discoveryClient.Request<ZeroServiceInfo, InvokeResult>("register", service, r =>
|
|
|
|
foreach (var service in services)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!r.Success)
|
|
|
|
var request = discoveryClient.Request<ZeroServiceInfo, InvokeResult>("register", service, r =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.SystemWarning($"[Exchange.RegisterServicesInDiscovery] Register canceled. {r.Comment}");
|
|
|
|
if (!r.Success)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.SystemWarning($"[Exchange.RegisterServicesInDiscovery] Register canceled. {r.Comment}");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (request.Success == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.SystemWarning($"[Exchange.RegisterServicesInDiscovery] Register canceled.{request.Comment}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (request.Success == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.SystemWarning($"[Exchange.RegisterServicesInDiscovery] Register canceled.{request.Comment}");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -547,55 +550,58 @@ namespace ZeroLevel.Network
|
|
|
|
if (discovery_endpoint.Success)
|
|
|
|
if (discovery_endpoint.Success)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var discoveryClient = _cachee.GetClient(discovery_endpoint.Value, true);
|
|
|
|
var discoveryClient = _cachee.GetClient(discovery_endpoint.Value, true);
|
|
|
|
try
|
|
|
|
if (discoveryClient != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var ir = discoveryClient.Request<IEnumerable<ServiceEndpointsInfo>>("services", records =>
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (records == null)
|
|
|
|
var ir = discoveryClient.Request<IEnumerable<ServiceEndpointsInfo>>("services", records =>
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.SystemWarning("[Exchange.UpdateServiceListFromDiscovery] UpdateServiceListInfo. Discrovery response is empty");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var endpoints = new HashSet<IPEndPoint>();
|
|
|
|
|
|
|
|
_dicovery_aliases.BeginUpdate();
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
foreach (var service in records)
|
|
|
|
if (records == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
endpoints.Clear();
|
|
|
|
Log.SystemWarning("[Exchange.UpdateServiceListFromDiscovery] UpdateServiceListInfo. Discrovery response is empty");
|
|
|
|
foreach (var ep in service.Endpoints)
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var endpoints = new HashSet<IPEndPoint>();
|
|
|
|
|
|
|
|
_dicovery_aliases.BeginUpdate();
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var service in records)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
endpoints.Clear();
|
|
|
|
{
|
|
|
|
foreach (var ep in service.Endpoints)
|
|
|
|
var endpoint = NetUtils.CreateIPEndPoint(ep);
|
|
|
|
|
|
|
|
endpoints.Add(endpoint);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.SystemWarning($"[Exchange.UpdateServiceListFromDiscovery] Can't parse address {ep} as IPEndPoint");
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var endpoint = NetUtils.CreateIPEndPoint(ep);
|
|
|
|
|
|
|
|
endpoints.Add(endpoint);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.SystemWarning($"[Exchange.UpdateServiceListFromDiscovery] Can't parse address {ep} as IPEndPoint");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_dicovery_aliases.Set(service.ServiceKey,
|
|
|
|
|
|
|
|
service.ServiceType,
|
|
|
|
|
|
|
|
service.ServiceGroup,
|
|
|
|
|
|
|
|
endpoints);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_dicovery_aliases.Set(service.ServiceKey,
|
|
|
|
_dicovery_aliases.Commit();
|
|
|
|
service.ServiceType,
|
|
|
|
|
|
|
|
service.ServiceGroup,
|
|
|
|
|
|
|
|
endpoints);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_dicovery_aliases.Commit();
|
|
|
|
catch
|
|
|
|
}
|
|
|
|
{
|
|
|
|
catch
|
|
|
|
_dicovery_aliases.Rollback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!ir.Success)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_dicovery_aliases.Rollback();
|
|
|
|
Log.SystemWarning($"[Exchange.UpdateServiceListFromDiscovery] Error request to inbox 'services'. {ir.Comment}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (!ir.Success)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.SystemWarning($"[Exchange.UpdateServiceListFromDiscovery] Error request to inbox 'services'. {ir.Comment}");
|
|
|
|
Log.SystemError(ex, "[Exchange.UpdateServiceListFromDiscovery] Discovery service response is absent");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.SystemError(ex, "[Exchange.UpdateServiceListFromDiscovery] Discovery service response is absent");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -777,6 +783,7 @@ namespace ZeroLevel.Network
|
|
|
|
Log.SystemError(ex, $"[Exchange.GetClientEnumerator] Can't get transport for endpoint '{endpoint}'");
|
|
|
|
Log.SystemError(ex, $"[Exchange.GetClientEnumerator] Can't get transport for endpoint '{endpoint}'");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transport == null) continue;
|
|
|
|
yield return transport;
|
|
|
|
yield return transport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -812,6 +819,7 @@ namespace ZeroLevel.Network
|
|
|
|
Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByType] Can't get transport for endpoint '{endpoint}'");
|
|
|
|
Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByType] Can't get transport for endpoint '{endpoint}'");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transport == null) continue;
|
|
|
|
yield return transport;
|
|
|
|
yield return transport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -847,6 +855,7 @@ namespace ZeroLevel.Network
|
|
|
|
Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByGroup] Can't get transport for endpoint '{service}'");
|
|
|
|
Log.SystemError(ex, $"[Exchange.GetClientEnumeratorByGroup] Can't get transport for endpoint '{service}'");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transport == null) continue;
|
|
|
|
yield return transport;
|
|
|
|
yield return transport;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -891,6 +900,7 @@ namespace ZeroLevel.Network
|
|
|
|
Log.SystemError(ex, $"[Exchange.CallService] Can't get transport for service '{serviceKey}'");
|
|
|
|
Log.SystemError(ex, $"[Exchange.CallService] Can't get transport for service '{serviceKey}'");
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transport == null) continue;
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
success = callHandler(transport);
|
|
|
|
success = callHandler(transport);
|
|
|
|