public WorkloadController(
            ApplicationBase application, string instanceName, string applicationName, IPEndPoint latencyEndpointTcp, IPEndPoint latencyEndpointUdp, byte latencyOperationCode, long updateIntervalInMs)
        {
            this.latencyOperationCode = latencyOperationCode;
            this.updateIntervalInMs = updateIntervalInMs;
            this.FeedbackLevel = FeedbackLevel.Normal;
            this.application = application;
            this.applicationName = applicationName;

            this.fiber = new PoolFiber();
            this.fiber.Start();

            this.remoteEndPointTcp = latencyEndpointTcp;
            this.remoteEndPointUdp = latencyEndpointUdp;

            this.cpuCounter = new AverageCounterReader(AverageHistoryLength, "Processor", "% Processor Time", "_Total");
            if (!this.cpuCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.cpuCounter.Name);
            }

            this.businessLogicQueueCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: Threads and Queues", "Business Logic Queue", instanceName);
            if (!this.businessLogicQueueCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.businessLogicQueueCounter.Name);
            }

            this.enetQueueCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: Threads and Queues", "ENet Queue", instanceName);
            if (!this.enetQueueCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.enetQueueCounter.Name);
            }

            // amazon instances do not have counter for network interfaces
            this.bytesInCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server", "bytes in/sec", instanceName);
            if (!this.bytesInCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.bytesInCounter.Name);
            }

            this.bytesOutCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server", "bytes out/sec", instanceName);
            if (!this.bytesOutCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.bytesOutCounter.Name);
            }

            this.enetThreadsProcessingCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: Threads and Queues", "ENet Threads Processing", instanceName);
            if (!this.enetThreadsProcessingCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.enetThreadsProcessingCounter.Name);
            }

            this.enetThreadsActiveCounter = new PerformanceCounterReader("Photon Socket Server: Threads and Queues", "ENet Threads Active", instanceName);
            if (!this.enetThreadsActiveCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.enetThreadsActiveCounter.Name);
            }

            this.timeSpentInServerInCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: ENet", "Time Spent In Server: In (ms)", instanceName);
            if (!this.timeSpentInServerInCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.timeSpentInServerInCounter.Name);
            }

            this.timeSpentInServerOutCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: ENet", "Time Spent In Server: Out (ms)", instanceName);
            if (!this.timeSpentInServerOutCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.timeSpentInServerOutCounter.Name);
            }
            
            this.tcpDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: TCP", "TCP: Disconnected Peers +/sec", instanceName); 
            if (!this.tcpDisconnectsPerSecondCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.tcpDisconnectsPerSecondCounter.Name);
            }

            this.tcpClientDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: TCP", "TCP: Disconnected Peers (C) +/sec", instanceName);
            if (!this.tcpClientDisconnectsPerSecondCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.tcpClientDisconnectsPerSecondCounter.Name);
            }


            this.tcpPeersCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: TCP", "TCP: Peers", instanceName);
            if (!this.tcpPeersCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.tcpPeersCounter.Name);
            }

            this.udpDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: UDP", "UDP: Disconnected Peers +/sec", instanceName);
            if (!this.udpDisconnectsPerSecondCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.udpDisconnectsPerSecondCounter.Name);
            }

            this.udpClientDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: UDP", "UDP: Disconnected Peers (C) +/sec", instanceName);
            if (!this.udpClientDisconnectsPerSecondCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.udpClientDisconnectsPerSecondCounter.Name);
            }

            this.udpPeersCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: UDP", "UDP: Peers", instanceName);
            if (!this.udpPeersCounter.InstanceExists)
            {
                log.WarnFormat("Did not find counter {0}", this.udpPeersCounter.Name);
            }

            this.feedbackControlSystem = new FeedbackControlSystem(1000, this.application.ApplicationRootPath);
        }
Пример #2
0
 public static void Setup(ApplicationBase server)
 {
     server.ConnectToServerTcp(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 4520), "BaccaratServer", null);
 }
