public void AddUpdateDeployment(DeploymentInformation descriptor)
 {
     using (_lock.Acquire())
     {
         _deployments.Put(descriptor.DeploymentId, descriptor);
     }
 }
示例#2
0
 public void OnInput(SupportBean @event)
 {
     using (_lock.Acquire())
     {
         _received.Add(@event);
     }
 }
示例#3
0
        /// <summary>
        /// Returns an EPServiceProvider for a given provider URI.
        /// Use the URI of "default" or null to return the default service provider.
        /// </summary>
        /// <param name="providerURI">- the provider URI. If null provided it assumes "default".</param>
        /// <param name="configuration">is the configuration for the service</param>
        /// <exception cref="ConfigurationException">to indicate a configuration problem</exception>
        /// <returns>EPServiceProvider for the given provider URI.</returns>
        public static EPServiceProvider GetProvider(string providerURI, Configuration configuration)
        {
            using (LockObj.Acquire())
            {
                var providerURINonNull = providerURI ?? EPServiceProviderConstants.DEFAULT_ENGINE_URI;

                if (Runtimes.ContainsKey(providerURINonNull))
                {
                    var provider = Runtimes.Get(providerURINonNull);
                    if (provider.IsDestroyed)
                    {
                        provider = GetProviderInternal(configuration, providerURINonNull);
                        Runtimes.Put(providerURINonNull, provider);
                    }
                    else
                    {
                        provider.SetConfiguration(configuration);
                    }
                    return(provider);
                }

                // New runtime
                var runtime = GetProviderInternal(configuration, providerURINonNull);
                Runtimes.Put(providerURINonNull, runtime);
                runtime.PostInitialize();

                return(runtime);
            }
        }
 /// <summary>
 /// Lookup an object by name.
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public object Lookup(string name)
 {
     using (_dataLock.Acquire())
     {
         return(_dataTable.Get(name));
     }
 }
示例#5
0
        /// <summary>
        ///     Thread-safe and efficient make-or-get
        /// </summary>
        /// <param name="statementContext">statement context</param>
        /// <returns>page resources</returns>
        private StatementResourceHolder MakeOrGetEntryUnpartitioned(
            StatementContext statementContext)
        {
            var resources = StatementResourceService.ResourcesUnpartitioned;
            if (resources == null) {
                using (@lock.Acquire()) {
                    resources = StatementResourceService.ResourcesUnpartitioned;
                    if (resources != null) {
                        return resources;
                    }

                    var agentInstanceContext = MakeNewAgentInstanceContextCanNull(
                        DEFAULT_AGENT_INSTANCE_ID,
                        statementContext,
                        false);
                    var result =
                        statementContext.StatementAIFactoryProvider.Factory.NewContext(agentInstanceContext, true);
                    HookUpNewRealization(result, statementContext);
                    resources = statementContext.StatementContextRuntimeServices.StatementResourceHolderBuilder.Build(
                        agentInstanceContext,
                        result);
                    // for consistency with context partition behavior we are holding on to resources for now
                    StatementResourceService.Unpartitioned = resources;
                }
            }

            return resources;
        }
示例#6
0
 /// <summary>
 /// Determines whether this instance is empty.
 /// </summary>
 /// <returns>
 /// <c>true</c> if this instance is empty; otherwise, <c>false</c>.
 /// </returns>
 /// <exception cref="NotImplementedException"></exception>
 public bool IsEmpty()
 {
     using (_queueLock.Acquire())
     {
         return(_queue.Count == 0);
     }
 }
