java.io.SyncFailedException Java Examples
The following examples show how to use
java.io.SyncFailedException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FolderObj.java From netbeans with Apache License 2.0 | 6 votes |
private void createFolder(final File folder2Create, final String name) throws IOException { boolean isSupported = new FileInfo(folder2Create).isSupportedFile(); ProvidedExtensions extensions = getProvidedExtensions(); if (!isSupported) { extensions.createFailure(this, folder2Create.getName(), true); FSException.io("EXC_CannotCreateFolder", folder2Create.getName(), getPath());// NOI18N } else if (FileChangedManager.getInstance().exists(folder2Create)) { extensions.createFailure(this, folder2Create.getName(), true); SyncFailedException sfe = new SyncFailedException(folder2Create.getAbsolutePath()); // NOI18N String msg = NbBundle.getMessage(FileBasedFileSystem.class, "EXC_CannotCreateFolder", folder2Create.getName(), getPath()); // NOI18N Exceptions.attachLocalizedMessage(sfe, msg); throw sfe; } else if (!folder2Create.mkdirs()) { extensions.createFailure(this, folder2Create.getName(), true); FSException.io("EXC_CannotCreateFolder", folder2Create.getName(), getPath());// NOI18N } LogRecord r = new LogRecord(Level.FINEST, "FolderCreated: "+ folder2Create.getAbsolutePath()); r.setParameters(new Object[] {folder2Create}); Logger.getLogger("org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj").log(r); }
Example #2
Source File: FolderObj.java From netbeans with Apache License 2.0 | 6 votes |
private void createData(final File file2Create) throws IOException { boolean isSupported = new FileInfo(file2Create).isSupportedFile(); ProvidedExtensions extensions = getProvidedExtensions(); if (!isSupported) { extensions.createFailure(this, file2Create.getName(), false); FSException.io("EXC_CannotCreateData", file2Create.getName(), getPath());// NOI18N } else if (FileChangedManager.getInstance().exists(file2Create)) { extensions.createFailure(this, file2Create.getName(), false); SyncFailedException sfe = new SyncFailedException(file2Create.getAbsolutePath()); // NOI18N String msg = NbBundle.getMessage(FileBasedFileSystem.class, "EXC_CannotCreateData", file2Create.getName(), getPath()); // NOI18N Exceptions.attachLocalizedMessage(sfe, msg); throw sfe; } else if (!file2Create.createNewFile()) { extensions.createFailure(this, file2Create.getName(), false); FSException.io("EXC_CannotCreateData", file2Create.getName(), getPath());// NOI18N } LogRecord r = new LogRecord(Level.FINEST, "DataCreated: "+ file2Create.getAbsolutePath()); r.setParameters(new Object[] {file2Create}); Logger.getLogger("org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj").log(r); }
Example #3
Source File: FileBasedStoreObjectAccessor.java From brooklyn-server with Apache License 2.0 | 6 votes |
private void syncFileSystem(final FileDescriptor fd) throws SyncFailedException { // Simple retry a number of times; avoids Repeater to avoid complications of timeouts and separate threads int maxTries = 3; SyncFailedException sfe = null; for (int c = 0 ; c < maxTries ; c++) { try { fd.sync(); sfe = null; break; } catch (SyncFailedException e) { sfe = e; } } if (sfe != null) { throw sfe; } }
Example #4
Source File: DropboxSyncService.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public List<RemoteDataInfo> getRemoteEntries() throws SyncFailedException { StringBuilder sb = new StringBuilder(); sb.append(getBaseFilePath()); sb.append(ENTRIES); List<RemoteDataInfo> dataInfoObjects = new ArrayList<>(); try { List<DropboxAPI.Entry> dropboxEntries = getFileInfo(sb.toString()).contents; for (DropboxAPI.Entry entry : dropboxEntries) { if ( !entry.isDir ) { RemoteDataInfo infoObject = new RemoteDataInfo(); infoObject.isDirectory = entry.isDir; infoObject.isDeleted = entry.isDeleted; infoObject.name = entry.fileName().toUpperCase(); infoObject.modifiedDate = RESTUtility.parseDate(entry.modified).getTime(); infoObject.revision = entry.rev; dataInfoObjects.add(infoObject); } } } catch (Exception e) { if (!BuildConfig.DEBUG) Crashlytics.logException(e); e.printStackTrace(); throw new SyncFailedException(e.getMessage()); } return dataInfoObjects; }
Example #5
Source File: NativeIO.java From vespa with Apache License 2.0 | 5 votes |
/** * Will hint the OS that data read so far will not be accessed again and should hence be dropped from the buffer cache. * @param fd The file descriptor to drop from buffer cache. */ public void dropPartialFileFromCache(FileDescriptor fd, long offset, long len, boolean sync) { if (sync) { try { fd.sync(); } catch (SyncFailedException e) { logger.warning("Sync failed while dropping cache: " + e.getMessage()); } } if (initialized) { posix_fadvise(getNativeFD(fd), offset, len, POSIX_FADV_DONTNEED); } }
Example #6
Source File: LogAccessFile.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Guarantee all writes up to the last call to flushLogAccessFile on disk. * <p> * A call for clients of LogAccessFile to insure that all data written * up to the last call to flushLogAccessFile() are written to disk. * This call will not return until those writes have hit disk. * <p> * Note that this routine may block waiting for I/O to complete so * callers should limit the number of resource held locked while this * operation is called. It is expected that the caller * Note that this routine only "writes" the data to the file, this does not * mean that the data has been synced to disk. The only way to insure that * is to first call switchLogBuffer() and then follow by a call of sync(). * **/ public void syncLogAccessFile() throws IOException, StandardException { for( int i=0; ; ) { // 3311: JVM sync call sometimes fails under high load against NFS // mounted disk. We re-try to do this 20 times. try { synchronized( this) { log.sync( false); } // the sync succeed, so return break; } catch( SyncFailedException sfe ) { i++; try { // wait for .2 of a second, hopefully I/O is done by now // we wait a max of 4 seconds before we give up Thread.sleep( 200 ); } catch( InterruptedException ie ) { //does not matter weather I get interrupted or not } if( i > 20 ) throw StandardException.newException( SQLState.LOG_FULL, sfe); } } }
Example #7
Source File: DirRandomAccessFile4.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Force any changes out to the persistent store. * * @param metaData If true then this method is required to force changes to both the file's * content and metadata to be written to storage; otherwise, it need only force content changes * to be written. * * @exception IOException If an IO error occurs. */ public void sync( boolean metaData) throws IOException { try { getChannel().force( metaData); } catch( ClosedChannelException cce) { throw cce;} catch( IOException ioe) { SyncFailedException sne = new SyncFailedException( ioe.getMessage()); sne.initCause( ioe); throw sne; } }
Example #8
Source File: LogAccessFile.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Guarantee all writes up to the last call to flushLogAccessFile on disk. * <p> * A call for clients of LogAccessFile to insure that all data written * up to the last call to flushLogAccessFile() are written to disk. * This call will not return until those writes have hit disk. * <p> * Note that this routine may block waiting for I/O to complete so * callers should limit the number of resource held locked while this * operation is called. It is expected that the caller * Note that this routine only "writes" the data to the file, this does not * mean that the data has been synced to disk. The only way to insure that * is to first call switchLogBuffer() and then follow by a call of sync(). * **/ public void syncLogAccessFile() throws IOException, StandardException { for( int i=0; ; ) { // 3311: JVM sync call sometimes fails under high load against NFS // mounted disk. We re-try to do this 20 times. try { synchronized( this) { log.sync( false); } // the sync succeed, so return break; } catch( SyncFailedException sfe ) { i++; try { // wait for .2 of a second, hopefully I/O is done by now // we wait a max of 4 seconds before we give up Thread.sleep( 200 ); } catch( InterruptedException ie ) { //does not matter weather I get interrupted or not } if( i > 20 ) throw StandardException.newException( SQLState.LOG_FULL, sfe); } } }
Example #9
Source File: DirRandomAccessFile4.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Force any changes out to the persistent store. * * @param metaData If true then this method is required to force changes to both the file's * content and metadata to be written to storage; otherwise, it need only force content changes * to be written. * * @exception IOException If an IO error occurs. */ public void sync( boolean metaData) throws IOException { try { getChannel().force( metaData); } catch( ClosedChannelException cce) { throw cce;} catch( IOException ioe) { SyncFailedException sne = new SyncFailedException( ioe.getMessage()); sne.initCause( ioe); throw sne; } }
Example #10
Source File: DriveSyncService.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public List<RemoteDataInfo> getRemotePhotos() throws SyncFailedException { LogUtil.log(DriveSyncService.class.getSimpleName(), "getRemotePhotos()"); List<RemoteDataInfo> dataObjects = new ArrayList<>(); try { List<File> result = getPhotosContents(); LogUtil.log(getClass().getSimpleName(), "Files in Narrate Drive Photos Folder:"); if (result.size() > 0) { for (File f : result) { LogUtil.log(getClass().getSimpleName(), f.getTitle()); RemoteDataInfo info = new RemoteDataInfo(); info.name = f.getTitle(); info.isDirectory = f.getMimeType().equals(FOLDER_MIME); info.isDeleted = f.getLabels().getTrashed(); info.modifiedDate = f.getModifiedDate().getValue(); info.revision = String.valueOf(f.getVersion()); dataObjects.add(info); } } } catch (Exception e) { if (!BuildConfig.DEBUG) Crashlytics.logException(e); e.printStackTrace(); throw new SyncFailedException(e.getMessage()); } return dataObjects; }
Example #11
Source File: DriveSyncService.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public List<RemoteDataInfo> getRemoteEntries() throws SyncFailedException { LogUtil.log(getClass().getSimpleName(), "Files in Narrate Drive AppFolder:"); List<RemoteDataInfo> dataObjects = new ArrayList<>(); try { List<File> contents = getContents(); if (contents != null) { Iterator<File> iter = contents.iterator(); File f; while (iter.hasNext()) { f = iter.next(); LogUtil.log(getClass().getSimpleName(), f.getTitle()); if (!f.getTitle().equals("photos")) { RemoteDataInfo info = new RemoteDataInfo(); info.name = f.getTitle(); info.isDirectory = f.getMimeType().equals(FOLDER_MIME); info.isDeleted = f.getLabels().getTrashed(); info.modifiedDate = f.getModifiedDate().getValue(); info.revision = String.valueOf(f.getVersion()); dataObjects.add(info); } } return dataObjects; } } catch (Exception e) { if (!BuildConfig.DEBUG) Crashlytics.logException(e); e.printStackTrace(); throw new SyncFailedException(e.getMessage()); } return null; }
Example #12
Source File: DropboxSyncService.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public List<RemoteDataInfo> getRemotePhotos() throws SyncFailedException { StringBuilder sb = new StringBuilder(); sb.append(getBaseFilePath()); sb.append(PHOTOS); List<RemoteDataInfo> dataInfoObjects = new ArrayList<>(); try { List<DropboxAPI.Entry> dropboxEntries = getFileInfo(sb.toString()).contents; for (DropboxAPI.Entry file : dropboxEntries) { if ( !file.isDir ) { RemoteDataInfo infoObject = new RemoteDataInfo(); infoObject.isDirectory = file.isDir; infoObject.isDeleted = file.isDeleted; infoObject.name = file.fileName().toLowerCase(); infoObject.modifiedDate = RESTUtility.parseDate(file.modified).getTime(); infoObject.revision = file.rev; dataInfoObjects.add(infoObject); } } } catch (Exception e) { if (!BuildConfig.DEBUG) Crashlytics.logException(e); e.printStackTrace(); throw new SyncFailedException(e.getMessage()); } return dataInfoObjects; }
Example #13
Source File: StdFsFileIO.java From edslite with GNU General Public License v2.0 | 5 votes |
@Override public void close() throws IOException { try { FileDescriptor fd = getFD(); if(fd!=null) fd.sync(); } catch(SyncFailedException ignored) {} super.close(); }
Example #14
Source File: DownloadUriOutputStreamTest.java From okdownload with Apache License 2.0 | 5 votes |
@Test public void flushAndSync() throws Exception { when(pdf.getFileDescriptor()).thenReturn(fd); thrown.expect(SyncFailedException.class); thrown.expectMessage("sync failed"); outputStream.flushAndSync(); verify(out).flush(); }
Example #15
Source File: AtomicFileOperations.java From protect with MIT License | 5 votes |
public static void atomicWriteBytes(final File destinationFile, final byte[] data) throws SyncFailedException, IOException { // Create a temporary file in the same directory as the desination file final File parentDirectory = destinationFile.getParentFile(); parentDirectory.mkdirs(); final File tempFile = new File(parentDirectory, destinationFile.getName() + UUID.randomUUID().toString() + ".tmp"); try (final FileOutputStream fos = new FileOutputStream(tempFile);) { // FIXME: Make serialization of state objects more efficient, currently a // performance problem // Do everything we can to ensure a flush to storage fos.write(data); //fos.getChannel().force(true); fos.flush(); //fos.getFD().sync(); fos.close(); try { // Attempt atomic rename Files.move(Paths.get(tempFile.getAbsolutePath()), Paths.get(destinationFile.getAbsolutePath()), StandardCopyOption.ATOMIC_MOVE); } catch (IOException e) { // Fall back to normal rename (may not be atomic) System.err.println("Atomic moves not supported on this platform. This can lead to data loss!"); tempFile.renameTo(destinationFile); } } }
Example #16
Source File: AtomicFileOperations.java From protect with MIT License | 4 votes |
public static void atomicWriteString(final File destinationFile, final String string) throws SyncFailedException, IOException { atomicWriteBytes(destinationFile, string.getBytes(StandardCharsets.UTF_8)); }
Example #17
Source File: PatchLogger.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Message(id = 18, value = "copied content does not match expected hash for item: %s") SyncFailedException wrongCopiedContent(ContentItem item);
Example #18
Source File: SnappyOutputStream.java From sparkey-java with Apache License 2.0 | 4 votes |
public void fsync() throws SyncFailedException { fileDescriptor.sync(); }
Example #19
Source File: AtomicFileOperations.java From protect with MIT License | 4 votes |
public static void atomicWriteSignedMessage(final File destinationFile, final SignedMessage signedMessage) throws SyncFailedException, IOException { byte[] messageData = MessageSerializer.serializeSignedMessage(signedMessage); atomicWriteBytes(destinationFile, messageData); }
Example #20
Source File: OverflowOplog.java From gemfirexd-oss with Apache License 2.0 | 3 votes |
/** * Test Method to be used only for testing purposes. Gets the underlying File * object for the Oplog . Oplog class uses this File object to obtain the * RandomAccessFile object. Before returning the File object , the dat present * in the buffers of the RandomAccessFile object is flushed. Otherwise, for * windows the actual file length does not match with the File size obtained * from the File object * * @throws IOException * @throws SyncFailedException */ File getOplogFile() throws SyncFailedException, IOException { synchronized (this.crf) { if (!this.crf.RAFClosed) { this.crf.raf.getFD().sync(); } return this.crf.f; } }
Example #21
Source File: OverflowOplog.java From gemfirexd-oss with Apache License 2.0 | 3 votes |
/** * Test Method to be used only for testing purposes. Gets the underlying File * object for the Oplog . Oplog class uses this File object to obtain the * RandomAccessFile object. Before returning the File object , the dat present * in the buffers of the RandomAccessFile object is flushed. Otherwise, for * windows the actual file length does not match with the File size obtained * from the File object * * @throws IOException * @throws SyncFailedException */ File getOplogFile() throws SyncFailedException, IOException { synchronized (this.crf) { if (!this.crf.RAFClosed) { this.crf.raf.getFD().sync(); } return this.crf.f; } }
Example #22
Source File: WritableStorageFactory.java From gemfirexd-oss with Apache License 2.0 | 2 votes |
/** * Force the data of an output stream out to the underlying storage. That is, ensure that * it has been made persistent. If the database is to be transient, that is, if the database * does not survive a restart, then the sync method implementation need not do anything. * * @param stream The stream to be synchronized. * @param metaData If true then this method must force both changes to the file's * contents and metadata to be written to storage; if false, it need only force file content changes * to be written. The implementation is allowed to ignore this parameter and always force out * metadata changes. * * @exception IOException if an I/O error occurs. * @exception SyncFailedException Thrown when the buffers cannot be flushed, * or because the system cannot guarantee that all the buffers have been * synchronized with physical media. */ public void sync( OutputStream stream, boolean metaData) throws IOException, SyncFailedException;
Example #23
Source File: CorruptBaseStorageFactory.java From gemfirexd-oss with Apache License 2.0 | 2 votes |
/** * Force the data of an output stream out to the underlying storage. * * That is, ensure that it has been made persistent. If the database is to * be transient, that is, if the database does not survive a restart, then * the sync method implementation need not do anything. * * @param stream The stream to be synchronized. * @param metaData If true then this method must force both changes to the * file's contents and metadata to be written to storage; * if false, it need only force file content changes to be * written. The implementation is allowed to ignore this * parameter and always force out metadata changes. * * @exception IOException if an I/O error occurs. * @exception SyncFailedException Thrown when the buffers cannot be flushed, * or because the system cannot guarantee that all the buffers * have been synchronized with physical media. */ public void sync( OutputStream stream, boolean metaData) throws IOException, SyncFailedException { realStorageFactory.sync(stream, metaData); }
Example #24
Source File: DirStorageFactory.java From gemfirexd-oss with Apache License 2.0 | 2 votes |
/** * Force the data of an output stream out to the underlying storage. That is, ensure that * it has been made persistent. If the database is to be transient, that is, if the database * does not survive a restart, then the sync method implementation need not do anything. * * @param stream The stream to be synchronized. * @param metaData If true then this method must force both changes to the file's * contents and metadata to be written to storage; if false, it need only force file content changes * to be written. The implementation is allowed to ignore this parameter and always force out * metadata changes. * * @exception IOException if an I/O error occurs. * @exception SyncFailedException Thrown when the buffers cannot be flushed, * or because the system cannot guarantee that all the buffers have been * synchronized with physical media. */ public void sync( OutputStream stream, boolean metaData) throws IOException, SyncFailedException { ((FileOutputStream) stream).getFD().sync(); }
Example #25
Source File: CorruptBaseStorageFactory.java From gemfirexd-oss with Apache License 2.0 | 2 votes |
/** * Force the data of an output stream out to the underlying storage. * * That is, ensure that it has been made persistent. If the database is to * be transient, that is, if the database does not survive a restart, then * the sync method implementation need not do anything. * * @param stream The stream to be synchronized. * @param metaData If true then this method must force both changes to the * file's contents and metadata to be written to storage; * if false, it need only force file content changes to be * written. The implementation is allowed to ignore this * parameter and always force out metadata changes. * * @exception IOException if an I/O error occurs. * @exception SyncFailedException Thrown when the buffers cannot be flushed, * or because the system cannot guarantee that all the buffers * have been synchronized with physical media. */ public void sync( OutputStream stream, boolean metaData) throws IOException, SyncFailedException { realStorageFactory.sync(stream, metaData); }
Example #26
Source File: DirStorageFactory.java From gemfirexd-oss with Apache License 2.0 | 2 votes |
/** * Force the data of an output stream out to the underlying storage. That is, ensure that * it has been made persistent. If the database is to be transient, that is, if the database * does not survive a restart, then the sync method implementation need not do anything. * * @param stream The stream to be synchronized. * @param metaData If true then this method must force both changes to the file's * contents and metadata to be written to storage; if false, it need only force file content changes * to be written. The implementation is allowed to ignore this parameter and always force out * metadata changes. * * @exception IOException if an I/O error occurs. * @exception SyncFailedException Thrown when the buffers cannot be flushed, * or because the system cannot guarantee that all the buffers have been * synchronized with physical media. */ public void sync( OutputStream stream, boolean metaData) throws IOException, SyncFailedException { ((FileOutputStream) stream).getFD().sync(); }
Example #27
Source File: WritableStorageFactory.java From gemfirexd-oss with Apache License 2.0 | 2 votes |
/** * Force the data of an output stream out to the underlying storage. That is, ensure that * it has been made persistent. If the database is to be transient, that is, if the database * does not survive a restart, then the sync method implementation need not do anything. * * @param stream The stream to be synchronized. * @param metaData If true then this method must force both changes to the file's * contents and metadata to be written to storage; if false, it need only force file content changes * to be written. The implementation is allowed to ignore this parameter and always force out * metadata changes. * * @exception IOException if an I/O error occurs. * @exception SyncFailedException Thrown when the buffers cannot be flushed, * or because the system cannot guarantee that all the buffers have been * synchronized with physical media. */ public void sync( OutputStream stream, boolean metaData) throws IOException, SyncFailedException;
Example #28
Source File: BinaryDataAccessor.java From io with Apache License 2.0 | 2 votes |
/** * ファイルディスクリプタの同期. * @param fd ファイルディスクリプタ * @exception SyncFailedException 同期に失敗 */ public void sync(FileDescriptor fd) throws SyncFailedException { fd.sync(); }
Example #29
Source File: BarFileInstaller.java From io with Apache License 2.0 | 2 votes |
/** * ファイルディスクリプタの同期. * @param fd ファイルディスクリプタ * @throws SyncFailedException 同期に失敗 */ public void sync(FileDescriptor fd) throws SyncFailedException { fd.sync(); }
Example #30
Source File: AbsSyncService.java From narrate-android with Apache License 2.0 | 2 votes |
/** * Queries remote sync service for information about the data the service stores (i.e. * a list of file names, modified date, etc.) * * @return list of info objects */ public abstract List<RemoteDataInfo> getRemoteEntries() throws SyncFailedException;