static void Main() { IUnityContainer unityContainer = UnityLoader.LoadContainer(); var engine = unityContainer.Resolve <Engine>(); engine.Start(); }
public void Initialize() { Container = UnityLoader.LoadContainer(); SinglePlayer = Container.Resolve <SinglePlayerGameOption>(); MultiPLayer = Container.Resolve <MultiPlayerGameOption>(); Exit = Container.Resolve <ExitGameOption>(); }
public void RunJob(string xmlFile, string jobName, UnityLoader loader, bool shouldFail) { // Flush output file GetFileNamesOut().ForEach(s => { if (File.Exists(s)) { File.Delete(s); } }); // Prerequisites GetFileNamesIn().ForEach(s => Assert.IsTrue(new FileInfo(s).Exists, "Job input file " + s + " does not exist, job can't be run")); GetFileNamesOut().ForEach(s => Assert.IsFalse(new FileInfo(s).Exists, "Job output file " + s + " should have been deleted before test")); XmlJob job = XmlJobParser.LoadJob(xmlFile); IJobOperator jobOperator = BatchRuntime.GetJobOperator(loader, job); Assert.IsNotNull(jobOperator); long?executionId = jobOperator.StartNextInstance(jobName); Assert.IsNotNull(executionId); JobExecution jobExecution = ((SimpleJobOperator)jobOperator).JobExplorer.GetJobExecution((long)executionId); //job SHOULD BE FAILED because of rollback having occured if (shouldFail) { Assert.IsTrue(jobExecution.Status.IsUnsuccessful()); } else { Assert.IsFalse(jobExecution.Status.IsUnsuccessful()); } Assert.IsFalse(jobExecution.Status.IsRunning()); }
public void Start() { this.setup(); if (enabled) { UnityLoader.load(this); } }
public PlutoRuntime() { this.lexer = new Lexer(); this.parser = new Parser(); this.interpreter = new Interpreter(); this.scope_resolver = new ScopeResolver(this.interpreter); UnityLoader.load_all(this.interpreter.loader); }
public static JobExecution Start(XmlJob job, UnityLoader loader) { loader.Job = job; var jobOperator = (SimpleJobOperator)BatchRuntime.GetJobOperator(loader); var executionId = jobOperator.StartNextInstance(job.Id); return(jobOperator.JobExplorer.GetJobExecution((long)executionId)); }
/// <summary> /// Starts given job. /// </summary> /// <param name="xmlJobFile"></param> /// <param name="loader"></param> /// <returns></returns> public static JobExecution Start(string xmlJobFile, UnityLoader loader) { var job = XmlJobParser.LoadJob(xmlJobFile); loader.Job = job; var jobOperator = (SimpleJobOperator)BatchRuntime.GetJobOperator(loader); var executionId = jobOperator.StartNextInstance(job.Id); return(jobOperator.JobExplorer.GetJobExecution((long)executionId)); }
public void Configuration(IAppBuilder app) { app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/login") }); HttpConfiguration config = new HttpConfiguration() { DependencyResolver = new UnityDependencyResolver(UnityLoader.GetConfiguredContainer()) }; WebApiConfig.Register(config); app.UseWebApi(config); }
/// <summary> /// Restarts given job. /// </summary> /// <param name="xmlJobFile"></param> /// <param name="loader"></param> /// <returns></returns> public static JobExecution ReStart(string xmlJobFile, UnityLoader loader) { var job = XmlJobParser.LoadJob(xmlJobFile); loader.Job = job; var jobOperator = (SimpleJobOperator)BatchRuntime.GetJobOperator(loader); var jobExecution = GetLastFailedJobExecution(job.Id, jobOperator.JobExplorer); if (jobExecution == null) { throw new JobExecutionNotFailedException( String.Format("No failed or stopped execution found for job={0}", job.Id)); } var executionId = jobOperator.Restart(jobExecution.Id.Value); return(jobOperator.JobExplorer.GetJobExecution((long)executionId)); }
/// <summary> /// Creates an <see cref="IJobOperator"/> with the specified <see cref="UnityLoader"/>. /// </summary> /// <param name="loader">The <see cref="UnityLoader"/> to use.</param> /// <returns>An instance of <see cref="IJobOperator"/>.</returns> public static IJobOperator GetJobOperator(UnityLoader loader) { IUnityContainer unityContainer = new UnityContainer(); unityContainer.AddNewExtension <PostprocessingUnityExtension>(); unityContainer.AddNewExtension <StepScopeExtension>(); unityContainer.AddNewExtension <SingletonExtension>(); loader.Load(unityContainer); IJobOperator jobOperator = unityContainer.Resolve <IJobOperator>(); if (jobOperator != null) { Logger.Debug("Loaded BatchContainerServiceProvider with className = {0}", jobOperator.GetType()); } return(jobOperator); }
static void Main(string[] args) { //ServiceHost host = new ServiceHost(typeof(LRPService)); //host.Open(); //Console.WriteLine("Services started. Press [Enter] to exit."); //Console.ReadLine(); //host.Close(); Log.Info("Starting the application..."); Unity.Container = UnityLoader.Init(); using (Unity.Container) { Log.Info("Configuring UnityServiceHost..."); // Step 2 Create a ServiceHost instance SM.ServiceHost hostLRPService = new UnityServiceHost(Unity.Container, typeof(LRPService)); try { StartService(hostLRPService, "LRP Service"); Console.WriteLine(""); Console.WriteLine("Press [Enter] to exit."); Console.ReadLine(); Console.WriteLine(""); StopService(hostLRPService, "LRP Service"); } catch (SM.CommunicationException ce) { Log.Error($"An Communication Exception occurred: {ce.Message}"); } catch (Exception ex) { Log.Error($"An exception occurred: {ex.Message}"); } finally { hostLRPService.Abort(); } } }
/// <summary> /// Stops a given running job. /// </summary> /// <param name="xmlJobFile"></param> /// <param name="loader"></param> public static void Stop(string xmlJobFile, UnityLoader loader) { var job = XmlJobParser.LoadJob(xmlJobFile); loader.Job = job; var jobOperator = (SimpleJobOperator)BatchRuntime.GetJobOperator(loader); var jobExecutions = GetRunningJobExecutions(job.Id, jobOperator.JobExplorer); if (jobExecutions == null || !jobExecutions.Any()) { throw new JobExecutionNotFailedException( string.Format("No running execution found for job={0}", job.Id)); } foreach (var jobExecution in jobExecutions) { jobExecution.Status = BatchStatus.Stopping; jobOperator.JobRepository.Update(jobExecution); } Logger.Info("Job {0} was stopped.", job.Id); }
public static void RegisterComponents() { var container = new UnityContainer(); UnityLoader.Init(container); // register all your components with the container here // it is NOT necessary to register your controllers // e.g. container.RegisterType<ITestService, TestService>(); //container.LoadConfiguration();//RegisterType<IRaisedTicketService, RaisedTicketService>(); //container.LoadConfiguration("services");//RegisterType<IRaisedTicketService, RaisedTicketService>(); //container.LoadConfiguration("repos");//RegisterType<IRaisedTicketService, RaisedTicketService>(); //var section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity"); //container.LoadConfiguration(section); DependencyResolver.SetResolver(new Unity.Mvc5.UnityDependencyResolver(container)); //GlobalConfiguration.Configuration.DependencyResolver = new Unity.WebApi.UnityDependencyResolver(container); }
/// <summary> /// Creates an <see cref="IJobOperator"/> with the specified <see cref="UnityLoader"/> and the given job specification. /// </summary> /// <param name="loader"></param> /// <param name="job">The job specification used to build the <see cref="UnityLoader"/>.</param> /// <returns>An instance of <see cref="IJobOperator"/>.</returns> public static IJobOperator GetJobOperator(UnityLoader loader, XmlJob job) { loader.Job = job; return(GetJobOperator(loader)); }
/// <summary> /// Starts given job. /// </summary> /// <param name="xmlJobFile"></param> /// <param name="loader"></param> /// <returns></returns> public static JobExecution Start(string xmlJobFile, UnityLoader loader) { var job = XmlJobParser.LoadJob(xmlJobFile); return(Start(job, loader)); }
public static void RegisterComponents() { var container = UnityLoader.GetConfiguredContainer(); DependencyResolver.SetResolver(new Unity.Mvc5.UnityDependencyResolver(container)); }
public void RunJob(string xmlFile, string jobName, UnityLoader loader) { RunJob(xmlFile, jobName, loader, false); }
public static JobExecution WorkerStart(string xmlJobFile, UnityLoader loader, string hostName, string username = "******", string password = "******", int workerUpdateTimeInterval = 15) { ControlQueue _controlQueue = GetControlQueue(controlQueueName, hostName, username, password); int messageCount = _controlQueue.GetMessageCount(); XmlJob job = null; TimeSpan WorkerUpdatetimeInterval = TimeSpan.FromSeconds(workerUpdateTimeInterval); if (messageCount != 0) { for (int i = 0; i < messageCount; i++) { string fileName = Path.GetFileName(xmlJobFile); string message = _controlQueue.Receive(fileName); if (ValidateMessage(message)) // for 3 items { Tuple <XmlJob, string, int, bool> tuple = ValidateFileName(message, xmlJobFile); if (tuple.Item4) { // Resend the message to the controlQueue if (tuple.Item3 > 0) { _controlQueue.Send(tuple.Item2); } job = tuple.Item1; Guid guid = Guid.NewGuid(); foreach (XmlStep step in job.JobElements) { step.RemoteChunking = new XmlRemoteChunking(); step.RemoteChunking.HostName = hostName; step.RemoteChunking.Master = false; step.RemoteChunking.WorkerID = guid.ToString(); } break; } } } } else { do { messageCount = _controlQueue.GetMessageCount(); if (messageCount != 0) { for (int i = 0; i < messageCount; i++) { string fileName = Path.GetFileName(xmlJobFile); string message = _controlQueue.Receive(fileName); if (ValidateMessage(message)) // for 3 items { Tuple <XmlJob, string, int, bool> tuple = ValidateFileName(message, xmlJobFile); if (tuple.Item4) { // Resend the message to the controlQueue if (tuple.Item3 > 0) { _controlQueue.Send(tuple.Item2); } job = tuple.Item1; Guid guid = Guid.NewGuid(); foreach (XmlStep step in job.JobElements) { step.RemoteChunking = new XmlRemoteChunking(); step.RemoteChunking.HostName = hostName; step.RemoteChunking.Master = false; step.RemoteChunking.WorkerID = guid.ToString(); } break; } } } break; } else { Logger.Info("No master job provided. Wait for worker {0} seconds.", WorkerUpdatetimeInterval.TotalSeconds); Thread.Sleep(WorkerUpdatetimeInterval); //throw new JobExecutionException("No master job provided"); } } while (messageCount == 0); } _controlQueue.Requeue(); loader.Job = job; var jobOperator = (SimpleJobOperator)BatchRuntime.GetJobOperator(loader); var executionId = jobOperator.StartNextInstance(job.Id); return(jobOperator.JobExplorer.GetJobExecution((long)executionId)); }