Ejemplo n.º 1
0
 public void CreateIndexes(ESConnection conn, ESIndexCmd._CheckIndexFlags flags)
 {
     for (int i = 0; i < list.Count; i++)
     {
         list[i].Create(conn, flags);
     }
 }
Ejemplo n.º 2
0
        internal void OpenIndex(PipelineContext ctx, ESIndexDefinition index)
        {
            if (index.IsOpen)
            {
                return;
            }
            ESHelper.SetLogging(ctx, Connection);
            ESIndexCmd._CheckIndexFlags flags = ESIndexCmd._CheckIndexFlags.AppendDate;
            if (ReadOnly)
            {
                flags |= ESIndexCmd._CheckIndexFlags.DontCreate;
            }
            if ((ctx.ImportFlags & _ImportFlags.ImportFull) != 0)
            {
                flags |= ESIndexCmd._CheckIndexFlags.ForceCreate;
            }
            index.Create(Connection, flags);
            WaitForStatus();

            var adminEp = this.GetAdminEndpoint(ctx);

            if (adminEp != null)
            {
                int oldCount = ctx.RunAdministrations.Count;
                ctx.RunAdministrations.Merge(adminEp.LoadAdministration(ctx));
                if (ctx.RunAdministrations.Count != oldCount)
                {
                    ctx.ImportLog.Log("-- merged {0} run-administrations from endpoint {1}. Now contains {2} runs.", ctx.RunAdministrations.Count - oldCount, this.Name, ctx.RunAdministrations.Count);
                }
            }
        }
Ejemplo n.º 3
0
        public bool Create(ESConnection conn, ESIndexCmd._CheckIndexFlags flags)
        {
            if (!Active)
            {
                return(false);
            }
            if (IsOpen)
            {
                return(false);
            }

            //Switch off append flags if there's nothing to append
            if (IndexDateTimeFormat == null || Generations == 0)
            {
                flags &= ~ESIndexCmd._CheckIndexFlags.AppendDate;
            }

            if (ReadOnly)
            {
                flags |= ESIndexCmd._CheckIndexFlags.DontCreate;
            }

            DocMappings = null;
            DateTime configDate;
            JObject  configJson = onLoadConfig(this, ConfigFile, out configDate);

            patchConfig(conn, configJson);

            ESIndexCmd cmd = createIndexCmd(conn);

            cmd.OnCreate = overrideShardsOnCreate;
            bool isNew;

            IndexName    = cmd.CheckIndexFromFile(AliasName, configJson, configDate, flags, out isNew);//PW naar kijken!
            IndexExists  = IndexName != null;
            IsNewIndex   = isNew;
            RenameNeeded = (flags & ESIndexCmd._CheckIndexFlags.AppendDate) != 0 && isNew;

            //Get possible mappings and determine default doctype
            conn.Logger.Log("");
            conn.Logger.Log("get mappings");
            DocMappings = new List <String>();

            if (IndexName != null) //Might be null if the index was not found (if Readonly==true)
            {
                ESGetMappingResponse resp = cmd.GetIndexMappings(IndexName);
                conn.Logger.Log("Index[0]={0}", resp[0].Name);
                foreach (var mapping in resp[0])
                {
                    conn.Logger.Log("-- Mapping={0}", mapping.Name);
                    DocMappings.Add(mapping.Name);
                }
            }

            if (RefreshIntervalDuringImport != null && !ReadOnly)
            {
                JObject curSettings = cmd.GetSettings();
                this.savedRefreshInterval = curSettings.ReadStr("refresh_interval", "1s");
                curSettings = new JObject();
                curSettings["refresh_interval"] = RefreshIntervalDuringImport;
                cmd.PutSettings(curSettings);
                conn.Logger.Log("-- RefreshInterval changed from={0} into {1}", savedRefreshInterval, RefreshIntervalDuringImport);
            }
            IsOpen = true;
            return(isNew);
        }