コード例 #1
0
    def test_get_indicies(self):
        db_batch = flexmock()
        db_batch.should_receive("range_query").and_return({})
        dd = DatastoreDistributed(db_batch, self.get_zookeeper())
        dd = flexmock(dd)
        dd.should_receive("get_meta_data_key").and_return("somekey").twice()

        self.assertEquals(dd.get_indices("appid"), [])
コード例 #2
0
 def test_get_indicies(self):
   db_batch = flexmock()
   db_batch.should_receive("range_query").and_return({})
   dd = DatastoreDistributed(db_batch, self.get_zookeeper())
   dd = flexmock(dd)
   dd.should_receive("get_meta_data_key").and_return("somekey").twice()
   
   self.assertEquals(dd.get_indices("appid"), [])
コード例 #3
0
  def test_get_indicies(self):
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version').and_return(True)
    db_batch.should_receive("range_query").and_return({})
    dd = DatastoreDistributed(db_batch, self.get_zookeeper())
    dd = flexmock(dd)

    self.assertEquals(dd.get_indices("appid"), [])
コード例 #4
0
def main(app_id, db_type):
    """ Updates a composite index after prompting the user.

  Args:
    app_id: A string containing the application ID.
    db_type: A string specifying which database backend to use.
  """
    datastore_batch = appscale_datastore_batch.DatastoreFactory.\
      getDatastore(db_type)
    zookeeper_locations = appscale_info.get_zk_locations_string()
    zookeeper = zk.ZKTransaction(host=zookeeper_locations)
    datastore_access = DatastoreDistributed(datastore_batch,
                                            zookeeper=zookeeper)

    pb_indices = datastore_access.get_indices(app_id)
    indices = [datastore_pb.CompositeIndex(index) for index in pb_indices]
    if len(indices) == 0:
        print('No composite indices found for app {}'.format(app_id))
        zookeeper.close()
        sys.exit(1)

    selection = -1
    selection_range = range(1, len(indices) + 1)
    while selection not in selection_range:
        for number, index in enumerate(indices, start=1):
            pretty_index = prettify_index(index.definition())
            print('{}) {}'.format(number, pretty_index))

        try:
            selection = int(
                raw_input(
                    'Select the index you want to update. (1-{}) '.format(
                        len(indices))))
        except KeyboardInterrupt:
            zookeeper.close()
            sys.exit()

    selected_index = indices[selection - 1]
    datastore_access.update_composite_index(app_id, selected_index)

    zookeeper.close()
コード例 #5
0
ファイル: update_index.py プロジェクト: darkflag/appscale
def main(app_id, db_type):
  """ Updates a composite index after prompting the user.

  Args:
    app_id: A string containing the application ID.
    db_type: A string specifying which database backend to use.
  """
  datastore_batch = appscale_datastore_batch.DatastoreFactory.\
    getDatastore(db_type)
  zookeeper_locations = appscale_info.get_zk_locations_string()
  zookeeper = zk.ZKTransaction(host=zookeeper_locations)
  datastore_access = DatastoreDistributed(datastore_batch,
    zookeeper=zookeeper)

  pb_indices = datastore_access.get_indices(app_id)
  indices = [datastore_pb.CompositeIndex(index) for index in pb_indices]
  if len(indices) == 0:
    print('No composite indices found for app {}'.format(app_id))
    zookeeper.close()
    sys.exit(1)

  selection = -1
  selection_range = range(1, len(indices) + 1)
  while selection not in selection_range:
    for number, index in enumerate(indices, start=1):
      pretty_index = prettify_index(index.definition())
      print('{}) {}'.format(number, pretty_index))

    try:
      selection = int(raw_input('Select the index you want to update. (1-{}) '
        .format(len(indices))))
    except KeyboardInterrupt:
      zookeeper.close()
      sys.exit()

  selected_index = indices[selection - 1]
  datastore_access.update_composite_index(app_id, selected_index)

  zookeeper.close()