Beispiel #1
0
        internal int RunServer(
            string pipeName,
            string tempPath,
            IClientConnectionHost clientConnectionHost = null,
            IDiagnosticListener listener        = null,
            TimeSpan?keepAlive                  = null,
            CancellationToken cancellationToken = default)
        {
            keepAlive ??= GetKeepAliveTimeout();
            listener ??= new EmptyDiagnosticListener();
            clientConnectionHost ??= CreateClientConnectionHost(pipeName);

            // Grab the server mutex to prevent multiple servers from starting with the same
            // pipename and consuming excess resources. If someone else holds the mutex
            // exit immediately with a non-zero exit code
            var  mutexName = BuildServerConnection.GetServerMutexName(pipeName);
            bool createdNew;

            using (var serverMutex = BuildServerConnection.OpenOrCreateMutex(name: mutexName,
                                                                             createdNew: out createdNew))
            {
                if (!createdNew)
                {
                    return(CommonCompiler.Failed);
                }

                CompilerServerLogger.Log("Keep alive timeout is: {0} milliseconds.", keepAlive?.TotalMilliseconds ?? 0);
                FatalError.Handler = FailFast.OnFatalException;

                var dispatcher = new ServerDispatcher(clientConnectionHost, listener);
                dispatcher.ListenAndDispatchConnections(keepAlive, cancellationToken);
                return(CommonCompiler.Succeeded);
            }
        }
 internal int RunServer(string pipeName, IClientConnectionHost clientConnectionHost = null, IDiagnosticListener listener = null, TimeSpan? keepAlive = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     keepAlive = keepAlive ?? GetKeepAliveTimeout();
     listener = listener ?? new EmptyDiagnosticListener();
     clientConnectionHost = clientConnectionHost ?? CreateClientConnectionHost(pipeName);
     return RunServerCore(pipeName, clientConnectionHost, listener, keepAlive, cancellationToken);
 }
Beispiel #3
0
 internal ServerDispatcher(ICompilerServerHost compilerServerHost, IClientConnectionHost clientConnectionHost, IDiagnosticListener?diagnosticListener = null)
 {
     _compilerServerHost   = compilerServerHost;
     _logger               = compilerServerHost.Logger;
     _clientConnectionHost = clientConnectionHost;
     _diagnosticListener   = diagnosticListener ?? new EmptyDiagnosticListener();
 }
        protected override int RunServerCore(string pipeName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan? keepAlive, CancellationToken cancellationToken)
        {
            // Grab the server mutex to prevent multiple servers from starting with the same
            // pipename and consuming excess resources. If someone else holds the mutex
            // exit immediately with a non-zero exit code
            var mutexName = DesktopBuildClient.GetServerMutexName(pipeName);
            bool holdsMutex;
            using (var serverMutex = new Mutex(initiallyOwned: true,
                                               name: mutexName,
                                               createdNew: out holdsMutex))
            {
                if (!holdsMutex)
                {
                    return CommonCompiler.Failed;
                }

                try
                {
                    return base.RunServerCore(pipeName, connectionHost, listener, keepAlive, cancellationToken);
                }
                finally
                {
                    serverMutex.ReleaseMutex();
                }
            }
        }
Beispiel #5
0
		public virtual void AddListener(IDiagnosticListener listener)
		{
			if (_listeners == null)
			{
				_listeners = new Collection4();
			}
			_listeners.Add(listener);
		}
Beispiel #6
0
    private static IEmbeddedConfiguration NewConfiguration(IDiagnosticListener diagnosticCollector)
    {
        IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration();

        configuration.Common.Diagnostic.AddListener(diagnosticCollector);

        return(configuration);
    }
Beispiel #7
0
 public virtual void AddListener(IDiagnosticListener listener)
 {
     if (_listeners == null)
     {
         _listeners = new Collection4();
     }
     _listeners.Add(listener);
 }
        protected virtual int RunServerCore(string pipeName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan? keepAlive, CancellationToken cancellationToken)
        {
            CompilerServerLogger.Log("Keep alive timeout is: {0} milliseconds.", keepAlive?.TotalMilliseconds ?? 0);
            FatalError.Handler = FailFast.OnFatalException;

            var dispatcher = new ServerDispatcher(connectionHost, listener);
            dispatcher.ListenAndDispatchConnections(keepAlive, cancellationToken);
            return CommonCompiler.Succeeded;
        }
        public void OnNext(DiagnosticListener listener)
        {
            IDiagnosticListener diagnosticListener = _listeners.Where(x => x.ListenerName == listener.Name).FirstOrDefault();

            if (diagnosticListener != null)
            {
                listener.Subscribe(diagnosticListener);
            }
        }
        internal static new int RunServer(
            string pipeName,
            string tempPath,
            IClientConnectionHost clientConnectionHost = null,
            IDiagnosticListener listener        = null,
            TimeSpan?keepAlive                  = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            GenerationServerController controller = new DesktopGenerationServerController(new NameValueCollection());

            return(controller.RunServer(pipeName, tempPath, clientConnectionHost, listener, keepAlive, cancellationToken));
        }
Beispiel #11
0
 internal int RunServer(
     string pipeName,
     string tempPath,
     IClientConnectionHost clientConnectionHost = null,
     IDiagnosticListener listener        = null,
     TimeSpan?keepAlive                  = null,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     keepAlive            = keepAlive ?? GetKeepAliveTimeout();
     listener             = listener ?? new EmptyDiagnosticListener();
     clientConnectionHost = clientConnectionHost ?? CreateClientConnectionHost(pipeName);
     return(RunServerCore(pipeName, clientConnectionHost, listener, keepAlive, cancellationToken));
 }
Beispiel #12
0
        internal static int CreateAndRunServer(
            string pipeName,
            string tempPath,
            IClientConnectionHost clientConnectionHost = null,
            IDiagnosticListener listener        = null,
            TimeSpan?keepAlive                  = null,
            NameValueCollection appSettings     = null,
            CancellationToken cancellationToken = default)
        {
            appSettings ??= new NameValueCollection();
            var controller = new BuildServerController(appSettings);

            return(controller.RunServer(pipeName, tempPath, clientConnectionHost, listener, keepAlive, cancellationToken));
        }
Beispiel #13
0
        private static int RunCore(
            IClientConnectionHost connectionHost,
            IDiagnosticListener listener,
            TimeSpan?keepAliveTimeout,
            CancellationToken cancellationToken)
        {
            CompilerServerLogger.Log("Keep alive timeout is: {0} milliseconds.", keepAliveTimeout?.TotalMilliseconds ?? 0);
            FatalError.Handler = FailFast.OnFatalException;

            var dispatcher = new ServerDispatcher(connectionHost, listener);

            dispatcher.ListenAndDispatchConnections(keepAliveTimeout, cancellationToken);
            return(CommonCompiler.Succeeded);
        }
		private static TResult DispatchToImpl<TResult>(
			IDiagnosticListener listener,
			Func<HttpDiagnosticListenerCoreImpl, TResult> coreImplFunc,
			Func<HttpDiagnosticListenerFullFrameworkImpl, TResult> fullFrameworkImplFunc
		)
		{
			switch (listener)
			{
				case HttpDiagnosticListenerCoreImpl impl:
					return coreImplFunc(impl);
				case HttpDiagnosticListenerFullFrameworkImpl impl:
					return fullFrameworkImplFunc(impl);
				default:
					throw new AssertionFailedException($"Unrecognized {nameof(HttpDiagnosticListener)} implementation - {listener.GetType()}");
			}
		}
        internal int RunServer(
            string pipeName,
            string tempPath,
            IClientConnectionHost clientConnectionHost = null,
            IDiagnosticListener listener        = null,
            TimeSpan?keepAlive                  = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            if (BuildServerConnection.IsPipePathTooLong(pipeName, tempPath))
            {
                return(CommonCompiler.Failed);
            }

            keepAlive            = keepAlive ?? GetKeepAliveTimeout();
            listener             = listener ?? new EmptyDiagnosticListener();
            clientConnectionHost = clientConnectionHost ?? CreateClientConnectionHost(pipeName);
            return(RunServerCore(pipeName, clientConnectionHost, listener, keepAlive, cancellationToken));
        }
