r40 - in trunk/diswork-fs/src: main/java/org/nuiton/disworkfs main/java/org/nuiton/disworkfs/transport test/java/org/nuiton/disworkfs
Author: bleny Date: 2010-05-17 11:58:49 +0200 (Mon, 17 May 2010) New Revision: 40 Url: http://nuiton.org/repositories/revision/diswork/40 Log: removing code moved to the jgroups branch Removed: trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/messages/ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/services/ 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/ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/util/ Modified: 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/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java 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-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DistributedFileSystem.java 2010-05-17 09:58:49 UTC (rev 40) @@ -12,9 +12,8 @@ * @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; + public boolean exists(String path); /** * write a file @@ -25,10 +24,8 @@ * 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; + public void write(String path, InputStream source) throws IOException; /** * read a file on the VFS, the file is downloaded if needed (may take some @@ -42,10 +39,9 @@ * {@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; + IOException; } 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-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkConfig.java 2010-05-17 09:58:49 UTC (rev 40) @@ -10,7 +10,6 @@ public DisworkConfig() { Random random = new Random(); setDefaultOption("storage", "/tmp/disworkfs/storage" + random.nextInt()); - setDefaultOption("jgroups.cluster_name", "diswork-fs"); // replication strategy... } @@ -18,8 +17,4 @@ 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-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/DisworkFileSystem.java 2010-05-17 09:58:49 UTC (rev 40) @@ -1,135 +1,43 @@ 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; -import org.nuiton.disworkfs.services.DownloadService; -import org.nuiton.disworkfs.services.LookUpService; -import org.nuiton.disworkfs.services.UploadService; -import org.nuiton.disworkfs.split.FileDescription; -import org.nuiton.disworkfs.util.SimpleDownload; -import org.nuiton.disworkfs.util.SimpleLookUp; +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) { - this.disworkConfig = disworkConfig; - - disworkServicesManager = new DisworkServicesManager(disworkConfig); - uploadService = new UploadService(); - disworkServicesManager.register(uploadService); - downloadService = new DownloadService(); - disworkServicesManager.register(downloadService); - lookUpService = new LookUpService(); - disworkServicesManager.register(lookUpService); - } @Override - public InputStream 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()); - - 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"); - - } - - return new BufferedInputStream(new FileInputStream(file)); + public boolean exists(String path) { + // TODO + throw new NotImplementedException(); } @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; - - try { - bufferedSource = new BufferedInputStream(source); - bufferedTarget = new BufferedOutputStream(new FileOutputStream( - target)); - IOUtils.copy(bufferedSource, bufferedTarget); - } finally { - IOUtils.closeQuietly(bufferedSource); - IOUtils.closeQuietly(bufferedTarget); - } - + public InputStream read(String path) throws FileNotFoundException, + IOException { + // TODO + throw new NotImplementedException(); } @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; + public void write(String path, InputStream source) throws IOException { + // TODO + throw new NotImplementedException(); } public void close() { - disworkServicesManager.stop(); } } Deleted: 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-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Address.java 2010-05-17 09:58:49 UTC (rev 40) @@ -1,12 +0,0 @@ -package org.nuiton.disworkfs.transport; - -import java.io.Serializable; - -public abstract class Address implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 4178387970911345672L; - -} Deleted: 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-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Message.java 2010-05-17 09:58:49 UTC (rev 40) @@ -1,44 +0,0 @@ -package org.nuiton.disworkfs.transport; - -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); - - public abstract Address getSource(); - - public abstract Address getDestination(); - - public abstract Serializable getContent(); - - public void send() { - this.transport.send(this); - } - - public abstract Message newReply(); - -} Deleted: 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-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Receiver.java 2010-05-17 09:58:49 UTC (rev 40) @@ -1,7 +0,0 @@ -package org.nuiton.disworkfs.transport; - -public interface Receiver { - - public void receiveMessage(Message message); - -} Deleted: 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-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/main/java/org/nuiton/disworkfs/transport/Transport.java 2010-05-17 09:58:49 UTC (rev 40) @@ -1,51 +0,0 @@ -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(); - - /** - * Factory method - * - * @return a new empty message, ready to be sent to all nodes - */ - public Message newMulticastMessage(); - - /** - * 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/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java =================================================================== --- trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java 2010-05-17 08:54:18 UTC (rev 39) +++ trunk/diswork-fs/src/test/java/org/nuiton/disworkfs/DistributedFileSystemTest.java 2010-05-17 09:58:49 UTC (rev 40) @@ -67,13 +67,19 @@ disworkConfig2 = new DisworkConfig(); disworkConfig2.setOption("storage", storagePath2); } - + @After public void tearDown() throws Exception { // cleaning FileUtil.deleteRecursively(tempDirectoryPath); } + + @Test + public void fakeTest() throws Exception { + // TODO 2010-05-17 to be removed when a test is written + } + /* @Test public void testWrite() throws Exception { @@ -94,12 +100,14 @@ 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. */ + /* @Test public void testRead() throws Exception { @@ -135,5 +143,6 @@ disworkFileSystem1.close(); disworkFileSystem2.close(); } + */ }
participants (1)
-
bleny@users.nuiton.org