Explorar o código

add service registers for op log

arthur.wu %!s(int64=2) %!d(string=hai) anos
pai
achega
b749d30fb5

+ 3 - 0
Clear-Not-Recommended.ps1

@@ -0,0 +1,3 @@
+dotnet nuget locals all --clear
+Write-Host 'Finished!' -NoNewline
+$null = [Console]::ReadKey('?')

+ 1 - 1
src/InteractionCenter/InteractionCenterService.cs

@@ -1,7 +1,7 @@
 using WingServerCommon.Service;
 using WingInterfaceLibrary.Interface.DBInterface;
 
-namespace src.InteractionCenter
+namespace WingCloudServer.InteractionCenter
 {
     public class InteractionCenterService : JsonRpcService
     {

+ 5 - 5
src/InteractionCenter/MasterInteractionCenterService.cs

@@ -5,7 +5,7 @@ using System.Threading.Tasks;
 using System.Collections.Generic;
 using WingInterfaceLibrary.Interface.DBInterface;
 
-namespace src.InteractionCenter
+namespace WingCloudServer.InteractionCenter
 {
     public class MasterInteractionCenterService : InteractionCenterService, IMasterInteractionCenterService
     {
@@ -22,9 +22,9 @@ namespace src.InteractionCenter
         /// </summary>
         /// <param name="request"></param>
         /// <returns>The op log list</returns>
-        public async Task<List<OperationLogDTO>> GetOpLogsFromMaster(GetOpLogsFormMasterRequest request)
+        public async Task<List<OperationLogDTO>> GetOpLogsFromMasterAsync(GetOpLogsFormMasterRequest request)
         {            
-            return await OpLogDBService.GetOpLog(request);
+            return await OpLogDBService.GetOpLogAsync(request);
         }     
 
         /// <summary>
@@ -32,9 +32,9 @@ namespace src.InteractionCenter
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
-        public async Task<bool> SyncOpLogToMaster(SyncOpLogToMasterRequest request)
+        public async Task<bool> SyncOpLogToMasterAsync(SyncOpLogToMasterRequest request)
         {            
-            return await OpLogDBService.SyncOpLog(request);
+            return await OpLogDBService.SyncOpLogAsync(request);
         }           
     }
 

+ 34 - 2
src/WingServer.cs

@@ -9,6 +9,8 @@ using WingServerCommon.Service;
 using WingServerCommon.Log;
 using WingServerCommon.Config;
 using WingServerCommon.Config.Parameters;
+using WingInterfaceLibrary.OpLog;
+using WingCloudServer.InteractionCenter;
 
 namespace WingCloudServer
 {
@@ -52,8 +54,8 @@ namespace WingCloudServer
         void InitializeServices()
         {
             //initiaize rpc client pool
-            var remoteRpcHttpServices = LoadRemoteServiceConfig();//new RemoteServiceInfo[0]; //TODO from settings
-            var rpcClientPool = new JsonRpcClientPool(_inProcessEngine);
+            var remoteRpcHttpServices = LoadRemoteServiceConfig();//new RemoteServiceInfo[0]; 
+            var rpcClientPool = new JsonRpcClientPool(_inProcessEngine);            
             rpcClientPool.Initialize(remoteRpcHttpServices.ToArray());
 
             var folder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Services");
@@ -92,6 +94,19 @@ namespace WingCloudServer
             }
 
             //Rpc http service load and register to rpc http server
+            if(ConfigurationManager.IsDistributed)
+            {
+                if(ConfigurationManager.IsMaster)
+                {
+                    _rpcHttpServer.RegisterService(typeof(IMasterInteractionCenterService), new MasterInteractionCenterService());
+                   
+                }
+                else
+                {
+                    //TODO determin if we need to assess slave server on master server
+                }
+            }
+
             foreach (var service in rpcHttpServices)
             {
                 var wingServiceType = LoadService(folder, service);
@@ -211,6 +226,23 @@ namespace WingCloudServer
         private List<RemoteServiceInfo> LoadRemoteServiceConfig()
         {
             List<RemoteServiceInfo> resList = new List<RemoteServiceInfo>();
+            if(ConfigurationManager.IsDistributed)
+            {
+                if(ConfigurationManager.IsMaster)
+                {
+                   //TODO determin if we need to assess slave server on master server
+                }
+                else
+                {
+                    var serviceInfo = new RemoteServiceInfo() 
+                    {
+                        ServiceName="MasterInteractionCenterService",
+                        Url = ConfigurationManager.MasterUrl
+                    };
+                    resList.Add(serviceInfo);
+                }
+            }
+
             var remoteStr = ConfigurationManager.GetParammeter<StringParameter>("Services", "Remote").Value;
             var rpcHttpServicesString = ConfigurationManager.GetParammeter<StringParameter>("Services", "JsonRpcHttp").Value;
             if (!string.IsNullOrEmpty(remoteStr) && remoteStr.Split(',').Length > 0)