public ICassandraClient Make(Endpoint key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var transport = new TSocket(key.Host, key.Port, timeout);
            var protocol  = new TBinaryProtocol(transport);

            Apache.Cassandra.Cassandra.Iface cassandra = null;
            cassandra = new Apache.Cassandra.Cassandra.Client(protocol);

            try
            {
                transport.Open();
            }
            catch (TTransportException e)
            {
                // Thrift exceptions aren't very good in reporting, so we have to catch the exception here and
                // add details to it.
                throw new Exception("Unable to open transport to " + key.ToString() + " , ", e);
            }

            return(new CassandraClient(cassandra, new KeyspaceFactory(monitor), key, pool));
        }
        public override void ActivateOptions()
        {
            base.ActivateOptions();
            try
            {
                ICassandraClientFactory cassandraClientFactory = null;

                if (String.IsNullOrWhiteSpace(LevelMapping.CassandraClientFactory))
                    cassandraClientFactory = new DefaultCassandraClientFactory();
                else
                    cassandraClientFactory = (ICassandraClientFactory)Activator.CreateInstance(Type.GetType(LevelMapping.CassandraClientFactory));

                this.client = cassandraClientFactory.CreateConnection(LevelMapping.Host, LevelMapping.GetPort());
            }
            catch (Exception exception)
            {
                throw new Exception("Can't initialize cassandra connections", exception);
            }

            try
            {
                SetupSchema();
            }
            catch (Exception exception)
            {
                throw new Exception("Error setting up cassandra logging schema", exception);
            }

            try
            {
                this.client.set_keyspace(LevelMapping.KeyspaceName);
            }
            catch (Exception exception)
            {
                throw new Exception("Error setting keyspace: " + LevelMapping.KeyspaceName, exception);
            }

            Reset();
        }
 public CassandraClientWrapper(Apache.Cassandra.Cassandra.Iface client)
 {
     _client = client;
 }
示例#4
0
 internal CassandraClient(Apache.Cassandra.Cassandra.Iface thriftClient, KeyspaceFactory keyspaceFactory, Endpoint endpoint, IKeyedObjectPool<Endpoint, ICassandraClient> pool)
     : this(keyspaceFactory, endpoint, pool)
 {
     cassandra = thriftClient;
 }
示例#5
0
 internal CassandraClient(Apache.Cassandra.Cassandra.Iface thriftClient, KeyspaceFactory keyspaceFactory, Endpoint endpoint, IKeyedObjectPool <Endpoint, ICassandraClient> pool)
     : this(keyspaceFactory, endpoint, pool)
 {
     cassandra = thriftClient;
 }