예제 #1
0
        private void CheckServerProtocolSignatures()
        {
            Log.WriteLine("Checking {0}-Server protocol signatures...", cluster_config.RunningMode);
            int my_server_id = (cluster_config.RunningMode == RunningMode.Server) ? MyPartitionId : -1;
            var storage      = StorageTable.Where((_, idx) => idx != my_server_id).FirstOrDefault() as RemoteStorage;

            CheckProtocolSignatures_impl(storage, cluster_config.RunningMode, RunningMode.Server);
        }
예제 #2
0
        /// <inheritdoc/>
        public override bool Open(ClusterConfig config, bool nonblocking)
        {
            this.cluster_config = config;

            Log.WriteLines(config.OutputCurrentConfig());

            if (config.RunningMode == RunningMode.Embedded)
            {
                return(SetupEmbeddedMemoryCloud());
            }

            if (_InstanceList(config.RunningMode).Count == 0 && config.RunningMode != RunningMode.Client)
            {
                Log.WriteLine(LogLevel.Warning, "No distributed instances configured. Turning on local test mode.");
                TrinityConfig.LocalTest = true;
            }
            server_count    = cluster_config.Servers.Count;
            my_partition_id = _GetPartitionId(config);
            my_proxy_id     = _GetProxyId(config);

            m_storageTable = new IStorage[server_count];

            if (server_count == 0 && config.RunningMode != RunningMode.Proxy)
            {
                Log.WriteLine(LogLevel.Error, $"{nameof(MemoryCloud)}: Failed to open cloud storage: No servers found.");
                return(false);
            }

            for (int i = 0; i < server_count; i++)
            {
                if (cluster_config.RunningMode == RunningMode.Server &&
                    (cluster_config.Servers[i].Has(Global.MyIPAddresses, Global.MyIPEndPoint.Port) || cluster_config.Servers[i].HasLoopBackEndpoint(Global.MyIPEndPoint.Port))
                    )
                {
                    StorageTable[i] = Global.LocalStorage;
                }
                else
                {
                    StorageTable[i] = new RemoteStorage(cluster_config.Servers[i].Instances, TrinityConfig.ClientMaxConn, this, i, nonblocking);
                }
            }

            StaticGetPartitionByCellId = this.GetServerIdByCellIdDefault;

            if (!nonblocking)
            {
                int my_server_id = (cluster_config.RunningMode == RunningMode.Server) ? MyPartitionId : -1;
                var storage      = StorageTable.Where((_, idx) => idx != my_server_id).FirstOrDefault() as RemoteStorage;
                CheckServerProtocolSignatures(storage);
            }
            else
            {
                ServerConnected += (_, rs_ev) => CheckServerProtocolSignatures(rs_ev.RemoteStorage);
            }

            return(true);
        }