|
@@ -23,6 +23,7 @@ using WingInterfaceLibrary.Enum;
|
|
|
using WingCloudServer.Plugin;
|
|
|
using System.Reflection;
|
|
|
using CSScriptLib;
|
|
|
+using WingInterfaceLibrary.DTO.DistributedServerInfo;
|
|
|
|
|
|
namespace WingCloudServer
|
|
|
{
|
|
@@ -79,9 +80,7 @@ namespace WingCloudServer
|
|
|
{
|
|
|
var folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
|
|
|
//initiaize rpc client pool
|
|
|
- var remoteRpcHttpServices = LoadRemoteServiceConfig(folder);//new RemoteServiceInfo[0];
|
|
|
var rpcClientPool = new JsonRpcClientPool(_inProcessEngine);
|
|
|
- rpcClientPool.Initialize(remoteRpcHttpServices.ToArray());
|
|
|
var inProcessServicesString = ConfigurationManager.GetParammeter<StringParameter>("Services", "InProcess").Value;
|
|
|
var inProcessServices = inProcessServicesString.Split(',');
|
|
|
var rpcHttpServicesString = ConfigurationManager.GetParammeter<StringParameter>("Services", "JsonRpcHttp").Value;
|
|
@@ -115,9 +114,8 @@ namespace WingCloudServer
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- //TestCSScript(rpcClientPool);
|
|
|
-
|
|
|
+ var remoteRpcHttpServices = LoadRemoteServiceConfig(folder);//new RemoteServiceInfo[0];
|
|
|
+ rpcClientPool.Initialize(remoteRpcHttpServices.ToArray());
|
|
|
//Rpc http service load and register to rpc http server
|
|
|
if (ConfigurationManager.IsDistributed)
|
|
|
{
|
|
@@ -126,7 +124,6 @@ namespace WingCloudServer
|
|
|
var masterInteractionCenterService = new MasterInteractionCenterService();
|
|
|
_rpcHttpServer.RegisterService(typeof(IMasterInteractionCenterService), masterInteractionCenterService);
|
|
|
masterInteractionCenterService.Load(rpcClientPool);
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -163,13 +160,6 @@ namespace WingCloudServer
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //load services
|
|
|
- foreach (var service in _rpcServices)
|
|
|
- {
|
|
|
- var method = service.Key.GetMethod("Load");
|
|
|
- method.Invoke(service.Value, new object[] { rpcClientPool });
|
|
|
- }
|
|
|
-
|
|
|
//load service if distrubuted system
|
|
|
if (ConfigurationManager.IsDistributed)
|
|
|
{
|
|
@@ -179,9 +169,18 @@ namespace WingCloudServer
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //TODO
|
|
|
+ //动态注册副服务器实时同步服务
|
|
|
+ RegisterDynamicSlaveInteractionCenterService(rpcClientPool);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //load services
|
|
|
+ foreach (var service in _rpcServices)
|
|
|
+ {
|
|
|
+ var method = service.Key.GetMethod("Load");
|
|
|
+ method.Invoke(service.Value, new object[] { rpcClientPool });
|
|
|
+ }
|
|
|
+
|
|
|
//最快服务器
|
|
|
var vinnoServerService = new VinnoServerService();
|
|
|
_rpcHttpServer.RegisterService(typeof(WingInterfaceLibrary.Interface.IVinnoServerService), vinnoServerService);
|
|
@@ -199,63 +198,53 @@ namespace WingCloudServer
|
|
|
_serverListPlugin.Load(rpcClientPool);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- public void TestCSScript(JsonRpcClientPool rpcClientPool)
|
|
|
+ //todo 待验证是否可以调用本地的service
|
|
|
+ public void RegisterDynamicSlaveInteractionCenterService(JsonRpcClientPool rpcClientPool)
|
|
|
{
|
|
|
- //接口
|
|
|
- var eval = CSScript.Evaluator.ReferenceDomainAssemblies(DomainAssemblies.AllStaticNonGAC);
|
|
|
- var host = ConfigurationManager.Host.Replace("http:", "").Replace(".", "").Replace("/", "");
|
|
|
- var str = @"
|
|
|
+ var eval = CSScript.Evaluator.ReferenceDomainAssemblies(DomainAssemblies.AllStaticNonGAC);
|
|
|
+ var host = ConfigurationManager.Host.Replace("http:", "").Replace(".", "").Replace("/", "");
|
|
|
+ var str = @"
|
|
|
using System;
|
|
|
using System.Threading.Tasks;
|
|
|
- using System;
|
|
|
using WingServerCommon.Service;
|
|
|
using WingInterfaceLibrary.OpLog;
|
|
|
- using System.Threading.Tasks;
|
|
|
using System.Collections.Generic;
|
|
|
using JsonRpcLite.Rpc;
|
|
|
using WingInterfaceLibrary.Interface.DBInterface;
|
|
|
using WingInterfaceLibrary.DB.Request;
|
|
|
|
|
|
- public interface ICSScriptTest"+host+@"
|
|
|
+ public interface IDynamicSlaveService" + host + @"
|
|
|
{
|
|
|
- Task<bool> CSScriptTestAsync();
|
|
|
+ Task<bool> DynamicSlaveAsync(SyncReceiveServiceDataRequest request);
|
|
|
}
|
|
|
- public class CSScriptTestService : JsonRpcService,ICSScriptTest"+host+@"
|
|
|
+ public class DynamicSlaveService : JsonRpcService,IDynamicSlaveService" + host + @"
|
|
|
{
|
|
|
- protected IOpLogDBService OpLogDBService;
|
|
|
- protected IDeviceInfoDBService deviceInfoDBService;
|
|
|
+ protected ISlaveInteractionCenterService _slaveInteractionCenterService;
|
|
|
public override void Load(JsonRpcClientPool jsonRpcClientPool)
|
|
|
{
|
|
|
base.Load(jsonRpcClientPool);
|
|
|
- OpLogDBService = GetProxy<IOpLogDBService>();
|
|
|
- deviceInfoDBService = GetProxy<IDeviceInfoDBService>();
|
|
|
+ _slaveInteractionCenterService = GetProxy<ISlaveInteractionCenterService>();
|
|
|
}
|
|
|
- public async Task<bool> CSScriptTestAsync()
|
|
|
+ public async Task<bool> DynamicSlaveAsync(SyncReceiveServiceDataRequest request)
|
|
|
{
|
|
|
- var res = deviceInfoDBService.FindDictionaryItemsAsync(new FindDictionaryItemsDBRequest()).Result;
|
|
|
- Console.WriteLine(""flytest""+res.Count);
|
|
|
+ await _slaveInteractionCenterService.SyncReceiveMasterServiceDataAsync(request);
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
- public class Test
|
|
|
+ public class DynamicMethodClass
|
|
|
{
|
|
|
- public void Test1(JsonRpcClientPool rpcClientPool,JsonRpcServer _rpcHttpServer){
|
|
|
- var csScriptTestService = new CSScriptTestService();
|
|
|
- _rpcHttpServer.RegisterService(typeof(ICSScriptTest"+host+@"), csScriptTestService);
|
|
|
- csScriptTestService.Load(rpcClientPool);
|
|
|
+ public void DynamicMethod(JsonRpcClientPool rpcClientPool,JsonRpcServer _rpcHttpServer){
|
|
|
+ var DynamicSlaveService = new DynamicSlaveService();
|
|
|
+ _rpcHttpServer.RegisterService(typeof(IDynamicSlaveService" + host + @"), DynamicSlaveService);
|
|
|
+ DynamicSlaveService.Load(rpcClientPool);
|
|
|
}
|
|
|
}
|
|
|
";
|
|
|
-
|
|
|
- Assembly compilecode = eval.CompileCode(str);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- var ps = compilecode.GetType("css_root+Test");
|
|
|
- var obj = compilecode.CreateInstance("css_root+Test");
|
|
|
- var mes = ps.GetMethod("Test1");
|
|
|
- mes.Invoke(obj, new object[] { rpcClientPool, _rpcHttpServer });
|
|
|
+ Assembly compilecode = eval.CompileCode(str);
|
|
|
+ var ps = compilecode.GetType("css_root+DynamicMethodClass");
|
|
|
+ var obj = compilecode.CreateInstance("css_root+DynamicMethodClass");
|
|
|
+ var mes = ps.GetMethod("DynamicMethod");
|
|
|
+ mes.Invoke(obj, new object[] { rpcClientPool, _rpcHttpServer });
|
|
|
}
|
|
|
|
|
|
void LoadDataAfterRegister()
|
|
@@ -297,7 +286,7 @@ namespace WingCloudServer
|
|
|
{
|
|
|
if (ConfigurationManager.IsMaster)
|
|
|
{
|
|
|
- //TODO determin if we need to assess slave server on master server
|
|
|
+ DynamicRemoteSlaveService(resList);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -342,6 +331,64 @@ namespace WingCloudServer
|
|
|
return resList;
|
|
|
}
|
|
|
|
|
|
+ public void DynamicRemoteSlaveService(List<RemoteServiceInfo> resList)
|
|
|
+ {
|
|
|
+ var slaveList = new List<DistributedServerInfoDTO>();
|
|
|
+ var host = ConfigurationManager.Host;
|
|
|
+ var eval = CSScript.Evaluator.ReferenceDomainAssemblies(DomainAssemblies.AllStaticNonGAC);
|
|
|
+ var str = @"
|
|
|
+ using System;
|
|
|
+ using System.Threading.Tasks;
|
|
|
+ using WingServerCommon.Service;
|
|
|
+ using WingInterfaceLibrary.OpLog;
|
|
|
+ using System.Collections.Generic;
|
|
|
+ using JsonRpcLite.Rpc;
|
|
|
+ using WingInterfaceLibrary.Interface.DBInterface;
|
|
|
+ using WingInterfaceLibrary.DB.Request;
|
|
|
+ using WingInterfaceLibrary.DTO.DistributedServerInfo;
|
|
|
+ using WingInterfaceLibrary.Request.DBRequest;
|
|
|
+ using System.Linq;
|
|
|
+
|
|
|
+ public class GetUrlListService : JsonRpcService
|
|
|
+ {
|
|
|
+ protected IDistributedServerInfoDBService _distributedServerInfoDBService;
|
|
|
+ public override void Load(JsonRpcClientPool jsonRpcClientPool)
|
|
|
+ {
|
|
|
+ base.Load(jsonRpcClientPool);
|
|
|
+ _distributedServerInfoDBService = GetProxy<IDistributedServerInfoDBService>();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<DistributedServerInfoDTO> GetSlaveList(string host,List<DistributedServerInfoDTO> slaveList)
|
|
|
+ {
|
|
|
+ var distributedServerInfoDBPagesRequest = new GetDistributedServerInfoDBPagesRequest();
|
|
|
+ distributedServerInfoDBPagesRequest.CurrentPage = 1;
|
|
|
+ distributedServerInfoDBPagesRequest.PageSize = 9999;
|
|
|
+ var result = _distributedServerInfoDBService.GetDistributedServerInfoPagesAsync(distributedServerInfoDBPagesRequest).Result;
|
|
|
+ if (result != null && result.TotalCount > 0)
|
|
|
+ {
|
|
|
+ slaveList = result.PageData;
|
|
|
+ slaveList = slaveList.Where(x => x.ServerUrl != host).ToList();
|
|
|
+ }
|
|
|
+ return slaveList;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ ";
|
|
|
+
|
|
|
+ //动态注册副服务器服务
|
|
|
+
|
|
|
+ foreach (var item in slaveList)
|
|
|
+ {
|
|
|
+ var serviceInfo = new RemoteServiceInfo()
|
|
|
+ {
|
|
|
+ ServiceName = "IDynamicSlaveService" + item.ServerUrl.Replace("http:", "").Replace(".", "").Replace("/", ""),
|
|
|
+ Url = ConfigurationManager.MasterUrl
|
|
|
+ };
|
|
|
+ resList.Add(serviceInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 初始化AIDiagnosis
|
|
|
/// </summary>
|