示例#7
0
        /// <summary>
        /// Returns an EPServiceProvider for a given provider URI.
        /// Use the URI of "default" or null to return the default service provider.
        /// </summary>
        /// <param name="providerURI">the provider URI.  If null provided it assumes "default".</param>
        /// <param name="configuration">is the configuration for the service</param>
        /// <returns>EPServiceProvider for the given provider URI.</returns>
        /// <throws>ConfigurationException to indicate a configuration problem</throws>
        public static EPServiceProvider GetProvider(String providerURI, Configuration configuration)
        {
            using (LockObj.Acquire())
            {
                if (String.IsNullOrEmpty(providerURI))
                {
                    providerURI = EPServiceProviderConstants.DEFAULT_ENGINE_URI;
                }

                if (Runtimes.ContainsKey(providerURI))
                {
                    var provider = Runtimes[providerURI];
                    if (provider.IsDestroyed)
                    {
                        provider = new EPServiceProviderImpl(configuration, providerURI, Runtimes);
                        Runtimes[providerURI] = provider;
                    }
                    else
                    {
                        provider.SetConfiguration(configuration);
                    }

                    return(provider);
                }

                // New runtime
                EPServiceProviderImpl runtime = new EPServiceProviderImpl(configuration, providerURI, Runtimes);
                Runtimes[providerURI] = runtime;
                runtime.PostInitialize();

                return(runtime);
            }
        }
示例#8
0
 public void OnInput(IDictionary<string, object> @event)
 {
     using (_lock.Acquire())
     {
         _received.Add(@event);
     }
 }
 public long DeltaAdd(long fromTime)
 {
     using (_iLock.Acquire())
     {
         long target = AddSubtract(fromTime, 1);
         return(target - fromTime);
     }
 }
        /// <summary>
        ///     Reserve an object, returning true when successfully reserved or false when the object is already reserved.
        /// </summary>
        /// <param name="object">object to reserve</param>
        /// <returns>true if reserved, false to indicate already reserved</returns>
        public bool Reserve(object @object)
        {
            using (reservedIdsLock.Acquire()) {
                if (reservedObjects.Contains(@object)) {
                    return false;
                }

                reservedObjects.Add(@object);
                return true;
            }
        }
示例#11
0
        /// <summary>
        /// Clears all items from the queue
        /// </summary>
        public void Clear()
        {
            using (_queueLock.Acquire())
            {
                _queue.Clear();

                PulsePushHandle();
                PulsePopHandle();

                //_queuePushWaitHandle.Insert();  // Push is clear
                //_queuePopWaitHandle.Reset(); // Pop now waits
            }
        }
示例#12
0
        public NamedWindowProcessorInstance AddInstance(AgentInstanceContext agentInstanceContext)
        {
            using (_lock.Acquire())
            {
                if (_contextName == null)
                {
                    return(new NamedWindowProcessorInstance(null, this, agentInstanceContext));
                }

                var instanceId = agentInstanceContext.AgentInstanceId;
                return(new NamedWindowProcessorInstance(instanceId, this, agentInstanceContext));
            }
        }
示例#13
0
 public IEnumerator <EventBean> GetEnumerator(int statementId, ContextPartitionSelector selector)
 {
     using (_iLock.Acquire())
     {
         var instances = GetAgentInstancesForStmt(statementId, selector);
         return(instances.SelectMany(instance => instance.FinalView).GetEnumerator());
     }
 }
示例#14
0
        /// <summary>
        /// Acquires the lock; the lock is released when the disposable
        /// object that was returned is disposed.
        /// </summary>
        /// <returns></returns>
        public IDisposable Acquire()
        {
            var timeLockRequested = PerformanceObserver.MicroTime;
            var disposableLock    = _subLock.Acquire();
            var timeLockAcquired  = PerformanceObserver.MicroTime;
            var disposableTrack   = new TrackedDisposable(
                delegate
            {
                disposableLock.Dispose();
                disposableLock = null;
                FinishTrackingPerformance(timeLockRequested, timeLockAcquired);
            });

            return(disposableTrack);
        }
示例#15
0
        public void Stop(AgentInstanceStopServices services)
        {
            using (_lock.Acquire()) {
                if (_filterHandle != null) {
                    FilterValueSetParam[][] addendum = null;
                    var agentInstanceContext = services.AgentInstanceContext;
                    if (agentInstanceContext.AgentInstanceFilterProxy != null) {
                        addendum = agentInstanceContext.AgentInstanceFilterProxy.GetAddendumFilters(
                            _filterSpecActivatable,
                            agentInstanceContext);
                    }

                    var filterValues = _filterSpecActivatable.GetValueSet(
                        null,
                        addendum,
                        agentInstanceContext,
                        agentInstanceContext.StatementContextFilterEvalEnv);
                    services.AgentInstanceContext.FilterService.Remove(
                        _filterHandle,
                        _filterSpecActivatable.FilterForEventType,
                        filterValues);
                }

                _filterHandle = null;
            }
        }
