You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by st...@apache.org on 2016/07/25 00:47:43 UTC

[27/41] cassandra git commit: Merge branch 'cassandra-2.1' into cassandra-2.2

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a7cfbd1/pylib/cqlshlib/copyutil.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/copyutil.py
index a1adbaa,0016dfd..c7a0e30
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@@ -665,11 -647,11 +665,11 @@@ class ExportTask(CopyTask)
              hosts = []
              if replicas:
                  for r in replicas:
--                    if r.is_up and r.datacenter == local_dc:
++                    if r.is_up is not False and r.datacenter == local_dc:
                          hosts.append(r.address)
              if not hosts:
                  hosts.append(hostname)  # fallback to default host if no replicas in current dc
--            return {'hosts': tuple(hosts), 'attempts': 0, 'rows': 0}
++            return {'hosts': tuple(hosts), 'attempts': 0, 'rows': 0, 'workerno': -1}
  
          if begin_token and begin_token < min_token:
              shell.printerr('Begin token %d must be bigger or equal to min token %d' % (begin_token, min_token))
@@@ -736,8 -718,8 +736,11 @@@
              return None
  
      def send_work(self, ranges, tokens_to_send):
--        i = 0
++        prev_worker_no = ranges[tokens_to_send[0]]['workerno']
++        i = prev_worker_no + 1 if -1 <= prev_worker_no < (self.num_processes - 1) else 0
++
          for token_range in tokens_to_send:
++            ranges[token_range]['workerno'] = i
              self.outmsg.channels[i].send((token_range, ranges[token_range]))
              ranges[token_range]['attempts'] += 1
  
@@@ -1327,6 -1299,6 +1330,7 @@@ class ChildProcess(mp.Process)
          self.thousands_sep = options.copy['thousandssep']
          self.boolean_styles = options.copy['boolstyle']
          self.max_attempts = options.copy['maxattempts']
++        self.encoding = options.copy['encoding']
          # Here we inject some failures for testing purposes, only if this environment variable is set
          if os.environ.get('CQLSH_COPY_TEST_FAILURES', ''):
              self.test_failures = json.loads(os.environ.get('CQLSH_COPY_TEST_FAILURES', ''))
@@@ -1442,7 -1414,7 +1446,6 @@@ class ExportProcess(ChildProcess)
      def __init__(self, params):
          ChildProcess.__init__(self, params=params, target=self.run)
          options = params['options']
--        self.encoding = options.copy['encoding']
          self.float_precision = options.copy['float_precision']
          self.nullval = options.copy['nullval']
          self.max_requests = options.copy['maxrequests']
@@@ -1692,8 -1664,8 +1695,9 @@@ class ImportConversion(object)
          self.decimal_sep = parent.decimal_sep
          self.thousands_sep = parent.thousands_sep
          self.boolean_styles = parent.boolean_styles
 -        self.time_format = parent.time_format
 +        self.date_time_format = parent.date_time_format.timestamp_format
          self.debug = parent.debug
++        self.encoding = parent.encoding
  
          self.table_meta = table_meta
          self.primary_key_indexes = [self.columns.index(col.name) for col in self.table_meta.primary_key]
@@@ -1713,10 -1685,10 +1717,15 @@@
  
          # the cql types for the entire statement, these are the same as the types above but
          # only when using prepared statements
 -        self.coltypes = [table_meta.columns[name].typestring for name in parent.valid_columns]
 +        self.coltypes = [table_meta.columns[name].cql_type for name in parent.valid_columns]
          # these functions are used for non-prepared statements to protect values with quotes if required
--        self.protectors = [protect_value if t in ('ascii', 'text', 'timestamp', 'date', 'time', 'inet') else lambda v: v
--                           for t in self.coltypes]
++        self.protectors = [self._get_protector(t) for t in self.coltypes]
++
++    def _get_protector(self, t):
++        if t in ('ascii', 'text', 'timestamp', 'date', 'time', 'inet'):
++            return lambda v: unicode(protect_value(v), self.encoding)
++        else:
++            return lambda v: v
  
      @staticmethod
      def _get_primary_key_statement(parent, table_meta):
@@@ -2043,7 -2019,7 +2052,7 @@@ class TokenMap(object)
  
      def filter_replicas(self, hosts):
          shuffled = tuple(sorted(hosts, key=lambda k: random.random()))
--        return filter(lambda r: r.is_up and r.datacenter == self.local_dc, shuffled) if hosts else ()
++        return filter(lambda r: r.is_up is not False and r.datacenter == self.local_dc, shuffled) if hosts else ()
  
  
  class FastTokenAwarePolicy(DCAwareRoundRobinPolicy):

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a7cfbd1/pylib/cqlshlib/test/test_cqlsh_output.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/test/test_cqlsh_output.py
index 60699f3,e3af8e8..e47b981
--- a/pylib/cqlshlib/test/test_cqlsh_output.py
+++ b/pylib/cqlshlib/test/test_cqlsh_output.py
@@@ -546,15 -540,11 +546,15 @@@ class TestCqlshOutput(BaseTestCase)
              c.send('use NONEXISTENTKEYSPACE;\n')
              outputlines = c.read_to_next_prompt().splitlines()
  
 -            self.assertEqual(outputlines[0], 'use NONEXISTENTKEYSPACE;')
 -            self.assertTrue(outputlines[2].endswith('cqlsh:system> '))
 -            midline = ColoredText(outputlines[1])
 +            start_index = 0
 +            if c.realtty:
 +                self.assertEqual(outputlines[start_index], 'use NONEXISTENTKEYSPACE;')
 +                start_index = 1
 +
 +            self.assertTrue(outputlines[start_index+1].endswith('cqlsh:system> '))
 +            midline = ColoredText(outputlines[start_index])
              self.assertEqual(midline.plain(),
--                             'InvalidRequest: code=2200 [Invalid query] message="Keyspace \'nonexistentkeyspace\' does not exist"')
++                             'InvalidRequest: Error from server: code=2200 [Invalid query] message="Keyspace \'nonexistentkeyspace\' does not exist"')
              self.assertColorFromTags(midline,
                               "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR")
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/3a7cfbd1/pylib/cqlshlib/tracing.py
----------------------------------------------------------------------
diff --cc pylib/cqlshlib/tracing.py
index c30965c,40d22f0..cea3568
--- a/pylib/cqlshlib/tracing.py
+++ b/pylib/cqlshlib/tracing.py
@@@ -77,13 -75,8 +77,13 @@@ def make_trace_rows(trace)
      return rows
  
  
 +def total_micro_seconds(td):
 +    """
 +    Convert a timedelta into total microseconds
 +    """
-     return int((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6)) if td else "--"
++    return int((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6)) if td else "--"
 +
 +
  def datetime_from_utc_to_local(utc_datetime):
      now_timestamp = time.time()
      offset = datetime.fromtimestamp(now_timestamp) - datetime.utcfromtimestamp(now_timestamp)