r29 - in trunk: . diswork-fs diswork-fs/src/main/java/org/nuiton/disworkfs diswork-fs/src/main/java/org/nuiton/disworkfs/messages diswork-fs/src/main/java/org/nuiton/disworkfs/services diswork-fs/src/main/java/org/nuiton/disworkfs/split diswork-fs/src/main/java/org/nuiton/disworkfs/transport diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups diswork-fs/src/main/java/org/nuiton/disworkfs/util diswork-fs/src/main/resources diswork-fs/src/test/java/org/nuiton/disworkfs diswork-fs
Author: bleny Date: 2010-05-10 11:30:32 +0200 (Mon, 10 May 2010) New Revision: 29 Url: http://nuiton.org/repositories/revision/diswork/29 Log: menage, exceptions, conventions Modified: trunk/diswork-fs/pom.xml trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DistributedFileSystem.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkConfig.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkFileSystem.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileRequestMessage.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileTransferMessage.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpMessage.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpResponseMessage.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/AbstractDisworkService.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DisworkServicesManager.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DownloadService.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/LookUpService.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/UploadService.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileChunk.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileDescription.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromChunks.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromLocalFile.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Address.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Message.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Receiver.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Transport.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsAddress.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsMessage.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsTransport.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/DownloadObserver.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/LookUpObserver.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleDownload.java trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleLookUp.java trunk/diswork-fs/src/main/resources/log4j.properties trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromChunksTest.java trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromLocalFileTest.java trunk/pom.xml Modified: trunk/diswork-fs/pom.xml =================================================================== --- trunk/diswork-fs/pom.xml 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/pom.xml 2010-05-10 09:30:32 UTC (rev 29) @@ -18,42 +18,31 @@ <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> - <version>1.1.1</version> - <scope>compile</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> - <version>1.2.14</version> - <scope>test</scope> </dependency> <dependency> <groupId>jgroups</groupId> <artifactId>jgroups</artifactId> - <version>2.9.0.GA</version> - <scope>compile</scope> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> - <version>1.4</version> - <type>jar</type> - <scope>compile</scope> </dependency> <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> - <version>2.5</version> - <type>jar</type> - <scope>compile</scope> </dependency> <dependency> <groupId>org.nuiton</groupId> <artifactId>nuiton-utils</artifactId> - <version>1.2.2</version> - <type>jar</type> - <scope>compile</scope> </dependency> + <dependency> + <groupId>fr.inria.peerunit</groupId> + <artifactId>PeerUnit</artifactId> + </dependency> <!-- test --> <dependency> @@ -63,13 +52,6 @@ <type>jar</type> <scope>test</scope> </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> - <version>1.8.4</version> - <type>jar</type> - <scope>test</scope> - </dependency> </dependencies> <build> <plugins> Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DistributedFileSystem.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DistributedFileSystem.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DistributedFileSystem.java 2010-05-10 09:30:32 UTC (rev 29) @@ -1,39 +1,53 @@ package org.nuiton.disworkfs; -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.io.InputStream; public interface DistributedFileSystem { - - /** - * checks the existence of a file on the virtual FS - * @param path a path to a file on the virtual FS - * @return true if the file exists, false if not - * @throws InterruptedException - */ - public boolean exists(String path) throws InterruptedException; - - /** - * write a file - * @param path path of the virtual FS where the file should be written - * @param source the file to copy on the VFS - * @throws IOException if problems occurs while reading the source or writing on VFS - * @throws InterruptedException - */ - public void write(String path, File source) throws IOException, InterruptedException; - - /** - * read a file on the VFS, the file is downloaded if needed (may take some times) - * @param path the path in the virtual FS to the file you want to read - * @return ?? - * @throws FileNotFoundException if no file have been written to this path (you may use {@link #exists(String) to check before read} - * @throws IOException if a problem occur while reading the local file - * @throws InterruptedException - */ - public File read(String path) throws FileNotFoundException, IOException, InterruptedException; - - public void remove(String path); - // TODO list a directory content + /** + * checks the existence of a file on the virtual FS + * + * @param path + * a path to a file on the virtual FS + * @return true if the file exists, false if not + * @throws InterruptedException + */ + public boolean exists(String path) throws InterruptedException; + + /** + * write a file + * + * @param path + * path of the virtual FS where the file should be written + * @param source + * the file to copy on the VFS + * @throws IOException + * if problems occurs while reading the source or writing on VFS + * @throws InterruptedException + */ + public void write(String path, InputStream source) throws IOException, + InterruptedException; + + /** + * read a file on the VFS, the file is downloaded if needed (may take some + * times) + * + * @param path + * the path in the virtual FS to the file you want to read + * @return ?? + * @throws FileNotFoundException + * if no file have been written to this path (you may use + * {@link #exists(String) to check before read} + * @throws IOException + * if a problem occur while reading the local file + * @throws InterruptedException + */ + public InputStream read(String path) throws FileNotFoundException, + IOException, InterruptedException; + + public void remove(String path); + + // TODO bleny 2010-05-10 list a directory content } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkConfig.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkConfig.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkConfig.java 2010-05-10 09:30:32 UTC (rev 29) @@ -7,19 +7,19 @@ public class DisworkConfig extends ApplicationConfig { - public DisworkConfig() { - Random random = new Random(); + public DisworkConfig() { + Random random = new Random(); setDefaultOption("storage", "/tmp/disworkfs/storage" + random.nextInt()); setDefaultOption("jgroups.cluster_name", "diswork-fs"); - + // replication strategy... - } - - public File getStoragePath() { - return getOptionAsFile("storage"); - } - - public String getJGroupsClusterName() { - return getOption("jgroups.cluster_name"); - } + } + + public File getStoragePath() { + return getOptionAsFile("storage"); + } + + public String getJGroupsClusterName() { + return getOption("jgroups.cluster_name"); + } } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkFileSystem.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkFileSystem.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkFileSystem.java 2010-05-10 09:30:32 UTC (rev 29) @@ -1,9 +1,15 @@ package org.nuiton.disworkfs; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.disworkfs.services.DisworkServicesManager; @@ -13,99 +19,127 @@ import org.nuiton.disworkfs.split.FileDescription; import org.nuiton.disworkfs.util.SimpleDownload; import org.nuiton.disworkfs.util.SimpleLookUp; -import org.nuiton.util.FileUtil; import sun.reflect.generics.reflectiveObjects.NotImplementedException; public class DisworkFileSystem implements DistributedFileSystem { - protected DownloadService downloadService; - protected UploadService uploadService; - protected LookUpService lookUpService; - protected DisworkConfig disworkConfig; - protected DisworkServicesManager disworkServicesManager; - - private static final Log log = LogFactory.getLog(DisworkFileSystem.class); - - public DisworkFileSystem(DisworkConfig disworkConfig) { + protected DownloadService downloadService; + protected UploadService uploadService; + protected LookUpService lookUpService; + protected DisworkConfig disworkConfig; + protected DisworkServicesManager disworkServicesManager; - this.disworkConfig = disworkConfig; + private static final Log log = LogFactory.getLog(DisworkFileSystem.class); - disworkServicesManager = new DisworkServicesManager(disworkConfig); - uploadService = new UploadService(); - disworkServicesManager.register(uploadService); - downloadService = new DownloadService(); - disworkServicesManager.register(downloadService); - lookUpService = new LookUpService(); - disworkServicesManager.register(lookUpService); + public DisworkFileSystem(DisworkConfig disworkConfig) { - } + this.disworkConfig = disworkConfig; - @Override - public File read(String path) throws InterruptedException, FileNotFoundException { - - log.info("trying to read " + path); - - File file = new File(disworkConfig.getStoragePath(), path); - log.info("trying at local file system " + file.getAbsolutePath()); + disworkServicesManager = new DisworkServicesManager(disworkConfig); + uploadService = new UploadService(); + disworkServicesManager.register(uploadService); + downloadService = new DownloadService(); + disworkServicesManager.register(downloadService); + lookUpService = new LookUpService(); + disworkServicesManager.register(lookUpService); - if (!file.exists()) { - // the file is not available - // let's download it + } - SimpleDownload simpleDownload = new SimpleDownload(path, lookUpService, downloadService); - boolean fileFound = simpleDownload.initiateDownload(); - if (fileFound) - simpleDownload.startDownload(); - else - throw new FileNotFoundException("no look-up response received"); - - } - - // FIXME - return null; - } + @Override + public InputStream read(String path) throws InterruptedException, + FileNotFoundException { - @Override - public void write(String path, File source) throws IOException, InterruptedException { - - File target = new File(disworkConfig.getStoragePath(), path); - - if (target.exists()) { - throw new IOException(target.getAbsolutePath() + " already exists"); - } - - if (this.exists(path)) { - throw new IOException(target.getAbsolutePath() + " already exists"); - } - - FileUtil.copy(source, target); - } + log.info("trying to read " + path); - @Override - public boolean exists(String path) throws InterruptedException { + File file = new File(disworkConfig.getStoragePath(), path); + log.info("trying at local file system " + file.getAbsolutePath()); - File file = new File(disworkConfig.getStoragePath(), path); - boolean fileExists = false; - - if (file.exists()) { - fileExists = true; - } else { - SimpleLookUp simpleLookUp = new SimpleLookUp(path, lookUpService); - FileDescription lookUpResult = simpleLookUp.runLookUp(); - fileExists = (lookUpResult != null); - } - - return fileExists; - } + if (!file.exists()) { + // the file is not available + // let's download it - @Override - public void remove(String path) { - throw new NotImplementedException(); - } + SimpleDownload simpleDownload = new SimpleDownload(path, + lookUpService, downloadService); + boolean fileFound = simpleDownload.initiateDownload(); + if (fileFound) + simpleDownload.startDownload(); + else + throw new FileNotFoundException("no look-up response received"); - public void close() { - disworkServicesManager.stop(); - } - + } + + return new BufferedInputStream(new FileInputStream(file)); + } + + @Override + public void write(String path, InputStream source) throws IOException, + InterruptedException { + + File target = new File(disworkConfig.getStoragePath(), path); + + // first, check if the already exists locally... + if (target.exists()) { + throw new IOException(target.getAbsolutePath() + " already exists"); + } + + // ... or on another node + if (this.exists(path)) { + throw new IOException(target.getAbsolutePath() + " already exists"); + } + + // the file does not exists, we can write it + // first, prepare all directories and file + target.getParentFile().mkdirs(); + target.createNewFile(); + + // copying data from given source on the virtual FS + BufferedInputStream bufferedSource = null; + BufferedOutputStream bufferedTarget = null; + + // FIXME bleny 2010-05-07 use buffered input stream ? + // FIXME bleny 2010-05-07 close 2 times when new... new ??? + + try { + bufferedSource = new BufferedInputStream(source); + bufferedTarget = new BufferedOutputStream(new FileOutputStream( + target)); + IOUtils.copy(bufferedSource, bufferedTarget); + } finally { + IOUtils.closeQuietly(bufferedSource); + IOUtils.closeQuietly(bufferedTarget); + } + + } + + @Override + public boolean exists(String path) throws InterruptedException { + + File file = new File(disworkConfig.getStoragePath(), path); + boolean fileExists = false; + + // first, check file exists locally + if (file.exists()) { + // the file is stored on the local FS + fileExists = true; + } else { + // the file is not on the local FS, + // let's check on other nodes + SimpleLookUp simpleLookUp = new SimpleLookUp(path, lookUpService); + FileDescription lookUpResult = simpleLookUp.runLookUp(); + fileExists = (lookUpResult != null); + } + + return fileExists; + } + + @Override + public void remove(String path) { + throw new NotImplementedException(); + } + + public void close() { + disworkServicesManager.stop(); + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileRequestMessage.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileRequestMessage.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileRequestMessage.java 2010-05-10 09:30:32 UTC (rev 29) @@ -5,17 +5,17 @@ import org.nuiton.disworkfs.split.FileDescription; public class FileRequestMessage implements Serializable { - + /** * */ private static final long serialVersionUID = 7208155655482510721L; private FileDescription fileDescription; - + public FileRequestMessage(FileDescription fileDescription) { this.fileDescription = fileDescription; } - + public FileDescription getfileDescription() { return this.fileDescription; } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileTransferMessage.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileTransferMessage.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/FileTransferMessage.java 2010-05-10 09:30:32 UTC (rev 29) @@ -6,7 +6,7 @@ import org.nuiton.disworkfs.split.FileDescription; public class FileTransferMessage implements Serializable { - + /** * */ @@ -14,18 +14,18 @@ private FileChunk fileChunk; private FileDescription fileDescription; - public FileTransferMessage(FileChunk fileChunk, FileDescription fileDescription) { - this.fileChunk = fileChunk; - this.fileDescription = fileDescription; - } - + public FileTransferMessage(FileChunk fileChunk, + FileDescription fileDescription) { + this.fileChunk = fileChunk; + this.fileDescription = fileDescription; + } + public FileChunk getFileChunk() { - return this.fileChunk; - } + return this.fileChunk; + } public FileDescription getFileDescrition() { return this.fileDescription; } - } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpMessage.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpMessage.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpMessage.java 2010-05-10 09:30:32 UTC (rev 29) @@ -3,17 +3,17 @@ import java.io.Serializable; public class LookUpMessage implements Serializable { - + /** * */ private static final long serialVersionUID = -1538199939808485195L; private String fileName; - + public LookUpMessage(String fileName) { this.fileName = fileName; } - + public String getFileName() { return this.fileName; } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpResponseMessage.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpResponseMessage.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/LookUpResponseMessage.java 2010-05-10 09:30:32 UTC (rev 29) @@ -5,15 +5,15 @@ import org.nuiton.disworkfs.split.FileDescription; public class LookUpResponseMessage implements Serializable { - + private static final long serialVersionUID = -8880348876968678210L; - + private FileDescription fileDescription; - + public LookUpResponseMessage(FileDescription fileDescription) { this.fileDescription = fileDescription; } - + public FileDescription getFileDescription() { return this.fileDescription; } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/AbstractDisworkService.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/AbstractDisworkService.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/AbstractDisworkService.java 2010-05-10 09:30:32 UTC (rev 29) @@ -17,56 +17,66 @@ public abstract class AbstractDisworkService implements Receiver, Runnable { // protected JChannel jChannel; - - protected Transport transport; - + + protected Transport transport; + protected DisworkConfig disworkConfig; - - private static final Log log = LogFactory.getLog(AbstractDisworkService.class); - public AbstractDisworkService() {} - - public AbstractDisworkService(Transport transport) { - this.transport = transport; - } - - @Override - public void receiveMessage(Message message) { + private static final Log log = LogFactory + .getLog(AbstractDisworkService.class); + + public AbstractDisworkService() { + } + + public AbstractDisworkService(Transport transport) { + this.transport = transport; + } + + @Override + public void receiveMessage(Message message) { try { - Serializable obj = message.getContent(); - if (obj instanceof LookUpMessage) { - receiveLookUpMessage(message); - } else if (obj instanceof LookUpResponseMessage) { - receiveLookUpResponseMessage(message); - } else if (obj instanceof FileRequestMessage) { - receiveFileRequestMessage(message); - } else if (obj instanceof FileTransferMessage) { - receiveFileTransferMessage(message); - } else { - log.error("unknow message received"); - } - } catch (IOException eee) { - log.error("IOException encoutered after receiving a message", eee); - } - } - - public void receiveLookUpMessage(Message msg) throws IOException {} - public void receiveLookUpResponseMessage(Message msg) {} - public void receiveFileRequestMessage(Message msg) throws IOException {} - public void receiveFileTransferMessage(Message msg) throws IOException {} - + Serializable obj = message.getContent(); + if (obj instanceof LookUpMessage) { + receiveLookUpMessage(message); + } else if (obj instanceof LookUpResponseMessage) { + receiveLookUpResponseMessage(message); + } else if (obj instanceof FileRequestMessage) { + receiveFileRequestMessage(message); + } else if (obj instanceof FileTransferMessage) { + receiveFileTransferMessage(message); + } else { + log.error("unknow message received"); + } + } catch (IOException eee) { + log.error("IOException encoutered after receiving a message", eee); + } + } + + public void receiveLookUpMessage(Message msg) throws IOException { + } + + public void receiveLookUpResponseMessage(Message msg) { + } + + public void receiveFileRequestMessage(Message msg) throws IOException { + } + + public void receiveFileTransferMessage(Message msg) throws IOException { + } + public void setTransport(Transport transport) { - this.transport = transport; + this.transport = transport; } - public void setDisworkConfig(DisworkConfig disworkConfig) { - this.disworkConfig = disworkConfig; - } + public void setDisworkConfig(DisworkConfig disworkConfig) { + this.disworkConfig = disworkConfig; + } - @Override - public void run() {} - - public void stop() {} - - + @Override + public void run() { + } + + public void stop() { + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DisworkServicesManager.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DisworkServicesManager.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DisworkServicesManager.java 2010-05-10 09:30:32 UTC (rev 29) @@ -10,61 +10,59 @@ import org.nuiton.disworkfs.transport.jgroups.JGroupsTransport; public class DisworkServicesManager implements Receiver { - + /** * all the running services */ private List<AbstractDisworkService> services = new ArrayList<AbstractDisworkService>(); - + protected Transport transport; - + private DisworkConfig disworkConfig; - + public DisworkServicesManager(DisworkConfig disworkConfig) { - this.disworkConfig = disworkConfig; - - transport = new JGroupsTransport(disworkConfig); - - transport.setReceiver(this); - + this.disworkConfig = disworkConfig; + + transport = new JGroupsTransport(disworkConfig); + + transport.setReceiver(this); + } - + public void register(AbstractDisworkService service) { - - // dependency injection, the service need a channel to send a message - // service.setJChannel(jChannel); - service.setTransport(transport); - // ... and the disworkConfig - service.setDisworkConfig(disworkConfig); - - // each service is run in his own thread - Thread thread = new Thread(service); - thread.start(); - - // add this service to the list of running services + + // dependency injection, the service need to send messages + service.setTransport(transport); + // ... and the disworkConfig + service.setDisworkConfig(disworkConfig); + + // each service is run in his own thread + Thread thread = new Thread(service); + thread.start(); + + // add this service to the list of running services services.add(service); } - + public void unRegister(AbstractDisworkService service) { services.remove(service); } - - @Override - public void receiveMessage(Message message) { + @Override + public void receiveMessage(Message message) { for (AbstractDisworkService service : services) { service.receiveMessage(message); } - } + } - /** - * this stop all the diswork services and close the - * ressources used by the transport layer - */ - public void stop() { + /** + * this stop all the diswork services and close the ressources used by the + * transport layer + */ + public void stop() { for (AbstractDisworkService service : services) { service.stop(); } transport.close(); - } + } } \ No newline at end of file Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DownloadService.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DownloadService.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/DownloadService.java 2010-05-10 09:30:32 UTC (rev 29) @@ -18,109 +18,118 @@ public class DownloadService extends AbstractDisworkService { - private Map<Long, SplitFileFromChunks> downloadsInProgress = new HashMap<Long, SplitFileFromChunks>(); + private Map<Long, SplitFileFromChunks> downloadsInProgress = new HashMap<Long, SplitFileFromChunks>(); - private List<Long> finishedDownloads = new LinkedList<Long>(); + private List<Long> finishedDownloads = new LinkedList<Long>(); - private Map<Long, List<DownloadObserver>> downloadObservers = new HashMap<Long, List<DownloadObserver>>(); + private Map<Long, List<DownloadObserver>> downloadObservers = new HashMap<Long, List<DownloadObserver>>(); - private static final Log log = LogFactory.getLog(DownloadService.class); + private static final Log log = LogFactory.getLog(DownloadService.class); - @Override - public void receiveFileTransferMessage(Message message) throws IOException { + @Override + public void receiveFileTransferMessage(Message message) throws IOException { - FileTransferMessage fileTransferMessage = (FileTransferMessage) message.getContent(); - FileDescription fileDescription = fileTransferMessage.getFileDescrition(); - - if (log.isDebugEnabled()) { - log.info("received file chunk " - + fileTransferMessage.getFileDescrition().getFileName() - + " chunk number " - + fileTransferMessage.getFileChunk().getChunkNumber() - + ")"); - } + FileTransferMessage fileTransferMessage = (FileTransferMessage) message + .getContent(); + FileDescription fileDescription = fileTransferMessage + .getFileDescrition(); - // Before do anything, check if we already have the complete file + if (log.isDebugEnabled()) { + log + .info("received file chunk " + + fileTransferMessage.getFileDescrition() + .getFileName() + + " chunk number " + + fileTransferMessage.getFileChunk() + .getChunkNumber() + ")"); + } - File newFile = new File(disworkConfig.getStoragePath(), fileDescription.getFileName()); - File newFileStatus = new File(disworkConfig.getStoragePath(), "." + fileDescription.getFileName() + ".index"); - - // file must exists, have the expected size and index should not exist - // TODO : use checksum ? - boolean alreadyHaveFile = newFile.exists() - && (newFile.length() == fileDescription.getTotalSize()) - && !newFileStatus.exists(); - - if (!alreadyHaveFile) { - Long checkSum = fileDescription.getFileCheckSum(); + // ignore message if already have finished the download + if (!finishedDownloads.contains(fileDescription.getFileCheckSum())) { + Long checkSum = fileDescription.getFileCheckSum(); - if (! downloadsInProgress.containsKey(checkSum)) { - // Start download + // this is the actual file we will write + File newFile = new File(disworkConfig.getStoragePath(), + fileDescription.getFileName()); - log.info("first chunk received, initiate download"); + if (!downloadsInProgress.containsKey(checkSum)) { + // Start download - SplitFileFromChunks newSplitFile = new SplitFileFromChunks(fileDescription, newFile); + log.info("first chunk received, initiate download"); - downloadsInProgress.put(checkSum, newSplitFile); - } + SplitFileFromChunks newSplitFile = new SplitFileFromChunks( + fileDescription, newFile); - // we have received a file chunk, let's add it - SplitFileFromChunks downloadingFile = downloadsInProgress.get(checkSum); + downloadsInProgress.put(checkSum, newSplitFile); + } - downloadingFile.addChunk(fileTransferMessage.getFileChunk()); - - // maybe the download is complete - if (downloadingFile.isComplete()) { - log.info("file " + newFile.getAbsolutePath() + " written"); + // we have received a file chunk, let's add it + SplitFileFromChunks downloadingFile = downloadsInProgress + .get(checkSum); - finishedDownloads.add(checkSum); - downloadsInProgress.remove(checkSum); + log.info("adding chunk " + + fileTransferMessage.getFileChunk().getChunkNumber()); - this.notifyAllDownloadObserversForFile(checkSum); - } - } - } + downloadingFile.addChunk(fileTransferMessage.getFileChunk()); - public void registerObserver(FileDescription fileDescription, DownloadObserver downloadObserver) { - List<DownloadObserver> observersList = downloadObservers.get(fileDescription.getFileCheckSum()); + // maybe the download is complete + if (downloadingFile.isComplete()) { + log.info("file " + newFile.getAbsolutePath() + " written"); - if (observersList == null) { - // it's the first observer for this download ever, let's construct a list - observersList = new LinkedList<DownloadObserver>(); - } - - observersList.add(downloadObserver); - downloadObservers.put(fileDescription.getFileCheckSum(), observersList); - } + finishedDownloads.add(checkSum); + downloadsInProgress.remove(checkSum); - private void notifyAllDownloadObserversForFile(Long checksum) { - List<DownloadObserver> downloadObserversForThisFile = downloadObservers.get(checksum); + this.notifyAllDownloadObserversForFile(checkSum); + } + } + } - // important check : maybe no observer for this file download - // so the list is null. - if (downloadObserversForThisFile != null) { + public void registerObserver(FileDescription fileDescription, + DownloadObserver downloadObserver) { + List<DownloadObserver> observersList = downloadObservers + .get(fileDescription.getFileCheckSum()); - for (DownloadObserver downloadObserver : downloadObserversForThisFile) { - downloadObserver.updateDownloadStatus(this); - } - } - } + if (observersList == null) { + // it's the first observer for this download ever, let's construct a + // list + observersList = new LinkedList<DownloadObserver>(); + } - public boolean isFinished(FileDescription fileDescription) { - boolean finished = finishedDownloads.contains(fileDescription.getFileCheckSum()); - return finished; - } + observersList.add(downloadObserver); + downloadObservers.put(fileDescription.getFileCheckSum(), observersList); + } + private void notifyAllDownloadObserversForFile(Long checksum) { + List<DownloadObserver> downloadObserversForThisFile = downloadObservers + .get(checksum); - public void startDownload(FileDescription fileDescription, DownloadObserver downloadObserver) { - Message message = transport.newMulticastMessage(); - message.setContent(new FileRequestMessage(fileDescription)); - message.send(); - - if (log.isDebugEnabled()) - log.info("sending file request for " + fileDescription.getFileName()); - - registerObserver(fileDescription, downloadObserver); - - } + // important check : maybe no observer for this file download + // so the list is null. + if (downloadObserversForThisFile != null) { + + for (DownloadObserver downloadObserver : downloadObserversForThisFile) { + downloadObserver.updateDownloadStatus(this); + } + } + } + + public boolean isFinished(FileDescription fileDescription) { + boolean finished = finishedDownloads.contains(fileDescription + .getFileCheckSum()); + return finished; + } + + public void startDownload(FileDescription fileDescription, + DownloadObserver downloadObserver) { + Message message = transport.newMulticastMessage(); + message.setContent(new FileRequestMessage(fileDescription)); + message.send(); + + if (log.isDebugEnabled()) + log.info("sending file request for " + + fileDescription.getFileName()); + + registerObserver(fileDescription, downloadObserver); + + } } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/LookUpService.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/LookUpService.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/LookUpService.java 2010-05-10 09:30:32 UTC (rev 29) @@ -1,6 +1,5 @@ package org.nuiton.disworkfs.services; - import java.util.HashMap; import java.util.Map; @@ -11,49 +10,53 @@ import org.nuiton.disworkfs.transport.Message; import org.nuiton.disworkfs.util.LookUpObserver; +public class LookUpService extends AbstractDisworkService { + /** + * this map store, for each request, the LookUpObserver to notify when the + * LookUpResponse is received + */ + Map<String, LookUpObserver> requestToRequester = new HashMap<String, LookUpObserver>(); -public class LookUpService extends AbstractDisworkService { - - /** - * this map store, for each request, the LookUpObserver to notify when - * the LookUpResponse is received - */ - Map<String, LookUpObserver> requestToRequester = new HashMap<String, LookUpObserver>(); - private static final Log log = LogFactory.getLog(LookUpService.class); /** * - * @param fileName the name of the file to search for - * @param lookUpObserver the object to notify when LookUpResponse have been sent back + * @param fileName + * the name of the file to search for + * @param lookUpObserver + * the object to notify when LookUpResponse have been sent back */ - public void lookForFileName(String fileName, LookUpObserver lookUpObserver) { - - LookUpMessage lookUpMessage = new LookUpMessage(fileName); - - Message message = transport.newMulticastMessage(); - message.setContent(lookUpMessage); - message.send(); - log.info("look-up message sent for " + fileName); - - // FIXME memory leak if multiple look-up on never-will-be-available files - requestToRequester.put(fileName, lookUpObserver); - } + public void lookForFileName(String fileName, LookUpObserver lookUpObserver) { - @Override - public void receiveLookUpResponseMessage(Message message) { + LookUpMessage lookUpMessage = new LookUpMessage(fileName); - LookUpResponseMessage lookUpResponse = (LookUpResponseMessage) message.getContent(); + Message message = transport.newMulticastMessage(); + message.setContent(lookUpMessage); + message.send(); + log.info("look-up message sent for " + fileName); - String requestedFileName = lookUpResponse.getFileDescription().getFileName(); + // FIXME bleny 2010-05-07 memory leak if multiple look-up on + // never-will-be-available files + requestToRequester.put(fileName, lookUpObserver); + } - if (requestToRequester.containsKey(requestedFileName)) { - LookUpObserver requester = requestToRequester.get(requestedFileName); - requester.receiveResult(lookUpResponse.getFileDescription()); - requestToRequester.remove(requestedFileName); - } + @Override + public void receiveLookUpResponseMessage(Message message) { - } + LookUpResponseMessage lookUpResponse = (LookUpResponseMessage) message + .getContent(); + String requestedFileName = lookUpResponse.getFileDescription() + .getFileName(); + + if (requestToRequester.containsKey(requestedFileName)) { + LookUpObserver requester = requestToRequester + .get(requestedFileName); + requester.receiveResult(lookUpResponse.getFileDescription()); + requestToRequester.remove(requestedFileName); + } + + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/UploadService.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/UploadService.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/UploadService.java 2010-05-10 09:30:32 UTC (rev 29) @@ -16,89 +16,106 @@ import org.nuiton.disworkfs.transport.Message; /** - * When receiving a FileRequest, sending the file - * When receiving a LookUp, sending a LookUpResponse if owning file on local FS + * When receiving a FileRequest, sending the file When receiving a LookUp, + * sending a LookUpResponse if owning file on local FS */ public class UploadService extends AbstractDisworkService { - private static final Log log = LogFactory.getLog(UploadService.class); + private static final Log log = LogFactory.getLog(UploadService.class); - @Override - public void receiveFileRequestMessage(Message message) throws IOException { - FileRequestMessage fileRequestMessage = (FileRequestMessage) message.getContent(); + @Override + public void receiveFileRequestMessage(Message message) throws IOException { + FileRequestMessage fileRequestMessage = (FileRequestMessage) message + .getContent(); - File file = new File(disworkConfig.getStoragePath(), fileRequestMessage.getfileDescription().getFileName()); + File file = new File(disworkConfig.getStoragePath(), fileRequestMessage + .getfileDescription().getFileName()); - if (log.isDebugEnabled()) - log.info("file request message received for " + fileRequestMessage.getfileDescription().getFileName()); + if (log.isDebugEnabled()) + log.info("file request message received for " + + fileRequestMessage.getfileDescription().getFileName()); - if (file.exists()) { + if (file.exists()) { - if (log.isDebugEnabled()) - log.info("file found in path " + file.getAbsolutePath()); + if (log.isDebugEnabled()) + log.info("file found in path " + file.getAbsolutePath()); - SplitFileFromLocalFile splitFileFromLocalFile = new SplitFileFromLocalFile(file); + SplitFileFromLocalFile splitFileFromLocalFile = new SplitFileFromLocalFile( + file); - FileDescription fileDescription = splitFileFromLocalFile.getFileDescription(); - fileDescription.setFileName(fileRequestMessage.getfileDescription().getFileName()); + FileDescription fileDescription = splitFileFromLocalFile + .getFileDescription(); + fileDescription.setFileName(fileRequestMessage.getfileDescription() + .getFileName()); - List<FileChunk> chunks = splitFileFromLocalFile.getAllChunks(); + List<FileChunk> chunks = splitFileFromLocalFile.getAllChunks(); - for (FileChunk fileChunk : chunks) { - Message reply = message.newReply(); + log.info("will send " + chunks.size() + " chunks"); - FileTransferMessage fileTransferMessage = new FileTransferMessage(fileChunk, fileDescription); + for (FileChunk fileChunk : chunks) { + Message reply = message.newReply(); - reply.setContent(fileTransferMessage); + FileTransferMessage fileTransferMessage = new FileTransferMessage( + fileChunk, fileDescription); - if (log.isDebugEnabled()) - log.info("sending chunk " + fileTransferMessage.getFileChunk().getChunkNumber()); + reply.setContent(fileTransferMessage); - reply.send(); + // if (true || log.isDebugEnabled()) + log.info("sending chunk " + + fileTransferMessage.getFileChunk().getChunkNumber()); - } + reply.send(); - if (log.isDebugEnabled()) - log.info("all chunks sent"); - } else { - if (log.isDebugEnabled()) - log.info("file not found in path " + file.getAbsolutePath() + " don't send response"); - } + } - } + if (log.isDebugEnabled()) + log.info("all chunks sent"); + } else { + if (log.isDebugEnabled()) + log.info("file not found in path " + file.getAbsolutePath() + + " don't send response"); + } - @Override - public void receiveLookUpMessage(Message message) throws IOException { - LookUpMessage lookUpMessage = (LookUpMessage) message.getContent(); + } - if (log.isDebugEnabled()) - log.info("lookup message received : looking for file " + lookUpMessage.getFileName()); + @Override + public void receiveLookUpMessage(Message message) throws IOException { + LookUpMessage lookUpMessage = (LookUpMessage) message.getContent(); - File file = new File(disworkConfig.getStoragePath(), lookUpMessage.getFileName()); + if (log.isDebugEnabled()) + log.info("lookup message received : looking for file " + + lookUpMessage.getFileName()); - if (file.exists()) { - if (log.isDebugEnabled()) - log.info(lookUpMessage.getFileName() + " file found at " + file.getAbsolutePath()); + File file = new File(disworkConfig.getStoragePath(), lookUpMessage + .getFileName()); - SplitFileFromLocalFile splitFileFromLocalFile = new SplitFileFromLocalFile(file); + if (file.exists()) { + if (log.isDebugEnabled()) + log.info(lookUpMessage.getFileName() + " file found at " + + file.getAbsolutePath()); + SplitFileFromLocalFile splitFileFromLocalFile = new SplitFileFromLocalFile( + file); - Message reply = message.newReply(); + Message reply = message.newReply(); - FileDescription fileDescription = splitFileFromLocalFile.getFileDescription(); + FileDescription fileDescription = splitFileFromLocalFile + .getFileDescription(); - fileDescription.setFileName(lookUpMessage.getFileName()); + fileDescription.setFileName(lookUpMessage.getFileName()); - reply.setContent(new LookUpResponseMessage(fileDescription)); + reply.setContent(new LookUpResponseMessage(fileDescription)); - if (log.isDebugEnabled()) - log.info("sending lookUpResponse response for " + lookUpMessage.getFileName()); + if (log.isDebugEnabled()) + log.info("sending lookUpResponse response for " + + lookUpMessage.getFileName()); - reply.send(); - } else { - if (log.isDebugEnabled()) - log.info(lookUpMessage.getFileName() + " file not found at " + file.getAbsolutePath() + " no response sent"); - } + reply.send(); + } else { + if (log.isDebugEnabled()) + log.info(lookUpMessage.getFileName() + " file not found at " + + file.getAbsolutePath() + " no response sent"); + } - } + } } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileChunk.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileChunk.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileChunk.java 2010-05-10 09:30:32 UTC (rev 29) @@ -4,54 +4,54 @@ public class FileChunk implements Serializable { - private static final long serialVersionUID = 9081850894548724600L; + private static final long serialVersionUID = 9081850894548724600L; - // FIXME dangerous : not final ! - public static int MAX_CHUNK_SIZE = 1024; + // FIXME bleny 2010-05-10 dangerous : not final ! + public static int MAX_CHUNK_SIZE = 1024; - private byte[] data = new byte[MAX_CHUNK_SIZE]; + private byte[] data = new byte[MAX_CHUNK_SIZE]; - private int chunkNumber; + private int chunkNumber; - private int chunkSize; + private int chunkSize; - public FileChunk(byte[] data) { - this.setData(data); - } + public FileChunk(byte[] data) { + this.setData(data); + } - public byte[] getData() { - return this.data; - } + public byte[] getData() { + return this.data; + } - public void setData(byte[] data) { - this.data = data; - } + public void setData(byte[] data) { + this.data = data; + } - public int getChunkNumber() { - return this.chunkNumber; - } + public int getChunkNumber() { + return this.chunkNumber; + } - public void setChunkNumber(int chunkNumber) { - this.chunkNumber = chunkNumber; - } + public void setChunkNumber(int chunkNumber) { + this.chunkNumber = chunkNumber; + } - public int getChunkSize() { - return this.chunkSize; - } + public int getChunkSize() { + return this.chunkSize; + } - public void setChunkSize(int chunkSize) { - this.chunkSize = chunkSize; - } + public void setChunkSize(int chunkSize) { + this.chunkSize = chunkSize; + } - public static int numberOfChunksNeededtoStore(long numberOfBytes) { - long numberOfChunks = numberOfBytes / MAX_CHUNK_SIZE; + public static int numberOfChunksNeededtoStore(long numberOfBytes) { + long numberOfChunks = numberOfBytes / MAX_CHUNK_SIZE; - if (numberOfBytes > numberOfChunks * MAX_CHUNK_SIZE) { - numberOfChunks += 1; - } + if (numberOfBytes > numberOfChunks * MAX_CHUNK_SIZE) { + numberOfChunks += 1; + } - // FIXME unsafe cast - return (int) numberOfChunks; - } + // FIXME bleny 2010-05-10 unsafe cast + return (int) numberOfChunks; + } } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileDescription.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileDescription.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/FileDescription.java 2010-05-10 09:30:32 UTC (rev 29) @@ -3,43 +3,37 @@ import java.io.Serializable; public class FileDescription implements Serializable { - + private static final long serialVersionUID = 1809101246917954092L; private String fileName; - private long totalSize; + private long totalSize; private long fileCheckSum; + public FileDescription(String fileName, long totalSize, long fileCheckSum) { + super(); + this.fileName = fileName; + this.totalSize = totalSize; + this.fileCheckSum = fileCheckSum; + } - public FileDescription(String fileName, long totalSize, long fileCheckSum) { - super(); - this.fileName = fileName; - this.totalSize = totalSize; - this.fileCheckSum = fileCheckSum; - } + public String getFileName() { + return fileName; + } + public long getTotalSize() { + return totalSize; + } - public String getFileName() { - return fileName; - } + public long getFileCheckSum() { + return fileCheckSum; + } + public int getNumberOfChunks() { + return FileChunk.numberOfChunksNeededtoStore(this.totalSize); + } - public long getTotalSize() { - return totalSize; - } - - - public long getFileCheckSum() { - return fileCheckSum; - } - - - public int getNumberOfChunks() { - return FileChunk.numberOfChunksNeededtoStore(this.totalSize); - } - public void setFileName(String fileName) { - this.fileName = fileName; - } - - + this.fileName = fileName; + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromChunks.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromChunks.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromChunks.java 2010-05-10 09:30:32 UTC (rev 29) @@ -17,90 +17,108 @@ public class SplitFileFromChunks { - protected FileDescription fileDescription; - protected File destination; - protected File chunkStatusFile; - - private Log log = LogFactory.getLog(SplitFileFromChunks.class); + protected FileDescription fileDescription; + protected File destination; + protected File chunkStatusFile; - public SplitFileFromChunks(FileDescription fileDescription, File destination) throws IOException { - this.fileDescription = fileDescription; - this.destination = destination; - this.chunkStatusFile = new File(destination.getParent(), "." + destination.getName() + ".index"); + private Log log = LogFactory.getLog(SplitFileFromChunks.class); - if (!destination.exists()) { - try { - RandomAccessFile randomAccessFile = new RandomAccessFile(destination, "rw"); - randomAccessFile.setLength(fileDescription.getTotalSize()); - randomAccessFile.close(); - } catch (FileNotFoundException e) { - // we just checked !destination.exists() - } - } - - if (!chunkStatusFile.exists()) { - // force the creation of all needed directories - log.debug("creating directory " + chunkStatusFile.getParentFile()); - chunkStatusFile.getParentFile().mkdirs(); - BitSet bitSet = new BitSet(fileDescription.getNumberOfChunks()); - bitSet.set(0, fileDescription.getNumberOfChunks()); - writeChunkStatusFile(bitSet); - bitSet = readChunkStatusFile(); - } + public SplitFileFromChunks(FileDescription fileDescription, File destination) + throws IOException { + this.fileDescription = fileDescription; + this.destination = destination; + this.chunkStatusFile = new File(destination.getParent(), "." + + destination.getName() + ".index"); - } + // force the creation of all needed directories - public boolean isComplete() throws IOException { - BitSet bitSet = readChunkStatusFile(); - boolean fileIsComplete = bitSet.cardinality() == 0; - return fileIsComplete; - } + File directory = destination.getParentFile(); + if (!directory.exists()) { + log.debug("creating directory " + directory.getAbsolutePath()); + directory.mkdirs(); + } + if (!destination.exists()) { + try { + RandomAccessFile randomAccessFile = new RandomAccessFile( + destination, "rw"); + randomAccessFile.setLength(fileDescription.getTotalSize()); + randomAccessFile.close(); + } catch (FileNotFoundException e) { + // we just checked !destination.exists() + } + } - protected BitSet readChunkStatusFile() throws IOException { - BitSet bitSet = null; - try { - FileInputStream is = new FileInputStream(chunkStatusFile); - bitSet = (BitSet) new ObjectInputStream(is).readObject(); - is.close(); - } catch (ClassNotFoundException e) { - throw new IOException("Unknown Metadata", e); - } - return bitSet; - } + if (!chunkStatusFile.exists()) { + BitSet bitSet = new BitSet(fileDescription.getNumberOfChunks()); + bitSet.set(0, fileDescription.getNumberOfChunks()); + writeChunkStatusFile(bitSet); + // bitSet = readChunkStatusFile(); + } + } - protected void writeChunkStatusFile(BitSet bitSet) throws IOException { - FileOutputStream os = new FileOutputStream(chunkStatusFile); - new ObjectOutputStream(os).writeObject(bitSet); - os.close(); - } + public boolean isComplete() throws IOException { + boolean fileIsComplete = false; + if (chunkStatusFile.exists()) { + BitSet bitSet = readChunkStatusFile(); + fileIsComplete = bitSet.cardinality() == 0; + } else { + fileIsComplete = true; + } + return fileIsComplete; + } + protected BitSet readChunkStatusFile() throws IOException { + BitSet bitSet = null; + try { + FileInputStream is = new FileInputStream(chunkStatusFile); + bitSet = (BitSet) new ObjectInputStream(is).readObject(); + is.close(); + } catch (ClassNotFoundException e) { + log.error("Metadata file corrupted, BitSet expected", e); + throw new IOException("Unknown Metadata", e); + } + return bitSet; + } - public void addChunk(FileChunk fileChunk) throws IOException { - RandomAccessFile randomAccessFile = new RandomAccessFile(destination, "rw"); - byte[] data = fileChunk.getData(); - int off = FileChunk.MAX_CHUNK_SIZE * fileChunk.getChunkNumber(); - int len = fileChunk.getChunkSize(); - randomAccessFile.seek(off); - randomAccessFile.write(data, 0, len); - randomAccessFile.close(); + protected void writeChunkStatusFile(BitSet bitSet) throws IOException { + FileOutputStream os = new FileOutputStream(chunkStatusFile); + new ObjectOutputStream(os).writeObject(bitSet); + os.close(); + } - // updating status - BitSet chunkStatus = readChunkStatusFile(); - chunkStatus.clear(fileChunk.getChunkNumber()); - writeChunkStatusFile(chunkStatus); + public void addChunk(FileChunk fileChunk) throws IOException { + RandomAccessFile randomAccessFile = new RandomAccessFile(destination, + "rw"); + byte[] data = fileChunk.getData(); + int off = FileChunk.MAX_CHUNK_SIZE * fileChunk.getChunkNumber(); + int len = fileChunk.getChunkSize(); + randomAccessFile.seek(off); + randomAccessFile.write(data, 0, len); + randomAccessFile.close(); + // updating status + BitSet chunkStatus = readChunkStatusFile(); + chunkStatus.clear(fileChunk.getChunkNumber()); + writeChunkStatusFile(chunkStatus); - if (isComplete()) { + if (isComplete()) { - long expectedChecksum = fileDescription.getFileCheckSum(); - long actualCheckSum = FileUtils.checksum(destination, new CRC32()).getValue(); + long expectedChecksum = fileDescription.getFileCheckSum(); + long actualCheckSum = FileUtils.checksum(destination, new CRC32()) + .getValue(); - if (actualCheckSum != expectedChecksum) { - throw new IOException("checksum fail"); - } - } - } + if (actualCheckSum != expectedChecksum) { + throw new IOException("checksum fail"); + } + chunkStatusFile.delete(); + } + } + /* + * public boolean isFinished() { boolean finished = ! + * chunkStatusFile.exists(); return finished; } + */ + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromLocalFile.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromLocalFile.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/split/SplitFileFromLocalFile.java 2010-05-10 09:30:32 UTC (rev 29) @@ -12,55 +12,57 @@ public class SplitFileFromLocalFile { - protected File source; - - public SplitFileFromLocalFile(File source) { - this.source = source; - } + protected File source; - public FileDescription getFileDescription() throws IOException { - String localFileName = source.getPath(); - long localFileTotalSize = source.length(); - long localFileCheckSum = FileUtils.checksum(source, new CRC32()).getValue(); - return new FileDescription(localFileName, localFileTotalSize, localFileCheckSum); - } + public SplitFileFromLocalFile(File source) { + this.source = source; + } - public List<FileChunk> getAllChunks() throws IOException, FileNotFoundException { + public FileDescription getFileDescription() throws IOException { + String localFileName = source.getPath(); + long localFileTotalSize = source.length(); + long localFileCheckSum = FileUtils.checksum(source, new CRC32()) + .getValue(); + return new FileDescription(localFileName, localFileTotalSize, + localFileCheckSum); + } - RandomAccessFile randomAccessFile = new RandomAccessFile(source, "r"); + public List<FileChunk> getAllChunks() throws IOException, + FileNotFoundException { - // preparing an empty list to store the result - List<FileChunk> result = new ArrayList<FileChunk>(); - - // this array will contains some bytes read from the file - byte[] read = new byte[FileChunk.MAX_CHUNK_SIZE]; + RandomAccessFile randomAccessFile = new RandomAccessFile(source, "r"); - // chunks have to be numbered - int chunkNumber = 0; - - // the last chunk will not be complete, so we have to store the - // chunkSize for each chunk - int chunkSize; + // preparing an empty list to store the result + List<FileChunk> result = new ArrayList<FileChunk>(); - // reading the file until the end - while ((chunkSize = randomAccessFile.read(read)) != -1) { + // this array will contains some bytes read from the file + byte[] read = new byte[FileChunk.MAX_CHUNK_SIZE]; - // creating a FileChunk from the data read - FileChunk fileChunk = new FileChunk(read); - fileChunk.setChunkNumber(chunkNumber); - fileChunk.setChunkSize(chunkSize); - - result.add(fileChunk); - - // preparing data for next iteration - read = new byte[FileChunk.MAX_CHUNK_SIZE]; - chunkNumber += 1; - } + // chunks have to be numbered + int chunkNumber = 0; - randomAccessFile.close(); - - return result; - } + // the last chunk will not be complete, so we have to store the + // chunkSize for each chunk + int chunkSize; + // reading the file until the end + while ((chunkSize = randomAccessFile.read(read)) != -1) { + // creating a FileChunk from the data read + FileChunk fileChunk = new FileChunk(read); + fileChunk.setChunkNumber(chunkNumber); + fileChunk.setChunkSize(chunkSize); + + result.add(fileChunk); + + // preparing data for next iteration + read = new byte[FileChunk.MAX_CHUNK_SIZE]; + chunkNumber += 1; + } + + randomAccessFile.close(); + + return result; + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Address.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Address.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Address.java 2010-05-10 09:30:32 UTC (rev 29) @@ -4,9 +4,9 @@ public abstract class Address implements Serializable { - /** + /** * */ - private static final long serialVersionUID = 4178387970911345672L; - + private static final long serialVersionUID = 4178387970911345672L; + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Message.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Message.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Message.java 2010-05-10 09:30:32 UTC (rev 29) @@ -2,38 +2,43 @@ import java.io.Serializable; - /** * Use Transport as a factory to create new instances of this class + * * @author bleny - * + * */ public abstract class Message { - - protected Transport transport; - - /** - * contructor is not available as public. Use {@link Transport#newEmptyMessage()} - * if you want to create a new message - * @param transport - */ - protected Message(Transport transport) { - // dependency injection done by the newEmptyMessage factory - this.transport = transport; - } - public abstract void setSource(Address source); - public abstract void setDestination(Address destination); - public abstract void setContent(Serializable content); + protected Transport transport; - public abstract Address getSource(); - public abstract Address getDestination(); - public abstract Serializable getContent(); - - public void send() { - this.transport.send(this); - } - - public abstract Message newReply(); - + /** + * contructor is not available as public. Use + * {@link Transport#newEmptyMessage()} if you want to create a new message + * + * @param transport + */ + protected Message(Transport transport) { + // dependency injection done by the newEmptyMessage factory + this.transport = transport; + } + + public abstract void setSource(Address source); + + public abstract void setDestination(Address destination); + + public abstract void setContent(Serializable content); + + public abstract Address getSource(); + + public abstract Address getDestination(); + + public abstract Serializable getContent(); + + public void send() { + this.transport.send(this); + } + + public abstract Message newReply(); + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Receiver.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Receiver.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Receiver.java 2010-05-10 09:30:32 UTC (rev 29) @@ -1,8 +1,7 @@ package org.nuiton.disworkfs.transport; - public interface Receiver { - public void receiveMessage(Message message); - + public void receiveMessage(Message message); + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Transport.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Transport.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Transport.java 2010-05-10 09:30:32 UTC (rev 29) @@ -1,49 +1,51 @@ package org.nuiton.disworkfs.transport; public interface Transport { - - /** - * @return true if the message have been sent without error - */ - public boolean send(Message message); - /** - * Factory method - * @return a new empty message, ready to be sent - */ - public Message newEmptyMessage(); + /** + * @return true if the message have been sent without error + */ + public boolean send(Message message); - /** - * Factory method - * @return a new empty message, ready to be sent to all nodes - */ - public Message newMulticastMessage(); + /** + * Factory method + * + * @return a new empty message, ready to be sent + */ + public Message newEmptyMessage(); - /** - * Use this method to set the receiver for this transport - * every message received by this transport will be sent - * to this object - * @param receiver - */ - public void setReceiver(Receiver receiver); - - /** - * @return an address you should use in {@link Message#setSource(Address)} - */ - public Address getLocalAddress(); - - /** - * if you want to send a message to all nodes, use this method - * to get the address you will use as destination in your - * message - * @return an address you can use in Message.setDestination() - */ - public Address getMulticastAddress(); + /** + * Factory method + * + * @return a new empty message, ready to be sent to all nodes + */ + public Message newMulticastMessage(); - /** - * this call should release all the ressources used by the transport layer - * i.e. close sockets, connections etc. - */ - public void close(); - + /** + * Use this method to set the receiver for this transport every message + * received by this transport will be sent to this object + * + * @param receiver + */ + public void setReceiver(Receiver receiver); + + /** + * @return an address you should use in {@link Message#setSource(Address)} + */ + public Address getLocalAddress(); + + /** + * if you want to send a message to all nodes, use this method to get the + * address you will use as destination in your message + * + * @return an address you can use in Message.setDestination() + */ + public Address getMulticastAddress(); + + /** + * this call should release all the ressources used by the transport layer + * i.e. close sockets, connections etc. + */ + public void close(); + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsAddress.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsAddress.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsAddress.java 2010-05-10 09:30:32 UTC (rev 29) @@ -4,16 +4,16 @@ public class JGroupsAddress extends Address { - private static final long serialVersionUID = 8851527317522260037L; - - org.jgroups.Address address; + private static final long serialVersionUID = 8851527317522260037L; - public JGroupsAddress(org.jgroups.Address address) { - this.address = address; - } - - public org.jgroups.Address getAddress() { - return address; - } - + org.jgroups.Address address; + + public JGroupsAddress(org.jgroups.Address address) { + this.address = address; + } + + public org.jgroups.Address getAddress() { + return address; + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsMessage.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsMessage.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsMessage.java 2010-05-10 09:30:32 UTC (rev 29) @@ -8,74 +8,72 @@ public class JGroupsMessage extends Message implements Serializable { - /** + /** * */ - private static final long serialVersionUID = 6239305387929159827L; - protected org.jgroups.Message message; - - protected JGroupsMessage(Transport transport) { - super(transport); - this.message = new org.jgroups.Message(); - } - - protected JGroupsMessage(Transport transport, org.jgroups.Message message) { - this(transport); - this.message = message; - } - - protected JGroupsMessage(Transport transport, - org.jgroups.Address source, - org.jgroups.Address destination, - Serializable content) { - this(transport); - this.message = new org.jgroups.Message(source, destination, content); - } - - @Override - public Serializable getContent() { - return (Serializable) this.message.getObject(); - } + private static final long serialVersionUID = 6239305387929159827L; + protected org.jgroups.Message message; - @Override - public Address getDestination() { - JGroupsAddress destination = new JGroupsAddress(message.getDest()); - return destination; - } + protected JGroupsMessage(Transport transport) { + super(transport); + this.message = new org.jgroups.Message(); + } - @Override - public Address getSource() { - JGroupsAddress destination = new JGroupsAddress(message.getSrc()); - return destination; - } + protected JGroupsMessage(Transport transport, org.jgroups.Message message) { + this(transport); + this.message = message; + } - @Override - public void setContent(Serializable content) { - this.message.setObject(content); - } + protected JGroupsMessage(Transport transport, org.jgroups.Address source, + org.jgroups.Address destination, Serializable content) { + this(transport); + this.message = new org.jgroups.Message(source, destination, content); + } - @Override - public void setDestination(Address destination) { - org.jgroups.Address dest = ((JGroupsAddress) destination).getAddress(); - this.message.setDest(dest); - } + @Override + public Serializable getContent() { + return (Serializable) this.message.getObject(); + } - @Override - public void setSource(Address source) { - org.jgroups.Address src = ((JGroupsAddress) source).getAddress(); - this.message.setDest(src); - } + @Override + public Address getDestination() { + JGroupsAddress destination = new JGroupsAddress(message.getDest()); + return destination; + } - public org.jgroups.Message getMessage() { - return this.message; - } + @Override + public Address getSource() { + JGroupsAddress destination = new JGroupsAddress(message.getSrc()); + return destination; + } - @Override - public Message newReply() { - Message reply = new JGroupsMessage(this.transport); - reply.setDestination(this.getSource()); - reply.setSource(this.getDestination()); - return reply; - } - + @Override + public void setContent(Serializable content) { + this.message.setObject(content); + } + + @Override + public void setDestination(Address destination) { + org.jgroups.Address dest = ((JGroupsAddress) destination).getAddress(); + this.message.setDest(dest); + } + + @Override + public void setSource(Address source) { + org.jgroups.Address src = ((JGroupsAddress) source).getAddress(); + this.message.setDest(src); + } + + public org.jgroups.Message getMessage() { + return this.message; + } + + @Override + public Message newReply() { + Message reply = new JGroupsMessage(this.transport); + reply.setDestination(this.getSource()); + reply.setSource(this.getDestination()); + return reply; + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsTransport.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsTransport.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/jgroups/JGroupsTransport.java 2010-05-10 09:30:32 UTC (rev 29) @@ -18,146 +18,147 @@ public class JGroupsTransport implements Transport { - protected DisworkConfig disworkConfig; - protected JChannel jChannel; - protected Receiver receiver; - - private static final Log log = LogFactory.getLog(JGroupsTransport.class); - - /** - * This class is just a delegator. Every message received on this.jChannel, - * will be sent to this.receiver who subscribed to transport - * @author bleny - */ - private class MyReceiver extends org.jgroups.ExtendedReceiverAdapter { - - private Transport tranport; - - public MyReceiver(Transport tranport) { - this.tranport = tranport; - } + protected DisworkConfig disworkConfig; + protected JChannel jChannel; + protected Receiver receiver; - /** - * receive a new message from the JChannel, send it to the - * transport layer - */ - public void receive(org.jgroups.Message msg) { - // this method is call be the jChannel when a message is received - if (log.isDebugEnabled()) - log.info("message received from jChannel " + msg); - - // let's create a new message for the transport layer - Message message = tranport.newEmptyMessage(); + private static final Log log = LogFactory.getLog(JGroupsTransport.class); - // setting the message attributes, according to the JGroups message - message.setSource(new JGroupsAddress(msg.getSrc())); - message.setSource(new JGroupsAddress(msg.getDest())); - message.setContent((Serializable) msg.getObject()); - - // sending our new message to the transport layer - if (log.isDebugEnabled()) - log.info("message received from jChannel sent to transport layer as " + message); - receiver.receiveMessage(message); - } + /** + * This class is just a delegator. Every message received on this.jChannel, + * will be sent to this.receiver who subscribed to transport + * + * @author bleny + */ + private class MyReceiver extends org.jgroups.ExtendedReceiverAdapter { - public void viewAccepted(View new_view) { - log.info("now seeing " + new_view.size() + " nodes"); - } - - } - - - public JGroupsTransport(DisworkConfig disworkConfig) { - this.disworkConfig = disworkConfig; + private Transport tranport; + + public MyReceiver(Transport tranport) { + this.tranport = tranport; + } + + /** + * receive a new message from the JChannel, send it to the transport + * layer + */ + public void receive(org.jgroups.Message msg) { + // this method is call be the jChannel when a message is received + if (log.isDebugEnabled()) + log.info("message received from jChannel " + msg); + + // let's create a new message for the transport layer + Message message = tranport.newEmptyMessage(); + + // setting the message attributes, according to the JGroups message + message.setSource(new JGroupsAddress(msg.getSrc())); + message.setSource(new JGroupsAddress(msg.getDest())); + message.setContent((Serializable) msg.getObject()); + + // sending our new message to the transport layer + if (log.isDebugEnabled()) + log + .info("message received from jChannel sent to transport layer as " + + message); + receiver.receiveMessage(message); + } + + public void viewAccepted(View new_view) { + log.info("now seeing " + new_view.size() + " nodes"); + } + + } + + public JGroupsTransport(DisworkConfig disworkConfig) { + this.disworkConfig = disworkConfig; try { jChannel = new JChannel("udp.xml"); - + String clusterName = disworkConfig.getJGroupsClusterName(); - - /* - String localIp; - try { - localIp = InetAddress.getLocalHost().getHostAddress(); - log.info("local IP is " + localIp); - } catch (UnknownHostException e) { - log.error("can't get local IP"); - } - */ - // System.setProperty("jgroups.bind_addr", localIp); - // System.setProperty("jgroups.tcpping.initial_hosts", localIp); - // System.setProperty("jgroups.udp.mcast_addr", "224.0.0.150"); - // System.setProperty("java.net.preferIPv4Stack", "true"); - - + + /* + * String localIp; try { localIp = + * InetAddress.getLocalHost().getHostAddress(); + * log.info("local IP is " + localIp); } catch (UnknownHostException + * e) { log.error("can't get local IP"); } + */ + // System.setProperty("jgroups.bind_addr", localIp); + // System.setProperty("jgroups.tcpping.initial_hosts", localIp); + // System.setProperty("jgroups.udp.mcast_addr", "224.0.0.150"); + // System.setProperty("java.net.preferIPv4Stack", "true"); + log.info("connecting to JGroup " + clusterName); jChannel.connect(clusterName); - + // don't receive messages sent by myself jChannel.setOpt(Channel.LOCAL, new Boolean(false)); - + // setting the receiver so every message received // on jChannel will be received by the rest of // the application MyReceiver myReceiver = new MyReceiver(this); jChannel.setReceiver(myReceiver); - + } catch (ChannelException e) { - log.error("error while creating and connecting to the JGroups channel"); + log + .error("error while creating and connecting to the JGroups channel"); } - } - - @Override - public void setReceiver(Receiver receiver) { + } + + @Override + public void setReceiver(Receiver receiver) { this.receiver = receiver; - } - - @Override - public Address getMulticastAddress() { - // null is the multicast destination in JGroups - return new JGroupsAddress(null); - } - - @Override - public boolean send(Message message) { - org.jgroups.Message msg = ((JGroupsMessage) message).getMessage(); - boolean success = true; - try { - jChannel.send(msg); - } catch (ChannelNotConnectedException e) { - log.error("JGroups channel not connected while trying to send a message"); + } + + @Override + public Address getMulticastAddress() { + // null is the multicast destination in JGroups + return new JGroupsAddress(null); + } + + @Override + public boolean send(Message message) { + org.jgroups.Message msg = ((JGroupsMessage) message).getMessage(); + boolean success = true; + try { + jChannel.send(msg); + } catch (ChannelNotConnectedException e) { + log + .error("JGroups channel not connected while trying to send a message"); success = false; - } catch (ChannelClosedException e) { - log.error("JGroups channel was closed while trying to send a message"); + } catch (ChannelClosedException e) { + log + .error("JGroups channel was closed while trying to send a message"); success = false; - } - return success; - } - - @Override - public Message newEmptyMessage() { - Message message = new JGroupsMessage(this, new org.jgroups.Message()); - message.setSource(this.getLocalAddress()); - return message; - } - - @Override - public Message newMulticastMessage() { - Message message = this.newEmptyMessage(); - message.setDestination(this.getMulticastAddress()); - return message; - } + } + return success; + } - @Override - public Address getLocalAddress() { - return new JGroupsAddress(jChannel.getAddress()); - } + @Override + public Message newEmptyMessage() { + Message message = new JGroupsMessage(this, new org.jgroups.Message()); + message.setSource(this.getLocalAddress()); + return message; + } - @Override - public void close() { - // leaving group - jChannel.disconnect(); - // closing the channel - jChannel.close(); - } - + @Override + public Message newMulticastMessage() { + Message message = this.newEmptyMessage(); + message.setDestination(this.getMulticastAddress()); + return message; + } + + @Override + public Address getLocalAddress() { + return new JGroupsAddress(jChannel.getAddress()); + } + + @Override + public void close() { + // leaving group + jChannel.disconnect(); + // closing the channel + jChannel.close(); + } + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/DownloadObserver.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/DownloadObserver.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/DownloadObserver.java 2010-05-10 09:30:32 UTC (rev 29) @@ -4,6 +4,6 @@ public interface DownloadObserver { - public void updateDownloadStatus(DownloadService downloadService); - + public void updateDownloadStatus(DownloadService downloadService); + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/LookUpObserver.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/LookUpObserver.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/LookUpObserver.java 2010-05-10 09:30:32 UTC (rev 29) @@ -4,6 +4,6 @@ public interface LookUpObserver { - public void receiveResult(FileDescription fileDescription); - + public void receiveResult(FileDescription fileDescription); + } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleDownload.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleDownload.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleDownload.java 2010-05-10 09:30:32 UTC (rev 29) @@ -6,66 +6,66 @@ import org.nuiton.disworkfs.services.LookUpService; import org.nuiton.disworkfs.split.FileDescription; +public class SimpleDownload implements DownloadObserver { + /** + * only used for synchronisation purpose + */ + protected final Object lock = new Object(); -public class SimpleDownload implements DownloadObserver { + protected Boolean downloadFinised = false; - /** - * only used for synchronisation purpose - */ - protected final Object lock = new Object(); - - protected Boolean downloadFinised = false; - protected FileDescription fileDescription = null; - + protected DownloadService downloadService; - + protected SimpleLookUp simpleLookUp; - + private static final Log log = LogFactory.getLog(SimpleDownload.class); - - public SimpleDownload(String filePath, LookUpService lookUpService, DownloadService downloadService) { - this.downloadService = downloadService; - - simpleLookUp = new SimpleLookUp(filePath, lookUpService); + + public SimpleDownload(String filePath, LookUpService lookUpService, + DownloadService downloadService) { + this.downloadService = downloadService; + + simpleLookUp = new SimpleLookUp(filePath, lookUpService); } - + public boolean initiateDownload() throws InterruptedException { - fileDescription = simpleLookUp.runLookUp(); - return fileDescription != null; + fileDescription = simpleLookUp.runLookUp(); + return fileDescription != null; } - + /** - * initiateDownload() must be called <strong>before</strong> - * download start. + * initiateDownload() must be called <strong>before</strong> download start. + * * @throws InterruptedException */ public void startDownload() throws InterruptedException { - if (fileDescription == null) { - log.error("download started without FileDescription"); - } else { - if (log.isDebugEnabled()) - log.info("starting download for " + fileDescription.getFileName()); + if (fileDescription == null) { + log.error("download started without FileDescription"); + } else { + if (log.isDebugEnabled()) + log.info("starting download for " + + fileDescription.getFileName()); - downloadService.startDownload(fileDescription, this); + downloadService.startDownload(fileDescription, this); - synchronized (lock) { - lock.wait(); - if (log.isDebugEnabled()) - log.info("download " + fileDescription.getFileName() + " is complete"); - } - } + synchronized (lock) { + lock.wait(); + if (log.isDebugEnabled()) + log.info("download " + fileDescription.getFileName() + + " is complete"); + } + } } - - + @Override public void updateDownloadStatus(DownloadService downloadService) { - downloadFinised = downloadService.isFinished(fileDescription); - if (downloadFinised) { - synchronized (lock) { - lock.notify(); - } - } - } + downloadFinised = downloadService.isFinished(fileDescription); + if (downloadFinised) { + synchronized (lock) { + lock.notify(); + } + } + } } Modified: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleLookUp.java =================================================================== --- trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleLookUp.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/SimpleLookUp.java 2010-05-10 09:30:32 UTC (rev 29) @@ -7,54 +7,55 @@ public class SimpleLookUp implements LookUpObserver { - /** - * only used for synchronisation purpose - */ - protected final Object lock = new Object(); + /** + * only used for synchronisation purpose + */ + protected final Object lock = new Object(); - protected Boolean lookUpResponseReceived = false; + protected Boolean lookUpResponseReceived = false; - protected FileDescription fileDescription = null; + protected FileDescription fileDescription = null; - protected LookUpService lookUpService; - - protected String filePath; + protected LookUpService lookUpService; - private static final Log log = LogFactory.getLog(SimpleDownload.class); + protected String filePath; - public SimpleLookUp(String filePath, LookUpService lookUpService) { - this.filePath = filePath; - this.lookUpService = lookUpService; - } + private static final Log log = LogFactory.getLog(SimpleLookUp.class); - /** - * - * @return the FileDescription or null if file is not found - * @throws InterruptedException - */ - public FileDescription runLookUp() throws InterruptedException { + public SimpleLookUp(String filePath, LookUpService lookUpService) { + this.filePath = filePath; + this.lookUpService = lookUpService; + } - lookUpService.lookForFileName(filePath, this); + /** + * + * @return the FileDescription or null if file is not found + * @throws InterruptedException + */ + public FileDescription runLookUp() throws InterruptedException { - synchronized (lock) { - lock.wait(10 * 1000); // time out at 10 seconds - } + lookUpService.lookForFileName(filePath, this); - if (lookUpResponseReceived) { - log.info("look-up response received for " + filePath); - } else { - log.info("no look-up response received for " + filePath); - } + synchronized (lock) { + lock.wait(10 * 1000); // time out at 10 seconds + } - return this.fileDescription; - } + if (lookUpResponseReceived) { + log.info("look-up response received for " + filePath); + } else { + log.info("no look-up response received for " + filePath); + } - @Override - public void receiveResult(FileDescription fileDescription) { - synchronized (lock) { - this.lookUpResponseReceived = true; - this.fileDescription = fileDescription; - lock.notify(); - } - } + // may be null if no response received + return this.fileDescription; + } + + @Override + public void receiveResult(FileDescription fileDescription) { + synchronized (lock) { + this.lookUpResponseReceived = true; + this.fileDescription = fileDescription; + lock.notify(); + } + } } Modified: trunk/diswork-fs/src/main/resources/log4j.properties =================================================================== --- trunk/diswork-fs/src/main/resources/log4j.properties 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/main/resources/log4j.properties 2010-05-10 09:30:32 UTC (rev 29) @@ -5,7 +5,7 @@ log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %5p [%t] (%F:%L) %M - %m%n # package level -log4j.logger.org.nuiton.disworkfs=DEBUG +log4j.logger.org.nuiton.disworkfs=TRACE #log4j.logger.org.nuiton.disworkfs.transport=WARN #log4j.logger.org.nuiton.disworkfs.services.DownloadService=WARN #log4j.logger.org.nuiton.disworkfs.services.UploadService=WARN Modified: trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java =================================================================== --- trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java 2010-05-10 09:30:32 UTC (rev 29) @@ -1,12 +1,10 @@ package org.nuiton.disworkfs; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.fail; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.util.Random; import org.apache.commons.io.FileUtils; @@ -19,11 +17,12 @@ public class DistributedFileSystemTest { /** - * a place to store files for the test - * it's a subdirectory of the OS temp dir - * e.g. under linux /tmp/disworkfs/tests/ + * a place to store files for the test it's a subdirectory of the OS temp + * dir e.g. under linux /tmp/disworkfs/tests/ */ - static protected String tempDirectoryPath = System.getProperty("java.io.tmpdir", ".") + "/disworkfs/tests"; + static protected String tempDirectoryPath = System.getProperty( + "java.io.tmpdir", ".") + + "/disworkfs/tests"; /** * We will create a file at this path for test purpose @@ -40,12 +39,11 @@ static protected DisworkConfig disworkConfig1; static protected DisworkConfig disworkConfig2; - + @Before public void setUp() throws Exception { File tempDirectory = new File(tempDirectoryPath); tempDirectory.mkdir(); - File storage1 = new File(tempDirectory, "storage1"); storage1.mkdir(); @@ -63,10 +61,9 @@ File randomFile = new File(randomFilePath); FileUtils.writeByteArrayToFile(randomFile, randomBytes); - disworkConfig1 = new DisworkConfig(); disworkConfig1.setOption("storage", storagePath1); - + disworkConfig2 = new DisworkConfig(); disworkConfig2.setOption("storage", storagePath2); } @@ -80,48 +77,63 @@ @Test public void testWrite() throws Exception { - DisworkFileSystem disworkFileSystem1 = new DisworkFileSystem(disworkConfig1); - disworkFileSystem1.write("monfichier", new File(randomFilePath)); - disworkFileSystem1.close(); + DisworkFileSystem disworkFileSystem1 = new DisworkFileSystem( + disworkConfig1); + disworkFileSystem1.write("monfichier", new FileInputStream(randomFilePath)); + disworkFileSystem1.close(); + + + File monfichier = new File(randomFilePath); + File monfichierstorage = new File(tempDirectoryPath + + "/storage1/monfichier"); + + boolean actualContentEquality = IOUtils.contentEquals( + new FileInputStream(monfichier), new FileInputStream( + monfichierstorage)); + + assertTrue("file and copy content should be the same", + actualContentEquality); } /** - * this test run two DistributedFS. A file is written on the first - * when. We try to read from the other FS : since it doesn't own the file, - * it will try a lookup and download the file. + * this test run two DistributedFS. A file is written on the first when. We + * try to read from the other FS : since it doesn't own the file, it will + * try a lookup and download the file. */ @Test public void testRead() throws Exception { - DisworkFileSystem disworkFileSystem1 = new DisworkFileSystem(disworkConfig1); - DisworkFileSystem disworkFileSystem2 = new DisworkFileSystem(disworkConfig2); + DisworkFileSystem disworkFileSystem1 = new DisworkFileSystem( + disworkConfig1); + DisworkFileSystem disworkFileSystem2 = new DisworkFileSystem( + disworkConfig2); + + disworkFileSystem1.write("mon/chemin/vers/mon/fichier", new FileInputStream( + randomFilePath)); + + boolean existsResult = disworkFileSystem2 + .exists("mon/chemin/vers/mon/fichier"); + assertTrue(existsResult); - disworkFileSystem1.write("mon/chemin/vers/mon/fichier", new File(randomFilePath)); - - boolean existsResult = disworkFileSystem2.exists("mon/chemin/vers/mon/fichier"); - assertTrue(existsResult); - existsResult = disworkFileSystem2.exists("unautrefichierquinexistepas"); - assertFalse(existsResult); - - disworkFileSystem2.read("mon/chemin/vers/mon/fichier"); - - // TODO - File monfichierstorage1 = new File(tempDirectoryPath + "/storage1/mon/chemin/vers/mon/fichier"); - File monfichierstorage2 = new File(tempDirectoryPath + "/storage2/mon/chemin/vers/mon/fichier"); + existsResult = disworkFileSystem2.exists("unautrefichierquinexistepas"); + assertFalse(existsResult); - try { - boolean actualContentEquality = IOUtils.contentEquals( - new FileInputStream(monfichierstorage1), - new FileInputStream(monfichierstorage2) - ); - assertTrue("file and copy content should be the same", actualContentEquality); - } catch (IOException e) { - fail("one or both files are not readable"); - e.printStackTrace(); - } + disworkFileSystem2.read("mon/chemin/vers/mon/fichier"); - disworkFileSystem1.close(); - disworkFileSystem2.close(); + File monfichierstorage1 = new File(tempDirectoryPath + + "/storage1/mon/chemin/vers/mon/fichier"); + File monfichierstorage2 = new File(tempDirectoryPath + + "/storage2/mon/chemin/vers/mon/fichier"); + + boolean actualContentEquality = IOUtils.contentEquals( + new FileInputStream(monfichierstorage1), new FileInputStream( + monfichierstorage2)); + + assertTrue("file and copy content should be the same", + actualContentEquality); + + disworkFileSystem1.close(); + disworkFileSystem2.close(); } } Modified: trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromChunksTest.java =================================================================== --- trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromChunksTest.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromChunksTest.java 2010-05-10 09:30:32 UTC (rev 29) @@ -2,11 +2,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import org.apache.commons.io.IOUtils; import org.junit.Test; @@ -14,52 +12,39 @@ public class SplitFileFromChunksTest extends AbstractSplitFileTest { @Test - public void simpleCopyRandomAccess() { + public void simpleCopyRandomAccess() throws Exception { + File randomFile = new File(randomFilePath); - try { - File randomFile = new File(randomFilePath); + // let's take a file + SplitFileFromLocalFile splitFile = new SplitFileFromLocalFile(randomFile); - // let's take a file - SplitFileFromLocalFile splitFile = new SplitFileFromLocalFile(randomFile); - - // let's create a second file - FileDescription fileDescription = splitFile.getFileDescription(); - String splitedFileCopyPath = fileDescription.getFileName() + "_copy"; - fileDescription.setFileName(splitedFileCopyPath); - - SplitFileFromChunks splitFileCopy = new SplitFileFromChunks(fileDescription, new File(splitedFileCopyPath)); - - // here is the simple copy from fist file to second file - for (FileChunk fileChunk : splitFile.getAllChunks()) { - assertFalse(splitFileCopy.isComplete()); - splitFileCopy.addChunk(fileChunk); - } + // let's create a second file + FileDescription fileDescription = splitFile.getFileDescription(); + String splitedFileCopyPath = fileDescription.getFileName() + "_copy"; + fileDescription.setFileName(splitedFileCopyPath); - assertTrue(splitFileCopy.isComplete()); - // write the copy to the FS + SplitFileFromChunks splitFileCopy = new SplitFileFromChunks(fileDescription, new File(splitedFileCopyPath)); - // compare the original and the copy byte by byte - try { - boolean actualContentEquality = IOUtils.contentEquals( - new FileInputStream(new File(randomFilePath)), - new FileInputStream(new File(splitedFileCopyPath)) - ); - assertTrue("file and copy content should be the same", actualContentEquality); - } catch (IOException e) { - fail("one or both files are not readable"); - e.printStackTrace(); - } - - // delete the copy - new File(splitedFileCopyPath).delete(); - - - } catch (IOException e) { - e.printStackTrace(); - } catch (Exception e) { - e.printStackTrace(); + // here is the simple copy from fist file to second file + for (FileChunk fileChunk : splitFile.getAllChunks()) { + assertFalse(splitFileCopy.isComplete()); + splitFileCopy.addChunk(fileChunk); } - + + assertTrue(splitFileCopy.isComplete()); + // write the copy to the FS + + // compare the original and the copy byte by byte + + boolean actualContentEquality = IOUtils.contentEquals( + new FileInputStream(new File(randomFilePath)), + new FileInputStream(new File(splitedFileCopyPath)) + ); + assertTrue("file and copy content should be the same", actualContentEquality); + + // delete the copy + new File(splitedFileCopyPath).delete(); + } } Modified: trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromLocalFileTest.java =================================================================== --- trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromLocalFileTest.java 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/split/SplitFileFromLocalFileTest.java 2010-05-10 09:30:32 UTC (rev 29) @@ -2,10 +2,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.io.File; -import java.io.IOException; import java.util.List; import org.junit.Test; @@ -13,32 +11,27 @@ public class SplitFileFromLocalFileTest extends AbstractSplitFileTest { @Test - public void testReadFromLocalFileSytem() { - try { - File randomFile = new File(randomFilePath); - - SplitFileFromLocalFile splitFileFromLocalFile = new SplitFileFromLocalFile(randomFile); - - FileDescription fileDescription = splitFileFromLocalFile.getFileDescription(); - assertTrue(fileDescription.getTotalSize() == randomFileSize); - assertTrue(fileDescription.getFileCheckSum() != 0); - assertEquals(FileChunk.numberOfChunksNeededtoStore(randomFileSize), fileDescription.getNumberOfChunks()); - assertEquals(fileDescription.getFileName(), randomFilePath); - - List<FileChunk> allChunks = splitFileFromLocalFile.getAllChunks(); - - for (FileChunk fileChunk : allChunks) { - int chunkSize = fileChunk.getChunkSize(); - - assertTrue( - chunkSize == FileChunk.MAX_CHUNK_SIZE - || chunkSize == randomFileSize % FileChunk.MAX_CHUNK_SIZE); - } - - } catch (IOException e) { - fail(); - e.printStackTrace(); + public void testReadFromLocalFileSytem() throws Exception { + File randomFile = new File(randomFilePath); + + SplitFileFromLocalFile splitFileFromLocalFile = new SplitFileFromLocalFile(randomFile); + + FileDescription fileDescription = splitFileFromLocalFile.getFileDescription(); + assertTrue(fileDescription.getTotalSize() == randomFileSize); + assertTrue(fileDescription.getFileCheckSum() != 0); + assertEquals(FileChunk.numberOfChunksNeededtoStore(randomFileSize), fileDescription.getNumberOfChunks()); + assertEquals(fileDescription.getFileName(), randomFilePath); + + List<FileChunk> allChunks = splitFileFromLocalFile.getAllChunks(); + + for (FileChunk fileChunk : allChunks) { + int chunkSize = fileChunk.getChunkSize(); + + assertTrue( + chunkSize == FileChunk.MAX_CHUNK_SIZE + || chunkSize == randomFileSize % FileChunk.MAX_CHUNK_SIZE); } + } } Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-05-09 12:33:47 UTC (rev 28) +++ trunk/pom.xml 2010-05-10 09:30:32 UTC (rev 29) @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> + <modelVersion>4.0.0</modelVersion> - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> <parent> <groupId>org.nuiton</groupId> @@ -13,145 +14,177 @@ <version>2.1.4</version> </parent> - <artifactId>diswork</artifactId> - <version>0.0.1-SNAPSHOT</version> + <artifactId>diswork</artifactId> + <version>0.0.1-SNAPSHOT</version> - <modules> - <module>diswork-fs</module> - </modules> + <modules> + <module>diswork-fs</module> + </modules> - <dependencies> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.1.1</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.14</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>jgroups</groupId> + <artifactId>jgroups</artifactId> + <version>2.9.0.GA</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>1.4</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.5</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + <version>1.2.2</version> + <type>jar</type> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>fr.inria.peerunit</groupId> + <artifactId>PeerUnit</artifactId> + <version>1.0</version> + <scope>compile</scope> + </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.1.1</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.14</version> - <scope>test</scope> - </dependency> + <!-- test --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <type>jar</type> + <scope>test</scope> + </dependency> + </dependencies> + </dependencyManagement> + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.8.1</version> - <scope>test</scope> - </dependency> + <name>Diswork</name> + <description>Distributed computing application</description> + <inceptionYear>2010</inceptionYear> + <url>http://maven-site.nuiton.org/diswork</url> + <developers> + <developer> + <name>Brendan Le Ny</name> + <id>bleny</id> + <email>leny@codelutin.com</email> + <organization>CodeLutin</organization> + <timezone>+2</timezone> + <roles> + <role>Développeur</role> + </roles> + </developer> + <developer> + <name>Benjamin Poussin</name> + <id>bpoussin</id> + <email>poussin@codelutin.com</email> + <organization>CodeLutin</organization> + <timezone>+2</timezone> + <roles> + <role>Développeur</role> + <role>Debian packager</role> + </roles> + </developer> + <developer> + <name>Eric Chatellier</name> + <id>echatellier</id> + <email>chatellier@codelutin.com</email> + <organization>CodeLutin</organization> + <timezone>+2</timezone> + <roles> + <role>Développeur</role> + </roles> + </developer> + <developer> + <name>Jean Couteau</name> + <id>jcouteau</id> + <email>couteau@codelutin.com</email> + <organization>CodeLutin</organization> + <timezone>+2</timezone> + <roles> + <role>Développeur</role> + </roles> + </developer> + <developer> + <name>Tony Chemit</name> + <id>tchemit</id> + <email>chemit@codelutin.com</email> + <organization>CodeLutin</organization> + <timezone>+2</timezone> + <roles> + <role>Développeur</role> + </roles> + </developer> + </developers> - </dependencies> + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> + <packaging>pom</packaging> - <name>Diswork</name> - <description>Distributed computing application</description> - <inceptionYear>2010</inceptionYear> - <url>http://maven-site.nuiton.org/diswork</url> + <properties> + <siteLocales>en</siteLocales> + </properties> - <developers> - <developer> - <name>Brendan Le Ny</name> - <id>bleny</id> - <email>leny@codelutin.com</email> - <organization>CodeLutin</organization> - <timezone>+2</timezone> - <roles> - <role>Développeur</role> - </roles> - </developer> - <developer> - <name>Benjamin Poussin</name> - <id>bpoussin</id> - <email>poussin@codelutin.com</email> - <organization>CodeLutin</organization> - <timezone>+2</timezone> - <roles> - <role>Développeur</role> - <role>Debian packager</role> - </roles> - </developer> - <developer> - <name>Eric Chatellier</name> - <id>echatellier</id> - <email>chatellier@codelutin.com</email> - <organization>CodeLutin</organization> - <timezone>+2</timezone> - <roles> - <role>Développeur</role> - </roles> - </developer> - <developer> - <name>Jean Couteau</name> - <id>jcouteau</id> - <email>couteau@codelutin.com</email> - <organization>CodeLutin</organization> - <timezone>+2</timezone> - <roles> - <role>Développeur</role> - </roles> - </developer> - <developer> - <name>Tony Chemit</name> - <id>tchemit</id> - <email>chemit@codelutin.com</email> - <organization>CodeLutin</organization> - <timezone>+2</timezone> - <roles> - <role>Développeur</role> - </roles> - </developer> - </developers> + <build> + <plugins> - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> + </plugins> - <packaging>pom</packaging> + <pluginManagement> + <plugins> - <properties> - <siteLocales>en</siteLocales> - </properties> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <dependencies> + <dependency> + <groupId>org.nuiton.jrst</groupId> + <artifactId>doxia-module-jrst</artifactId> + <version>${jrst.version}</version> + </dependency> + </dependencies> + </plugin> - <build> - <plugins> + </plugins> + </pluginManagement> - </plugins> + </build> - <pluginManagement> - <plugins> + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> - <plugin> - <artifactId>maven-site-plugin</artifactId> - <dependencies> - <dependency> - <groupId>org.nuiton.jrst</groupId> - <artifactId>doxia-module-jrst</artifactId> - <version>${jrst.version}</version> - </dependency> - </dependencies> - </plugin> + <!-- Source control management. --> + <scm> + <connection>scm:svn:http://svn.nuiton.org/svn/diswork/diswork/trunk</connection> + <developerConnection>scm:svn:http://svn.nuiton.org/svn/diswork/diswork/trunk</developerConnection> + <url>http://www.nuiton.org/repositories/browse/diswork/diswork/trunk</url> + </scm> - </plugins> - </pluginManagement> - - </build> - - <!-- ************************************************************* --> - <!-- *** Build Environment ************************************** --> - <!-- ************************************************************* --> - - <!-- Source control management. --> - <scm> - <connection>scm:svn:http://svn.nuiton.org/svn/diswork/diswork/trunk</connection> - <developerConnection>scm:svn:http://svn.nuiton.org/svn/diswork/diswork/trunk</developerConnection> - <url>http://www.nuiton.org/repositories/browse/diswork/diswork/trunk</url> - </scm> - </project>
participants (1)
-
bleny@users.nuiton.org