def _create_checkpointer(self): if self.use_kvstore_checkpointer: checkpointer_name = ':'.join([ self.app, self.config_name, self.kvstore_checkpointer_collection_name ]) checkpointer_name = ':'.join([ self.app, self.config_name, self.kvstore_checkpointer_collection_name ]) try: return checkpointer.KVStoreCheckpointer( checkpointer_name, self.session_key, self.app, owner='nobody', scheme=self.server_scheme, host=self.server_host, port=self.server_port) except binding.HTTPError as e: logging.error('Failed to init kvstore checkpointer: %s.', traceback.format_exc(e)) raise else: return checkpointer.FileCheckpointer(self._checkpoint_dir)
def _init_ckpt(self): if self.ckpt is None: if 'AOB_TEST' in os.environ: ckpt_dir = self.context_meta.get('checkpoint_dir', tempfile.mkdtemp()) if not os.path.exists(ckpt_dir): os.makedirs(ckpt_dir) self.ckpt = checkpointer.FileCheckpointer(ckpt_dir) else: if 'server_uri' not in self.context_meta: raise ValueError('server_uri not found in input meta.') if 'session_key' not in self.context_meta: raise ValueError('session_key not found in input meta.') dscheme, dhost, dport = sutils.extract_http_scheme_host_port(self.context_meta[ 'server_uri']) self.ckpt = checkpointer.KVStoreCheckpointer(self.app + "_checkpointer", self.context_meta['session_key'], self.app, scheme=dscheme, host=dhost, port=dport)
def checkpoint_handler(checkpoint_name, session_key, logger): """ This function handles checkpoint. This is not being used at this point but we will need this for future enhancements. :param checkpoint_name: represents checkpoint file name. :param session_key: session key for particular modular input. :param logger: provides logger of current input. :return : checkpoint object and start date of the query. """ try: ck = checkpointer.KVStoreCheckpointer(checkpoint_name, session_key, APP_NAME) checkpoint_marker = ck.get(checkpoint_name) return ck, query_start_date except Exception as exception: logger.error( "Error occurred while fetching checkpoint, error={}".format( exception)) sys.exit(1)