Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the ServiceClientManager class
        /// </summary>
        /// <param name="sessionId">indicating the session id</param>
        /// <param name="headNode">indicating the head node</param>
        public ServiceClientManager(int sessionId, string headNode, BrokerManagementService serviceInstance)
        {
            this.serviceInstance = serviceInstance;

            this.sessionId              = sessionId;
            this.dispatcherList         = new SortedList <int, Dispatcher>();
            this.schedulerAdapterClient = new SchedulerAdapterClient(headNode, new InstanceContext(this), schedulerAdapterBinding);

            // Register to scheduler adapter so that callback could be raised
            this.schedulerAdapterClient.RegisterJob(sessionId).GetAwaiter().GetResult();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">indicating arguments</param>
        /// <returns>returns the exit code</returns>
        private static int Main(string[] args)
        {
            ManualResetEvent exitWaitHandle = new ManualResetEvent(false);

            int pid = Process.GetCurrentProcess().Id;
            Uri brokerManagementServiceAddress = new Uri(String.Format("http://localhost:9093/BrokerManagementService/{0}", pid));

            BrokerManagementService instance;

            try
            {
                instance = new BrokerManagementService(exitWaitHandle);

                Trace.TraceInformation("[Main] Try open broker management service at {0}.", brokerManagementServiceAddress.ToString());
                ServiceHost      host = new ServiceHost(instance, brokerManagementServiceAddress);
                BasicHttpBinding hardCodedBrokerManagementServiceBinding = new BasicHttpBinding();
                host.AddServiceEndpoint(typeof(IBrokerManagementService), hardCodedBrokerManagementServiceBinding, String.Empty);
                host.Open();

                Trace.TraceInformation("[Main] Open broker management service succeeded.");
            }
            catch (Exception e)
            {
                Trace.TraceError("[Main] Failed to open broker management service: {0}", e);
                return((int)BrokerShimExitCode.FailedOpenServiceHost);
            }

            bool            createdNew;
            EventWaitHandle initializeWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset, String.Format("HpcBroker{0}", pid), out createdNew);

            if (createdNew)
            {
                Trace.TraceError("[Main] Initialize wait handle has not been created by the broker launcher.");
                return((int)BrokerShimExitCode.InitializeWaitHandleNotExist);
            }

            if (!initializeWaitHandle.Set())
            {
                Trace.TraceError("[Main] Failed to set the initialize wait handle.");
                return((int)BrokerShimExitCode.FailedToSetInitializeWaitHandle);
            }

            // Wait for exit
            exitWaitHandle.WaitOne();


            return((int)BrokerShimExitCode.Success);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the BrokerEntry class
        /// </summary>
        /// <param name="startInfo">indicating the start info</param>
        /// <param name="brokerInfo">indicating the broker info</param>
        public BrokerEntry(SessionStartInfoContract startInfo, BrokerStartInfo brokerInfo, BrokerManagementService serviceInstance)
        {
            if (startInfo.TransportScheme != TransportScheme.NetTcp)
            {
                throw new NotSupportedException("Sample broker does not support transport scheme other than NetTcp.");
            }

            if (brokerInfo.Durable)
            {
                throw new NotSupportedException("Sample broker does not support durable session.");
            }

            this.clientManager = new ServiceClientManager(brokerInfo.SessionId, brokerInfo.Headnode, serviceInstance);
            Frontend frontend = new Frontend(this.clientManager);

            // Choose different binding configuration by start info
            NetTcpBinding frontendBinding;

            if (startInfo.Secure)
            {
                frontendBinding = new NetTcpBinding();
            }
            else
            {
                frontendBinding = new NetTcpBinding(SecurityMode.None);
            }

            frontendBinding.PortSharingEnabled = true;

            this.frontendServiceHost = new ServiceHost(frontend, new Uri(String.Format("net.tcp://{0}:9091/SampleBroker", Environment.MachineName)));
            string listenUri = this.frontendServiceHost.AddServiceEndpoint(typeof(IDuplexService), frontendBinding, String.Empty).ListenUri.AbsoluteUri;

            this.frontendServiceHost.Open();

            this.result           = new BrokerInitializationResult();
            this.result.BrokerEpr = new string[3] {
                listenUri, null, null
            };
            this.result.ControllerEpr = new string[3];
            this.result.ResponseEpr   = new string[3];
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the BrokerEntry class
        /// </summary>
        /// <param name="startInfo">indicating the start info</param>
        /// <param name="brokerInfo">indicating the broker info</param>
        public BrokerEntry(SessionStartInfoContract startInfo, BrokerStartInfo brokerInfo, BrokerManagementService serviceInstance)
        {
            if (startInfo.TransportScheme != TransportScheme.NetTcp)
            {
                throw new NotSupportedException("Sample broker does not support transport scheme other than NetTcp.");
            }

            if (brokerInfo.Durable)
            {
                throw new NotSupportedException("Sample broker does not support durable session.");
            }

            this.clientManager = new ServiceClientManager(brokerInfo.SessionId, brokerInfo.Headnode, serviceInstance);

            Frontend       frontend = new Frontend(this.clientManager);
            WebHttpBinding binding  = new WebHttpBinding();

            binding.MaxBufferPoolSize      = 5000000;
            binding.MaxBufferSize          = 5000000;
            binding.MaxReceivedMessageSize = 5000000;

            binding.ReaderQuotas.MaxArrayLength         = 5000000;
            binding.ReaderQuotas.MaxBytesPerRead        = 5000000;
            binding.ReaderQuotas.MaxDepth               = 5000000;
            binding.ReaderQuotas.MaxNameTableCharCount  = 5000000;
            binding.ReaderQuotas.MaxStringContentLength = 5000000;

            this.frontendServiceHost = new WebServiceHost(frontend, new Uri(String.Format("http://{0}:8081/", Environment.MachineName)));
            ServiceEndpoint endpoint = this.frontendServiceHost.AddServiceEndpoint(typeof(IWebHttpFrontendService), binding, String.Empty);

            endpoint.Behaviors.Add(new WebHttpBehavior());

            string listenUri = endpoint.ListenUri.AbsoluteUri;

            this.frontendServiceHost.Open();

            this.result           = new BrokerInitializationResult();
            this.result.BrokerEpr = new string[3] {
                listenUri, null, null
            };
            this.result.ControllerEpr = new string[3];
            this.result.ResponseEpr   = new string[3];
        }