def __moveFilespaces(self, gparray, target_segment): """ Moves filespaces for temporary and transaction files to a particular location. """ master_seg = gparray.master default_filespace_dir = master_seg.getSegmentDataDirectory() cur_filespace_entries = GetFilespaceEntriesDict( GetFilespaceEntries(gparray, PG_SYSTEM_FILESPACE).run()).run() pg_system_filespace_entries = GetFilespaceEntriesDict( GetFilespaceEntries(gparray, PG_SYSTEM_FILESPACE).run()).run() cur_filespace_name = gparray.getFileSpaceName( int(cur_filespace_entries[1][0])) segments = [target_segment] + [ seg for seg in gparray.getDbList() if seg.getSegmentContentId() == target_segment.getSegmentContentId( ) and seg.getSegmentDbId() != target_segment.getSegmentDbId() ] self.__logger.info('Starting file move procedure for %s' % target_segment) if os.path.exists( os.path.join(default_filespace_dir, GP_TRANSACTION_FILES_FILESPACE)): # On the expansion segments, the current filespace used by existing nodes will be the # new filespace to which we want to move the transaction and temp files. # The filespace directories which have to be moved will be the default pg_system directories. new_filespace_entries = GetFilespaceEntriesDict( GetCurrentFilespaceEntries( gparray, FileType.TRANSACTION_FILES).run()).run() self.__logger.info('getting filespace information') new_filespace_name = gparray.getFileSpaceName( int(new_filespace_entries[1][0])) self.__logger.info( 'getting move operations list for filespace %s' % new_filespace_name) operation_list = GetMoveOperationList( segments, FileType.TRANSACTION_FILES, new_filespace_name, new_filespace_entries, cur_filespace_entries, pg_system_filespace_entries).run() self.__logger.info('Starting transaction files move') ParallelOperation(operation_list).run() self.__logger.debug('Checking transaction files move') try: for operation in operation_list: operation.get_ret() pass except Exception, e: self.__logger.info( 'Failed to move transaction filespace. Rolling back changes ...' ) RollBackFilespaceChanges(gparray.getExpansionSegDbList(), FileType.TRANSACTION_FILES, cur_filespace_name, cur_filespace_entries, new_filespace_entries, pg_system_filespace_entries).run() raise
def __moveFilespaces(self, gparray, target_segment): """ Moves filespaces for temporary and transaction files to a particular location. """ master_seg = gparray.master default_filespace_dir = master_seg.getSegmentDataDirectory() cur_filespace_entries = GetFilespaceEntriesDict(GetFilespaceEntries(gparray, PG_SYSTEM_FILESPACE).run()).run() pg_system_filespace_entries = GetFilespaceEntriesDict( GetFilespaceEntries(gparray, PG_SYSTEM_FILESPACE).run() ).run() cur_filespace_name = gparray.getFileSpaceName(int(cur_filespace_entries[1][0])) segments = [target_segment] + [ seg for seg in gparray.getDbList() if seg.getSegmentContentId() == target_segment.getSegmentContentId() and seg.getSegmentDbId() != target_segment.getSegmentDbId() ] logger.info("Starting file move procedure for %s" % target_segment) if os.path.exists(os.path.join(default_filespace_dir, GP_TRANSACTION_FILES_FILESPACE)): # On the expansion segments, the current filespace used by existing nodes will be the # new filespace to which we want to move the transaction and temp files. # The filespace directories which have to be moved will be the default pg_system directories. new_filespace_entries = GetFilespaceEntriesDict( GetCurrentFilespaceEntries(gparray, FileType.TRANSACTION_FILES).run() ).run() logger.info("getting filespace information") new_filespace_name = gparray.getFileSpaceName(int(new_filespace_entries[1][0])) logger.info("getting move operations list for filespace %s" % new_filespace_name) operation_list = GetMoveOperationList( segments, FileType.TRANSACTION_FILES, new_filespace_name, new_filespace_entries, cur_filespace_entries, pg_system_filespace_entries, ).run() logger.info("Starting transaction files move") ParallelOperation(operation_list).run() logger.debug("Checking transaction files move") try: for operation in operation_list: operation.get_ret() pass except Exception, e: logger.info("Failed to move transaction filespace. Rolling back changes ...") RollBackFilespaceChanges( gparray.getExpansionSegDbList(), FileType.TRANSACTION_FILES, cur_filespace_name, cur_filespace_entries, new_filespace_entries, pg_system_filespace_entries, ).run() raise