Beispiel #16
0
 public DiagnosticFilter(IDiagnosticListener target, params Type[] filterFor)
 {
     this.target = target;
     this.filterFor = new List<Type>(filterFor);
 }
 public void RegisterListener(IDiagnosticListener listener)
 {
     listeners.Add(listener);
 }
 internal DiagnosticInitializer(IApmLogger baseLogger, IDiagnosticListener listener)
 {
     _logger   = baseLogger.Scoped(nameof(DiagnosticInitializer));
     _listener = listener;
 }
Beispiel #19
0
 private static int ProcessingRequestsCount(IDiagnosticListener listener) =>
 DispatchToImpl(listener, impl => impl.ProcessingRequests.Count, impl => impl.ProcessingRequests.Count);
Beispiel #20
0
 /// <summary>
 /// Create a new server that listens on the given base pipe name.
 /// When a request comes in, it is dispatched on a separate thread
 /// via the IRequestHandler interface passed in.
 /// </summary>
 public ServerDispatcher(IRequestHandler handler, IDiagnosticListener diagnosticListener)
 {
     _handler            = handler;
     _diagnosticListener = diagnosticListener;
 }
 public void RegisterListener(IDiagnosticListener listener)
 {
     listeners.Add(listener);
 }
Beispiel #22
0
        internal static int Run(string mutexName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan?keepAlive, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Grab the server mutex to prevent multiple servers from starting with the same
            // pipename and consuming excess resources. If someone else holds the mutex
            // exit immediately with a non-zero exit code
            bool holdsMutex;

            using (var serverMutex = new Mutex(initiallyOwned: true,
                                               name: mutexName,
                                               createdNew: out holdsMutex))
            {
                if (!holdsMutex)
                {
                    return(CommonCompiler.Failed);
                }

                try
                {
                    return(RunCore(connectionHost, listener, keepAlive, cancellationToken));
                }
                finally
                {
                    serverMutex.ReleaseMutex();
                }
            }
        }
Beispiel #23
0
 public DiagnosticFilter(IDiagnosticListener target, params Type[] filterFor)
 {
     this.target    = target;
     this.filterFor = new List <Type>(filterFor);
 }
        protected override int RunServerCore(string pipeName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan?keepAlive, CancellationToken cancellationToken)
        {
            // Grab the server mutex to prevent multiple servers from starting with the same
            // pipename and consuming excess resources. If someone else holds the mutex
            // exit immediately with a non-zero exit code
            var  mutexName = GenerationServerConnection.GetServerMutexName(pipeName);
            bool holdsMutex;

            using (var serverMutex = new Mutex(initiallyOwned: true,
                                               name: mutexName,
                                               createdNew: out holdsMutex))
            {
                if (!holdsMutex)
                {
                    return(CommonGenerator.Failed);
                }

                try
                {
                    return(base.RunServerCore(pipeName, connectionHost, listener, keepAlive, cancellationToken));
                }
                finally
                {
                    serverMutex.ReleaseMutex();
                }
            }
        }
 /// <summary>
 /// Register a logging listener
 /// </summary>
 /// <param name="listener">Listener</param>
 public DiagnosticsConfiguration RegisterListener(IDiagnosticListener listener)
 {
     dispatcher.RegisterListener(listener);
     return(this);
 }
Beispiel #26
0
 internal ServerDispatcher(ICompilerServerHost compilerServerHost, IRequestHandler handler, IDiagnosticListener diagnosticListener)
 {
     _compilerServerHost = compilerServerHost;
     _handler = handler;
     _diagnosticListener = diagnosticListener;
 }
