示例#1
0
 public void Deserialize(CompactReader reader)
 {
     _messageInfo      = reader.ReadObject() as MessageInfo;
     _subscriptionInfo = reader.ReadObject() as SubscriptionInfo;
     _type             = (TopicOperationType)reader.ReadInt32();
     _context          = reader.ReadObject() as OperationContext;
 }
示例#2
0
 public AssignmentOperation(MessageInfo messageInfo, SubscriptionInfo subscriptionInfo, TopicOperationType type, OperationContext context)
 {
     _messageInfo      = messageInfo;
     _subscriptionInfo = subscriptionInfo;
     _type             = type;
     _context          = context;
 }
示例#3
0
        internal ITopic GetOrCreateTopic(string topicName, TopicOperationType type)
        {
            if (string.IsNullOrEmpty(topicName))
            {
                throw new ArgumentException("TopicName is null or empty string");
            }

            Topic topic = null;

            if (_cacheImpl.GetOrCreate(topicName, type))
            {
                lock (this)
                {
                    if (_topicsDic.TryGetValue(topicName, out topic))
                    {
                        if (topic.IsClosed)
                        {
                            _topicsDic.TryRemove(topic.Name, out topic);

                            topic = new Topic(topicName, _cacheImpl, _perfStatsCollector, this);
                            _topicsDic.TryAdd(topicName, topic);
                        }

                        topic.IncrementRefCount();
                        return(topic);
                    }

                    topic = new Topic(topicName, _cacheImpl, _perfStatsCollector, this);
                    topic.IncrementRefCount();
                    _topicsDic.TryAdd(topicName, topic);
                }
            }

            return(topic);
        }
示例#4
0
        public GetTopicCommand(string topicName, TopicOperationType type)
        {
            name = "GetTopicCommand";

            _getTopicCommand           = new Common.Protobuf.GetTopicCommand();
            _getTopicCommand.topicName = topicName;
            _getTopicCommand.type      = (int)type;
        }
示例#5
0
        internal ITopic GetOrCreateTopic(TopicIdentity topicPair, TopicOperationType type, bool internalOperation)
        {
            if (string.IsNullOrEmpty(topicPair.TopicName))
            {
                throw new ArgumentException("TopicName is null or empty string");
            }


            if (!internalOperation && IsDefaultTopicName(topicPair.TopicName))
            {
                throw new OperationFailedException(ErrorCodes.PubSub.DEFAULT_TOPICS, ErrorMessages.GetErrorMessage(ErrorCodes.PubSub.DEFAULT_TOPICS));
            }

            if (_cacheImpl == null)
            {
                throw new OperationFailedException(ErrorCodes.CacheInit.CACHE_NOT_INIT, ErrorMessages.GetErrorMessage(ErrorCodes.CacheInit.CACHE_NOT_INIT));
            }

            Topic topic = null;

            if (_cacheImpl.GetOrCreate(topicPair.TopicName, type))
            {
                lock (this)
                {
                    if (_topicsDic.TryGetValue(topicPair, out topic))
                    {
                        if (topic.IsClosed)
                        {
                            _topicsDic.TryRemove(topicPair, out topic);
                            TopicSearchOptions searchOptions = topic.SearchOptions;
                            topic = new Topic(topicPair.TopicName, _cacheImpl, _perfStatsCollector, this);
                            topic.SearchOptions = searchOptions;
                        }

                        topic.IncrementRefCount();
                        return(topic);
                    }

                    topic = new Topic(topicPair.TopicName, _cacheImpl, _perfStatsCollector, this);

                    topic.IncrementRefCount();
                    _topicsDic.TryAdd(topicPair, topic);
                }
            }
            return(topic);
        }
示例#6
0
 public SubscriptionOperation(string topic, TopicOperationType topicOperationType, SubscriptionInfo subscriptionInfo, bool isDispose = false)
     : base(topic, topicOperationType)
 {
     _subscriptionInfo = subscriptionInfo;
     _dispose          = isDispose;
 }
示例#7
0
 public virtual void Deserialize(CompactReader reader)
 {
     _topicOperationType = (TopicOperationType)reader.ReadInt32();
     _topic = reader.ReadObject() as string;
 }
示例#8
0
 public TopicOperation(string topic, TopicOperationType topicOperationType)
 {
     _topic = topic;
     _topicOperationType = topicOperationType;
 }
示例#9
0
 internal virtual bool GetOrCreate(string topicName, TopicOperationType type)
 {
     return(false);
 }
示例#10
0
        public override bool AssignmentOperation(MessageInfo messageInfo, SubscriptionInfo subscriptionInfo, TopicOperationType type, OperationContext context)
        {
            Topic instance = _topicManager.GetTopic(messageInfo.Topic);

            if (instance != null)
            {
                switch (type)
                {
                case TopicOperationType.AssignSubscription:
                    return(instance.AssignSubscription(messageInfo, subscriptionInfo));

                case TopicOperationType.RevokeAssignment:
                    instance.RevokeAssignment(messageInfo, subscriptionInfo);
                    return(true);
                }
            }
            return(false);
        }
 public SubscriptionOperation(string topic, TopicOperationType topicOperationType, SubscriptionInfo subscriptionInfo)
     : base(topic, topicOperationType)
 {
     _subscriptionInfo = subscriptionInfo;
 }
示例#12
0
 public ExpireSubscriptionOperation(string topic, TopicOperationType topicOperationType, IList <SubscriptionIdentifier> subscriptionIdentifier)
     : base(topic, topicOperationType)
 {
     _subscriptionIdentifier = subscriptionIdentifier;
 }