From: <bsc...@us...> - 2011-03-02 15:41:10
|
Revision: 9151 http://unicore.svn.sourceforge.net/unicore/?rev=9151&view=rev Author: bschuller Date: 2011-03-02 15:41:03 +0000 (Wed, 02 Mar 2011) Log Message: ----------- doc; other stuff Modified Paths: -------------- uftp/trunk/README.txt uftp/trunk/src/main/java/eu/unicore/uftp/client/UFTPClient.java uftp/trunk/src/main/java/eu/unicore/uftp/dpc/DPCServer.java uftp/trunk/src/main/java/eu/unicore/uftp/jparss/POutputStream.java uftp/trunk/src/main/java/eu/unicore/uftp/server/ConnectionThread.java uftp/trunk/src/main/java/eu/unicore/uftp/server/ServerThread.java uftp/trunk/src/main/java/eu/unicore/uftp/server/UFTPServer.java uftp/trunk/src/test/java/eu/unicore/uftp/dpc/TestFiletransferClientServerMultiStream.java Modified: uftp/trunk/README.txt =================================================================== --- uftp/trunk/README.txt 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/README.txt 2011-03-02 15:41:03 UTC (rev 9151) @@ -12,12 +12,78 @@ Thomas Jefferson National Accelerator Facility +The server part, called UFTPD listens on two ports (possibly on two +different network interfaces): + + - the command port receives control commands + + - the listen port accepts data connections from clients. + +To initiate a data transfer, + + - a request (a "job") is sent to the command port which notifies UFTPD of + an upcoming client request. The job contains the following information + - the client's IP address + - the source/target file name + - whether to send or receive data + - a "secret", i.e. a string the client will send to authenticate itself + - how many data connections will be openerd + - the user and group id for who to create the file (in case of send mode) + + - then, the UFTPD server will accept incoming connections from the announced IP + address and check the supplied secret. + + - if everything is OK, the requested number of data connections from the + client can be opened. Firewall transversal will be negotiated using a pseudo FTP + protocol. + + - the file is sent/received using the requested number of data connections + + Installation and use -------------------- -TODO +Prerequisites ++++++++++++++ + - Java 1.6 is required + - the server "listen" port needs to be accessible through your firewalls, declaring it + an "FTP" port. + + +Starting and stopping the UFTPD server +++++++++++++++++++++++++++++++++++++++ + +In the bin/ directory, start/stop and status scripts are provided. +The parameters such as server host/port, control host/port are +set in the start script. + +In a production scenario with multiple users, the uftpd server +needs to be started as root. This is necessary to be able to +set the correct file permissions. + + +Configuration paramenters ++++++++++++++++++++++++++ + +The following variables can be defined in the start script: + + SERVER : the interface where the server listens for client data + connections + + SERVER_PORT : the port where the server listens for client data + connections + + CMD : the interface where the server listens for control commands + + CMD_PORT : the port where the server listens for control commands + + +If possible, use an "internal" interface for the Command socket. If that +is not possible, make sure the Command socket is protected by a firewall! + + Further info ------------ Modified: uftp/trunk/src/main/java/eu/unicore/uftp/client/UFTPClient.java =================================================================== --- uftp/trunk/src/main/java/eu/unicore/uftp/client/UFTPClient.java 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/src/main/java/eu/unicore/uftp/client/UFTPClient.java 2011-03-02 15:41:03 UTC (rev 9151) @@ -128,18 +128,22 @@ if (reader != null) { reader.close(); } - } catch (IOException ignored) {} + } catch (IOException e) { + logger.warn("Error closing reader.", e); + } try { if (writer != null) { writer.close(); } - } catch (IOException ignored) {} + } catch (IOException e) { + logger.warn("Error closing writer.", e); + } try { client.close(); } catch (IOException e) { - //Fehler beim Schliessen. Ignorieren. + logger.warn("Error closing DPC client.", e); } } Modified: uftp/trunk/src/main/java/eu/unicore/uftp/dpc/DPCServer.java =================================================================== --- uftp/trunk/src/main/java/eu/unicore/uftp/dpc/DPCServer.java 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/src/main/java/eu/unicore/uftp/dpc/DPCServer.java 2011-03-02 15:41:03 UTC (rev 9151) @@ -35,9 +35,15 @@ * String-Array holding response messages used to * establish the pseudo-FTP connection */ - protected static final String[] responses = {"220 (" + VER + ")\r\n", "331 Please specify the password\r\n", - "230 Login successful\r\n", "215 Unix Type: L8\r\n", - "211 Features:\r\n", "PASV\r\n", "211 END\r\n"}; + protected static final String[] responses = { + "220 (" + VER + ")\r\n", + "331 Please specify the password\r\n", + "230 Login successful\r\n", + "215 Unix Type: L8\r\n", + "211 Features:\r\n", + "PASV\r\n", + "211 END\r\n" + }; /** @@ -290,7 +296,7 @@ /** * close all data and control sockets * - * @throws IOException: Wenn ein Fehler beim Schliessen der Sockets auftritt. + * @throws IOException */ public void close() throws IOException { closeData(); Modified: uftp/trunk/src/main/java/eu/unicore/uftp/jparss/POutputStream.java =================================================================== --- uftp/trunk/src/main/java/eu/unicore/uftp/jparss/POutputStream.java 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/src/main/java/eu/unicore/uftp/jparss/POutputStream.java 2011-03-02 15:41:03 UTC (rev 9151) @@ -76,7 +76,6 @@ if (PConfig.usethreads == true) { Thread worker = null; - writers_ = new PWriter[outputs_.length]; for (i = 0; i < outputs_.length; i++) { writers_[i] = new PWriter(this, outputs_[i], i, outputs_.length); @@ -274,7 +273,7 @@ else tlen = chunk; - //if (PConfig.debug == true) + if (PConfig.debug == true) System.out.println("Writer " + String.valueOf(i) + " writes from " + String.valueOf(toffset) + " with " + String.valueOf(tlen) + " bytes"); Modified: uftp/trunk/src/main/java/eu/unicore/uftp/server/ConnectionThread.java =================================================================== --- uftp/trunk/src/main/java/eu/unicore/uftp/server/ConnectionThread.java 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/src/main/java/eu/unicore/uftp/server/ConnectionThread.java 2011-03-02 15:41:03 UTC (rev 9151) @@ -6,7 +6,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.InetAddress; import java.net.Socket; import org.apache.log4j.Logger; @@ -88,7 +87,7 @@ reader.close(); } } catch (IOException e) { - //Fehler beim Schliessen. Ignorieren. + logger.warn("Error closing reader", e); } try { @@ -96,13 +95,13 @@ writer.close(); } } catch (IOException e) { - //Fehler beim Schliessen. Ignorieren. + logger.warn("Error closing writer", e); } try { connection.close(); } catch (IOException e) { - //Fehler beim Schliessen. Ignorieren. + logger.warn("Error closing connection.", e); } } @@ -119,12 +118,15 @@ String chmod="chmod 600 "+file.getAbsolutePath(); Process p=Runtime.getRuntime().exec(chmod); - p.waitFor(); + int exit=p.waitFor(); + logger.info("Executed "+chmod+" exit code="+exit); String group=job.getGroup(); - String chown=group!=null?"chown "+user+":"+group + " "+file.getAbsolutePath() - : "chown "+user+" "+file.getAbsolutePath(); + String chown=(group!=null && !"null".equals(group)) ? + "chown "+user+":"+group + " "+file.getAbsolutePath() : + "chown "+user+":"+"OWNER"+file.getAbsolutePath(); Process p2=Runtime.getRuntime().exec(chown); - p2.waitFor(); + exit=p2.waitFor(); + logger.info("Executed "+chown+" exit code="+exit); } protected Socket makeSocket(int n, Connection connection)throws Exception{ @@ -134,9 +136,7 @@ logger.info("Creating parallel socket with "+n+" streams." ); Socket[] dataCons = connection.openDataConnections(n); PSocket parallelSocket = new PSocket(); - parallelSocket.init(1, dataCons.length); //(ID, numCons) - - //Verbindungen zu parallelSocket hinzufuegen + parallelSocket.init(1, dataCons.length); for (int i = 0; i < dataCons.length; i++) { parallelSocket.addSocketStream(dataCons[i]); } @@ -149,22 +149,10 @@ } /** - * Gibt den zur Verbindung gehoerenden Job zurueck. - * - * @return: zur Verbindung gehoerender Job + * returns the {@link Job} for this connection */ public Job getJob() { return job; } - - /** - * Gibt die IP-Adresse des Clients zurueck. - * - * @return: IP-Adresse des Clients - */ - public InetAddress getAddress() { - return connection.getAddress(); - } - } Modified: uftp/trunk/src/main/java/eu/unicore/uftp/server/ServerThread.java =================================================================== --- uftp/trunk/src/main/java/eu/unicore/uftp/server/ServerThread.java 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/src/main/java/eu/unicore/uftp/server/ServerThread.java 2011-03-02 15:41:03 UTC (rev 9151) @@ -128,6 +128,7 @@ * @throws IOException: Wenn der DPPServer eine IOException beim Schliessen wirft (i.d.R. ein Socket-Problem) */ public void close() throws IOException { + logger.info("Closing UFTPD server"); halt(); server.close(); } Modified: uftp/trunk/src/main/java/eu/unicore/uftp/server/UFTPServer.java =================================================================== --- uftp/trunk/src/main/java/eu/unicore/uftp/server/UFTPServer.java 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/src/main/java/eu/unicore/uftp/server/UFTPServer.java 2011-03-02 15:41:03 UTC (rev 9151) @@ -141,8 +141,16 @@ */ public void stop(){ if(!stopped){ - if(svrThread!=null)svrThread.interrupt(); + if(svrThread!=null){ + try{ + svrThread.close(); + }catch(Exception ex){ + logger.error("Error stopping",ex); + } + svrThread.interrupt(); + } stopped=true; + } } Modified: uftp/trunk/src/test/java/eu/unicore/uftp/dpc/TestFiletransferClientServerMultiStream.java =================================================================== --- uftp/trunk/src/test/java/eu/unicore/uftp/dpc/TestFiletransferClientServerMultiStream.java 2011-03-02 11:54:29 UTC (rev 9150) +++ uftp/trunk/src/test/java/eu/unicore/uftp/dpc/TestFiletransferClientServerMultiStream.java 2011-03-02 15:41:03 UTC (rev 9151) @@ -48,17 +48,20 @@ client.setSecret("secretCode"); client.setNumConnections(2); client.run(); - + System.out.println("Finished client."); // check that file exists and has correct content File targetFile = new File(target); assertTrue(targetFile.exists()); String expected = Utils.md5(sourceFile); String actual = Utils.md5(targetFile); assertEquals("File contents do not match", expected, actual); + System.out.println("Stopping Server."); + server.stop(); } - + + UFTPServer server ; private void startServer() throws Exception { - UFTPServer server = new UFTPServer(host, jobPort, host, srvPort); + server = new UFTPServer(host, jobPort, host, srvPort); Thread serverThread = new Thread(server); serverThread.start(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |