本文整理匯總了Java中java.io.SyncFailedException類的典型用法代碼示例。如果您正苦於以下問題:Java SyncFailedException類的具體用法?Java SyncFailedException怎麽用?Java SyncFailedException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SyncFailedException類屬於java.io包,在下文中一共展示了SyncFailedException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFolder
import java.io.SyncFailedException; //導入依賴的package包/類
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);
}
示例2: createData
import java.io.SyncFailedException; //導入依賴的package包/類
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);
}
示例3: closeSync
import java.io.SyncFailedException; //導入依賴的package包/類
@ObfuscatedName("k")
@ObfuscatedSignature(
signature = "(ZI)V",
garbageValue = "-1673795207"
)
@Export("closeSync")
public final void closeSync(boolean var1) throws IOException {
if(this.file != null) {
if(var1) {
try {
this.file.getFD().sync();
} catch (SyncFailedException var3) {
;
}
}
this.file.close();
this.file = null;
}
}
示例4: commitTransactionStage1
import java.io.SyncFailedException; //導入依賴的package包/類
public void commitTransactionStage1() throws SyncFailedException, IOException
{
//System.out.println("commitTransactionStage1: "+this);
//stage 1
//flush and sync everything
insertRecordOut.flush();
insertRecordFileOut.getFD().sync();
insertRecordOut.close();
rollForwardOut.flush();
rollForwardFileOut.getFD().sync();
rollForwardOut.close();
//mark the roll back file as a real roll back file
getRollForwardFile(true).renameTo(getRollForwardFile(false));
//System.out.println("commitTransactionStage1 end: "+this);
}
示例5: releaseApplicationLock
import java.io.SyncFailedException; //導入依賴的package包/類
/**
* release the application lock
* @param request the HTTP request
* @param requestor the HTTP requestor
* @return
* @throws SyncFailedException
* @throws SecurityException
*/
public synchronized static boolean releaseApplicationLock(HttpServletRequest request, Serializable requestor)
throws SyncFailedException, SecurityException
{
if(request == null)
return false;
ServletContext application = Web.getApplication(request);
//get previous
Serializable previous = (Serializable)application.getAttribute(lockKey);
if(previous != null && previous.toString().length() > 0)
{
Debugger.printWarn(WebLock.class,"Lock was owner by "+previous+" but release by "+requestor);
}
application.setAttribute(lockKey, null);
return true;
}
示例6: test_ConstructorLjava_lang_String
import java.io.SyncFailedException; //導入依賴的package包/類
/**
* @tests java.io.SyncFailedException#SyncFailedException(java.lang.String)
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
method = "SyncFailedException",
args = {java.lang.String.class}
)
public void test_ConstructorLjava_lang_String() {
try {
if (true) // To avoid unreachable code compilation error.
throw new SyncFailedException("Something went wrong.");
fail("Test 1: SyncFailedException expected.");
} catch (SyncFailedException e) {
assertEquals("Test 2: Incorrect message;",
"Something went wrong.", e.getMessage());
}
}
示例7: test_ConstructorLjava_lang_String
import java.io.SyncFailedException; //導入依賴的package包/類
/**
* @tests java.io.SyncFailedException#SyncFailedException(java.lang.String)
*/
public void test_ConstructorLjava_lang_String() throws Exception {
// Test for method java.io.SyncFailedException(java.lang.String)
File f = null;
try {
f = new File(System.getProperty("user.dir"), "synfail.tst");
FileOutputStream fos = new FileOutputStream(f.getPath());
FileDescriptor fd = fos.getFD();
fos.close();
fd.sync();
} catch (SyncFailedException e) {
f.delete();
return;
}
fail("Failed to generate expected Exception");
}
示例8: close
import java.io.SyncFailedException; //導入依賴的package包/類
/**
* Close the appropriate stream
*
* @throws IOException
*/
public void close() throws IOException {
if (this.isWriting) {
// To the degree possible, make sure the bytes get forced to the file system,
// or else cause an exception to be thrown.
if (this.outputStream instanceof FileOutputStream) {
this.outputStream.flush();
FileOutputStream fos = (FileOutputStream)this.outputStream;
try {
fos.getFD().sync();
} catch (SyncFailedException e) {
// Since the sync is belt-and-suspenders anyway, don't throw an exception if it
// fails,
// because on some OSs it will fail for some types of output. E.g. writing to
// /dev/null
// on some Unixes.
}
}
this.outputStream.close();
} else {
this.inputStream.close();
}
}
示例9: isConnectionException
import java.io.SyncFailedException; //導入依賴的package包/類
/**
* Check if the exception is something that indicates that we cannot
* contact/communicate with the server.
*
* @param e
* @return true when exception indicates that the client wasn't able to make contact with server
*/
private boolean isConnectionException(Throwable e) {
if (e == null)
return false;
// This list covers most connectivity exceptions but not all.
// For example, in SocketOutputStream a plain IOException is thrown
// at times when the channel is closed.
return (e instanceof SocketTimeoutException
|| e instanceof ConnectException || e instanceof ClosedChannelException
|| e instanceof SyncFailedException || e instanceof EOFException
|| e instanceof TimeoutException
|| e instanceof ConnectionClosingException || e instanceof FailedServerException);
}
示例10: getRemoteEntries
import java.io.SyncFailedException; //導入依賴的package包/類
@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;
}
示例11: getRemotePhotos
import java.io.SyncFailedException; //導入依賴的package包/類
@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;
}
示例12: getRemoteEntries
import java.io.SyncFailedException; //導入依賴的package包/類
@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;
}
示例13: getRemotePhotos
import java.io.SyncFailedException; //導入依賴的package包/類
@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;
}
示例14: syncLogAccessFile
import java.io.SyncFailedException; //導入依賴的package包/類
/**
* 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);
}
}
}
示例15: sync
import java.io.SyncFailedException; //導入依賴的package包/類
/**
* 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;
}
}