Пример #1
0
 def attach_local_producer(self):
     producer = get_producer_for_id(self.ref.id)
     if producer is None:
         raise PlanFailedError(
             "Plan attach-local-producer failed for %s: not being produced here" % self.ref,
             "BLOCKSTORE",
             logging.DEBUG,
         )
     else:
         is_pipe = producer.subscribe(self, try_direct=(self.may_pipe and self.sole_consumer))
         if is_pipe:
             ciel.log("Fetch-ref %s: attached to direct pipe!" % self.ref, "BLOCKSTORE", logging.DEBUG)
             filename = producer.get_fifo_filename()
         else:
             ciel.log("Fetch-ref %s: following local producer's file" % self.ref, "BLOCKSTORE", logging.DEBUG)
             filename = producer_filename(self.ref.id)
         self.set_filename(filename, is_pipe)
Пример #2
0
 def attach_local_producer(self):
     producer = get_producer_for_id(self.ref.id)
     if producer is None:
         raise PlanFailedError(
             "Plan attach-local-producer failed for %s: not being produced here"
             % self.ref, "BLOCKSTORE", logging.DEBUG)
     else:
         is_pipe = producer.subscribe(self,
                                      try_direct=(self.may_pipe
                                                  and self.sole_consumer))
         if is_pipe:
             ciel.log("Fetch-ref %s: attached to direct pipe!" % self.ref,
                      "BLOCKSTORE", logging.DEBUG)
             filename = producer.get_fifo_filename()
         else:
             ciel.log(
                 "Fetch-ref %s: following local producer's file" % self.ref,
                 "BLOCKSTORE", logging.DEBUG)
             filename = producer_filename(self.ref.id)
         self.set_filename(filename, is_pipe)
Пример #3
0
def subscribe_output(otherend_netloc, chunk_size, id):
    post = None
    with module_lock:
        try:
            producer = get_producer_for_id(id)
            if producer is not None:
                try:
                    remote_stream_subscribers[(
                        id, otherend_netloc)].set_chunk_size(chunk_size)
                    ciel.log(
                        "Remote %s changed chunk size for %s to %d" %
                        (otherend_netloc, id, chunk_size), "BLOCKSTORE",
                        logging.DEBUG)
                except KeyError:
                    new_subscriber = RemoteOutputSubscriber(
                        producer, otherend_netloc, chunk_size)
                    producer.subscribe(new_subscriber, try_direct=False)
                    ciel.log(
                        "Remote %s subscribed to output %s (chunk size %d)" %
                        (otherend_netloc, id, chunk_size), "BLOCKSTORE",
                        logging.DEBUG)
            else:
                try:
                    st = os.stat(filename(id))
                    post = simplejson.dumps({
                        "bytes": st.st_size,
                        "done": True
                    })
                except OSError:
                    post = simplejson.dumps({"absent": True})
        except Exception as e:
            ciel.log(
                "Subscription to %s failed with exception %s; reporting absent"
                % (id, e), "BLOCKSTORE", logging.WARNING)
            post = simplejson.dumps({"absent": True})
    if post is not None:
        post_string_noreturn(
            "http://%s/control/streamstat/%s/advert" % (otherend_netloc, id),
            post)
Пример #4
0
def subscribe_output(otherend_netloc, chunk_size, id):
    post = None
    with module_lock:
        try:
            producer = get_producer_for_id(id)
            if producer is not None:
                try:
                    remote_stream_subscribers[(id, otherend_netloc)].set_chunk_size(chunk_size)
                    ciel.log("Remote %s changed chunk size for %s to %d" % (otherend_netloc, id, chunk_size), "BLOCKSTORE", logging.DEBUG)
                except KeyError:
                    new_subscriber = RemoteOutputSubscriber(producer, otherend_netloc, chunk_size)
                    producer.subscribe(new_subscriber, try_direct=False)
                    ciel.log("Remote %s subscribed to output %s (chunk size %d)" % (otherend_netloc, id, chunk_size), "BLOCKSTORE", logging.DEBUG)
            else:
                try:
                    st = os.stat(filename(id))
                    post = simplejson.dumps({"bytes": st.st_size, "done": True})
                except OSError:
                    post = simplejson.dumps({"absent": True})
        except Exception as e:
            ciel.log("Subscription to %s failed with exception %s; reporting absent" % (id, e), "BLOCKSTORE", logging.WARNING)
            post = simplejson.dumps({"absent": True})
    if post is not None:
        post_string_noreturn("http://%s/control/streamstat/%s/advert" % (otherend_netloc, id), post)