示例#16
0
        public static TimeZoneInfo GetTimeZoneInfo(string specOrId)
        {
            using (TimeZoneInfoLock.Acquire())
            {
                var timeZoneInfo = TimeZoneInfoDictionary.Get(specOrId);
                if (timeZoneInfo == null)
                {
                    try
                    {
                        timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(specOrId);
                    }
                    catch (TimeZoneNotFoundException)
                    {
                        var regex = new Regex("^GMT([+-])(\\d{1,2}):(\\d{2})$");
                        var match = regex.Match(specOrId);
                        if (match == Match.Empty)
                        {
                            throw;
                        }

                        var multiplier = match.Groups[1].Value == "+" ? 1 : -1;
                        var offset     = new TimeSpan(
                            multiplier * int.Parse(match.Groups[2].Value), // hours
                            multiplier * int.Parse(match.Groups[3].Value),
                            0);

                        timeZoneInfo = TimeZoneInfo.CreateCustomTimeZone(specOrId, offset, specOrId, specOrId);
                    }

                    TimeZoneInfoDictionary[specOrId] = timeZoneInfo;
                }

                return(timeZoneInfo);
            }
        }
示例#17
0
        private EventBean GetEventBean(Object theEvent)
        {
            // type check
            if (theEvent.GetType() != _beanEventType.UnderlyingType)
            {
                using (_iLock.Acquire())
                {
                    if (!_compatibleClasses.Contains(theEvent.GetType()))
                    {
                        if (TypeHelper.IsSubclassOrImplementsInterface(
                                theEvent.GetType(), _beanEventType.UnderlyingType))
                        {
                            _compatibleClasses.Add(theEvent.GetType());
                        }
                        else
                        {
                            throw new EPException(
                                      "Event object of type " + theEvent.GetType().FullName +
                                      " does not equal, extend or implement the type " + _beanEventType.UnderlyingType.FullName +
                                      " of event type '" + _beanEventType.Name + "'");
                        }
                    }
                }
            }

            return(_eventAdapterService.AdapterForTypedObject(theEvent, _beanEventType));
        }
示例#18
0
        public FragmentEventType GetFragmentType(String property)
        {
            using (_iLock.Acquire())
            {
                Pair <ExplicitPropertyDescriptor, FragmentEventType> pair = _propertyFragmentTypes.Get(property);
                if (pair == null)
                {
                    return(_propertyFragmentTypes.ContainsKey(property) ? null : DoResolveFragmentType(property));
                }

                // if a type is assigned, use that
                if (pair.Second != null)
                {
                    return(pair.Second);
                }

                // resolve event type
                EventType existingType = _eventAdapterService.GetEventTypeByName(pair.First.OptionalFragmentTypeName);
                if (!(existingType is BaseConfigurableEventType))
                {
                    Log.Warn("Type configured for fragment event property '" + property + "' by name '" + pair.First +
                             "' could not be found");
                    return(null);
                }

                var fragmentType = new FragmentEventType(existingType, pair.First.IsFragmentArray, false);
                pair.Second = fragmentType;
                return(fragmentType);
            }
        }