Beispiel #27
0
 /// <summary>
 /// Create a new server that listens on the given base pipe name.
 /// When a request comes in, it is dispatched on a separate thread
 /// via the IRequestHandler interface passed in.
 /// </summary>
 public ServerDispatcher(IRequestHandler handler, IDiagnosticListener diagnosticListener)
 {
     _handler = handler;
     _diagnosticListener = diagnosticListener;
 }
 /// <summary>
 /// Register a logging listener
 /// </summary>
 /// <param name="listener">Listener</param>
 public DiagnosticsConfiguration RegisterListener(IDiagnosticListener listener)
 {
     dispatcher.RegisterListener(listener);
     return this;
 }
 internal ServerDispatcher(IClientConnectionHost clientConnectionHost, IDiagnosticListener diagnosticListener = null)
 {
     _clientConnectionHost = clientConnectionHost;
     _diagnosticListener = diagnosticListener ?? new EmptyDiagnosticListener();
 }
 public TransparentActivationDiagnosticsTestCase()
 {
     _checker = new _IDiagnosticListener_60(this);
 }
 internal DiagnosticInitializer(IApmAgent agent, IDiagnosticListener listener)
 {
     _agent    = agent as ApmAgent;
     _logger   = agent.Logger.Scoped(nameof(DiagnosticInitializer));
     _listener = listener;
 }
 public TransparentActivationDiagnosticsTestCase()
 {
     _checker = new _IDiagnosticListener_60(this);
 }
Beispiel #33
0
        internal static new int RunServer(string pipeName, IClientConnectionHost clientConnectionHost = null, IDiagnosticListener listener = null, TimeSpan?keepAlive = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            BuildServerController controller = new DesktopBuildServerController();

            return(controller.RunServer(pipeName, clientConnectionHost, listener, keepAlive, cancellationToken));
        }
Beispiel #34
0
 internal ServerDispatcher(IClientConnectionHost clientConnectionHost, IDiagnosticListener diagnosticListener = null)
 {
     _clientConnectionHost = clientConnectionHost;
     _diagnosticListener   = diagnosticListener ?? new EmptyDiagnosticListener();
 }
Beispiel #35
0
        protected virtual int RunServerCore(string pipeName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan?keepAlive, CancellationToken cancellationToken)
        {
            this.Log().DebugFormat("Keep alive timeout is: {0} milliseconds.", keepAlive?.TotalMilliseconds ?? 0);
            // FatalError.Handler = FailFast.OnFatalException;

            var dispatcher = new ServerDispatcher(connectionHost, listener);

            dispatcher.ListenAndDispatchConnections(keepAlive, cancellationToken);
            return(CommonGenerator.Succeeded);
        }
Beispiel #36
0
 private static string StopEventKey(IDiagnosticListener listener) =>
 DispatchToImpl(listener, impl => impl.StopEventKey, impl => impl.StopEventKey);
        protected override int RunServerCore(string pipeName, IClientConnectionHost connectionHost, IDiagnosticListener listener, TimeSpan?keepAlive, CancellationToken cancellationToken)
        {
            // Grab the server mutex to prevent multiple servers from starting with the same
            // pipename and consuming excess resources. If someone else holds the mutex
            // exit immediately with a non-zero exit code
            var  mutexName = BuildServerConnection.GetServerMutexName(pipeName);
            bool createdNew;

            using (var serverMutex = BuildServerConnection.OpenOrCreateMutex(name: mutexName,
                                                                             createdNew: out createdNew))
            {
                if (!createdNew)
                {
                    return(CommonCompiler.Failed);
                }

                return(base.RunServerCore(pipeName, connectionHost, listener, keepAlive, cancellationToken));
            }
        }
Beispiel #38
0
 private static ISpan GetSpanForRequest(IDiagnosticListener listener, object request) =>
 DispatchToImpl(
     listener,
     impl => impl.ProcessingRequests[(HttpRequestMessage)request],
     impl => impl.ProcessingRequests[(HttpWebRequest)request]
     );
 internal static new int RunServer(string pipeName, IClientConnectionHost clientConnectionHost = null, IDiagnosticListener listener = null, TimeSpan? keepAlive = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     BuildServerController controller = new DesktopBuildServerController();
     return controller.RunServer(pipeName, clientConnectionHost, listener, keepAlive, cancellationToken);
 }