public DriverTestStartHandler(IClock clock, HttpServerPort httpServerPort)
 {
     _clock          = clock;
     _httpServerPort = httpServerPort;
     Identifier      = "DriverTestStartHandler";
     LOGGER.Log(Level.Info, "Http Server port number: " + httpServerPort.PortNumber);
 }
예제 #2
0
 public HttpServerHandler([Parameter(Value = typeof(DriverBridgeConfigurationOptions.HttpEventHandlers))] ISet <IHttpHandler> httpEventHandlers,
                          HttpServerPort httpServerPort)
 {
     LOGGER.Log(Level.Info, "Constructing HttpServerHandler");
     foreach (var h in httpEventHandlers)
     {
         string spec = h.GetSpecification();
         if (spec.Contains(":"))
         {
             Exceptions.Throw(new ArgumentException("spec cannot contain :"), "The http spec given is " + spec, LOGGER);
         }
         LOGGER.Log(Level.Info, "HttpHandler spec:" + spec);
         eventHandlers.Add(spec.ToLower(CultureInfo.CurrentCulture), h);
     }
     this.httpServerPort = httpServerPort;
 }
예제 #3
0
        private static ulong[] GetHandlers(string httpServerPortNumber)
        {
            IStartHandler startHandler;
            IInjector     injector = null;
            string        errorMessage;
            string        bridgeConfiguration = Path.Combine(Directory.GetCurrentDirectory(), "reef", "global", Constants.DriverBridgeConfiguration);

            if (!File.Exists(bridgeConfiguration))
            {
                errorMessage = "Cannot find CLR Driver bridge configuration file " + bridgeConfiguration;
                Exceptions.Throw(new InvalidOperationException(errorMessage), LOGGER);
            }
            try
            {
                IConfiguration driverBridgeConfiguration = new AvroConfigurationSerializer().FromFile(bridgeConfiguration);
                injector = TangFactory.GetTang().NewInjector(driverBridgeConfiguration);
            }
            catch (Exception e)
            {
                errorMessage = "Failed to get injector from driver bridge configuration.";
                Exceptions.CaughtAndThrow(new InvalidOperationException(errorMessage, e), Level.Error, errorMessage, LOGGER);
            }

            try
            {
                HttpServerPort port = injector.GetInstance <HttpServerPort>();
                port.PortNumber = httpServerPortNumber == null ? 0 : int.Parse(httpServerPortNumber, CultureInfo.InvariantCulture);

                startHandler = injector.GetInstance <IStartHandler>();
                LOGGER.Log(Level.Info, "Start handler set to be " + startHandler.Identifier);
                _driverBridge = injector.GetInstance <DriverBridge>();
            }
            catch (Exception e)
            {
                Exceptions.CaughtAndThrow(e, Level.Error, "Cannot get instance.", LOGGER);
            }

            return(_driverBridge.Subscribe());
        }
예제 #4
0
 public HelloStartHandler(HttpServerPort httpServerPort)
 {
     CreateClassHierarchy();
     Identifier = "HelloStartHandler";
     LOGGER.Log(Level.Info, "HttpPort received in HelloStartHandler: " + httpServerPort.PortNumber);
 }