Inheritance: Cassandra.SimpleStatement
示例#1
0
        private IStatement AdaptRpcMasterResult(Task <RowSet> task, TargettedSimpleStatement statement)
        {
            if (task.IsFaulted)
            {
                Logger.Verbose("Error querying graph analytics server, query will not be routed optimally: {0}", task.Exception);
                return(statement);
            }
            var row = task.Result.FirstOrDefault();

            if (row == null)
            {
                Logger.Verbose("Empty response querying graph analytics server, query will not be routed optimally");
                return(statement);
            }
            var resultField = row.GetValue <IDictionary <string, string> >("result");

            if (resultField == null || !resultField.ContainsKey("location") || resultField["location"] == null)
            {
                Logger.Verbose("Could not extract graph analytics server location from RPC, query will not be routed optimally");
                return(statement);
            }
            var location = resultField["location"];
            var hostName = location.Substring(0, location.LastIndexOf(':'));
            var address  = _config.AddressTranslator.Translate(
                new IPEndPoint(IPAddress.Parse(hostName), _config.CassandraConfiguration.ProtocolOptions.Port));
            var host = _coreSession.Cluster.GetHost(address);

            statement.PreferredHost = host;
            return(statement);
        }
        private IEnumerable <Host> YieldPreferred(string keyspace, TargettedSimpleStatement statement)
        {
            yield return(statement.PreferredHost);

            foreach (var h in _childPolicy.NewQueryPlan(keyspace, statement))
            {
                yield return(h);
            }
        }
示例#3
0
 private IStatement AdaptRpcMasterResult(Task<RowSet> task, TargettedSimpleStatement statement)
 {
     if (task.IsFaulted)
     {
         Logger.Verbose("Error querying graph analytics server, query will not be routed optimally: {0}", task.Exception);
         return statement;
     }
     var row = task.Result.FirstOrDefault();
     if (row == null)
     {
         Logger.Verbose("Empty response querying graph analytics server, query will not be routed optimally");
         return statement;
     }
     var resultField = row.GetValue<IDictionary<string, string>>("result");
     if (resultField == null || !resultField.ContainsKey("location") || resultField["location"] == null)
     {
         Logger.Verbose("Could not extract graph analytics server location from RPC, query will not be routed optimally");
         return statement;
     }
     var location = resultField["location"];
     var hostName = location.Substring(0, location.LastIndexOf(':'));
     var address = _config.AddressTranslator.Translate(
         new IPEndPoint(IPAddress.Parse(hostName),_config.CassandraConfiguration.ProtocolOptions.Port));
     var host = _coreSession.Cluster.GetHost(address);
     statement.PreferredHost = host;
     return statement;
 }