Beispiel #1
0
 def _write_entire_chunk(self, chunk):
     bytes_per_sync = self._disk_file._mgr.bytes_per_sync
     while chunk:
         written = do_write(self._fd, chunk)
         chunk = chunk[written:]
         self._upload_size += written
         # For large files sync every 512MB (by default) written
         diff = self._upload_size - self._last_sync
         if diff >= bytes_per_sync:
             do_fdatasync(self._fd)
             do_fadvise64(self._fd, self._last_sync, diff)
             self._last_sync = self._upload_size
Beispiel #2
0
 def _write_entire_chunk(self, chunk):
     bytes_per_sync = self._disk_file._mgr.bytes_per_sync
     while chunk:
         written = do_write(self._fd, chunk)
         chunk = chunk[written:]
         self._upload_size += written
         # For large files sync every 512MB (by default) written
         diff = self._upload_size - self._last_sync
         if diff >= bytes_per_sync:
             do_fdatasync(self._fd)
             do_fadvise64(self._fd, self._last_sync, diff)
             self._last_sync = self._upload_size
Beispiel #3
0
 def test_do_fdatasync_err(self):
     tmpdir = mkdtemp()
     try:
         fd, tmpfile = mkstemp(dir=tmpdir)
         os.write(fd, 'test')
         with patch('os.fdatasync', mock_os_fdatasync):
             assert fs.do_fdatasync(fd) is None
         os.close(fd)
         try:
             fs.do_fdatasync(fd)
         except GlusterFileSystemOSError:
             pass
         else:
             self.fail("Expected GlusterFileSystemOSError")
     finally:
         shutil.rmtree(tmpdir)
Beispiel #4
0
 def test_do_fdatasync_err(self):
     tmpdir = mkdtemp()
     try:
         fd, tmpfile = mkstemp(dir=tmpdir)
         os.write(fd, 'test')
         with patch('os.fdatasync', mock_os_fdatasync):
             assert fs.do_fdatasync(fd) is None
         os.close(fd)
         try:
             fs.do_fdatasync(fd)
         except GlusterFileSystemOSError:
             pass
         else:
             self.fail("Expected GlusterFileSystemOSError")
     finally:
         shutil.rmtree(tmpdir)
Beispiel #5
0
 def test_do_fdatasync(self):
     tmpdir = mkdtemp()
     try:
         fd, tmpfile = mkstemp(dir=tmpdir)
         try:
             os.write(fd, 'test')
             with patch('os.fdatasync', mock_os_fdatasync):
                 assert fs.do_fdatasync(fd) is None
         except GlusterFileSystemOSError as ose:
             self.fail('Opening a temporary file failed with %s' %
                       ose.strerror)
         else:
             os.close(fd)
     finally:
         shutil.rmtree(tmpdir)
Beispiel #6
0
 def test_do_fdatasync(self):
     tmpdir = mkdtemp()
     try:
         fd, tmpfile = mkstemp(dir=tmpdir)
         try:
             os.write(fd, 'test')
             with patch('os.fdatasync', mock_os_fdatasync):
                 assert fs.do_fdatasync(fd) is None
         except GlusterFileSystemOSError as ose:
             self.fail('Opening a temporary file failed with %s' %
                       ose.strerror)
         else:
             os.close(fd)
     finally:
         shutil.rmtree(tmpdir)