public void Stop() { HttpServiceListener.Dispose(); try { if (Silo != null && Silo.IsStarted) { Silo.StopOrleansSilo(); } } catch (System.Net.Sockets.SocketException) { //Orleans 1.3.1 thorws this exception most of the time } finally { try { GrainClient.Uninitialize(); } catch (Exception exc) { Log.Warn("Exception Uninitializing grain client", exception: exc); } } }
public async Task CreateListener_HttpsDisabled_CreationSucceedsNoNeedForCertificate() { var endpointDefinition = Substitute.For <IServiceEndPointDefinition>(); using (var httpPort = DisposablePort.GetPort()) { endpointDefinition.HttpsPort.Returns(ci => httpPort.Port); endpointDefinition.HttpsPort.Returns(ci => null); // HTTPS disabled by a null HTTPS port var certificateLocator = Substitute.For <ICertificateLocator>(); certificateLocator.GetCertificate(Arg.Any <string>()).Throws <Exception>(); using (var listener = new HttpServiceListener(Substitute.For <IActivator>(), Substitute.For <IWorker>(), endpointDefinition, certificateLocator, Substitute.For <ILog>(), Enumerable.Empty <ICustomEndpoint>(), Substitute.For <IEnvironment>(), new JsonExceptionSerializer(Substitute.For <IStackTraceEnhancer>(), new JsonExceptionSerializationSettings(() => new ExceptionSerializationConfig(false, false))), new ServiceSchema(), () => new LoadShedding(), Substitute.For <IServerRequestPublisher>(), new CurrentApplicationInfo( nameof(HttpServiceListenerTests), Environment.UserName, System.Net.Dns.GetHostName()) )) { listener.Start(); } certificateLocator.DidNotReceive().GetCertificate(Arg.Any <string>()); } }
private async Task BootstrapInit(IProviderRuntime providerRuntime) { GrainTaskScheduler = TaskScheduler.Current; GrainFactory = providerRuntime.GrainFactory; providerRuntime.SetInvokeInterceptor(Interceptor); try { if (AfterOrleansStartup != null) { await AfterOrleansStartup(GrainFactory); } } catch (Exception ex) { BootstrapException = ex; throw; } try { HttpServiceListener.Start(); } catch (Exception ex) { BootstrapException = ex; Log.Error("Failed to start HttpServiceListener", exception: ex); throw; } }
public GigyaSiloHost(ILog log, OrleansConfigurationBuilder configBuilder, HttpServiceListener httpServiceListener, IEventPublisher <GrainCallEvent> eventPublisher, Func <LoadShedding> loadSheddingConfig, ISourceBlock <OrleansConfig> orleansConfigSourceBlock, OrleansConfig orleansConfig) { Log = log; ConfigBuilder = configBuilder; HttpServiceListener = httpServiceListener; EventPublisher = eventPublisher; LoadSheddingConfig = loadSheddingConfig; OrleansConfigSourceBlock = orleansConfigSourceBlock; PreviousOrleansConfig = orleansConfig; OrleansConfigSourceBlock.LinkTo(new ActionBlock <OrleansConfig>(config => UpdateOrleansAgeLimitChange(config))); if (DelegatingBootstrapProvider.OnInit != null || DelegatingBootstrapProvider.OnClose != null) { throw new InvalidOperationException("DelegatingBootstrapProvider is already in use."); } DelegatingBootstrapProvider.OnInit = BootstrapInit; DelegatingBootstrapProvider.OnClose = BootstrapClose; EventsDiscarded = Metric.Context("GigyaSiloHost").Counter("GrainCallEvents discarded", Unit.Items); }
/// <summary> /// Called when the service is started. This method first calls <see cref="CreateKernel"/>, configures it with /// infrastructure binding, calls <see cref="Configure"/> to configure additional bindings and settings, then /// start a <see cref="HttpServiceListener"/>. In most scenarios, you shouldn't override this method. /// </summary> protected override void OnStart() { Kernel = CreateKernel(); Kernel.Rebind <IActivator>().To <InstanceBasedActivator <TInterface> >().InSingletonScope(); Kernel.Rebind <IServiceInterfaceMapper>().To <IdentityServiceInterfaceMapper>().InSingletonScope().WithConstructorArgument(typeof(TInterface)); PreConfigure(Kernel); Configure(Kernel, Kernel.Get <BaseCommonConfig>()); PreInitialize(Kernel); OnInitilize(Kernel); Listener = Kernel.Get <HttpServiceListener>(); Listener.Start(); }
public static HttpResponseMessage GetResponseWithException(Exception ex, HttpStatusCode?statusCode = null, bool withGigyaHostHeader = true) { var resMessage = new HttpResponseMessage { StatusCode = statusCode ?? HttpServiceListener.GetExceptionStatusCode(ex) }; if (withGigyaHostHeader) { resMessage.Headers.Add(GigyaHttpHeaders.ServerHostname, "host"); } resMessage.Content = new StringContent(JsonExceptionSerializer.Serialize(ex)); return(resMessage); }
public GigyaSiloHost(ILog log, HttpServiceListener httpServiceListener, IOrleansToNinjectBinding serviceProvider, OrleansLogProvider logProvider, OrleansConfigurationBuilder orleansConfigurationBuilder, OrleansConfig orleansConfig, Func <IServiceProvider> factoryServiceProvider ) { _serviceProvider = serviceProvider; _logProvider = logProvider; _orleansConfigurationBuilder = orleansConfigurationBuilder; _orleansConfig = orleansConfig; _factoryServiceProvider = factoryServiceProvider; Log = log; HttpServiceListener = httpServiceListener; }
public void Stop() { HttpServiceListener.Dispose(); if (Silo != null && Silo.IsStarted) { Silo.StopOrleansSilo(); } try { GrainClient.Uninitialize(); } catch (Exception exc) { Log.Warn("Exception Uninitializing grain client", exception: exc); } }
public GigyaSiloHost(ILog log, OrleansConfigurationBuilder configBuilder, HttpServiceListener httpServiceListener, IEventPublisher <GrainCallEvent> eventPublisher) { Log = log; ConfigBuilder = configBuilder; HttpServiceListener = httpServiceListener; EventPublisher = eventPublisher; if (DelegatingBootstrapProvider.OnInit != null || DelegatingBootstrapProvider.OnClose != null) { throw new InvalidOperationException("DelegatingBootstrapProvider is already in use."); } DelegatingBootstrapProvider.OnInit = BootstrapInit; DelegatingBootstrapProvider.OnClose = BootstrapClose; EventsDiscarded = Metric.Context("GigyaSiloHost").Counter("GrainCallEvents discarded", Unit.Items); }
/// <summary> /// Called when the service is started. This method first calls <see cref="CreateKernel"/>, configures it with /// infrastructure binding, calls <see cref="Configure"/> to configure additional bindings and settings, then /// start a <see cref="HttpServiceListener"/>. In most scenarios, you shouldn't override this method. /// </summary> protected override void OnStart() { Kernel = CreateKernel(); Kernel.Bind <CurrentApplicationInfo>().ToConstant(new CurrentApplicationInfo(ServiceName, Arguments.InstanceName)).InSingletonScope(); Kernel.Rebind <IActivator>().To <InstanceBasedActivator <TInterface> >().InSingletonScope(); Kernel.Rebind <IServiceInterfaceMapper>().To <IdentityServiceInterfaceMapper>().InSingletonScope().WithConstructorArgument(typeof(TInterface)); PreConfigure(Kernel); Configure(Kernel, Kernel.Get <BaseCommonConfig>()); PreInitialize(Kernel); OnInitilize(Kernel); //don't move up the get should be after all the binding are done var log = Kernel.Get <ILog>(); Listener = Kernel.Get <HttpServiceListener>(); Listener.Start(); Listener.StartGettingTraffic(); log.Info(_ => _("start getting traffic", unencryptedTags: new { siloName = CurrentApplicationInfo.HostName })); }
public GigyaSiloHostFake(WarmupTestServiceHostWithSiloHostFake host, ILog log, OrleansConfigurationBuilder configBuilder, HttpServiceListener httpServiceListener, IEventPublisher <GrainCallEvent> eventPublisher, Func <LoadShedding> loadSheddingConfig, ISourceBlock <OrleansConfig> orleansConfigSourceBlock, OrleansConfig orleansConfig) : base(log, configBuilder, httpServiceListener, eventPublisher, loadSheddingConfig, orleansConfigSourceBlock, orleansConfig) { try { Assert.AreEqual(DependantClassFake.WarmedTimes, 1); } catch (Exception e) { } finally { host.StopHost(); //awaitable, but can't be awaited in ctor. There is await into the "StopHost" method } }