cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cassandra-node.apache-extras....@codespot.com
Subject [cassandra-node] 4 new revisions pushed by gdusbabek@gmail.com on 2011-11-11 16:58 GMT
Date Fri, 11 Nov 2011 16:58:34 GMT
4 new revisions:

Revision: 2ab6848a2e23
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:28:13 2011
Log:      Use a different route for logging CQL queries. Patch by Tomaz  
Muraus (...
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=2ab6848a2e23

Revision: e08994af7783
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:40:52 2011
Log:      Fix race condition in driver test. Patch by Tomaz Muraus  
(tomaz.muraus...
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=e08994af7783

Revision: 1f91baccc2b6
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:48:27 2011
Log:      test for logging and new timing. Patch by Tomaz Muraus  
(tomaz.muraus@g...
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=1f91baccc2b6

Revision: 452d56cdf40c
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:57:42 2011
Log:      convert cql query to a string prior to logging it
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=452d56cdf40c

==============================================================================
Revision: 2ab6848a2e23
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:28:13 2011
Log:      Use a different route for logging CQL queries. Patch by Tomaz  
Muraus (tomaz.muraus@gmail.com)

http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=2ab6848a2e23

Modified:
  /lib/driver.js

=======================================
--- /lib/driver.js	Fri Nov 11 07:49:04 2011
+++ /lib/driver.js	Fri Nov 11 08:28:13 2011
@@ -18,6 +18,9 @@
  /** node.js driver for Cassandra-CQL. */

  var log = require('logmagic').local('node-cassandra-client.driver');
+var logCql = require('logmagic').local('node-cassandra-client.driver.cql');
+var logTiming =  
require('logmagic').local('node-cassandra-client.driver.timing');
+
  var sys = require('sys');
  var Buffer = require('buffer').Buffer;
  var EventEmitter = require('events').EventEmitter;
@@ -185,6 +188,7 @@
    this.holdFor = 10000;
    this.current_node = 0;
    this.use_bigints = config.use_bigints ? true : false;
+  this.log_time = config.log_time || false;

    // Construct a list of nodes from hosts in <host>:<port> form
    for (var i = 0; i < config.hosts.length; i++) {
@@ -234,7 +238,8 @@
                                     keyspace: config.keyspace,
                                     user: config.user,
                                     pass: config.pass,
-                                   use_bigints: self.use_bigints});
+                                   use_bigints: self.use_bigints,
+                                   log_time: self.log_time});

  	      conn.connect(function(err) {
  	        if (!err) {                   // Success, we're connected
@@ -324,7 +329,7 @@

  /**
   * @param options: valid parts are:
- *  user, pass, host, port, keyspace, use_bigints
+ *  user, pass, host, port, keyspace, use_bigints, log_time
   */
  Connection = module.exports.Connection = function(options) {
    log.info('connecting ' + options.host + ':' + options.port);
@@ -452,9 +457,20 @@
    if (cql === nullBindError) {
      callback(new Error(nullBindError.message));
    } else {
-    var self = this;
-    log.trace1('CQL QUERY: ' + cql);
+    var self = this,
+        start, end, diff;
+
+    start = new Date().getTime();
+    logCql.trace('CQL QUERY', {'query': query, 'parameterized_query':  
cql, 'args': args});
+
      this.client.execute_cql_query(cql, ttypes.Compression.NONE,  
function(err, res) {
+      end = new Date().getTime();
+      diff = (end - start);
+      if (self.connectionInfo.log_time) {
+        logTiming.trace('CQL QUERY TIMING', {'query':  
query, 'parameterized_query': cql, 'args': args,
+                                             'time': diff});
+      }
+
        if (err) {
          amendError(err);
          callback(err, null);

==============================================================================
Revision: e08994af7783
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:40:52 2011
Log:      Fix race condition in driver test. Patch by Tomaz Muraus  
(tomaz.muraus@gmail.com)

http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=e08994af7783

Modified:
  /test/test_driver.js

=======================================
--- /test/test_driver.js	Fri Nov 11 07:49:04 2011
+++ /test/test_driver.js	Fri Nov 11 08:40:52 2011
@@ -19,6 +19,7 @@
  var assert = require('assert');
  var console = require('console');
  var EventEmitter = require('events').EventEmitter;
+var async = require('async');

  var BigInteger = require('../lib/bigint').BigInteger;

@@ -777,21 +778,26 @@
    var hosts = ["127.0.0.1:19170"];
    var conn = new PooledConnection({'hosts':  
hosts, 'keyspace': 'Keyspace1', use_bigints: true});

+  var range = new Array(100).join(' ').split(' ');
+
    // Hammer time...
    conn.execute('UPDATE CfUgly SET A=1 WHERE KEY=1', [], function(err) {
      if (err) { bail(conn, err); }
-
-    for (var i = 0; i < 100; i++) {
+
+    async.forEach(range, function (_, callback) {
        conn.execute('SELECT A FROM CfUgly WHERE KEY=1', [], function(err,  
rows) {
          if (err) { bail(conn, err); }
          assert.strictEqual(rows.rowCount(), 1);
          var row = rows[0];
          assert.strictEqual(row.cols[0].name.toString(), 'A');
+        callback();
        });
-    }
-
-    conn.shutdown();
-    test.finish();
+    },
+
+    function(err) {
+      conn.shutdown();
+      test.finish();
+    });
    });
  };


==============================================================================
Revision: 1f91baccc2b6
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:48:27 2011
Log:      test for logging and new timing. Patch by Tomaz Muraus  
(tomaz.muraus@gmail.com)

http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=1f91baccc2b6

Modified:
  /test/test_driver.js

=======================================
--- /test/test_driver.js	Fri Nov 11 08:40:52 2011
+++ /test/test_driver.js	Fri Nov 11 08:48:27 2011
@@ -19,6 +19,8 @@
  var assert = require('assert');
  var console = require('console');
  var EventEmitter = require('events').EventEmitter;
+
+var logmagic = require('logmagic');
  var async = require('async');

  var BigInteger = require('../lib/bigint').BigInteger;
@@ -801,4 +803,63 @@
    });
  };

-
+exports.testTimeLogging = function(test, assert) {
+  var hosts = ["127.0.0.1:19170"];
+  var baseOptions = {'hosts': hosts, 'keyspace': 'Keyspace1', use_bigints:  
true};
+  var options1 = merge(baseOptions, {});
+  var options2 = merge(baseOptions, {'log_time': true});
+  var conn1 = new PooledConnection(options1);
+  var conn2 = new PooledConnection(options2);
+
+  var logObjsCql = [];
+  var logObjsTime = [];
+
+  logmagic.registerSink('cql_sink', function(module, level, message, obj) {
+    logObjsCql.push(arguments);
+  });
+
+  logmagic.registerSink('timing_sink', function(module, level, message,  
obj) {
+    logObjsTime.push(arguments);
+  });
+
+  logmagic.route('node-cassandra-client.driver.cql',  
logmagic.TRACE1, 'cql_sink');
+  logmagic.route('node-cassandra-client.driver.timing',  
logmagic.TRACE1, 'timing_sink');
+
+  conn1.execute('UPDATE CfUgly SET A=1 WHERE KEY=1', [], function(err) {
+    var logObj;
+    assert.ifError(err);
+
+    // Timing log is disabled, logObjs should be empty.
+    assert.equal(logObjsCql.length, 1);
+    assert.equal(logObjsTime.length, 0);
+
+    logObj = logObjsCql[0];
+    assert.ok(logObj[3].hasOwnProperty('query'));
+    assert.ok(logObj[3].hasOwnProperty('parameterized_query'));
+    assert.ok(logObj[3].hasOwnProperty('args'));
+    assert.ok(!logObj[3].hasOwnProperty('time'));
+
+    conn2.execute('SELECT A FROM CfUgly WHERE KEY=1', [], function(err,  
rows) {
+      var logObj;
+      assert.ifError(err);
+      assert.strictEqual(rows.rowCount(), 1);
+
+      // Timing log is enabled, logObjs should have 1 item
+      assert.equal(logObjsCql.length, 2);
+      assert.equal(logObjsTime.length, 1);
+      logObj = logObjsTime[0];
+
+      assert.ok(logObj[3].hasOwnProperty('query'));
+      assert.ok(logObj[3].hasOwnProperty('parameterized_query'));
+      assert.ok(logObj[3].hasOwnProperty('args'));
+      assert.ok(logObj[3].hasOwnProperty('time'));
+
+      conn1.shutdown();
+      conn2.shutdown();
+      test.finish();
+    });
+  });
+};
+
+
+

==============================================================================
Revision: 452d56cdf40c
Author:   Gary Dusbabek <gdusbabek@gmail.com>
Date:     Fri Nov 11 08:57:42 2011
Log:      convert cql query to a string prior to logging it

http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=452d56cdf40c

Modified:
  /lib/driver.js

=======================================
--- /lib/driver.js	Fri Nov 11 08:28:13 2011
+++ /lib/driver.js	Fri Nov 11 08:57:42 2011
@@ -458,16 +458,17 @@
      callback(new Error(nullBindError.message));
    } else {
      var self = this,
+        cqlString = cql.toString(),
          start, end, diff;

      start = new Date().getTime();
-    logCql.trace('CQL QUERY', {'query': query, 'parameterized_query':  
cql, 'args': args});
+    logCql.trace('CQL QUERY', {'query': query, 'parameterized_query':  
cqlString, 'args': args});

      this.client.execute_cql_query(cql, ttypes.Compression.NONE,  
function(err, res) {
        end = new Date().getTime();
        diff = (end - start);
        if (self.connectionInfo.log_time) {
-        logTiming.trace('CQL QUERY TIMING', {'query':  
query, 'parameterized_query': cql, 'args': args,
+        logTiming.trace('CQL QUERY TIMING', {'query':  
query, 'parameterized_query': cqlString, 'args': args,
                                               'time': diff});
        }


Mime
View raw message