Ejemplo n.º 1
0
class SpringSpatialQueryLatency(SpringLatency):

    COLLECTOR = "spring_query_latency"

    METRICS = ("latency_query",)

    def __init__(self, settings, workload, spatial_settings, prefix=None):
        super(SpringSpatialQueryLatency, self).__init__(settings, workload, prefix)
        self.offset = 0
        view_names = self._parse_views(spatial_settings.indexes)
        self.clients = []
        for bucket in self.get_buckets():
            client = SpatialGen(
                bucket=bucket, host=settings.master_node, username=bucket, password=settings.bucket_password
            )
            self.clients.append((bucket, client))

        self.new_queries = SpatialQueryFromFile(
            spatial_settings.queries, spatial_settings.dimensionality, view_names, spatial_settings.params
        )

    @staticmethod
    def _parse_views(indexes):
        views = []
        for index in indexes:
            ddoc_name, ddoc = index.split("::", 1)
            for view_name in json.loads(ddoc)["spatial"].keys():
                views.append("{}::{}".format(ddoc_name, view_name))
        return views

    def measure(self, client, metric, bucket):
        ddoc_name, view_name, query = self.new_queries.next(self.offset)
        _, latency = client.query(ddoc_name, view_name, query=query)
        self.offset += 1
        return 1000 * latency  # s -> ms
Ejemplo n.º 2
0
class SpatialWorker(QueryWorker):

    def __init__(self, workload_settings, target_settings, shutdown_event):
        super(QueryWorker, self).__init__(workload_settings, target_settings,
                                          shutdown_event)
        self.total_workers = self.ws.spatial.workers
        self.throughput = self.ws.spatial.throughput
        self.name = 'spatial-worker'

        self.new_queries = SpatialQueryFromFile(
            workload_settings.spatial.queries,
            workload_settings.spatial.dimensionality,
            workload_settings.spatial.view_names,
            workload_settings.spatial.params)

        host, port = self.ts.node.split(':')
        params = {'bucket': self.ts.bucket, 'host': host, 'port': port,
                  'username': self.ts.bucket, 'password': self.ts.password}
        self.cb = SpatialGen(**params)

    @with_sleep
    def do_batch(self):
        for i in xrange(self.BATCH_SIZE):
            offset = self.curr_queries.value - self.BATCH_SIZE + i
            ddoc_name, view_name, query = self.new_queries.next(offset)
            self.cb.query(ddoc_name, view_name, query=query)
Ejemplo n.º 3
0
    def __init__(self, settings, workload, spatial_settings, prefix=None):
        super(SpringSpatialQueryLatency,
              self).__init__(settings, workload, prefix)
        self.offset = 0
        view_names = self._parse_views(spatial_settings.indexes)
        self.clients = []
        for bucket in self.get_buckets():
            client = SpatialGen(bucket=bucket,
                                host=settings.master_node,
                                username=bucket,
                                password=settings.bucket_password)
            self.clients.append((bucket, client))

        self.new_queries = SpatialQueryFromFile(
            spatial_settings.queries, spatial_settings.dimensionality,
            view_names, spatial_settings.params)
Ejemplo n.º 4
0
    def __init__(self, workload_settings, target_settings, shutdown_event):
        super(QueryWorker, self).__init__(workload_settings, target_settings,
                                          shutdown_event)
        self.total_workers = self.ws.spatial.workers
        self.throughput = self.ws.spatial.throughput
        self.name = 'spatial-worker'

        self.new_queries = SpatialQueryFromFile(
            workload_settings.spatial.queries,
            workload_settings.spatial.dimensionality,
            workload_settings.spatial.view_names,
            workload_settings.spatial.params)

        host, port = self.ts.node.split(':')
        params = {'bucket': self.ts.bucket, 'host': host, 'port': port,
                  'username': self.ts.bucket, 'password': self.ts.password}
        self.cb = SpatialGen(**params)
Ejemplo n.º 5
0
    def __init__(self, settings, workload, spatial_settings, prefix=None):
        super(SpringSpatialQueryLatency, self).__init__(settings, workload, prefix)
        self.offset = 0
        view_names = self._parse_views(spatial_settings.indexes)
        self.clients = []
        for bucket in self.get_buckets():
            client = SpatialGen(
                bucket=bucket, host=settings.master_node, username=bucket, password=settings.bucket_password
            )
            self.clients.append((bucket, client))

        self.new_queries = SpatialQueryFromFile(
            spatial_settings.queries, spatial_settings.dimensionality, view_names, spatial_settings.params
        )
Ejemplo n.º 6
0
class SpringSpatialQueryLatency(SpringLatency):

    COLLECTOR = "spring_query_latency"

    METRICS = ("latency_query", )

    def __init__(self, settings, workload, spatial_settings, prefix=None):
        super(SpringSpatialQueryLatency,
              self).__init__(settings, workload, prefix)
        self.offset = 0
        view_names = self._parse_views(spatial_settings.indexes)
        self.clients = []
        for bucket in self.get_buckets():
            client = SpatialGen(bucket=bucket,
                                host=settings.master_node,
                                username=bucket,
                                password=settings.bucket_password)
            self.clients.append((bucket, client))

        self.new_queries = SpatialQueryFromFile(
            spatial_settings.queries, spatial_settings.dimensionality,
            view_names, spatial_settings.params)

    @staticmethod
    def _parse_views(indexes):
        views = []
        for index in indexes:
            ddoc_name, ddoc = index.split('::', 1)
            for view_name in json.loads(ddoc)['spatial'].keys():
                views.append('{}::{}'.format(ddoc_name, view_name))
        return views

    def measure(self, client, metric, bucket):
        ddoc_name, view_name, query = self.new_queries.next(self.offset)
        _, latency = client.query(ddoc_name, view_name, query=query)
        self.offset += 1
        return 1000 * latency  # s -> ms