Example #1
0
        private void GetConfig()
        {
            EventHandler reloadEventHandler = ReloadConfig;

            configuration = RelayNodeConfig.GetRelayNodeConfig(reloadEventHandler);

            if (configuration != null)
            {
                if (configuration.GetMyNode() != null)
                {
                    MyZone = configuration.GetMyNode().Zone;
                }

                instanceName = configuration.InstanceName;
                if (configuration.TransportSettings != null)
                {
                    portNumber     = configuration.TransportSettings.ListenPort;
                    httpPortNumber = configuration.TransportSettings.HttpListenPort;
                }
            }
            else
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("NO CONFIG SECTION FOUND, SERVICE NOT STARTING.");
                }
            }
        }
        /// <summary>
        /// Initializes the <see cref="ComponentTestManager"/>, gets the <see cref="RelayNodeConfig"/>
        /// and Initializes the forwarder.
        /// </summary>
        /// <param name="createTransports">Optional, creates other
        /// <see cref="IRelayTransport"/>s to be added to the transports.</param>
        public void Initialize(params CreateTransportDelegate[] createTransports)
        {
            _createTransports = createTransports;
            TransportFactory.CreateTransportMethod = _createTransportDelegate;
            _forwarder = new Forwarder();              //we initialize because there's a static singleton we're wanting to get set.
            RelayNodeConfig config = RelayNodeConfig.GetRelayNodeConfig();

            if (config == null)
            {
                throw new InvalidOperationException("RelayNodeConfig not found.");
            }

            if (config.TransportSettings != null && config.TransportSettings.ListenPort != 0)
            {
                //do we fix for them?
                throw new InvalidOperationException("TransportSettings.ListenPort must be zero to make forwarder act like a client.");
            }
            _config = config;
            _forwarder.Initialize(config, null);
        }
        /// <summary>
        /// Initializes the cluster info.
        /// </summary>
        /// <param name="myClusterPos">My cluster pos.</param>
        /// <param name="numClustersInGroup">The num clusters in group.</param>
        /// <param name="myZone">My zone.</param>
        private static void InitializeClusterInfo(out int myClusterPos, out int numClustersInGroup, out ushort myZone)
        {
            RelayNodeGroupDefinition myGroup = RelayNodeConfig.GetRelayNodeConfig().GetMyGroup();

            RelayNodeClusterDefinition myCluster = RelayNodeConfig.GetRelayNodeConfig().GetMyCluster();

            RelayNodeDefinition myNode = RelayNodeConfig.GetRelayNodeConfig().GetMyNode();

            myZone             = myNode.Zone;
            numClustersInGroup = myGroup.RelayNodeClusters.Length;
            myClusterPos       = 0;

            foreach (RelayNodeClusterDefinition cluster in myGroup.RelayNodeClusters)
            {
                if (cluster.RelayNodes.Length == myCluster.RelayNodes.Length &&
                    cluster.ContainsNode(myNode.IPAddress, myNode.Port))
                {
                    // this cluster contains my Node
                    break;
                }
                myClusterPos++;
            }
        }
Example #4
0
 private void EnvironmentChangedHandler(string oldEnvironment, string newEnvironment)
 {
     ReloadConfig(RelayNodeConfig.GetRelayNodeConfig());
 }
Example #5
0
 internal RelayMessageClient()
 {
     UpdateConfig(RelayNodeConfig.GetRelayNodeConfig(ReloadConfigHandler));
 }