00001 /* 00002 * ################################################################ 00003 * 00004 * ProActive: The Java(TM) library for Parallel, Distributed, 00005 * Concurrent computing with Security and Mobility 00006 * 00007 * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis 00008 * Contact: proactive@objectweb.org 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 * USA 00024 * 00025 * Initial developer(s): The ProActive Team 00026 * http://www.inria.fr/oasis/ProActive/contacts.html 00027 * Contributor(s): 00028 * 00029 * ################################################################ 00030 */ 00031 package org.objectweb.proactive.core.filetransfer; 00032 00033 import java.io.File; 00034 import java.io.Serializable; 00035 import java.util.Random; 00036 00037 import org.objectweb.proactive.ProActive; 00038 00039 00048 public class FileTransferRequest implements Serializable { 00049 private FileTransferService sourceFTS; 00050 private FileTransferService destinationFTS; 00051 private File srcFile; 00052 private File dstFile; 00053 private OperationStatus operationFuture; 00054 private int id; 00055 00056 /* 00057 public FileTransferRequest(File srcFile, File dstFile, File futureDstFile, 00058 FileTransferService localFTS, FileTransferService remoteFTS) { 00059 00060 this(srcFile, dstFile, new OperationFuture(futureDstFile), localFTS, remoteFTS); 00061 } 00062 */ 00063 public FileTransferRequest(File srcFile, File dstFile, 00064 OperationStatus futureDstFile, FileTransferService srcFTS, 00065 FileTransferService dstFTS) { 00066 this.srcFile = srcFile; 00067 this.dstFile = dstFile; 00068 this.operationFuture = futureDstFile; 00069 this.sourceFTS = srcFTS; 00070 this.destinationFTS = dstFTS; 00071 00072 Random generator = new Random(); 00073 this.id = generator.nextInt(); 00074 } 00075 00076 public OperationStatus getOperationFuture() { 00077 return operationFuture; 00078 } 00079 00080 public void waitForOperation() { 00081 ProActive.waitFor(operationFuture); 00082 } 00083 00084 public boolean isAwaited() { 00085 return ProActive.isAwaited(operationFuture); 00086 } 00087 00088 public File getDstFile() { 00089 return dstFile; 00090 } 00091 00092 public FileTransferService getSourceFTS() { 00093 return sourceFTS; 00094 } 00095 00096 public FileTransferService getDestinationFTS() { 00097 return destinationFTS; 00098 } 00099 00100 public File getSrcFile() { 00101 return srcFile; 00102 } 00103 00104 public void setDstFuture(OperationStatus futureDstFile) { 00105 this.operationFuture = futureDstFile; 00106 } 00107 00108 public boolean equals(Object o) { 00109 FileTransferRequest ftr = (FileTransferRequest) o; 00110 return getDstFile().equals(ftr.getDstFile()) && 00111 getSrcFile().equals(ftr.getSrcFile()) && (getId() == ftr.getId()); 00112 } 00113 00114 public int getId() { 00115 return id; 00116 } 00117 00118 public void setSourceFTS(FileTransferService sourceFTS) { 00119 this.sourceFTS = sourceFTS; 00120 } 00121 00122 public String toString() { 00123 return getSrcFile().getAbsolutePath() + "->" + 00124 getDstFile().getAbsolutePath(); 00125 } 00126 }