示例#19
0
        /// <summary>
        /// Creates a new EventType object for a object of the specified class if this is the first time the class has been seen. Else uses a cached EventType instance, i.e. client classes do not need to cache.
        /// </summary>
        /// <param name="name">is the name</param>
        /// <param name="clazz">is the class of the object.</param>
        /// <param name="isPreconfiguredStatic">if from static engine config</param>
        /// <param name="isPreconfigured">if configured before use</param>
        /// <param name="isConfigured">if the class is a configuration value, false if discovered</param>
        /// <returns>EventType implementation for bean class</returns>
        public BeanEventType CreateBeanType(String name, Type clazz, bool isPreconfiguredStatic, bool isPreconfigured, bool isConfigured)
        {
            if (clazz == null)
            {
                throw new ArgumentException("Null value passed as class");
            }

            BeanEventType eventType;

            // not created yet, thread-safe create
            using (_typesPerObjectLock.Acquire())
            {
                eventType = _typesPerObject.Get(clazz);
                if (eventType != null)
                {
                    _eventTypeIdGenerator.AssignedType(name, eventType);
                    return(eventType);
                }

                // Check if we have a legacy type definition for this class
                ConfigurationEventTypeLegacy legacyDef = _typeToLegacyConfigs.Get(clazz.FullName);
                if ((legacyDef == null) && (_defaultAccessorStyle != AccessorStyleEnum.NATIVE))
                {
                    legacyDef = new ConfigurationEventTypeLegacy();
                    legacyDef.AccessorStyle = _defaultAccessorStyle;
                }

                int typeId = _eventTypeIdGenerator.GetTypeId(name);
                EventTypeMetadata metadata = EventTypeMetadata.CreateBeanType(name, clazz, isPreconfiguredStatic, isPreconfigured, isConfigured, TypeClass.APPLICATION);
                eventType = new BeanEventType(metadata, typeId, clazz, _eventAdapterService, legacyDef);
                _typesPerObject.Put(clazz, eventType);
            }

            return(eventType);
        }
示例#20
0
 /// <summary>
 /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"></see>.
 /// </summary>
 /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"></see>.</param>
 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"></see> is read-only.</exception>
 public virtual void Add(T item)
 {
     using (_writerLock.Acquire())
     {
         List <T> tempList = new List <T>(_arrayList);
         tempList.Add(item);
         _arrayList = tempList.ToArray();
     }
 }
示例#21
0
        /// <summary>
        /// Add a filter to the event type index structure, and to the filter subtree.
        /// Throws an IllegalStateException exception if the callback is already registered.
        /// </summary>
        /// <param name="filterValueSet">is the filter information</param>
        /// <param name="filterCallback">is the callback</param>
        /// <param name="lockFactory">The lock factory.</param>
        /// <returns></returns>
        /// <exception cref="IllegalStateException">Callback for filter specification already exists in collection</exception>
        public FilterServiceEntry Add(FilterValueSet filterValueSet, FilterHandle filterCallback, FilterServiceGranularLockFactory lockFactory)
        {
            using (Instrument.With(
                       i => i.QFilterAdd(filterValueSet, filterCallback),
                       i => i.AFilterAdd()))
            {
                var eventType = filterValueSet.EventType;

                // Check if a filter tree exists for this event type
                var rootNode = _eventTypeIndex.Get(eventType);

                // Make sure we have a root node
                if (rootNode == null)
                {
                    using (_callbacksLock.Acquire())
                    {
                        rootNode = _eventTypeIndex.Get(eventType);
                        if (rootNode == null)
                        {
                            rootNode = new FilterHandleSetNode(lockFactory.ObtainNew());
                            _eventTypeIndex.Add(eventType, rootNode);
                        }
                    }
                }

                // GetInstance add to tree
                var path      = IndexTreeBuilder.Add(filterValueSet, filterCallback, rootNode, lockFactory);
                var pathArray = path.Select(p => p.ToArray()).ToArray();
                var pair      = new EventTypeIndexBuilderValueIndexesPair(filterValueSet, pathArray);

                // for non-isolatable callbacks the consumer keeps track of tree location
                if (_isolatableCallbacks == null)
                {
                    return(pair);
                }

                // for isolatable callbacks this class is keeping track of tree location
                using (_callbacksLock.Acquire()) {
                    _isolatableCallbacks.Put(filterCallback, pair);
                }

                return(null);
            }
        }
