コード例 #1
0
ファイル: FTService.cs プロジェクト: AndriiZ/BH
        public void CheckIndexes()
        {
            TryCatch(() =>
            {
                if (!IsStarted())
                {
                    throw new Exception("Service is not started.");
                }

                var dirsLenSort = GetInstances();

                for (int i = 0; i < dirsLenSort.Length; i++)
                {
                    string[] parts = dirsLenSort[i].Item1.Split(new string[] { "Instance" }, StringSplitOptions.None);

                    string instance = parts[parts.Length - 1];

                    UInt32 instanceNumber = uint.Parse(instance);

                    FTSearch fts = new FTSearch();

                    var conf = GetConfiguration();

                    conf.InstanceNumber = instanceNumber;
                    //conf.OnlyCheckIndex = false;

                    fts.StartInstance(conf, true);

                    fts.StopInstance();
                }
            });
        }
コード例 #2
0
ファイル: FTService.cs プロジェクト: AndriiZ/BH
        public void Start(int instanceNumber = 0)
        {
            TryCatch(() =>
            {
                if (IsStarted())
                {
                    throw new Exception("Service already started.");
                }

                var dirsLenSort = GetInstances(instanceNumber);

                uint maxInstanceNumber = 0;

                for (int i = 0; i < dirsLenSort.Length; i++)
                {
                    string[] parts = dirsLenSort[i].Item1.Split(new string[] { "Instance" }, StringSplitOptions.None);

                    string instance = parts[parts.Length - 1];

                    UInt32 currInstanceNumber = uint.Parse(instance);

                    FTSearch fts = new FTSearch();

                    var conf = GetConfiguration();

                    conf.InstanceNumber = currInstanceNumber;

                    fts.StartInstance(conf);

                    Instances.Add(fts);

                    if (ActiveInstance == null && dirsLenSort[i].Item2 < MaxSizeActiveInstance)
                    {
                        ActiveInstance = fts;
                    }

                    if (currInstanceNumber > maxInstanceNumber)
                    {
                        maxInstanceNumber = currInstanceNumber;
                    }
                }

                if (ActiveInstance == null)
                {
                    FTSearch fts = new FTSearch();

                    var conf = GetConfiguration();

                    conf.InstanceNumber = maxInstanceNumber + 1;

                    fts.StartInstance(conf);

                    Instances.Add(fts);

                    ActiveInstance = fts;
                }
            });
        }
コード例 #3
0
ファイル: FTService.cs プロジェクト: AndriiZ/BH
        public void MergeIndexes()
        {
            TryCatch(() =>
            {
                if (!IsStarted())
                {
                    throw new Exception("Service is not started.");
                }

                int skipedBySize = 0;

                while (true)
                {
                    var dirsLenSort = GetInstances();

                    if (dirsLenSort.Length <= skipedBySize + 1)
                    {
                        break;
                    }

                    skipedBySize = 0;

                    for (int i = 0; i < dirsLenSort.Length - 1; i += 2)
                    {
                        if (dirsLenSort[i].Item2 + dirsLenSort[i + 1].Item2 < MaxSizeActiveInstance)
                        {
                            string path1 = dirsLenSort[i].Item1;
                            string path2 = dirsLenSort[i + 1].Item1;

                            string[] parts = path1.Split(new string[] { "Instance" }, StringSplitOptions.None);

                            string instance = parts[parts.Length - 1];

                            UInt32 instanceNumber = uint.Parse(instance);

                            FTSearch fts = new FTSearch();

                            var conf = GetConfiguration();

                            conf.InstanceNumber = instanceNumber;

                            fts.StartInstance(conf);

                            fts.ImportIndex(path2);

                            fts.StopInstance();

                            Directory.Delete(path2, true);
                        }
                        else
                        {
                            skipedBySize += 2;
                        }
                    }
                }
            });
        }