|
@@ -75,7 +75,12 @@ namespace Vinno.vCloud.Common.FIS
|
|
|
var result = LeafTest();
|
|
|
stopwatch.Stop();
|
|
|
Logger.WriteLineInfo($"LeafTest 1st Time Cost {stopwatch.ElapsedMilliseconds}ms,result is {result}");
|
|
|
- if (!result && !_cts.IsCancellationRequested)
|
|
|
+ if (_cts.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ Logger.WriteLineInfo($"LeafTest 2nd Time Cancelled");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (!result)
|
|
|
{
|
|
|
stopwatch.Restart();
|
|
|
result = LeafTest();
|
|
@@ -88,20 +93,26 @@ namespace Vinno.vCloud.Common.FIS
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (_leaf != null)
|
|
|
+ _leaf?.Close();
|
|
|
+ _leaf = null;
|
|
|
+ var url = $"{_host}:{_port}";
|
|
|
+ _leaf = new ClientLeaf(new LeafIdContext(), LeafMode.Dual, new TcpCreator(url));
|
|
|
+ if (_cts.IsCancellationRequested)
|
|
|
{
|
|
|
- _leaf.Close();
|
|
|
+ _leaf?.Close();
|
|
|
_leaf = null;
|
|
|
+ return false;
|
|
|
}
|
|
|
- var url = $"{_host}:{_port}";
|
|
|
- _leaf = new ClientLeaf(new LeafIdContext(), LeafMode.Dual, new TcpCreator(url));
|
|
|
- if (_leaf.Online)
|
|
|
+ else
|
|
|
{
|
|
|
- _testResult = ServerTestResult.OldServer;
|
|
|
- _manualResetEvent.Set();
|
|
|
- return true;
|
|
|
+ if (_leaf.Online)
|
|
|
+ {
|
|
|
+ _testResult = ServerTestResult.OldServer;
|
|
|
+ _manualResetEvent.Set();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
@@ -123,7 +134,20 @@ namespace Vinno.vCloud.Common.FIS
|
|
|
{
|
|
|
Logger.WriteLineInfo($"JsonRpcTest For Http 1st Time Cost {stopwatch.ElapsedMilliseconds}ms,result is {result}");
|
|
|
}
|
|
|
- if (!result && !_cts.IsCancellationRequested)
|
|
|
+ if (_cts.IsCancellationRequested)
|
|
|
+ {
|
|
|
+ if (isUseHttps)
|
|
|
+ {
|
|
|
+ Logger.WriteLineInfo($"JsonRpcTest For Https 2nd Time Cancelled");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Logger.WriteLineInfo($"JsonRpcTest For Http 2nd Time Cancelled");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (!result)
|
|
|
{
|
|
|
stopwatch.Restart();
|
|
|
result = isUseHttps ? JsonRpcTestWithHttps() : JsonRpcTestWithHttp();
|
|
@@ -143,24 +167,30 @@ namespace Vinno.vCloud.Common.FIS
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (_clientForHttp != null)
|
|
|
- {
|
|
|
- _clientForHttp.Dispose();
|
|
|
- _clientForHttp = null;
|
|
|
- }
|
|
|
+ _clientForHttp?.Dispose();
|
|
|
+ _clientForHttp = null;
|
|
|
var url = $"http://{_host}:{_port}";
|
|
|
_clientForHttp = new JsonRpcClient();
|
|
|
var clientEngine = new JsonRpcHttpClientEngine(url);
|
|
|
_clientForHttp.UseEngine(clientEngine);
|
|
|
var vinnoServerService = _clientForHttp.CreateProxy<IVinnoServerService>(5000);
|
|
|
var echoResult = JsonRpcHelper.Echo(vinnoServerService);
|
|
|
- if (echoResult != null && echoResult.Code == 0)
|
|
|
+ if (_cts.IsCancellationRequested)
|
|
|
{
|
|
|
- _testResult = ServerTestResult.NewServerWithHttp;
|
|
|
- _manualResetEvent.Set();
|
|
|
- return true;
|
|
|
+ _clientForHttp?.Dispose();
|
|
|
+ _clientForHttp = null;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (echoResult != null && echoResult.Code == 0)
|
|
|
+ {
|
|
|
+ _testResult = ServerTestResult.NewServerWithHttp;
|
|
|
+ _manualResetEvent.Set();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
@@ -172,24 +202,30 @@ namespace Vinno.vCloud.Common.FIS
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- if (_clientForHttps != null)
|
|
|
- {
|
|
|
- _clientForHttps.Dispose();
|
|
|
- _clientForHttps = null;
|
|
|
- }
|
|
|
+ _clientForHttps?.Dispose();
|
|
|
+ _clientForHttps = null;
|
|
|
var url = $"https://{_host}:{_port}";
|
|
|
_clientForHttps = new JsonRpcClient();
|
|
|
var clientEngine = new JsonRpcHttpClientEngine(url);
|
|
|
_clientForHttps.UseEngine(clientEngine);
|
|
|
var vinnoServerService = _clientForHttps.CreateProxy<IVinnoServerService>(5000);
|
|
|
var echoResult = JsonRpcHelper.Echo(vinnoServerService);
|
|
|
- if (echoResult != null && echoResult.Code == 0)
|
|
|
+ if (_cts.IsCancellationRequested)
|
|
|
{
|
|
|
- _testResult = ServerTestResult.NewServerWithHttps;
|
|
|
- _manualResetEvent.Set();
|
|
|
- return true;
|
|
|
+ _clientForHttps?.Dispose();
|
|
|
+ _clientForHttps = null;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (echoResult != null && echoResult.Code == 0)
|
|
|
+ {
|
|
|
+ _testResult = ServerTestResult.NewServerWithHttps;
|
|
|
+ _manualResetEvent.Set();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
@@ -203,21 +239,12 @@ namespace Vinno.vCloud.Common.FIS
|
|
|
{
|
|
|
_manualResetEvent.Set();
|
|
|
_cts?.Cancel();
|
|
|
- if (_leaf != null)
|
|
|
- {
|
|
|
- _leaf.Close();
|
|
|
- _leaf = null;
|
|
|
- }
|
|
|
- if (_clientForHttp != null)
|
|
|
- {
|
|
|
- _clientForHttp.Dispose();
|
|
|
- _clientForHttp = null;
|
|
|
- }
|
|
|
- if (_clientForHttps != null)
|
|
|
- {
|
|
|
- _clientForHttps.Dispose();
|
|
|
- _clientForHttps = null;
|
|
|
- }
|
|
|
+ _clientForHttp?.Dispose();
|
|
|
+ _clientForHttp = null;
|
|
|
+ _clientForHttps?.Dispose();
|
|
|
+ _clientForHttps = null;
|
|
|
+ _leaf?.Close();
|
|
|
+ _leaf = null;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|