コード例 #1
0
ファイル: lmonfe.py プロジェクト: ctanis/PGDB
    def attachAndSpawnDaemons(self, session, hostname, pid, daemon, d_argv,
                              febe_data, befe_data):
        """Invoke LMON_fe_attachAndSpawnDaemons.

        See the manpages. d_argv is a list.
        befe_data is the size of the desired buffer or None.

        """
        # Need a trailing null entry on the array.
        d_argv += [None]
        _d_argv = lmon.create_array(c_char_p, d_argv)
        if febe_data is not None:
            _febe_data = lmon.udata_serialize(febe_data)
        else:
            _febe_data = cast(None, c_void_p)
        buf = None
        if befe_data is not None:
            buf = create_string_buffer(befe_data)
            _befe_data = cast(buf, c_void_p)
        else:
            _befe_data = cast(None, c_void_p)
        lmon.call(self.lib.LMON_fe_attachAndSpawnDaemons, session, hostname,
                  pid, daemon, _d_argv, _febe_data, _befe_data)
        if befe_data:
            return lmon.udata_unserialize(buf.value)
        else:
            return None
コード例 #2
0
    def attachAndSpawnDaemons(self, session, hostname, pid, daemon, d_argv,
                              febe_data, befe_data):
        """Invoke LMON_fe_attachAndSpawnDaemons.

        See the manpages. d_argv is a list.
        befe_data is the size of the desired buffer or None.

        """
        # Need a trailing null entry on the array.
        d_argv += [None]
        _d_argv = lmon.create_array(c_char_p, d_argv)
        if febe_data is not None:
            _febe_data = lmon.udata_serialize(febe_data)
        else:
            _febe_data = cast(None, c_void_p)
        buf = None
        if befe_data is not None:
            buf = create_string_buffer(befe_data)
            _befe_data = cast(buf, c_void_p)
        else:
            _befe_data = cast(None, c_void_p)
        lmon.call(self.lib.LMON_fe_attachAndSpawnDaemons, session, hostname,
                  pid, daemon, _d_argv, _febe_data, _befe_data)
        if befe_data:
            return lmon.udata_unserialize(buf.value)
        else:
            return None
コード例 #3
0
ファイル: lmonbe.py プロジェクト: ctanis/PGDB
    def scatter(self, udata_array, elem_size):
        """Scatter data.

        The master provides udata_array, which is an array of data to scatter.
        The slaves may provide None for the data.
        elem_size is the size of each element. Due to serialization of data,
        this should be the maximum size of the data, and the elements are padded
        to this length.

        All callers return their respective data (including the master).

        """
        buf = create_string_buffer(elem_size)
        if self.amIMaster():
            # Master pads data if needed and sends.
            total_size = len(udata_array) * elem_size
            send_buf = create_string_buffer(total_size)
            buf_addr = addressof(send_buf)
            idx = 0
            for elem in udata_array:
                tmp_buf = create_string_buffer(
                    string_at(lmon.udata_serialize(elem)), elem_size)
                memmove(buf_addr + (idx * elem_size), tmp_buf, elem_size)
                idx += 1
            lmon.call(self.lib.LMON_be_scatter, cast(send_buf, c_void_p),
                      elem_size, cast(buf, c_void_p))
        else:
            lmon.call(self.lib.LMON_be_scatter, cast(None, c_void_p), elem_size,
                      cast(buf, c_void_p))
        # This is here for the same reason as in broadcast.
        # Note that it appears that the null byte is only present for children.
        if buf.raw[0] == "\0" and buf.raw[1] != "\0":
            buf = string_at(addressof(buf) + 1)
        else:
            buf = buf.value
        return lmon.udata_unserialize(buf)
コード例 #4
0
ファイル: lmonbe.py プロジェクト: ctanis/PGDB
    def broadcast(self, udata, size):
        """Broadcast data.

        The master provides data and the size of it, and this returns None.
        The slaves can provide None for the data, and size is the size of the
        buffer, which is returned after unserialization.

        """
        if self.amIMaster():
            # Master sends the data, returns None.
            lmon.call(self.lib.LMON_be_broadcast, lmon.udata_serialize(udata),
                      size)
            return None
        else:
            # Slave returns the data.
            buf = create_string_buffer(size)
            lmon.call(self.lib.LMON_be_broadcast, cast(buf, c_void_p), size)
            # Depending on the application, there appears to be a spurious null
            # byte at the start of the data. I do not know why. This avoids it.
            if buf.raw[0] == "\0" and buf.raw[1] != "\0":
                buf = string_at(addressof(buf) + 1)
            else:
                buf = buf.value
            return lmon.udata_unserialize(buf)
コード例 #5
0
ファイル: lmonfe.py プロジェクト: alexzah/PGDB
 def launchAndSpawnDaemons(self, session, hostname, launcher, l_argv, daemon, d_argv, febe_data,
                           befe_data):
     """Invoke LMON_fe_launchAndSpawnDaemons."""
     # Need trailing null entries on the arrays.
     l_argv += [None]
     d_argv += [None]
     _l_argv = lmon.create_array(c_char_p, l_argv)
     _d_argv = lmon.create_array(c_char_p, d_argv)
     if febe_data is not None:
         _febe_data = lmon.udata_serialize(febe_data)
     else:
         _febe_data = cast(None, c_void_p)
     buf = None
     if befe_data is not None:
         buf = create_string_buffer(befe_data)
         _befe_data = cast(buf, c_void_p)
     else:
         _befe_data = cast(None, c_void_p)
     lmon.call(self.lib.LMON_fe_launchAndSpawnDaemons, session, hostname, launcher, _l_argv,
               daemon, _d_argv, _febe_data, _befe_data)
     if befe_data:
         return lmon.udata_unserialize(buf.value)
     else:
         return None
