Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Chen2012-06-25 09:54:42 +0000
committerWilliam Chen2012-06-25 09:54:42 +0000
commit02cd0eac0fe289186e3977f52eb45d62e43600d7 (patch)
tree710c067edcfbf75695a2ff7f3c0f9644f75850e6 /target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core
parent6e694cd3027f03c5c469887836e5ce96f11aa715 (diff)
downloadorg.eclipse.tcf-02cd0eac0fe289186e3977f52eb45d62e43600d7.tar.gz
org.eclipse.tcf-02cd0eac0fe289186e3977f52eb45d62e43600d7.tar.xz
org.eclipse.tcf-02cd0eac0fe289186e3977f52eb45d62e43600d7.zip
Target Explorer: User a static proxy class to replace BlockingCallProxy
which is not debug friendly.
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java21
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java631
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties24
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java68
5 files changed, 696 insertions, 70 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java
index 12b61d105..117667b3e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/operations/Operation.java
@@ -14,6 +14,7 @@ import java.lang.reflect.InvocationTargetException;
import java.net.ConnectException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.TimeoutException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
@@ -37,14 +38,14 @@ import org.eclipse.tcf.services.IFileSystem.FileSystemException;
import org.eclipse.tcf.services.IFileSystem.IFileHandle;
import org.eclipse.tcf.te.core.utils.Ancestor;
import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.concurrent.BlockingCallProxy;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
+import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IOperation;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFChannelException;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFException;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFFileSystemException;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.BlockingFileSystemProxy;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
@@ -55,6 +56,8 @@ import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
* @see IOperation
*/
public class Operation extends Ancestor<FSTreeNode> implements IOperation {
+ // The default timeout waiting for blocked invocations.
+ public static final long DEFAULT_TIMEOUT = 60000L;
// The flag indicating if the following action should be executed without asking.
protected boolean yes2All = false;
@@ -140,11 +143,10 @@ public class Operation extends Ancestor<FSTreeNode> implements IOperation {
* @return The channel or null if the operation fails.
*/
public static IChannel openChannel(final IPeer peer) throws TCFChannelException {
- IChannelManager channelManager = Tcf.getChannelManager();
- channelManager = BlockingCallProxy.newInstance(IChannelManager.class, channelManager);
final TCFChannelException[] errors = new TCFChannelException[1];
final IChannel[] channels = new IChannel[1];
- channelManager.openChannel(peer, null, new DoneOpenChannel() {
+ final Rendezvous rendezvous = new Rendezvous();
+ Tcf.getChannelManager().openChannel(peer, null, new DoneOpenChannel() {
@Override
public void doneOpenChannel(Throwable error, IChannel channel) {
if (error != null) {
@@ -160,8 +162,15 @@ public class Operation extends Ancestor<FSTreeNode> implements IOperation {
else {
channels[0] = channel;
}
+ rendezvous.arrive();
}
});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new TCFChannelException(IStatus.ERROR, Messages.Operation_TimeoutOpeningChannel);
+ }
if (errors[0] != null) {
throw errors[0];
}
@@ -184,7 +193,7 @@ public class Operation extends Ancestor<FSTreeNode> implements IOperation {
public static IFileSystem getBlockingFileSystem(final IChannel channel) {
if(Protocol.isDispatchThread()) {
IFileSystem service = channel.getRemoteService(IFileSystem.class);
- return BlockingCallProxy.newInstance(IFileSystem.class, service);
+ return new BlockingFileSystemProxy(service);
}
final IFileSystem[] service = new IFileSystem[1];
Protocol.invokeAndWait(new Runnable(){
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java
new file mode 100644
index 000000000..59755fe02
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/internal/utils/BlockingFileSystemProxy.java
@@ -0,0 +1,631 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.core.internal.utils;
+
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.IToken;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.services.IFileSystem;
+import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation;
+import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
+
+/**
+ * A blocking call proxy for a file system service.
+ * All calls to the service method are blocked until its
+ * "Done" handler is invoked.
+ * <p>
+ * <em>Note that all method call over the proxy must be made <b>OUTSIDE</b> of
+ * the dispatching thread.</em> If it is called inside of the dispatching thread, the call will be
+ * blocked forever.
+ * <p>
+ * This class is used to replace BlockingProxyCall for better debugability.
+ *
+ * @see BlockingCallProxy
+ */
+public class BlockingFileSystemProxy implements IFileSystem {
+ // The default timeout waiting for blocked invocations.
+ private static final long DEFAULT_TIMEOUT = Operation.DEFAULT_TIMEOUT;
+
+ // The actual object that provides file system services.
+ IFileSystem service;
+ // The rendezvous used to synchronize invocation
+ Rendezvous rendezvous;
+ /**
+ * Constructor with an delegating service.
+ *
+ * @param service The delegating service.
+ */
+ public BlockingFileSystemProxy(IFileSystem service) {
+ Assert.isNotNull(service);
+ this.service = service;
+ this.rendezvous = new Rendezvous();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.protocol.IService#getName()
+ */
+ @Override
+ public String getName() {
+ return service.getName();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#open(java.lang.String, int, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneOpen)
+ */
+ @Override
+ public IToken open(String file_name, int flags, FileAttrs attrs, final DoneOpen done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.open(file_name, flags, attrs, new DoneOpen(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneOpen#doneOpen(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.IFileHandle)
+ */
+ @Override
+ public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
+ done.doneOpen(token, error, handle);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutOpeningFile, file_name), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#close(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneClose)
+ */
+ @Override
+ public IToken close(IFileHandle handle, final DoneClose done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.close(handle, new DoneClose(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneClose#doneClose(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneClose(IToken token, FileSystemException error) {
+ done.doneClose(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutClosingFile, handle), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#read(org.eclipse.tcf.services.IFileSystem.IFileHandle, long, int, org.eclipse.tcf.services.IFileSystem.DoneRead)
+ */
+ @Override
+ public IToken read(IFileHandle handle, long offset, int len, final DoneRead done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.read(handle, offset, len, new DoneRead(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneRead#doneRead(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, byte[], boolean)
+ */
+ @Override
+ public void doneRead(IToken token, FileSystemException error, byte[] data, boolean eof) {
+ done.doneRead(token, error, data, eof);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingFile, handle), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#write(org.eclipse.tcf.services.IFileSystem.IFileHandle, long, byte[], int, int, org.eclipse.tcf.services.IFileSystem.DoneWrite)
+ */
+ @Override
+ public IToken write(IFileHandle handle, long offset, byte[] data, int data_pos, int data_size, final DoneWrite done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.write(handle, offset, data, data_pos, data_size, new DoneWrite(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneWrite#doneWrite(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneWrite(IToken token, FileSystemException error) {
+ done.doneWrite(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutWritingFile, handle), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#stat(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneStat)
+ */
+ @Override
+ public IToken stat(String path, final DoneStat done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.stat(path, new DoneStat(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneStat#doneStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.FileAttrs)
+ */
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ done.doneStat(token, error, attrs);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutStat, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#lstat(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneStat)
+ */
+ @Override
+ public IToken lstat(String path, final DoneStat done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.lstat(path, new DoneStat(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneStat#doneStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.FileAttrs)
+ */
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ done.doneStat(token, error, attrs);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutLstat, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#fstat(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneStat)
+ */
+ @Override
+ public IToken fstat(IFileHandle handle, final DoneStat done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.fstat(handle, new DoneStat(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneStat#doneStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.FileAttrs)
+ */
+ @Override
+ public void doneStat(IToken token, FileSystemException error, FileAttrs attrs) {
+ done.doneStat(token, error, attrs);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutFstat, handle), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#setstat(java.lang.String, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneSetStat)
+ */
+ @Override
+ public IToken setstat(String path, FileAttrs attrs, final DoneSetStat done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.setstat(path, attrs, new DoneSetStat(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneSetStat#doneSetStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneSetStat(IToken token, FileSystemException error) {
+ done.doneSetStat(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutSetStat, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#fsetstat(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneSetStat)
+ */
+ @Override
+ public IToken fsetstat(IFileHandle handle, FileAttrs attrs, final DoneSetStat done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.fsetstat(handle, attrs, new DoneSetStat(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneSetStat#doneSetStat(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneSetStat(IToken token, FileSystemException error) {
+ done.doneSetStat(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutFSetStat, handle), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#opendir(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneOpen)
+ */
+ @Override
+ public IToken opendir(String path, final DoneOpen done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.opendir(path, new DoneOpen(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneOpen#doneOpen(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.IFileHandle)
+ */
+ @Override
+ public void doneOpen(IToken token, FileSystemException error, IFileHandle handle) {
+ done.doneOpen(token, error, handle);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutOpeningDir, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#readdir(org.eclipse.tcf.services.IFileSystem.IFileHandle, org.eclipse.tcf.services.IFileSystem.DoneReadDir)
+ */
+ @Override
+ public IToken readdir(IFileHandle handle, final DoneReadDir done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.readdir(handle, new DoneReadDir(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneReadDir#doneReadDir(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[], boolean)
+ */
+ @Override
+ public void doneReadDir(IToken token, FileSystemException error, DirEntry[] entries, boolean eof) {
+ done.doneReadDir(token, error, entries, eof);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingDir, handle), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#mkdir(java.lang.String, org.eclipse.tcf.services.IFileSystem.FileAttrs, org.eclipse.tcf.services.IFileSystem.DoneMkDir)
+ */
+ @Override
+ public IToken mkdir(String path, FileAttrs attrs, final DoneMkDir done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.mkdir(path, attrs, new DoneMkDir(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneMkDir#doneMkDir(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneMkDir(IToken token, FileSystemException error) {
+ done.doneMkDir(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutMakingDir, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#rmdir(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRemove)
+ */
+ @Override
+ public IToken rmdir(String path, final DoneRemove done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.rmdir(path, new DoneRemove(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneRemove#doneRemove(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneRemove(IToken token, FileSystemException error) {
+ done.doneRemove(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRemovingDir, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#roots(org.eclipse.tcf.services.IFileSystem.DoneRoots)
+ */
+ @Override
+ public IToken roots(final DoneRoots done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.roots(new DoneRoots(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneRoots#doneRoots(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, org.eclipse.tcf.services.IFileSystem.DirEntry[])
+ */
+ @Override
+ public void doneRoots(IToken token, FileSystemException error, DirEntry[] entries) {
+ done.doneRoots(token, error, entries);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(Messages.BlockingFileSystemProxy_TimeoutListingRoots, e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#remove(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRemove)
+ */
+ @Override
+ public IToken remove(String file_name, final DoneRemove done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.remove(file_name, new DoneRemove(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneRemove#doneRemove(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneRemove(IToken token, FileSystemException error) {
+ done.doneRemove(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRemovingFile, file_name), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#realpath(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRealPath)
+ */
+ @Override
+ public IToken realpath(String path, final DoneRealPath done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.realpath(path, new DoneRealPath(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneRealPath#doneRealPath(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, java.lang.String)
+ */
+ @Override
+ public void doneRealPath(IToken token, FileSystemException error, String path) {
+ done.doneRealPath(token, error, path);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutGettingRealPath, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#rename(java.lang.String, java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneRename)
+ */
+ @Override
+ public IToken rename(String old_path, String new_path, final DoneRename done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.rename(old_path, new_path, new DoneRename(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneRename#doneRename(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneRename(IToken token, FileSystemException error) {
+ done.doneRename(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutRenamingFile, old_path, new_path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#readlink(java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneReadLink)
+ */
+ @Override
+ public IToken readlink(String path, final DoneReadLink done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.readlink(path, new DoneReadLink(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneReadLink#doneReadLink(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, java.lang.String)
+ */
+ @Override
+ public void doneReadLink(IToken token, FileSystemException error, String path) {
+ done.doneReadLink(token, error, path);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutReadingLink, path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#symlink(java.lang.String, java.lang.String, org.eclipse.tcf.services.IFileSystem.DoneSymLink)
+ */
+ @Override
+ public IToken symlink(String link_path, String target_path, final DoneSymLink done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.symlink(link_path, target_path, new DoneSymLink(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneSymLink#doneSymLink(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneSymLink(IToken token, FileSystemException error) {
+ done.doneSymLink(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutSymLink, link_path, target_path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#copy(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.tcf.services.IFileSystem.DoneCopy)
+ */
+ @Override
+ public IToken copy(String src_path, String dst_path, boolean copy_permissions, boolean copy_ownership, final DoneCopy done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.copy(src_path, dst_path, copy_permissions, copy_ownership, new DoneCopy(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneCopy#doneCopy(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException)
+ */
+ @Override
+ public void doneCopy(IToken token, FileSystemException error) {
+ done.doneCopy(token, error);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(NLS.bind(Messages.BlockingFileSystemProxy_TimeoutCopying, src_path, dst_path), e);
+ }
+ return token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem#user(org.eclipse.tcf.services.IFileSystem.DoneUser)
+ */
+ @Override
+ public IToken user(final DoneUser done) {
+ Assert.isTrue(!Protocol.isDispatchThread());
+ rendezvous.reset();
+ IToken token = service.user(new DoneUser(){
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.services.IFileSystem.DoneUser#doneUser(org.eclipse.tcf.protocol.IToken, org.eclipse.tcf.services.IFileSystem.FileSystemException, int, int, int, int, java.lang.String)
+ */
+ @Override
+ public void doneUser(IToken token, FileSystemException error, int real_uid, int effective_uid, int real_gid, int effective_gid, String home) {
+ done.doneUser(token, error, real_uid, effective_uid, real_gid, effective_gid, home);
+ rendezvous.arrive();
+ }});
+ try {
+ rendezvous.waiting(DEFAULT_TIMEOUT);
+ }
+ catch(TimeoutException e) {
+ throw new RuntimeException(Messages.BlockingFileSystemProxy_TimeoutGettingUser, e);
+ }
+ return token;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
index 289c18bd7..b49b665e7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.java
@@ -45,6 +45,7 @@ public class Messages extends NLS {
public static String Operation_CopyNOfFile;
public static String Operation_CopyOfFile;
public static String Operation_CannotCreateDirectory;
+ public static String Operation_TimeoutOpeningChannel;
public static String OpCopy_Copying;
public static String OpCopy_CannotCopyFile;
@@ -96,4 +97,25 @@ public class Messages extends NLS {
public static String CacheManager_MkdirFailed;
public static String FileTransferService_error_mkdirFailed;
+ public static String BlockingFileSystemProxy_TimeoutOpeningFile;
+ public static String BlockingFileSystemProxy_TimeoutClosingFile;
+ public static String BlockingFileSystemProxy_TimeoutReadingFile;
+ public static String BlockingFileSystemProxy_TimeoutWritingFile;
+ public static String BlockingFileSystemProxy_TimeoutStat;
+ public static String BlockingFileSystemProxy_TimeoutLstat;
+ public static String BlockingFileSystemProxy_TimeoutFstat;
+ public static String BlockingFileSystemProxy_TimeoutSetStat;
+ public static String BlockingFileSystemProxy_TimeoutFSetStat;
+ public static String BlockingFileSystemProxy_TimeoutOpeningDir;
+ public static String BlockingFileSystemProxy_TimeoutReadingDir;
+ public static String BlockingFileSystemProxy_TimeoutMakingDir;
+ public static String BlockingFileSystemProxy_TimeoutRemovingDir;
+ public static String BlockingFileSystemProxy_TimeoutListingRoots;
+ public static String BlockingFileSystemProxy_TimeoutRemovingFile;
+ public static String BlockingFileSystemProxy_TimeoutGettingRealPath;
+ public static String BlockingFileSystemProxy_TimeoutRenamingFile;
+ public static String BlockingFileSystemProxy_TimeoutReadingLink;
+ public static String BlockingFileSystemProxy_TimeoutSymLink;
+ public static String BlockingFileSystemProxy_TimeoutCopying;
+ public static String BlockingFileSystemProxy_TimeoutGettingUser;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
index 25be5c120..b0a9e5c59 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/nls/Messages.properties
@@ -8,6 +8,27 @@
# Wind River Systems - initial API and implementation
###############################################################################
+BlockingFileSystemProxy_TimeoutOpeningFile=Timeout while opening the file ''{0}''.
+BlockingFileSystemProxy_TimeoutClosingFile=Timeout while closing the handle ''{0}''.
+BlockingFileSystemProxy_TimeoutReadingFile=Timeout while reading the handle ''{0}''.
+BlockingFileSystemProxy_TimeoutWritingFile=Timeout while writing the handle ''{0}''.
+BlockingFileSystemProxy_TimeoutStat=Timeout while getting the stat of ''{0}''.
+BlockingFileSystemProxy_TimeoutLstat=Timeout while getting the lstat of ''{0}''.
+BlockingFileSystemProxy_TimeoutFstat=Timeout while getting the fstat of ''{0}''.
+BlockingFileSystemProxy_TimeoutSetStat=Timeout while setting the stat of ''{0}''.
+BlockingFileSystemProxy_TimeoutFSetStat=Timeout while setting the fstat of ''{0}''.
+BlockingFileSystemProxy_TimeoutOpeningDir=Timeout while opening the directory ''{0}''.
+BlockingFileSystemProxy_TimeoutReadingDir=Timeout while reading the directory ''{0}''.
+BlockingFileSystemProxy_TimeoutMakingDir=Timeout while making the directory ''{0}''.
+BlockingFileSystemProxy_TimeoutRemovingDir=Timeout while removing the directory ''{0}''.
+BlockingFileSystemProxy_TimeoutListingRoots=Timeout while listing root directories.
+BlockingFileSystemProxy_TimeoutRemovingFile=Timeout while removing the file ''{0}''.
+BlockingFileSystemProxy_TimeoutGettingRealPath=Timeout while getting real path for ''{0}''.
+BlockingFileSystemProxy_TimeoutRenamingFile=Timeout while renaming the file from ''{0}'' to ''{1}''.
+BlockingFileSystemProxy_TimeoutReadingLink=Timeout while reading the link for ''{0}''.
+BlockingFileSystemProxy_TimeoutSymLink=Timeout while creating a link ''{0}'' for ''{1}''.
+BlockingFileSystemProxy_TimeoutCopying=Timeout while copying files from ''{0}'' to ''{1}''.
+BlockingFileSystemProxy_TimeoutGettingUser=Timeout while getting the user data.
FSTreeNodeContentProvider_rootNode_label=File System
FSTreeNode_TypeFile=File
FSTreeNode_TypeFileFolder=File Folder
@@ -23,6 +44,7 @@ Operation_CannotOpenDir=Cannot open directory {0} because {1}
Operation_CopyNOfFile=Copy ({0}) of {1}
Operation_CopyOfFile=Copy of {0}
Operation_CannotCreateDirectory=Cannot create the directory {0} because: {1}
+Operation_TimeoutOpeningChannel=Timeout while opening a channel\!
OpCopy_Copying=Copying {0} ...
OpCopy_CannotCopyFile=Cannot copy file {0} because: {1}
@@ -75,4 +97,4 @@ TcfURLStreamHandlerService_OnlyDiskPartError=A Windows path should not contain o
CacheManager_MkdirFailed=Making directory {0} failed
-FileTransferService_error_mkdirFailed=Failed to create directory structure to {0}.
+FileTransferService_error_mkdirFailed=Failed to create directory structure to {0}. \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
index 7bed5703c..160cf70ed 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.core/src/org/eclipse/tcf/te/tcf/filesystem/core/services/FileTransferService.java
@@ -17,7 +17,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.net.ConnectException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
@@ -30,7 +29,6 @@ import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.protocol.IChannel;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.IToken;
-import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.services.IFileSystem;
import org.eclipse.tcf.services.IFileSystem.FileAttrs;
import org.eclipse.tcf.services.IFileSystem.FileSystemException;
@@ -40,10 +38,8 @@ import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransfer
import org.eclipse.tcf.te.runtime.utils.ProgressHelper;
import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.concurrent.BlockingCallProxy;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager.DoneOpenChannel;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.exceptions.TCFChannelException;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.Operation;
import org.eclipse.tcf.te.tcf.filesystem.core.nls.Messages;
import org.eclipse.tcf.util.TCFFileInputStream;
import org.eclipse.tcf.util.TCFFileOutputStream;
@@ -69,9 +65,9 @@ public class FileTransferService {
try {
if (channel == null) {
ownChannel = true;
- channel = openChannel(peer);
+ channel = Operation.openChannel(peer);
}
- fileSystem = getBlockingFileSystem(channel);
+ fileSystem = Operation.getBlockingFileSystem(channel);
Assert.isNotNull(fileSystem);
@@ -112,7 +108,7 @@ public class FileTransferService {
}
try {
- IChannel channel = openChannel(peer);
+ IChannel channel = Operation.openChannel(peer);
transfer(peer, channel, item, monitor, callback);
closeChannel(peer, channel);
}
@@ -376,40 +372,6 @@ public class FileTransferService {
}
/**
- * Open a channel for file transfer.
- * @param peer
- * @return
- * @throws TCFChannelException
- */
- protected static IChannel openChannel(final IPeer peer) throws TCFChannelException {
- IChannelManager proxy = BlockingCallProxy.newInstance(IChannelManager.class, Tcf.getChannelManager());
- final TCFChannelException[] errors = new TCFChannelException[1];
- final IChannel[] channels = new IChannel[1];
- proxy.openChannel(peer, null, new DoneOpenChannel() {
- @Override
- public void doneOpenChannel(Throwable error, IChannel channel) {
- if (error != null) {
- if (error instanceof ConnectException) {
- String message = NLS.bind(Messages.Operation_NotResponding, peer.getID());
- errors[0] = new TCFChannelException(IStatus.ERROR, message);
- }
- else {
- String message = NLS.bind(Messages.Operation_OpeningChannelFailureMessage, peer.getID(), error.getMessage());
- errors[0] = new TCFChannelException(IStatus.ERROR, message, error);
- }
- }
- else {
- channels[0] = channel;
- }
- }
- });
- if (errors[0] != null) {
- throw errors[0];
- }
- return channels[0];
- }
-
- /**
* Close the channel for file transfer.
* @param peer
* @param channel
@@ -417,28 +379,8 @@ public class FileTransferService {
*/
protected static void closeChannel(final IPeer peer, final IChannel channel) throws TCFChannelException {
if (channel != null) {
- IChannelManager proxy = BlockingCallProxy.newInstance(IChannelManager.class, Tcf.getChannelManager());
- proxy.closeChannel(channel);
- }
- }
-
- /**
- * Get a blocking file system.
- * @param channel
- * @return
- */
- protected static IFileSystem getBlockingFileSystem(final IChannel channel) {
- if(Protocol.isDispatchThread()) {
- IFileSystem service = channel.getRemoteService(IFileSystem.class);
- return BlockingCallProxy.newInstance(IFileSystem.class, service);
+ Tcf.getChannelManager().closeChannel(channel);
}
- final IFileSystem[] service = new IFileSystem[1];
- Protocol.invokeAndWait(new Runnable(){
- @Override
- public void run() {
- service[0] = getBlockingFileSystem(channel);
- }});
- return service[0];
}
private static String getProgressMessage(long bytesDone, long bytesTotal, long bytesSpeed) {

Back to the top