Пример #3
0
        public WorkloadController(
            ApplicationBase application, string instanceName, long updateIntervalInMs, string serverId, string workLoadConfigFile)
        {
            try
            {
                this.updateIntervalInMs = updateIntervalInMs;
                this.FeedbackLevel = FeedbackLevel.Normal;
                this.application = application;

                this.fiber = new PoolFiber();
                this.fiber.Start();
                this.serverId = serverId;

                this.cpuCounter = new AverageCounterReader(AverageHistoryLength, "Processor", "% Processor Time", "_Total");
                if (!this.cpuCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.cpuCounter.Name);
                }

                this.businessLogicQueueCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: Threads and Queues", "Business Logic Queue", instanceName);
                if (!this.businessLogicQueueCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.businessLogicQueueCounter.Name);
                }

                this.enetQueueCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: Threads and Queues", "ENet Queue", instanceName);
                if (!this.enetQueueCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.enetQueueCounter.Name);
                }

                // amazon instances do not have counter for network interfaces
                this.bytesInCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server", "bytes in/sec", instanceName);
                if (!this.bytesInCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.bytesInCounter.Name);
                }

                this.bytesOutCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server", "bytes out/sec", instanceName);
                if (!this.bytesOutCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.bytesOutCounter.Name);
                }

                this.enetThreadsProcessingCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: Threads and Queues", "ENet Threads Processing", instanceName);
                if (!this.enetThreadsProcessingCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.enetThreadsProcessingCounter.Name);
                }

                this.enetThreadsActiveCounter = new PerformanceCounterReader("Photon Socket Server: Threads and Queues", "ENet Threads Active", instanceName);
                if (!this.enetThreadsActiveCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.enetThreadsActiveCounter.Name);
                }

                this.timeSpentInServerInCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: ENet", "Time Spent In Server: In (ms)", instanceName);
                if (!this.timeSpentInServerInCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.timeSpentInServerInCounter.Name);
                }

                this.timeSpentInServerOutCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: ENet", "Time Spent In Server: Out (ms)", instanceName);
                if (!this.timeSpentInServerOutCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.timeSpentInServerOutCounter.Name);
                }

                this.tcpDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: TCP", "TCP: Disconnected Peers +/sec", instanceName);
                if (!this.tcpDisconnectsPerSecondCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.tcpDisconnectsPerSecondCounter.Name);
                }

                this.tcpClientDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: TCP", "TCP: Disconnected Peers (C) +/sec", instanceName);
                if (!this.tcpClientDisconnectsPerSecondCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.tcpClientDisconnectsPerSecondCounter.Name);
                }

                this.tcpPeersCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: TCP", "TCP: Peers", instanceName);
                if (!this.tcpPeersCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.tcpPeersCounter.Name);
                }

                this.udpDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: UDP", "UDP: Disconnected Peers +/sec", instanceName);
                if (!this.udpDisconnectsPerSecondCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.udpDisconnectsPerSecondCounter.Name);
                }

                this.udpClientDisconnectsPerSecondCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: UDP", "UDP: Disconnected Peers (C) +/sec", instanceName);
                if (!this.udpClientDisconnectsPerSecondCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.udpClientDisconnectsPerSecondCounter.Name);
                }

                this.udpPeersCounter = new AverageCounterReader(AverageHistoryLength, "Photon Socket Server: UDP", "UDP: Peers", instanceName);
                if (!this.udpPeersCounter.InstanceExists)
                {
                    log.WarnFormat("Did not find counter {0}", this.udpPeersCounter.Name);
                }

                this.feedbackControlSystem = new FeedbackControlSystem(1000, this.application.ApplicationRootPath, workLoadConfigFile);

                this.IsInitialized = true;
            }
            catch (Exception e)
            {
                log.ErrorFormat("Exception during WorkloadController construction. Exception: {0}", e);
            }
        }
 public PhotonWireOutboundS2SPeer(ApplicationBase application)
     : base(application)
 {
     Items = new ConcurrentDictionary<object, object>();
 }