Loading transfer_service/db_connector.py +6 −2 Original line number Diff line number Diff line Loading @@ -25,12 +25,12 @@ class DbConnector(object): self.cursor = self.conn.cursor() def disconnect(self): if(self.conn): if self.conn: self.cursor.close() self.conn.close() def insertNode(self, node, parentOSPath): if(self.conn): if self.conn: #print(f"parentOSPath: {parentOSPath}") self.cursor.execute("SELECT get_ltree_path(%s)", (parentOSPath,)) parentLtreePath = self.cursor.fetchone()[0] Loading @@ -42,3 +42,7 @@ class DbConnector(object): def selectNode(self): pass def getRapId(self, username): if self.conn: self.cursor.execute("SELECT rap_id FROM Users WHERE user_name = %s;", (username,)) return self.cursor.fetchone()[0] No newline at end of file transfer_service/store_preprocessor.py +10 −6 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ class StorePreprocessor(Preprocessor): self.params = config.loadSection("transfer_node") self.storageBasePath = self.params["base_path"] self.jobObj = None self.username = None self.userId = None self.dbConn.connect() super(StorePreprocessor, self).__init__() Loading Loading @@ -132,6 +134,7 @@ class StorePreprocessor(Preprocessor): # File catalog update out = open("log.txt", "w") self.userId = self.dbConn.getRapId(self.username) for dir in dirs: out.write(f"DIR: {dir}\n") pathPrefix = self.storageBasePath.replace("{username}", self.username) Loading @@ -140,8 +143,8 @@ class StorePreprocessor(Preprocessor): out.write(f"basePath: {basePath}\n") cnode = Node(os.path.basename(dir), "container"); cnode.setParentPath(basePath) cnode.setOwnerID("3354") cnode.setCreatorID("3354") cnode.setOwnerID(self.userId) cnode.setCreatorID(self.userId) self.dbConn.insertNode(cnode, cnode.parentPath) for flist in files: Loading @@ -154,8 +157,8 @@ class StorePreprocessor(Preprocessor): out.write(f"basePath: {basePath}\n") dnode = Node(os.path.basename(file), "data") dnode.setParentPath(basePath) dnode.setOwnerID("3354") dnode.setCreatorID("3354") dnode.setOwnerID(self.userId) dnode.setCreatorID(self.userId) dnode.setContentMD5(self.md5calc.getMD5(file)) self.dbConn.insertNode(dnode, dnode.parentPath) Loading @@ -164,6 +167,7 @@ class StorePreprocessor(Preprocessor): def run(self): while True: time.sleep(10) if(self.readyQueue.len() <= self.maxReadyJobs and self.pendingQueue.len() > 0): self.jobObj = self.pendingQueue.getJob() self.username = self.jobObj["jobInfo"]["userName"] Loading @@ -171,7 +175,7 @@ class StorePreprocessor(Preprocessor): self.execute() self.pendingQueue.moveJobTo("ready") print("Job MOVED!") time.sleep(1) time.sleep(10) # Test #sp = StorePreprocessor() Loading Loading
transfer_service/db_connector.py +6 −2 Original line number Diff line number Diff line Loading @@ -25,12 +25,12 @@ class DbConnector(object): self.cursor = self.conn.cursor() def disconnect(self): if(self.conn): if self.conn: self.cursor.close() self.conn.close() def insertNode(self, node, parentOSPath): if(self.conn): if self.conn: #print(f"parentOSPath: {parentOSPath}") self.cursor.execute("SELECT get_ltree_path(%s)", (parentOSPath,)) parentLtreePath = self.cursor.fetchone()[0] Loading @@ -42,3 +42,7 @@ class DbConnector(object): def selectNode(self): pass def getRapId(self, username): if self.conn: self.cursor.execute("SELECT rap_id FROM Users WHERE user_name = %s;", (username,)) return self.cursor.fetchone()[0] No newline at end of file
transfer_service/store_preprocessor.py +10 −6 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ class StorePreprocessor(Preprocessor): self.params = config.loadSection("transfer_node") self.storageBasePath = self.params["base_path"] self.jobObj = None self.username = None self.userId = None self.dbConn.connect() super(StorePreprocessor, self).__init__() Loading Loading @@ -132,6 +134,7 @@ class StorePreprocessor(Preprocessor): # File catalog update out = open("log.txt", "w") self.userId = self.dbConn.getRapId(self.username) for dir in dirs: out.write(f"DIR: {dir}\n") pathPrefix = self.storageBasePath.replace("{username}", self.username) Loading @@ -140,8 +143,8 @@ class StorePreprocessor(Preprocessor): out.write(f"basePath: {basePath}\n") cnode = Node(os.path.basename(dir), "container"); cnode.setParentPath(basePath) cnode.setOwnerID("3354") cnode.setCreatorID("3354") cnode.setOwnerID(self.userId) cnode.setCreatorID(self.userId) self.dbConn.insertNode(cnode, cnode.parentPath) for flist in files: Loading @@ -154,8 +157,8 @@ class StorePreprocessor(Preprocessor): out.write(f"basePath: {basePath}\n") dnode = Node(os.path.basename(file), "data") dnode.setParentPath(basePath) dnode.setOwnerID("3354") dnode.setCreatorID("3354") dnode.setOwnerID(self.userId) dnode.setCreatorID(self.userId) dnode.setContentMD5(self.md5calc.getMD5(file)) self.dbConn.insertNode(dnode, dnode.parentPath) Loading @@ -164,6 +167,7 @@ class StorePreprocessor(Preprocessor): def run(self): while True: time.sleep(10) if(self.readyQueue.len() <= self.maxReadyJobs and self.pendingQueue.len() > 0): self.jobObj = self.pendingQueue.getJob() self.username = self.jobObj["jobInfo"]["userName"] Loading @@ -171,7 +175,7 @@ class StorePreprocessor(Preprocessor): self.execute() self.pendingQueue.moveJobTo("ready") print("Job MOVED!") time.sleep(1) time.sleep(10) # Test #sp = StorePreprocessor() Loading