pull/1/head
a.bozhenov 5 years ago
parent 886b2fd5b5
commit 689c12e8dc

@ -1,4 +1,5 @@
using System.Threading;
using System;
using System.Threading;
using ZeroLevel;
using ZeroLevel.Network;
using ZeroLevel.Services.Applications;
@ -12,6 +13,12 @@ namespace Consumer
{
ReadServiceInfo();
AutoregisterInboxes(UseHost());
Sheduller.RemindEvery(TimeSpan.FromSeconds(1), () =>
{
Console.SetCursorPosition(0, 0);
Console.WriteLine(_proceed);
});
}
protected override void StopAction()

@ -13,6 +13,12 @@ namespace Processor
{
ReadServiceInfo();
AutoregisterInboxes(UseHost());
Sheduller.RemindEvery(TimeSpan.FromSeconds(1), () =>
{
Console.SetCursorPosition(0, 0);
Console.WriteLine(_proceed);
});
}
protected override void StopAction()

@ -14,7 +14,7 @@ namespace Source
ReadServiceInfo();
AutoregisterInboxes(UseHost());
Sheduller.RemindEvery(TimeSpan.FromMilliseconds(10), () =>
Sheduller.RemindEvery(TimeSpan.FromMilliseconds(100), () =>
{
if (Exchange.Send("test.processor", "handle", Environment.TickCount))
{

@ -22,6 +22,11 @@ namespace Watcher
var success = Exchange.RequestBroadcastByGroup<ZeroServiceInfo>("Test", "meta", records =>
{
if (records.Any() == false)
{
Log.Info("No services");
}
foreach (var record in records.OrderBy(r=>r.Name))
{
sb.Append(record.Name);

@ -127,6 +127,7 @@ namespace ZeroLevel.Discovery
foreach (var ep in pair.Value)
{
_table[pair.Key].Endpoints.Remove(ep);
Log.Debug($"Removed address {ep}");
}
}
var badKeys = _table.Where(f => f.Value.Endpoints.Count == 0)
@ -135,6 +136,7 @@ namespace ZeroLevel.Discovery
foreach (var badKey in badKeys)
{
_table.Remove(badKey);
Log.Debug($"Removed service {badKey}");
}
}
finally

@ -343,13 +343,14 @@ namespace ZeroLevel.Services.Applications
{
try
{
StartAction();
_state = ZeroServiceStatus.Running;
StartAction();
Log.Debug($"[{Name}] Service started");
}
catch (Exception ex)
{
Log.Fatal(ex, $"[{Name}] Failed to start service");
Stop();
}
}
}

@ -42,7 +42,11 @@ namespace ZeroLevel
public BootstrapFluent EnableConsoleLog(LogLevel level = LogLevel.FullStandart) { Log.AddConsoleLogger(level); return this; }
public ZeroServiceStatus Status { get { return _service.Status; } }
public IServiceExecution Run() { _service.Start(); return this; }
public IServiceExecution Run()
{
_service.Start();
return this;
}
public IServiceExecution Stop()
{
try

@ -27,7 +27,6 @@ namespace ZeroLevel.Network
public Exchange(IZeroService owner)
{
_owner = owner;
_cachee.OnBrokenConnection += _cachee_OnBrokenConnection;
}
#endregion Ctor
@ -920,7 +919,7 @@ namespace ZeroLevel.Network
{
try
{
if (false == client.Request<Treq, Tresp>(inbox, data, resp => { waiter.Signal(); response.Add(resp); }).Success)
if (false == client.Request<Treq, Tresp>(inbox, data, resp => { response.Add(resp); waiter.Signal(); }).Success)
{
waiter.Signal();
}
@ -948,7 +947,7 @@ namespace ZeroLevel.Network
{
try
{
if (false == client.Request<Tresp>(inbox, resp => { waiter.Signal(); response.Add(resp); }).Success)
if (false == client.Request<Tresp>(inbox, resp => { response.Add(resp); waiter.Signal(); }).Success)
{
waiter.Signal();
}
@ -964,11 +963,6 @@ namespace ZeroLevel.Network
}
return response;
}
private void _cachee_OnBrokenConnection(IPEndPoint endpoint)
{
//_aliases.Remove(endpoint); ??? no need
}
#endregion
public void Dispose()

@ -8,16 +8,6 @@ namespace ZeroLevel.Network
internal sealed class ExClientServerCachee
: IDisposable
{
internal event Action<IPEndPoint> OnBrokenConnection;
private void RiseBrokenConnectionEvent(IPEndPoint endpoint)
{
var e = OnBrokenConnection;
if (e != null)
{
e.Invoke(endpoint);
}
}
private static readonly ConcurrentDictionary<string, ExClient> _clientInstances = new ConcurrentDictionary<string, ExClient>();
private readonly ConcurrentDictionary<string, SocketServer> _serverInstances = new ConcurrentDictionary<string, SocketServer>();
@ -44,12 +34,8 @@ namespace ZeroLevel.Network
}
instance = new ExClient(new SocketClient(endpoint, router ?? new Router()));
instance.ForceConnect();
if (instance.Status != SocketClientStatus.Initialized &&
instance.Status != SocketClientStatus.Working)
{
OnBrokenConnection(endpoint);
}
else
if (instance.Status == SocketClientStatus.Initialized
||instance.Status == SocketClientStatus.Working)
{
_clientInstances[key] = instance;
return instance;
@ -58,12 +44,8 @@ namespace ZeroLevel.Network
else
{
var instance = new ExClient(new SocketClient(endpoint, router ?? new Router()));
if (instance.Status != SocketClientStatus.Initialized &&
instance.Status != SocketClientStatus.Working)
{
OnBrokenConnection(endpoint);
}
else
if (instance.Status == SocketClientStatus.Initialized
|| instance.Status == SocketClientStatus.Working)
{
return instance;
}

Loading…
Cancel
Save

Powered by TurnKey Linux.