/// <summary>
 /// Initializes a new instance of the SchedulerAdapterClientFactory class
 /// </summary>
 /// <param name="sharedData">indicating the shared data</param>
 /// <param name="monitor">indicating the monitor</param>
 /// <param name="dispatcherManager">indicating the dispatcher manager</param>
 public SchedulerAdapterClientFactory(SharedData sharedData, ServiceJobMonitorBase monitor, DispatcherManager dispatcherManager, ITelepathyContext context)
 {
     this.sharedData        = sharedData;
     this.monitor           = monitor;
     this.dispatcherManager = dispatcherManager;
     this.context           = context;
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the BrokerManager class
        /// </summary>
        public BrokerManager(bool needRecover, ITelepathyContext context)
        {
            TraceHelper.TraceEvent(TraceEventType.Verbose, "[BrokerManager] Constructor: needRecover={0}", needRecover);
            this.headnode = SoaHelper.GetSchedulerName();

            this.context = context;

            this.brokerDic = new Dictionary <string, BrokerInfo>();

            this.staleSessionCleanupTimer = new Timer(this.CleanStaleSessionData, null, Timeout.Infinite, Timeout.Infinite);
#if HPCPACK
            if (!SoaHelper.IsOnAzure())
            {
                // TODO: on azure, about the MSMQ. Don't use the MSMQ in the Azure cluster.
                this.updateQueueLengthTimer = new Timer(this.CallbackToUpdateMSMQLength, null, Timeout.Infinite, Timeout.Infinite);
            }
#endif

            this.pool = new BrokerProcessPool();

            // TODO: enable recovery in Telepathy
#if HPCPACK
            if (needRecover && !BrokerLauncherEnvironment.Standalone)
            {
                this.ts = new CancellationTokenSource();
                CancellationToken ct = ts.Token;
                this.RecoverTask = Task.Run(async() => await this.RecoverThreadProc(ct), ct);
            }
#endif
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the LauncherHostService class
        /// This will be called when run in debug mode
        /// </summary>
        /// <param name="launcherChoose">launcher choose</param>
        internal LauncherHostService(bool console, ITelepathyContext context)
        {
            this.context         = context;
            isConsoleApplication = console;
            InitializeComponent();

            this.OpenService();
        }
 public static ISchedulerHelper GetSchedulerHelper(ITelepathyContext context)
 {
     if (BrokerLauncherEnvironment.Standalone)
     {
         return(new DummySchedulerHelper());
     }
     else
     {
         return(new SchedulerHelper(context));
     }
 }
Example #5
0
        /// <summary>
        /// Resolve session launcher node on IaaS
        /// </summary>
        /// <param name="context"></param>
        /// <param name="headnode"></param>
        /// <returns></returns>
        public static async Task <string> ResolveSessionLauncherNodeOnIaasAsync(this ITelepathyContext context, string headnode)
        {
            string sessionLauncher = await context.ResolveSessionLauncherNodeAsync().ConfigureAwait(false);

            if (SoaHelper.IsSchedulerOnIaaS(headnode))
            {
                string suffix = SoaHelper.GetSuffixFromHeadNodeEpr(headnode);
                sessionLauncher += suffix;
            }

            return(sessionLauncher);
        }
Example #6
0
        public static async Task <ServiceHost> SetupInternalWcfChannelAsync <T>(ITelepathyContext context, object singletonInstance, string serviceUri, ServiceAuthorizationManager manager = null)
        {
            var thumbPrint = await context.GetSSLThumbprint().ConfigureAwait(false);

            Trace.TraceInformation("[WcfHost] Begin to setup WCF channel on {0}, thumbprint is {1}", serviceUri, thumbPrint);
            var tcpBinding      = NetTcpBindingWithCertFactory();
            var internalWcfHost = CreateWcfChannel <T>(singletonInstance, tcpBinding, serviceUri, thumbPrint, manager, PrincipalPermissionMode.None, DefaultServiceThrottlingBehavior());
            await Task.Factory.FromAsync(internalWcfHost.BeginOpen(null, null), internalWcfHost.EndOpen).ConfigureAwait(false);

            Trace.TraceInformation("[WcfHost] End to setup internal WCF channel");
            return(internalWcfHost);
        }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the SchedulerHelper class
 /// </summary>
 public SchedulerHelper(ITelepathyContext context)
 {
     this.context         = context;
     this.sessionNode     = new Lazy <string>(() => this.ResolveSessionNodeWithRetries().GetAwaiter().GetResult(), LazyThreadSafetyMode.ExecutionAndPublication);
     this.certThumbprint  = new Lazy <string>(() => this.context.GetSSLThumbprint().GetAwaiter().GetResult(), LazyThreadSafetyMode.ExecutionAndPublication);
     this.schedulerClient = new Lazy <SchedulerAdapterClient>(
         () => new SchedulerAdapterClient(BindingHelper.HardCodedUnSecureNetTcpBinding, new EndpointAddress(SoaHelper.GetSchedulerDelegationAddress(this.sessionNode.Value)), new InstanceContext(new TraceOnlyServiceJobMonitor())),
         LazyThreadSafetyMode.ExecutionAndPublication);
     this.sessionLauncherClient = new Lazy <SessionLauncherClient>(
         () => new SessionLauncherClient(this.sessionNode.Value, this.certThumbprint.Value),
         LazyThreadSafetyMode.ExecutionAndPublication);
 }
Example #8
0
        public BrokerLauncher(bool managementOperationsOnly, ITelepathyContext context)
        {
            this.context = context;

            // Initializes the job object
            this.job = new JobObject();

            // Assign broker launcher process to the job object
            this.job.Assign(Process.GetCurrentProcess());

            // If this instance of HpcBroker service should handle mgmt and app operations
            if (!managementOperationsOnly)
            {
                // Force the broker mananger to intialize when the service is online
                this.brokerManager = new BrokerManager(this.IsOnline, context);
            }
        }
Example #9
0
        /// <summary>
        /// Initializes a new instance of the DispatcherManager class
        /// </summary>
        /// <param name="bindings">indicating the bindings section</param>
        /// <param name="observer">indicating the observer</param>
        /// <param name="queueFactory">indicating the queue factory</param>
        /// <param name="sharedData">indicating the shared data</param>
        /// <param name="frontendResult">indicating the frontend result</param>
        public DispatcherManager(BindingsSection bindings, SharedData sharedData, BrokerObserver observer, ServiceJobMonitorBase monitor, BrokerQueueFactory queueFactory, ITelepathyContext context)
        {
            this.dispatcherDic          = new Dictionary <string, Dispatcher>();
            this.failedDispatcherList   = new List <string>();
            this.blockedDispatcherDic   = new Dictionary <string, DispatcherInfo>();
            this.blockedDispatcherQueue = new Queue <DispatcherInfo>();

            this.sharedData      = sharedData;
            this.observer        = observer;
            this.monitor         = monitor;
            this.queueFactory    = queueFactory;
            this.context         = context;
            this.defaultCapacity = this.sharedData.ServiceConfig.MaxConcurrentCalls;
            this.blockTimeSpan   = TimeSpan.FromMilliseconds(this.sharedData.Config.LoadBalancing.EndpointNotFoundRetryPeriod);
            this.unblockTimer    = new Timer(new ThreadHelper <object>(new TimerCallback(this.CallbackToQueryBlockedDispatcherList)).CallbackRoot, null, -1, -1);

            this.defaultBinding = BindingHelper.GetBackEndBinding(bindings);
            this.isHttp         = this.defaultBinding.CreateBindingElements().Find <HttpTransportBindingElement>() != null;

            // Update binding's maxMessageSize settings with global maxMessageSize if its enabled (> 0)
            int maxMessageSize = sharedData.ServiceConfig.MaxMessageSize;

            if (maxMessageSize > 0)
            {
                BindingHelper.ApplyMaxMessageSize(this.defaultBinding, maxMessageSize);
            }

            // get soa burst protocol info
            this.httpsBurst = sharedData.BrokerInfo.HttpsBurst;
            if (this.httpsBurst)
            {
                this.azureQueueManager = new AzureQueueManager(sharedData.BrokerInfo.SessionId, this.sharedData.BrokerInfo.ClusterName, this.sharedData.BrokerInfo.ClusterId);
            }

            this.supportsMessageDetails = this.defaultBinding.MessageVersion.Addressing != AddressingVersion.None || this.defaultBinding is BasicHttpBinding;
            BrokerTracing.TraceEvent(TraceEventType.Information, 0, "[DispatcherManager] Init backend binding: OperatiomTimeout = {0}, DefaultCapacity = {1}", this.sharedData.Config.LoadBalancing.ServiceOperationTimeout, this.defaultCapacity);
            BrokerTracing.EtwTrace.LogBackendBindingLoaded(
                sharedData.BrokerInfo.SessionId,
                "Backend",
                maxMessageSize,
                this.defaultBinding.ReceiveTimeout.Ticks,
                this.defaultBinding.SendTimeout.Ticks,
                this.defaultBinding.MessageVersion.ToString(),
                this.defaultBinding.Scheme);
        }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the LauncherHostService class
 /// </summary>
 public LauncherHostService(ITelepathyContext context)
 {
     Trace.TraceInformation("LauncherHostService init.");
     this.context = context;
     InitializeComponent();
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the ServiceJobMonitor class
 /// </summary>
 /// <param name="sharedData">indicating the shared data</param>
 /// <param name="stateManager">indicating the state manager</param>
 public ServiceJobMonitor(SharedData sharedData, BrokerStateManager stateManager, NodeMappingData nodeMappingData, ITelepathyContext context)
     : base(sharedData, stateManager, nodeMappingData, context)
 {
 }
Example #12
0
 public static async Task <string> GetSSLThumbprint(this ITelepathyContext context)
 {
     return(await context.Registry.GetSSLThumbprint(context.CancellationToken).ConfigureAwait(false));
 }
 public static async Task <string> ResolveSessionLauncherNodeAsync(this ITelepathyContext context)
 {
     return(await context.FabricContext.ResolveSingletonServicePrimaryAsync(SessionLauncherStatefulService, context.CancellationToken).ConfigureAwait(false));
 }