コード例 #6
0
 def launchAndSpawnDaemons(self, session, hostname, launcher, l_argv,
                           daemon, d_argv, febe_data, befe_data):
     """Invoke LMON_fe_launchAndSpawnDaemons."""
     # Need trailing null entries on the arrays.
     l_argv += [None]
     d_argv += [None]
     _l_argv = lmon.create_array(c_char_p, l_argv)
     _d_argv = lmon.create_array(c_char_p, d_argv)
     if febe_data is not None:
         _febe_data = lmon.udata_serialize(febe_data)
     else:
         _febe_data = cast(None, c_void_p)
     buf = None
     if befe_data is not None:
         buf = create_string_buffer(befe_data)
         _befe_data = cast(buf, c_void_p)
     else:
         _befe_data = cast(None, c_void_p)
     lmon.call(self.lib.LMON_fe_launchAndSpawnDaemons, session, hostname,
               launcher, _l_argv, daemon, _d_argv, _febe_data, _befe_data)
     if befe_data:
         return lmon.udata_unserialize(buf.value)
     else:
         return None
コード例 #7
0
ファイル: lmonbe.py プロジェクト: thaolt/PGDB
    def scatter(self, udata_array, elem_size):
        """Scatter data.

        The master provides udata_array, which is an array of data to scatter.
        The slaves may provide None for the data.
        elem_size is the size of each element. Due to serialization of data,
        this should be the maximum size of the data, and the elements are padded
        to this length.

        All callers return their respective data (including the master).

        """
        buf = create_string_buffer(elem_size)
        if self.amIMaster():
            # Master pads data if needed and sends.
            total_size = len(udata_array) * elem_size
            send_buf = create_string_buffer(total_size)
            buf_addr = addressof(send_buf)
            idx = 0
            for elem in udata_array:
                tmp_buf = create_string_buffer(
                    string_at(lmon.udata_serialize(elem)), elem_size)
                memmove(buf_addr + (idx * elem_size), tmp_buf, elem_size)
                idx += 1
            lmon.call(self.lib.LMON_be_scatter, cast(send_buf, c_void_p),
                      elem_size, cast(buf, c_void_p))
        else:
            lmon.call(self.lib.LMON_be_scatter, cast(None, c_void_p),
                      elem_size, cast(buf, c_void_p))
        # This is here for the same reason as in broadcast.
        # Note that it appears that the null byte is only present for children.
        if buf.raw[0] == "\0" and buf.raw[1] != "\0":
            buf = string_at(addressof(buf) + 1)
        else:
            buf = buf.value
        return lmon.udata_unserialize(buf)
コード例 #8
0
ファイル: lmonbe.py プロジェクト: thaolt/PGDB
    def broadcast(self, udata, size):
        """Broadcast data.

        The master provides data and the size of it, and this returns None.
        The slaves can provide None for the data, and size is the size of the
        buffer, which is returned after unserialization.

        """
        if self.amIMaster():
            # Master sends the data, returns None.
            lmon.call(self.lib.LMON_be_broadcast, lmon.udata_serialize(udata),
                      size)
            return None
        else:
            # Slave returns the data.
            buf = create_string_buffer(size)
            lmon.call(self.lib.LMON_be_broadcast, cast(buf, c_void_p), size)
            # Depending on the application, there appears to be a spurious null
            # byte at the start of the data. I do not know why. This avoids it.
            if buf.raw[0] == "\0" and buf.raw[1] != "\0":
                buf = string_at(addressof(buf) + 1)
            else:
                buf = buf.value
            return lmon.udata_unserialize(buf)
コード例 #9
0
ファイル: lmonbe.py プロジェクト: ctanis/PGDB
 def sendUsrData(self, udata):
     """Send data to the front-end."""
     lmon.call(self.lib.LMON_be_sendUsrData, lmon.udata_serialize(udata))
コード例 #10
0
ファイル: lmonbe.py プロジェクト: ctanis/PGDB
 def ready(self, udata):
     """Inform the front-end that we are ready."""
     if udata is None:
         lmon.call(self.lib.LMON_be_ready, cast(None, c_void_p))
     else:
         lmon.call(self.lib.LMON_be_ready, lmon.udata_serialize(udata))
コード例 #11
0
ファイル: lmonfe.py プロジェクト: alexzah/PGDB
 def sendUsrDataBe(self, session, febe_data):
     """Send user data to the backend with LMON_fe_sendUsrDataBe (it is serialized)."""
     lmon.call(self.lib.LMON_fe_sendUsrDataBe, session, lmon.udata_serialize(febe_data))
コード例 #12
0
 def sendUsrDataBe(self, session, febe_data):
     """Send user data to the backend."""
     lmon.call(self.lib.LMON_fe_sendUsrDataBe, session,
               lmon.udata_serialize(febe_data))
コード例 #13
0
ファイル: lmonbe.py プロジェクト: thaolt/PGDB
 def sendUsrData(self, udata):
     """Send data to the front-end."""
     lmon.call(self.lib.LMON_be_sendUsrData, lmon.udata_serialize(udata))
コード例 #14
0
ファイル: lmonbe.py プロジェクト: thaolt/PGDB
 def ready(self, udata):
     """Inform the front-end that we are ready."""
     if udata is None:
         lmon.call(self.lib.LMON_be_ready, cast(None, c_void_p))
     else:
         lmon.call(self.lib.LMON_be_ready, lmon.udata_serialize(udata))