示例#1
0
        public void Refresh()
        {
            builderController.RefreshState();
            Load();

            if (Building == null)
            {
                return;
            }

            if (Builder.State == BuilderState.Stopping)
            {
                TryToStop();
            }

            if (Builder.State == BuilderState.Running)
            {
                if (Settings.Current.Builder.IsLead)
                {
                    CreateDestination();
                    CreateChunks();
                }

                var complete = Build();

                if (Settings.Current.Builder.IsLead)
                {
                    CopyVocabulary();
                    FillPostBuildTables();
                }
                else
                {
                    StopEC2Instance();
                }

                if (Settings.Current.Builder.IsLead && complete)
                {
                    CreateIndexes();
                    RunPostprocess();

                    if (Builder.State == BuilderState.Running)
                    {
                        builderController.UpdateState(BuilderState.Stopped);
                    }

                    //StopEC2Instance();
                }

                if (Builder.State == BuilderState.Running)
                {
                    if (!Settings.Current.Builder.IsLead && Building.ChunksCreated && builderController.AllChunksStarted)
                    {
                        builderController.UpdateState(BuilderState.Stopped);
                    }
                }
            }
        }
        public void Refresh()
        {
            builderController.RefreshState();
            Load();

            if (Building == null)
            {
                return;
            }

            if (Builder.State == BuilderState.Stopping)
            {
                TryToStop();
            }

            if (Builder.State == BuilderState.Running)
            {
                if (Settings.Current.Builder.IsLead)
                {
                    CreateDestination();
                    CreateChunks();
                }

                Build();

                if (Settings.Current.Builder.IsLead && builderController.AllChunksComplete)
                {
                    CopyVocabulary();
                    CreateIndexes();

                    if (Builder.State == BuilderState.Running)
                    {
                        builderController.UpdateState(BuilderState.Stopped);
                    }
                }

                if (Builder.State == BuilderState.Running)
                {
                    if (Settings.Current.Builder.IsLead)
                    {
                        builderController.UpdateState(BuilderState.Stopped);
                    }
                    else if (builderController.AllChunksStarted)
                    {
                        builderController.UpdateState(BuilderState.Stopped);
                    }
                }
            }
        }
示例#3
0
        private static void Build(BuilderController builderController)
        {
            var dbChunk = new DbChunk(Settings.Current.Building.BuilderConnectionString);
             int? chunkId = null;
             while (true)
             {
            try
            {
               builderController.RefreshState();
               if (builderController.Builder.State == BuilderState.Stopping)
                  break;

               if (builderController.Builder.State == BuilderState.Stopped)
                  break;

               if (builderController.Builder.State == BuilderState.Error)
                  break;

               if (builderController.Builder.State == BuilderState.Unknown || builderController.Builder.State == BuilderState.Idle)
                  continue;

               chunkId = dbChunk.TakeChunk(Settings.Current.Building.Id.Value);
               if (!chunkId.HasValue) break;

               var builder = new ChunkBuilder(new ChunkData { Id = chunkId.Value }, GetBuilderType(Settings.Current.Building.Vendor));
               var loaded_chunk = builder.Load();
               var built_chunk = loaded_chunk.Build();
               var task = built_chunk.Save();
               tasks.Add(task);
            }
            catch (Exception e)
            {
               if (chunkId.HasValue)
                  Logger.WriteError(chunkId, e);
               else
                  Logger.Write(null, Settings.Current.Building.Id.Value, null, LogMessageTypes.Error, Logger.CreateExceptionString(e));

               builderController.UpdateState(BuilderState.Error);
            }
             }
        }