public NewRelicInsightsMessageBroker(ShellSettings shellSettings, IEnumerable <INewRelicInsightsMessageTransformer> messageTransformers)
        {
            _shellSettings       = shellSettings;
            _messageTransformers = messageTransformers;
            _messages            = new Collection <object>();

            Settings = new LazyField <NewRelicInsightsSettingsPart>();
            Settings.Loader(() =>
            {
                var settings = new NewRelicInsightsSettingsPart
                {
                    AccountId  = GetLongConfig("Glimpse.Orchard.NewRelicInsights.AccountId"),
                    AppId      = GetLongConfig("Glimpse.Orchard.NewRelicInsights.AppId"),
                    InsertKey  = ConfigurationManager.AppSettings["Glimpse.Orchard.NewRelicInsights.InsertKey"],
                    BufferSize = GetIntConfig("Glimpse.Orchard.NewRelicInsights.BufferSize"),
                };

                SettingsAreValid = !string.IsNullOrEmpty(settings.InsertKey) &&
                                   settings.AccountId > 0 &&
                                   settings.BufferSize > 0 &&
                                   settings.BufferSize <= 1000;

                return(settings);
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an IndexableField whose value will be lazy loaded if and
        /// when it is used.
        /// <para>
        /// <b>NOTE:</b> This method must be called once for each value of the field
        /// name specified in sequence that the values exist.  This method may not be
        /// used to generate multiple, lazy, IndexableField instances refering to
        /// the same underlying IndexableField instance.
        /// </para>
        /// <para>
        /// The lazy loading of field values from all instances of IndexableField
        /// objects returned by this method are all backed by a single Document
        /// per LazyDocument instance.
        /// </para>
        /// </summary>
        public virtual IIndexableField GetField(FieldInfo fieldInfo)
        {
            fieldNames.Add(fieldInfo.Name);
            if (!fields.TryGetValue(fieldInfo.Number, out IList <LazyField> values) || null == values)
            {
                values = new JCG.List <LazyField>();
                fields[fieldInfo.Number] = values;
            }

            LazyField value = new LazyField(this, fieldInfo.Name, fieldInfo.Number);

            values.Add(value);

            UninterruptableMonitor.Enter(this);
            try
            {
                // edge case: if someone asks this LazyDoc for more LazyFields
                // after other LazyFields from the same LazyDoc have been
                // actuallized, we need to force the doc to be re-fetched
                // so the new LazyFields are also populated.
                doc = null;
            }
            finally
            {
                UninterruptableMonitor.Exit(this);
            }
            return(value);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates an IndexableField whose value will be lazy loaded if and
        /// when it is used.
        /// <para>
        /// <b>NOTE:</b> This method must be called once for each value of the field
        /// name specified in sequence that the values exist.  This method may not be
        /// used to generate multiple, lazy, IndexableField instances refering to
        /// the same underlying IndexableField instance.
        /// </para>
        /// <para>
        /// The lazy loading of field values from all instances of IndexableField
        /// objects returned by this method are all backed by a single Document
        /// per LazyDocument instance.
        /// </para>
        /// </summary>
        public virtual IndexableField GetField(FieldInfo fieldInfo)
        {
            fieldNames.Add(fieldInfo.Name);
            IList <LazyField> values = fields.ContainsKey(fieldInfo.Number) ? fields[fieldInfo.Number] : null;

            if (null == values)
            {
                values = new List <LazyField>();
                fields[fieldInfo.Number] = values;
            }

            LazyField value = new LazyField(this, fieldInfo.Name, fieldInfo.Number);

            values.Add(value);

            lock (this)
            {
                // edge case: if someone asks this LazyDoc for more LazyFields
                // after other LazyFields from the same LazyDoc have been
                // actuallized, we need to force the doc to be re-fetched
                // so the new LazyFields are also populated.
                doc = null;
            }
            return(value);
        }
Esempio n. 4
0
        private void  AddFieldLazy(Document doc, FieldInfo fi, bool binary, bool compressed, bool tokenize)
        {
            if (binary)
            {
                int  toRead  = fieldsStream.ReadVInt();
                long pointer = fieldsStream.GetFilePointer();
                if (compressed)
                {
                    //was: doc.add(new Fieldable(fi.name, uncompress(b), Fieldable.Store.COMPRESS));
                    doc.Add(new LazyField(this, fi.name, Field.Store.COMPRESS, toRead, pointer, binary));
                }
                else
                {
                    //was: doc.add(new Fieldable(fi.name, b, Fieldable.Store.YES));
                    doc.Add(new LazyField(this, fi.name, Field.Store.YES, toRead, pointer, binary));
                }
                //Need to move the pointer ahead by toRead positions
                fieldsStream.Seek(pointer + toRead);
            }
            else
            {
                Field.Store      store      = Field.Store.YES;
                Field.Index      index      = GetIndexType(fi, tokenize);
                Field.TermVector termVector = GetTermVectorType(fi);

                AbstractField f;
                if (compressed)
                {
                    store = Field.Store.COMPRESS;
                    int  toRead  = fieldsStream.ReadVInt();
                    long pointer = fieldsStream.GetFilePointer();
                    f = new LazyField(this, fi.name, store, toRead, pointer, binary);
                    //skip over the part that we aren't loading
                    fieldsStream.Seek(pointer + toRead);
                    f.SetOmitNorms(fi.omitNorms);
                    f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions);
                }
                else
                {
                    int  length  = fieldsStream.ReadVInt();
                    long pointer = fieldsStream.GetFilePointer();
                    //Skip ahead of where we are by the length of what is stored
                    if (format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
                    {
                        fieldsStream.Seek(pointer + length);
                    }
                    else
                    {
                        fieldsStream.SkipChars(length);
                    }
                    f = new LazyField(this, fi.name, store, index, termVector, length, pointer, binary);
                    f.SetOmitNorms(fi.omitNorms);
                    f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions);
                }
                doc.Add(f);
            }
        }
        public DefaultLayerEvaluationService(IConditionManager conditionManager, IOrchardServices orchardServices) {
            _conditionManager = conditionManager;
            _orchardServices = orchardServices;

            Logger = NullLogger.Instance;
            T = NullLocalizer.Instance;

            _activeLayerIDs = new LazyField<int[]>();
            _activeLayerIDs.Loader(PopulateActiveLayers);
        }
        public DefaultLayerEvaluationService(IConditionManager conditionManager, IOrchardServices orchardServices)
        {
            _conditionManager = conditionManager;
            _orchardServices  = orchardServices;

            Logger = NullLogger.Instance;
            T      = NullLocalizer.Instance;

            _activeLayerIDs = new LazyField <int[]>();
            _activeLayerIDs.Loader(PopulateActiveLayers);
        }
        public CachedLayerEvaluationService(IPerformanceMonitor performanceMonitor, IRuleManager ruleManager, ILayerRetrievalService layerRetrievalService) 
        {
            _performanceMonitor = performanceMonitor;
            _ruleManager = ruleManager;
            _layerRetrievalService = layerRetrievalService;

            Logger = NullLogger.Instance;
            T = NullLocalizer.Instance;

            _activeLayerIds = new LazyField<int[]>();
            _activeLayerIds.Loader(PopulateActiveLayers);
        }
Esempio n. 8
0
        public CachedLayerEvaluationService(IPerformanceMonitor performanceMonitor, IRuleManager ruleManager, ILayerRetrievalService layerRetrievalService)
        {
            _performanceMonitor    = performanceMonitor;
            _ruleManager           = ruleManager;
            _layerRetrievalService = layerRetrievalService;

            Logger = NullLogger.Instance;
            T      = NullLocalizer.Instance;

            _activeLayerIds = new LazyField <int[]>();
            _activeLayerIds.Loader(PopulateActiveLayers);
        }
        public GlimpseLayerEvaluationService(IGlimpseService glimpseService, IOrchardServices orchardServices, UrlHelper urlHelper, IConditionManager conditionManager)
        {
            _glimpseService   = glimpseService;
            _orchardServices  = orchardServices;
            _urlHelper        = urlHelper;
            _conditionManager = conditionManager;

            Logger = NullLogger.Instance;
            T      = NullLocalizer.Instance;

            _activeLayerIDs = new LazyField <int[]>();
            _activeLayerIDs.Loader(PopulateActiveLayers);
        }
        private void  AddFieldLazy(Document doc, FieldInfo fi, bool binary, bool compressed, bool tokenize)
        {
            if (binary)
            {
                int  toRead  = fieldsStream.ReadVInt();
                long pointer = fieldsStream.FilePointer;
                //was: doc.add(new Fieldable(fi.name, b, Fieldable.Store.YES));
                doc.Add(new LazyField(this, fi.name, Field.Store.YES, toRead, pointer, binary, compressed));

                //Need to move the pointer ahead by toRead positions
                fieldsStream.Seek(pointer + toRead);
            }
            else
            {
                const Field.Store store      = Field.Store.YES;
                Field.Index       index      = FieldExtensions.ToIndex(fi.isIndexed, tokenize);
                Field.TermVector  termVector = FieldExtensions.ToTermVector(fi.storeTermVector, fi.storeOffsetWithTermVector, fi.storePositionWithTermVector);

                AbstractField f;
                if (compressed)
                {
                    int  toRead  = fieldsStream.ReadVInt();
                    long pointer = fieldsStream.FilePointer;
                    f = new LazyField(this, fi.name, store, toRead, pointer, binary, compressed);
                    //skip over the part that we aren't loading
                    fieldsStream.Seek(pointer + toRead);
                    f.OmitNorms = fi.omitNorms;
                    f.OmitTermFreqAndPositions = fi.omitTermFreqAndPositions;
                }
                else
                {
                    int  length  = fieldsStream.ReadVInt();
                    long pointer = fieldsStream.FilePointer;
                    //Skip ahead of where we are by the length of what is stored
                    if (format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
                    {
                        fieldsStream.Seek(pointer + length);
                    }
                    else
                    {
                        fieldsStream.SkipChars(length);
                    }
                    f = new LazyField(this, fi.name, store, index, termVector, length, pointer, binary, compressed)
                    {
                        OmitNorms = fi.omitNorms, OmitTermFreqAndPositions = fi.omitTermFreqAndPositions
                    };
                }

                doc.Add(f);
            }
        }
        public DefaultMessageBroker()
        {
            _messageBroker = new LazyField <IMessageBroker>();

            _messageBroker.Loader(() => {
                var context = HttpContext.Current;
                if (context == null)
                {
                    return(new NullMessageBroker());
                }

                return(((GlimpseRuntime)context.Application.Get("__GlimpseRuntime")).Configuration.MessageBroker);
            });
        }
Esempio n. 12
0
        // :TODO: synchronize to prevent redundent copying? (sync per field name?)
        private void FetchRealValues(string name, int fieldNum)
        {
            Document d = Document;

            IList <LazyField> lazyValues = fields[fieldNum];

            IndexableField[] realValues = d.GetFields(name);

            Debug.Assert(realValues.Length <= lazyValues.Count, "More lazy values then real values for field: " + name);

            for (int i = 0; i < lazyValues.Count; i++)
            {
                LazyField f = lazyValues[i];
                if (null != f)
                {
                    f.realValue = realValues[i];
                }
            }
        }
Esempio n. 13
0
        // :TODO: synchronize to prevent redundent copying? (sync per field name?)
        private void FetchRealValues(string name, int fieldNum)
        {
            Document d = GetDocument();

            fields.TryGetValue(fieldNum, out IList <LazyField> lazyValues);
            IIndexableField[] realValues = d.GetFields(name);

            if (Debugging.AssertsEnabled)
            {
                Debugging.Assert(realValues.Length <= lazyValues.Count,
                                 "More lazy values then real values for field: {0}", name);
            }

            for (int i = 0; i < lazyValues.Count; i++)
            {
                LazyField f = lazyValues[i];
                if (null != f)
                {
                    f.realValue = realValues[i];
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Creates an IndexableField whose value will be lazy loaded if and 
        /// when it is used. 
        /// <para>
        /// <b>NOTE:</b> This method must be called once for each value of the field 
        /// name specified in sequence that the values exist.  This method may not be 
        /// used to generate multiple, lazy, IndexableField instances refering to 
        /// the same underlying IndexableField instance.
        /// </para>
        /// <para>
        /// The lazy loading of field values from all instances of IndexableField 
        /// objects returned by this method are all backed by a single Document 
        /// per LazyDocument instance.
        /// </para>
        /// </summary>
        public virtual IndexableField GetField(FieldInfo fieldInfo)
        {
            fieldNames.Add(fieldInfo.Name);
            IList<LazyField> values = fields.ContainsKey(fieldInfo.Number) ? fields[fieldInfo.Number] : null;
            if (null == values)
            {
                values = new List<LazyField>();
                fields[fieldInfo.Number] = values;
            }

            LazyField value = new LazyField(this, fieldInfo.Name, fieldInfo.Number);
            values.Add(value);

            lock (this)
            {
                // edge case: if someone asks this LazyDoc for more LazyFields
                // after other LazyFields from the same LazyDoc have been
                // actuallized, we need to force the doc to be re-fetched
                // so the new LazyFields are also populated.
                doc = null;
            }
            return value;
        }
Esempio n. 15
0
        private void AddFieldLazy(Document doc, FieldInfo fi, bool binary, bool compressed, bool tokenize)
        {
            if (binary)
            {
                int toRead = fieldsStream.ReadVInt();
                long pointer = fieldsStream.FilePointer;
                //was: doc.add(new Fieldable(fi.name, b, Fieldable.Store.YES));
                doc.Add(new LazyField(this, fi.name, Field.Store.YES, toRead, pointer, binary, compressed));

                //Need to move the pointer ahead by toRead positions
                fieldsStream.Seek(pointer + toRead);
            }
            else
            {
                const Field.Store store = Field.Store.YES;
                Field.Index index = FieldExtensions.ToIndex(fi.isIndexed, tokenize);
                Field.TermVector termVector = FieldExtensions.ToTermVector(fi.storeTermVector, fi.storeOffsetWithTermVector, fi.storePositionWithTermVector);

                AbstractField f;
                if (compressed)
                {
                    int toRead = fieldsStream.ReadVInt();
                    long pointer = fieldsStream.FilePointer;
                    f = new LazyField(this, fi.name, store, toRead, pointer, binary, compressed);
                    //skip over the part that we aren't loading
                    fieldsStream.Seek(pointer + toRead);
                    f.OmitNorms = fi.omitNorms;
                    f.OmitTermFreqAndPositions = fi.omitTermFreqAndPositions;
                }
                else
                {
                    int length = fieldsStream.ReadVInt();
                    long pointer = fieldsStream.FilePointer;
                    //Skip ahead of where we are by the length of what is stored
                    if (format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
                    {
                        fieldsStream.Seek(pointer + length);
                    }
                    else
                    {
                        fieldsStream.SkipChars(length);
                    }
                    f = new LazyField(this, fi.name, store, index, termVector, length, pointer, binary, compressed)
                            {OmitNorms = fi.omitNorms, OmitTermFreqAndPositions = fi.omitTermFreqAndPositions};
                }

                doc.Add(f);
            }
        }
 public TaxonomyField() {
     TermsField = new LazyField<IEnumerable<TermPart>>();
 }
 public HelixItemReferenceListField(LazyField field, string indexValue) : base(field, indexValue)
 {
 }
 public TaxonomyField()
 {
     TermsField = new LazyField <IEnumerable <TermPart> >();
 }
Esempio n. 19
0
		private void  AddFieldLazy(Document doc, FieldInfo fi, bool binary, bool compressed, bool tokenize)
		{
			if (binary)
			{
				int toRead = fieldsStream.ReadVInt();
				long pointer = fieldsStream.GetFilePointer();
				if (compressed)
				{
					//was: doc.add(new Fieldable(fi.name, uncompress(b), Fieldable.Store.COMPRESS));
					doc.Add(new LazyField(this, fi.name, Field.Store.COMPRESS, toRead, pointer, binary));
				}
				else
				{
					//was: doc.add(new Fieldable(fi.name, b, Fieldable.Store.YES));
					doc.Add(new LazyField(this, fi.name, Field.Store.YES, toRead, pointer, binary));
				}
				//Need to move the pointer ahead by toRead positions
				fieldsStream.Seek(pointer + toRead);
			}
			else
			{
				Field.Store store = Field.Store.YES;
				Field.Index index = GetIndexType(fi, tokenize);
				Field.TermVector termVector = GetTermVectorType(fi);
				
				AbstractField f;
				if (compressed)
				{
					store = Field.Store.COMPRESS;
					int toRead = fieldsStream.ReadVInt();
					long pointer = fieldsStream.GetFilePointer();
					f = new LazyField(this, fi.name, store, toRead, pointer, binary);
					//skip over the part that we aren't loading
					fieldsStream.Seek(pointer + toRead);
					f.SetOmitNorms(fi.omitNorms);
					f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions);
				}
				else
				{
					int length = fieldsStream.ReadVInt();
					long pointer = fieldsStream.GetFilePointer();
					//Skip ahead of where we are by the length of what is stored
					if (format >= FieldsWriter.FORMAT_VERSION_UTF8_LENGTH_IN_BYTES)
						fieldsStream.Seek(pointer + length);
					else
						fieldsStream.SkipChars(length);
					f = new LazyField(this, fi.name, store, index, termVector, length, pointer, binary);
					f.SetOmitNorms(fi.omitNorms);
					f.SetOmitTermFreqAndPositions(fi.omitTermFreqAndPositions);
				}
				doc.Add(f);
			}
		}
Esempio n. 20
0
 public OptionSetField() {
     OptionItemsField = new LazyField<IEnumerable<OptionItemPart>>();
 }
Esempio n. 21
0
 public OptionSetField()
 {
     OptionItemsField = new LazyField <IEnumerable <OptionItemPart> >();
 }