Example #1
0
    def add(self, partition):
        uuid = partition.uuid
        if uuid in self.jobs:
            logger.warning('duplicated job service:' + uuid)
            return
        service = Service(name=uuid, type=_JOB_CASTER_TYPE, location=self.ip, port=self.port)
        service.partition = partition  # attach additional information for handler

        self.jobs[uuid] = service
        super(JobServer, self).add(service)
    def add(self, uuid, result=None):
        if self.exists(uuid):
            logger.warning('duplicated partition service:' + uuid)
            return
        if result is None:
            raise Exception("Result shouldn't be None!")
        service = Service(name=uuid, type=_PARTITION_CASTER_TYPE, location=self.ip, port=self.port)
        service.result = result  # attach additional information for handler

        self.partitions[uuid] = service
        super(PartitionServer, self).add(service)