Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 165409 | Differences between
and this patch

Collapse All | Expand All

(-)src-core/org/eclipse/hyades/internal/execution/core/file/dynamic/DetermineServerReachCommand.java (-5 / +7 lines)
Lines 14-20 Link Here
14
14
15
import java.io.IOException;
15
import java.io.IOException;
16
import java.net.InetSocketAddress;
16
import java.net.InetSocketAddress;
17
import java.nio.channels.SocketChannel;
17
import java.net.Socket;
18
18
19
import org.eclipse.hyades.internal.execution.core.file.socket.ISocketChannel;
19
import org.eclipse.hyades.internal.execution.core.file.socket.ISocketChannel;
20
20
Lines 111-121 Link Here
111
					&& DetermineServerReachCommand.this.port >= 0) {
111
					&& DetermineServerReachCommand.this.port >= 0) {
112
112
113
				try {
113
				try {
114
					SocketChannel sc = SocketChannel.open(new InetSocketAddress(
114
					
115
							DetermineServerReachCommand.this.host,
115
					// This was changed from NIO to IO, because NIO doesn't support IPv6 at the moment.
116
							DetermineServerReachCommand.this.port));
116
					Socket s = new Socket(DetermineServerReachCommand.this.host,
117
							DetermineServerReachCommand.this.port);
118
					
117
					DetermineServerReachCommand.this.isHostReachable = true;
119
					DetermineServerReachCommand.this.isHostReachable = true;
118
					sc.close();  /* bugzilla_152351: Socket should be closed on a successful connection */
120
					s.close();  /* bugzilla_152351: Socket should be closed on a successful connection */
119
				} catch (Throwable t) {
121
				} catch (Throwable t) {
120
122
121
					/*
123
					/*
(-)src-local/org/eclipse/hyades/internal/execution/file/FileServerExtended.java (-20 / +40 lines)
Lines 15-20 Link Here
15
import java.io.IOException;
15
import java.io.IOException;
16
import java.net.BindException;
16
import java.net.BindException;
17
import java.net.InetSocketAddress;
17
import java.net.InetSocketAddress;
18
import java.net.ServerSocket;
19
import java.net.Socket;
18
import java.nio.channels.ServerSocketChannel;
20
import java.nio.channels.ServerSocketChannel;
19
import java.nio.channels.SocketChannel;
21
import java.nio.channels.SocketChannel;
20
22
Lines 67-73 Link Here
67
	 * in typical use via the agent controller it is a singleton in practice,
69
	 * in typical use via the agent controller it is a singleton in practice,
68
	 * every instance must have its own unique port to accept connections on
70
	 * every instance must have its own unique port to accept connections on
69
	 */
71
	 */
70
	private ServerSocketChannel serverSocket;
72
//	private ServerSocketChannel serverSocketChannel;
73
	
74
	private ServerSocket serverSocket;
75
	
71
76
72
	/**
77
	/**
73
	 * The file server status
78
	 * The file server status
Lines 102-109 Link Here
102
	 */
107
	 */
103
	private void cleanup() {
108
	private void cleanup() {
104
		try {
109
		try {
110
105
			this.serverSocket.close();
111
			this.serverSocket.close();
106
			this.serverSocket = null;
112
			serverSocket = null;
113
			
114
//			this.serverSocketChannel.close();
115
//			this.serverSocketChannel = null;
107
			this.parameters = null;
116
			this.parameters = null;
108
		} catch (IOException e) {
117
		} catch (IOException e) {
109
			//
118
			//
Lines 209-224 Link Here
209
				// Continue to hold lock until initialized, then notify waiters
218
				// Continue to hold lock until initialized, then notify waiters
210
				synchronized (this) {
219
				synchronized (this) {
211
220
212
					// Establish file server using a java.nio server channel
221
					initServerSocket();
213
					this.serverSocket = ServerSocketChannel.open();
214
					this.serverSocket.configureBlocking(true);
215
216
					// Set server socket timeout and bind to port
217
					this.serverSocket.socket().setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
218
					this.serverSocket.socket().bind(new InetSocketAddress(this.getPort()));
219
220
					// Store the file server port to be used for the file server
221
					FileServer.setServerPort(this.serverSocket.socket().getLocalPort());
222
222
223
					// Change state to initialized and notify any waiters
223
					// Change state to initialized and notify any waiters
224
					this.initStatus = FileServiceConstants.RA_FS_INITIALIZED;
224
					this.initStatus = FileServiceConstants.RA_FS_INITIALIZED;
Lines 240-258 Link Here
240
				while (!this.shutdown) {
240
				while (!this.shutdown) {
241
241
242
					// Output debug output
242
					// Output debug output
243
					FileSystemServices.println(NLS.bind(LocalResourceBundle.FileServerExtended_EXTENDED_FILE_SERVER_LISTENING_, String.valueOf(this.getPort())),
243
					FileSystemServices.println(NLS.bind(LocalResourceBundle.FileServerExtended_EXTENDED_FILE_SERVER_LISTENING_, String.valueOf(this.getPort())), this);
244
							this);
245
244
246
					// Block until connection is requested on known port
245
					// Block until connection is requested on known port
247
					SocketChannel clientChannel = this.serverSocket.accept();
246
					Socket s = this.serverSocket.accept();
248
247
249
					// Set socket timeout to avoid blocking forever
248
					// Set socket timeout to avoid blocking forever
250
					clientChannel.socket().setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
249
					s.setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
251
					clientChannel.socket().setTcpNoDelay(true);
250
					s.setTcpNoDelay(true);
252
251
253
					// Take newly connected socket to client and send to handler
252
					// Take newly connected socket to client and send to handler
254
					IConnectionHandler handler = (IConnectionHandler) this.parameters.getConnectionHandler();
253
					IConnectionHandler handler = (IConnectionHandler) this.parameters.getConnectionHandler();
255
					handler.connectionAccepted(SocketChannelFactory.getInstance().create(clientChannel));
254
					handler.connectionAccepted(SocketChannelFactory.getInstance().create(s));
256
255
257
				}
256
				}
258
257
Lines 287-295 Link Here
287
286
288
			// Clean-up resources appropriately
287
			// Clean-up resources appropriately
289
			this.cleanup();
288
			this.cleanup();
290
289
			
291
		}
290
		}
292
293
	}
291
	}
292
	
293
	private void initServerSocket() throws IOException {
294
		
295
		this.serverSocket = new ServerSocket(this.getPort());
296
				
297
		FileServer.setServerPort(this.serverSocket.getLocalPort());
298
	}
299
	
300
//	private void oldInitIpv4SocketChannel() throws IOException {
301
//		
302
//		// Establish file server using a java.nio server channel
303
//		this.serverSocketChannel = ServerSocketChannel.open();
304
//		this.serverSocketChannel.configureBlocking(true);
305
//
306
//		// Set server socket timeout and bind to port
307
//		this.serverSocketChannel.socket().setSoTimeout(DEFAULT_SOCKET_TIMEOUT);
308
//		this.serverSocketChannel.socket().bind(new InetSocketAddress(this.getPort()));
309
//
310
//		// Store the file server port to be used for the file server
311
//		FileServer.setServerPort(this.serverSocketChannel.socket().getLocalPort());
312
//		
313
//	}
294
314
295
}
315
}
(-)src-core/org/eclipse/hyades/internal/execution/core/file/socket/SocketChannelFactory.java (+12 lines)
Lines 68-73 Link Here
68
	 */
68
	 */
69
	public ISocketChannel create(InetSocketAddress address, int timeout)
69
	public ISocketChannel create(InetSocketAddress address, int timeout)
70
			throws IOException {
70
			throws IOException {
71
		
72
		if(address.getAddress().getAddress().length == 16) {
73
			Socket s = new Socket(address.getAddress(), address.getPort());
74
			
75
			s.setSoTimeout(timeout);
76
			s.setTcpNoDelay(true);
77
			s.setReuseAddress(true);
78
			
79
			return new SocketChannel(s);
80
			
81
		}
82
		
71
		java.nio.channels.SocketChannel socketChannel = java.nio.channels.SocketChannel
83
		java.nio.channels.SocketChannel socketChannel = java.nio.channels.SocketChannel
72
				.open();
84
				.open();
73
		socketChannel.configureBlocking(true);
85
		socketChannel.configureBlocking(true);
(-)src-local/org/eclipse/hyades/internal/execution/local/common/Console.java (-2 / +11 lines)
Lines 211-218 Link Here
211
		try {
211
		try {
212
			IFileManagerExtended fileManager = FileManagerFactory.getInstance()
212
			IFileManagerExtended fileManager = FileManagerFactory.getInstance()
213
					.create(this._node.getConnection());
213
					.create(this._node.getConnection());
214
			serverCanReach = fileManager.determineServerReach(localHost
214
215
					.getHostAddress(), (int) this._port);
215
			String hostname = null;
216
			try {
217
				hostname = InetAddress.getLocalHost().getCanonicalHostName();
218
			} catch (UnknownHostException e) { }
219
			
220
			if(hostname == null) {
221
				hostname = localHost.getHostAddress();
222
			}
223
			
224
			serverCanReach = fileManager.determineServerReach(hostname, (int) this._port);
216
		} catch (ServerNotAvailableException e) {
225
		} catch (ServerNotAvailableException e) {
217
			e.printStackTrace();
226
			e.printStackTrace();
218
		}
227
		}

Return to bug 165409