Example #1
0
    def __open_remote_file(
        self,
        path,
        mode='r',
        buf=-1,
    ):
        """Request the current leader to open the active session for
        file with supplied path.
        """

        if -1 != buf:
            raise IOError('buffered reads are not supported!')

        # TODO: eliminate need for CREATE in storage code - WRITE
        # should be enough!

        if mode.startswith('w'):
            self.session_type = 'CREATE'
            distbase.open_session(path, self.session_type)
            distbase.close_session(path, self.session_type)
            self.session_type = 'WRITE'
        else:

            # TODO: handle other modes like 'a', "r+"?

            self.session_type = 'READ'

        return distbase.open_session(path, self.session_type)
Example #2
0
    def __close_remote_file(self, path):
        """Tell the current leader to close the active session for
        file with supplied path.
        """

        return distbase.close_session(path, self.session_type)