private void SetupEventListener()
        {
            _session.BinaryProtocolVersion = _controlConnectionProtocolVersion;
            var        handler    = new RequestHandler <RowSet>(_session, null, null);
            Connection connection = null;

            try
            {
                connection = handler.GetNextConnection(null);
            }
            catch (UnsupportedProtocolVersionException)
            {
                _logger.Verbose(String.Format("Unsupported protocol version {0}, trying with a lower version", _controlConnectionProtocolVersion));
                _controlConnectionProtocolVersion--;
                if (_controlConnectionProtocolVersion < 1)
                {
                    throw new DriverInternalError("Invalid protocol version");
                }
                SetupEventListener();
                return;
            }
            _activeConnection.Value = connection;
            _activeConnection.Value.CassandraEventResponse += conn_CassandraEvent;
            const CassandraEventType eventTypes = CassandraEventType.TopologyChange | CassandraEventType.StatusChange | CassandraEventType.SchemaChange;
            var registerTask = _activeConnection.Value.Send(new RegisterForEventRequest(_controlConnectionProtocolVersion, eventTypes));

            TaskHelper.WaitToComplete(registerTask, 10000);
            if (!(registerTask.Result is ReadyResponse))
            {
                throw new DriverInternalError("Expected ReadyResponse, obtained " + registerTask.Result.GetType().Name);
            }
        }
 public RegisterForEventRequest(int streamId, CassandraEventType eventTypes)
 {
     this._streamId = streamId;
     this._eventTypes = new List<string>();
     if ((eventTypes & CassandraEventType.StatusChange) == CassandraEventType.StatusChange)
         this._eventTypes.Add("STATUS_CHANGE");
     if ((eventTypes & CassandraEventType.TopologyChange) == CassandraEventType.TopologyChange)
         this._eventTypes.Add("TOPOLOGY_CHANGE");
     if ((eventTypes & CassandraEventType.SchemaChange) == CassandraEventType.SchemaChange)
         this._eventTypes.Add("SCHEMA_CHANGE");
 }
 public RegisterForEventRequest(CassandraEventType eventTypes)
 {
     _eventTypes = new List <string>();
     if ((eventTypes & CassandraEventType.StatusChange) == CassandraEventType.StatusChange)
     {
         _eventTypes.Add("STATUS_CHANGE");
     }
     if ((eventTypes & CassandraEventType.TopologyChange) == CassandraEventType.TopologyChange)
     {
         _eventTypes.Add("TOPOLOGY_CHANGE");
     }
     if ((eventTypes & CassandraEventType.SchemaChange) == CassandraEventType.SchemaChange)
     {
         _eventTypes.Add("SCHEMA_CHANGE");
     }
 }
 public RegisterForEventRequest(CassandraEventType eventTypes)
 {
     _eventTypes = new List<string>();
     if ((eventTypes & CassandraEventType.StatusChange) == CassandraEventType.StatusChange)
     {
         _eventTypes.Add("STATUS_CHANGE");
     }
     if ((eventTypes & CassandraEventType.TopologyChange) == CassandraEventType.TopologyChange)
     {
         _eventTypes.Add("TOPOLOGY_CHANGE");
     }
     if ((eventTypes & CassandraEventType.SchemaChange) == CassandraEventType.SchemaChange)
     {
         _eventTypes.Add("SCHEMA_CHANGE");
     }
 }
예제 #5
0
 public IAsyncResult BeginRegisterForCassandraEvent(CassandraEventType eventTypes, AsyncCallback callback, object state, object owner)
 {
     return(BeginJob(callback, state, owner, "REGISTER", new Action <int>((streamId) =>
     {
         Evaluate(new RegisterForEventRequest(streamId, eventTypes), streamId, new Action <ResponseFrame>((frame2) =>
         {
             var response = FrameParser.Parse(frame2);
             if (response is ReadyResponse)
             {
                 JobFinished(streamId, new OutputVoid(null));
             }
             else
             {
                 _protocolErrorHandlerAction(new ErrorActionParam()
                 {
                     AbstractResponse = response, StreamId = streamId
                 });
             }
         }));
     })));
 }
예제 #6
0
        public IAsyncResult BeginRegisterForCassandraEvent(int streamId, CassandraEventType eventTypes, AsyncCallback callback, object state,
                                                           object owner)
        {
            AsyncResult <IOutput> jar = SetupJob(streamId, callback, state, owner, "REGISTER");

            BeginJob(jar, () =>
            {
                Evaluate(new RegisterForEventRequest(jar.StreamId, eventTypes), jar.StreamId, frame2 =>
                {
                    AbstractResponse response = FrameParser.Parse(frame2);
                    if (response is ReadyResponse)
                    {
                        JobFinished(jar, new OutputVoid(null));
                    }
                    else
                    {
                        _protocolErrorHandlerAction(new ErrorActionParam {
                            AbstractResponse = response, Jar = jar
                        });
                    }
                });
            });
            return(jar);
        }
예제 #7
0
 public IOutput RegisterForCassandraEvent(CassandraEventType eventTypes)
 {
     return(EndRegisterForCassandraEvent(BeginRegisterForCassandraEvent(eventTypes, null, null, this), this));
 }
 public IOutput RegisterForCassandraEvent(CassandraEventType eventTypes)
 {
     return EndRegisterForCassandraEvent(BeginRegisterForCassandraEvent(eventTypes, null, null, this), this);
 }
        public IAsyncResult BeginRegisterForCassandraEvent(CassandraEventType eventTypes, AsyncCallback callback, object state, object owner)
        {
            return BeginJob(callback, state, owner, "REGISTER", new Action<int>((streamId) =>
            {
                Evaluate(new RegisterForEventRequest(streamId, eventTypes),streamId, new Action<ResponseFrame>((frame2) =>
                {
                    var response = FrameParser.Parse(frame2);
                    if (response is ReadyResponse)
                        JobFinished( streamId, new OutputVoid(null));
                    else
                        _protocolErrorHandlerAction(new ErrorActionParam() {AbstractResponse = response, StreamId = streamId });

                }));
            }));
        }
예제 #10
0
 public IOutput RegisterForCassandraEvent(int streamId, CassandraEventType eventTypes)
 {
     return(EndRegisterForCassandraEvent(BeginRegisterForCassandraEvent(streamId, eventTypes, null, null, this), this));
 }
 public IOutput RegisterForCassandraEvent(int streamId, CassandraEventType eventTypes)
 {
     return EndRegisterForCassandraEvent(BeginRegisterForCassandraEvent(streamId, eventTypes, null, null, this), this);
 }
        public IAsyncResult BeginRegisterForCassandraEvent(int _streamId, CassandraEventType eventTypes, AsyncCallback callback, object state, object owner)
        {
            var jar = SetupJob(_streamId, callback, state, owner, "REGISTER");
            BeginJob(jar, new Action(() =>
            {
                Evaluate(new RegisterForEventRequest(jar.StreamId, eventTypes), jar.StreamId, new Action<ResponseFrame>((frame2) =>
                {
                    var response = FrameParser.Parse(frame2);
                    if (response is ReadyResponse)
                        JobFinished(jar, new OutputVoid(null));
                    else
                        _protocolErrorHandlerAction(new ErrorActionParam() { AbstractResponse = response, Jar = jar });

                }));
            }));
            return jar;
        }