private void OnConnectionCassandraEvent(object sender, CassandraEventArgs e) { //This event is invoked from a worker thread (not a IO thread) if (e is TopologyChangeEventArgs) { var tce = (TopologyChangeEventArgs)e; if (tce.What == TopologyChangeEventArgs.Reason.NewNode || tce.What == TopologyChangeEventArgs.Reason.RemovedNode) { // Start refresh Refresh().Forget(); return; } } if (e is StatusChangeEventArgs) { HandleStatusChangeEvent((StatusChangeEventArgs)e); return; } if (e is SchemaChangeEventArgs) { var ssc = (SchemaChangeEventArgs)e; if (!string.IsNullOrEmpty(ssc.Table)) { //Can be either a table or a view _metadata.RefreshTable(ssc.Keyspace, ssc.Table); _metadata.RefreshView(ssc.Keyspace, ssc.Table); return; } if (ssc.FunctionName != null) { _metadata.ClearFunction(ssc.Keyspace, ssc.FunctionName, ssc.Signature); return; } if (ssc.AggregateName != null) { _metadata.ClearAggregate(ssc.Keyspace, ssc.AggregateName, ssc.Signature); return; } if (ssc.Type != null) { return; } if (ssc.What == SchemaChangeEventArgs.Reason.Dropped) { _metadata.RemoveKeyspace(ssc.Keyspace); return; } _metadata.RefreshSingleKeyspace(ssc.What == SchemaChangeEventArgs.Reason.Created, ssc.Keyspace); } }
private void OnConnectionCassandraEvent(object sender, CassandraEventArgs e) { //This event is invoked from a worker thread (not a IO thread) if (e is TopologyChangeEventArgs) { var tce = (TopologyChangeEventArgs)e; if (tce.What == TopologyChangeEventArgs.Reason.NewNode || tce.What == TopologyChangeEventArgs.Reason.RemovedNode) { Refresh(); return; } } if (e is StatusChangeEventArgs) { var sce = (StatusChangeEventArgs)e; //The address in the Cassandra event message needs to be translated var address = TranslateAddress(sce.Address); _logger.Info("Received Node status change event: host {0} is {1}", address, sce.What.ToString().ToUpper()); if (sce.What == StatusChangeEventArgs.Reason.Up) { _metadata.BringUpHost(address, this); return; } if (sce.What == StatusChangeEventArgs.Reason.Down) { _metadata.SetDownHost(address, this); return; } } if (e is SchemaChangeEventArgs) { var ssc = (SchemaChangeEventArgs)e; if (!string.IsNullOrEmpty(ssc.Table)) { //Can be either a table or a view _metadata.RefreshTable(ssc.Keyspace, ssc.Table); _metadata.RefreshView(ssc.Keyspace, ssc.Table); return; } if (ssc.FunctionName != null) { _metadata.ClearFunction(ssc.Keyspace, ssc.FunctionName, ssc.Signature); return; } if (ssc.AggregateName != null) { _metadata.ClearAggregate(ssc.Keyspace, ssc.AggregateName, ssc.Signature); return; } if (ssc.Type != null) { return; } if (ssc.What == SchemaChangeEventArgs.Reason.Dropped) { _metadata.RemoveKeyspace(ssc.Keyspace); return; } _metadata.RefreshSingleKeyspace(ssc.What == SchemaChangeEventArgs.Reason.Created, ssc.Keyspace); } }