def __init__(self, ppa_comm, db_connection, args): threading.Thread.__init__(self) self.setDaemon(True) if (db_connection is None): db_connection = query_db.ODIDB() self.ppa_comm = ppa_comm self.odidb = db_connection self.args = args self.logger = logging.getLogger("ExposureWatcher") # self.sub = self.odidb.connection.subscribe( # callback=new_exposure_callback, # timeout=30, # operations= # qos=cx_Oracle.SUBSCR_QOS_ROWIDS, # ) # # print("Subscription:", self.sub) # print("--> Connection:", self.sub.connection) # print("--> Callback:", self.sub.callback) # print("--> Namespace:", self.sub.namespace) # print("--> Protocol:", self.sub.protocol) # print("--> Timeout:", self.sub.timeout) # print("--> Operations:", self.sub.operations) # print("--> Rowids?:", bool(self.sub.qos & cx_Oracle.SUBSCR_QOS_ROWIDS)) # self.sub.registerquery("select * from DEBUGLOG") self.shutdown = False
def __init__(self, odidb, ppa, args): threading.Thread.__init__(self) if (odidb is None): odidb = query_db.ODIDB() self.odidb = odidb self.ppa = ppa self.dts_queue = queue.Queue() self.args = args self.logger = logging.getLogger("ExposureSender") self.shutdown = False self.setDaemon(True)
def __init__(self, odidb, server_name=None, username=None, password=None, virtual_host=None, port=5672): """Create a new instance of the consumer class, passing in the AMQP URL used to connect to RabbitMQ. :param str amqp_url: The AMQP url to connect with """ self.private_db = False if (odidb is None): odidb = query_db.ODIDB() self.private_db = True self.odidb = odidb self._connection = None self._channel = None self._closing = False self._consumer_tag = None self._url = None #amqp_url self.server_name = server_name if server_name is not None else config.ppa_server_name self.username = username if username is not None else config.ppa_username self.password = password if password is not None else config.ppa_password self.portnumber = port if port is not None else config.ppa_port self.virtual_host = virtual_host if virtual_host is not None else config.ppa_virtualhost self.credentials = pika.PlainCredentials( username=self.username, password=self.password, erase_on_connect=False, ) self.parameters = pika.ConnectionParameters( host=self.server_name, port=self.portnumber, virtual_host=self.virtual_host, credentials=self.credentials, ) self.logger = logging.getLogger("ResendRequestHandler") self.logger.setLevel(logging.INFO)
# setup logging dtslog = dts_logger.dts_logging() logger = logging.getLogger("ODI-DTS") ppa = ppa_sender.PPA_Sender() ppa.start() time.sleep(1) # make sure to create the DTS scratch directory if (not os.path.isdir(config.tar_scratchdir)): os.mkdir(config.tar_scratchdir) if (not args.db or not args.monitor): # This is just a one-time transfer odidb = query_db.ODIDB() transfer_onetime(odidb=odidb, ppa=ppa, args=args) sys.exit(0) # # Coming up is the default way of running DTS: # Checking the database for new exposures on a regular basis # # Start the exposure-sender thread # sender = DTS_ExposureSender(odidb=odidb, ppa=ppa, args=args) sender = DTS_ExposureSender(odidb=None, ppa=ppa, args=args) sender.start() time.sleep(1) watcher = db_watcher.ExposureWatcher(ppa_comm=ppa,