示例#22
0
        public String AddExpressionOrScript(CreateExpressionDesc expressionDesc)
        {
            using (_iLock.Acquire())
            {
                if (expressionDesc.Expression != null)
                {
                    ExpressionDeclItem expression = expressionDesc.Expression;
                    String             name       = expression.Name;
                    if (_globalExpressions.ContainsKey(name))
                    {
                        throw new ExprValidationException("Expression '" + name + "' has already been declared");
                    }
                    _globalExpressions.Put(name, expression);
                    return(name);
                }
                else
                {
                    ExpressionScriptProvided newScript = expressionDesc.Script;
                    String name = newScript.Name;

                    List <ExpressionScriptProvided> scripts = _globalScripts.Get(name);
                    if (scripts != null)
                    {
                        foreach (ExpressionScriptProvided script in scripts)
                        {
                            if (script.ParameterNames.Count == newScript.ParameterNames.Count)
                            {
                                throw new ExprValidationException(
                                          "Script '" + name +
                                          "' that takes the same number of parameters has already been declared");
                            }
                        }
                    }
                    else
                    {
                        scripts = new List <ExpressionScriptProvided>(2);
                        _globalScripts.Put(name, scripts);
                    }
                    scripts.Add(newScript);

                    return(name);
                }
            }
        }
        public void Add(long afterTime, ScheduleHandle handle, long slot)
        {
            using (Instrument.With(
                       i => i.QScheduleAdd(_currentTime, afterTime, handle, slot),
                       i => i.AScheduleAdd()))
            {
                using (_uLock.Acquire())
                {
                    if (_handleSetMap.ContainsKey(handle))
                    {
                        Remove(handle, slot);
                    }

                    long triggerOnTime = _currentTime + afterTime;

                    AddTrigger(slot, handle, triggerOnTime);
                }
            }
        }
示例#24
0
 public void Update(object sender, UpdateEventArgs args)
 {
     using (_lock.Acquire())
     {
         for (int i = 0; i < args.NewEvents.Length; i++)
         {
             Received.Add(args.NewEvents[i].Underlying);
         }
     }
 }
        public void Update(Object sender, UpdateEventArgs e)
        {
            var oldData = e.OldEvents;
            var newData = e.NewEvents;

            using (_oLock.Acquire()) {
                _oldDataList.Add(oldData);
                _newDataList.Add(newData);
                _lastNewData = newData;
                _lastOldData = oldData;
                _isInvoked   = true;
            }
        }
示例#26
0
        public static MagicType GetCachedType(Type t)
        {
            using (TypeCacheLock.Acquire()) {
                MagicType magicType;
                if (!TypeCacheTable.TryGetValue(t, out magicType))
                {
                    TypeCacheTable[t] = magicType = new MagicType(t);
                }

                return(magicType);
            }
        }
示例#27
0
 public void Close(DataFlowOpCloseContext openContext)
 {
     using (_iLock.Acquire())
     {
         if (callbackHandle != null)
         {
             agentInstanceContext.StatementContext.FilterService.Remove(callbackHandle, filterServiceEntry);
             callbackHandle     = null;
             filterServiceEntry = null;
         }
     }
 }
示例#28
0
            public void Update(Object sender, UpdateEventArgs args)
            {
                using (_lock.Acquire())
                {
                    if (args.NewEvents.Length > 1)
                    {
                        Assert.AreEqual(1, args.NewEvents.Length);
                    }

                    _beans.Add((SupportBean)args.NewEvents[0].Underlying);
                }
            }
示例#29
0
        public override ExprNode Validate(ExprValidationContext validationContext)
        {
            if (ChildNodes.Length != 1)
            {
                throw new ExprValidationException("Instanceof node must have 1 child expression node supplying the expression to test");
            }
            if ((_classIdentifiers == null) || (_classIdentifiers.Length == 0))
            {
                throw new ExprValidationException("Instanceof node must have 1 or more class identifiers to verify type against");
            }

            _evaluator = ChildNodes[0].ExprEvaluator;

            var classList = GetClassSet(_classIdentifiers);

            using (_oLock.Acquire()) {
                _classes = classList.ToArray();
            }

            return(null);
        }
示例#30
0
            public void Update(object sender, UpdateEventArgs args)
            {
                using (_lock.Acquire())
                {
                    if (args.NewEvents.Length > 1)
                    {
                        Assert.AreEqual(1, args.NewEvents.Length);
                    }

                    Count += 1;
                }
            }