예제 #1
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);
                }
            }
        }
예제 #2
0
 private static JObject _defOnLoadConfig(ESIndexDefinition index, String fn, out DateTime fileUtcDate)
 {
     if (fn == null)
     {
         fileUtcDate = DateTime.MinValue;
         return(null);
     }
     fileUtcDate = File.GetLastWriteTimeUtc(fn);
     return(JObject.Parse(IOUtils.LoadFromFile(fn)));
 }
예제 #3
0
        public ESIndexDocType(ESIndexDefinition indexDefinition, XmlNode node)
        {
            Index = indexDefinition;

            Name          = node.ReadStr("@name");
            TypeName      = node.ReadStr("@typename", Name);
            KeyFieldName  = node.ReadStr("@keyfield", null);
            DateFieldName = node.ReadStr("@datefield", null);
            shouldNull(node, "@idfield", "_id");
            shouldNull(node, "@routingfield", "_routing");
            AutoTimestampFieldName = node.ReadStr("@ts", indexDefinition.AutoTimestampFieldName);
        }
예제 #4
0
        private JObject _loadConfig(ESIndexDefinition index, String fn, out DateTime fileUtcDate)
        {
            if (fn == null)
            {
                fileUtcDate = DateTime.MinValue;
                return(null);
            }
            Engine.ImportLog.Log("Loading config via template. fn={0}", fn);
            fileUtcDate = File.GetLastWriteTimeUtc(fn);
            ITemplateEngine template = Engine.TemplateFactory.CreateEngine();

            template.LoadFromFile(fn);
            var rdr = template.ResultAsStream().CreateJsonReader();

            return(JObject.Load(rdr));
        }
예제 #5
0
        protected ESIndexDocType getDocType(String name, bool mustExcept)
        {
            ESIndexDocType ret = null;
            int            ix  = -1;
            int            cnt = 0;

            if (name != null && 0 <= (ix = name.IndexOf('.')))
            {
                ret = getDocType(name.Substring(0, ix), name.Substring(ix + 1));
                if (ret == null)
                {
                    goto EXIT_RTN;
                }
                return(ret);
            }

            if (String.IsNullOrEmpty(name))
            {
                ESIndexDefinition def = null;
                if (Indexes.Count == 1)
                {
                    def = Indexes[0];
                    if (def.DocTypes.Count == 1)
                    {
                        return(def.DocTypes[0]);
                    }
                }
                goto EXIT_RTN;
            }

            var doctype = getDocType(name, null);

            if (doctype != null)
            {
                return(doctype);
            }

            foreach (var index in Indexes)
            {
                foreach (var dt in index.DocTypes)
                {
                    if (String.Equals(name, dt.Name))
                    {
                        ret = dt;
                        cnt++;
                    }
                }
            }
            if (cnt == 1)
            {
                return(ret);
            }

EXIT_RTN:
            if (!mustExcept)
            {
                return(null);
            }
            Logger errorLog = Logs.ErrorLog;

            errorLog.Log("Type {0} is not found or is ambiguous. Found cnt={1}. All types:", name, cnt);
            foreach (var index in Indexes)
            {
                errorLog.Log("-- Index {0}:", index.Name);
                foreach (var dt in index.DocTypes)
                {
                    if (String.Equals(name, dt.Name))
                    {
                        errorLog.Log("-- -- Type {0}", dt.Name);
                    }
                }
            }
            throw new BMException("Cannot find endpoint [{0}]. It is not found or ambiguous.", name);
        }