コード例 #1
0
    def _get_running_postgres_segments(self, segments):
        running_segments = []
        for seg in segments:
            datadir = self.dereference_remote_symlink(
                seg.getSegmentDataDirectory(), seg.getSegmentHostName())
            pid = get_pid_from_remotehost(seg.getSegmentHostName(), datadir)
            if pid is not None:
                if check_pid_on_remotehost(pid, seg.getSegmentHostName()):
                    if is_pid_postmaster(datadir, pid,
                                         seg.getSegmentHostName()):
                        running_segments.append(seg)
                    else:
                        logger.info(
                            "Skipping to stop segment %s on host %s since it is not a postgres process"
                            % (seg.getSegmentDataDirectory(),
                               seg.getSegmentHostName()))
                else:
                    logger.debug(
                        "Skipping to stop segment %s on host %s since process with pid %s is not running"
                        % (seg.getSegmentDataDirectory(),
                           seg.getSegmentHostName(), pid))
            else:
                logger.debug(
                    "Skipping to stop segment %s on host %s since pid could not be found"
                    %
                    (seg.getSegmentDataDirectory(), seg.getSegmentHostName()))

        return running_segments
コード例 #2
0
ファイル: buildMirrorSegments.py プロジェクト: AnLingm/gpdb
    def _get_running_postgres_segments(self, segments):
        running_segments = []
        for seg in segments:
            datadir = self.dereference_remote_symlink(seg.getSegmentDataDirectory(), seg.getSegmentHostName())
            pid = get_pid_from_remotehost(seg.getSegmentHostName(), datadir)
            if pid is not None:
                if check_pid_on_remotehost(pid, seg.getSegmentHostName()):
                    if is_pid_postmaster(datadir, pid, seg.getSegmentHostName()):
                        running_segments.append(seg)
                    else:
                        logger.info("Skipping to stop segment %s on host %s since it is not a postgres process" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName()))
                else:
                    logger.debug("Skipping to stop segment %s on host %s since process with pid %s is not running" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName(), pid))
            else:
                logger.debug("Skipping to stop segment %s on host %s since pid could not be found" % (seg.getSegmentDataDirectory(), seg.getSegmentHostName()))

        return running_segments
コード例 #3
0
 def test_is_pid_postmaster_pid_doesnt_exists_remote(self, mock1, mock2):
     pid = 1234
     datadir = '/data/primary/gpseg0'
     remoteHost = 'smdw'
     self.assertFalse(is_pid_postmaster(datadir, pid, remoteHost=remoteHost))
コード例 #4
0
 def test_is_pid_postmaster_pgrep_failed(self, mock1, mock2):
     pid = '1234'
     datadir = '/data/primary/gpseg0' 
     self.assertTrue(is_pid_postmaster(datadir, pid))
コード例 #5
0
 def test_is_pid_postmaster_no_result(self, mock1, mock2):
     pid = '1234'
     datadir = None
     self.assertFalse(is_pid_postmaster(datadir, pid))
コード例 #6
0
 def test_is_pid_postmaster_pid_doesnt_exists(self, mock1, mock2):
     pid = 1234
     datadir = '/data/primary/gpseg0'
     self.assertFalse(is_pid_postmaster(datadir, pid))
コード例 #7
0
 def test_is_pid_postmaster_pgrep_failed_remote(self, mock1, mock2):
     pid = '1234'
     datadir = '/data/primary/gpseg0' 
     remoteHost = 'smdw'
     self.assertTrue(is_pid_postmaster(datadir, pid, remoteHost=remoteHost))
コード例 #8
0
 def test_is_pid_postmaster_no_result_remote(self, mock1, mock2):
     pid = '1234'
     datadir = None
     remoteHost = 'smdw'
     self.assertFalse(is_pid_postmaster(datadir, pid, remoteHost=remoteHost))