Author: bback
Date: 2006-02-12 17:03:14 +0000 (Sun, 12 Feb 2006)
New Revision: 8025
Modified:
trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java
trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java
trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java
trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadThread.java
trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadTicker.java
trunk/apps/frost-0.7/source/frost/fileTransfer/upload/UploadThread.java
trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java
trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java
trunk/apps/frost-0.7/source/frost/threads/RunningBoardUpdateThreads.java
trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java
Log:
insert transfers from file to socket (no mem) and cleanups
Modified: trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java 2006-02-12
16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/fcp/FcpConnection.java 2006-02-12
17:03:14 UTC (rev 8025)
@@ -52,18 +52,18 @@
private static long staticFcpConnectionId = 0;
+ private static synchronized long getNextId() {
+ return staticFcpConnectionId++;
+ }
+
/**
- * Create a default connection to localhost using FCP
+ * Create a connection to localhost using FCP
*
* @exception UnknownHostException if the localhost cannot be
* determined.
* @exception IOException if there is a problem with the connection
* to the FCP host.
*/
-// public FcpConnection() throws UnknownHostException, IOException,
FcpToolsException {
-// this("127.0.0.1", 26000);
-// }
-
public FcpConnection(String host, String port) throws
UnknownHostException, IOException, FcpToolsException {
this(host, Integer.parseInt(port));
}
@@ -88,10 +88,6 @@
fcpConnectionId = getNextId();
}
- private static synchronized long getNextId() {
- return staticFcpConnectionId++;
- }
-
//needs reimplementation, fetches data from hallo
public String[] getInfo() throws IOException, FcpToolsException {
@@ -151,18 +147,15 @@
* @param htl the HTL to use in this request
* @return the results filled with metadata
*/
- public FcpResults getKeyToFile(String keyString,
- String filename,
- int htl) throws IOException,
FcpToolsException, InterruptedIOException {
+ public FcpResults getKeyToFile(String keyString, String filename)
+ throws IOException, FcpToolsException, InterruptedIOException {
- keyString = FcpDisconnect(keyString);
keyString = StripSlashes(keyString);
FcpResults result = new FcpResults();
FreenetKey key = new FreenetKey(keyString);
logger.fine("KeyString = " + keyString + "\n" +
"Key = " + key + "\n" +
- "KeyType = " + key.getKeyType() +
"\n" +
- "HTL = " + htl);
+ "KeyType = " + key.getKeyType());
FileOutputStream fileOut = new FileOutputStream(filename);
@@ -292,10 +285,6 @@
case FcpKeyword.UnknownError:
receivedFinalByte = true;
break;
- /*case FcpKeyword.MetadataLength:
- metaDataLength = kw.getLongVal();
- break;*/
-
case FcpKeyword.EndMessage:
break;
case FcpKeyword.DataChunk:
@@ -315,11 +304,8 @@
*/
case FcpKeyword.AllData:
break;
-
case FcpKeyword.Identifier:
break;
-
-
case FcpKeyword.Timeout:
// it WOULD be actually better for freenet AND the node to do it this way
@@ -337,7 +323,6 @@
byte[] b = new byte[dataChunkLength];
int bytesRead = 0, count;
-
while( bytesRead < dataChunkLength ) {
count = fcpIn.read(b, bytesRead, dataChunkLength -
bytesRead);
System.out.println("read following:");
@@ -375,19 +360,16 @@
/**
* Inserts the specified key with the data from the file specified.
*
- * @param key
- * the key to be inserted
- * @param data
- * the bytearray with the data to be inserted
- * @param htl
- * the HTL to use for this insert
+ * @param key the key to be inserted
+ * @param data the bytearray with the data to be inserted
* @return the results filled with metadata and the CHK used to insert the
data
*/
- public String putKeyFromArray(String key, byte[] data, int htl, boolean
getchkonly)
+ public String putKeyFromFile(String key, File sourceFile, boolean
getchkonly)
throws IOException, FcpToolsException {
+
+ long dataLength = sourceFile.length();
+ BufferedInputStream fileInput = new BufferedInputStream(new
FileInputStream(sourceFile));
- key = FcpDisconnect(key);
-
// stripping slashes
key = StripSlashes(key);
fcpSock = new Socket(host, port);
@@ -396,7 +378,7 @@
doHandshake(fcpSock);
fcpOut = new PrintStream(fcpSock.getOutputStream());
- DataOutputStream dOut = new
DataOutputStream(fcpSock.getOutputStream());
+ BufferedOutputStream dOut = new
BufferedOutputStream(fcpSock.getOutputStream());
fcpIn = new BufferedInputStream(fcpSock.getInputStream());
fcpOut.println("ClientPut");
@@ -405,14 +387,9 @@
fcpOut.println("URI=" + key);
System.out.println("URI="+key);
- int dataLength = 0;
- if (data != null) {
- dataLength = data.length;
- }
+ fcpOut.println("DataLength=" + Long.toString(dataLength));
+ System.out.println("DataLength="+ Long.toString(dataLength));
- fcpOut.println("DataLength=" + Integer.toString(dataLength));
- System.out.println("DataLength="+ Integer.toString(dataLength));
-
fcpOut.println("Identifier=put-" + fcpConnectionId );
System.out.println("Identifier=put-" + fcpConnectionId );
fcpOut.println("Verbosity=0");
@@ -428,10 +405,14 @@
System.out.println("Data");
fcpOut.flush();
- if (data != null) {
- dOut.write(data);
- //System.out.println( new
String(data,Charset.defaultCharset().toString()) );
- }
+ // write complete file to socket
+ while( true ) {
+ int d = fileInput.read();
+ if( d < 0 ) {
+ break; // EOF
+ }
+ dOut.write(d);
+ }
dOut.flush();
int c;
@@ -462,7 +443,6 @@
*/
public void doHandshake(Socket fcpSocket) throws IOException,
FcpToolsException
{
- //fcpSock = new Socket(host, port);
fcpIn = new BufferedInputStream(fcpSocket.getInputStream());
fcpOut = new PrintStream(fcpSocket.getOutputStream());
fcpSocket.setSoTimeout(TIMEOUT);
@@ -496,17 +476,16 @@
if (timeout == 32) {
throw new ConnectionException();
}
- //fcpSock.close();
}
/**
- * generates chk for the data
+ * Generates a CHK key for the given File (no upload).
*/
- public String generateCHK(byte[] data) throws IOException,
FcpToolsException
- {
+ public String generateCHK(File file) throws IOException, FcpToolsException
{
+
String uri = "";
- String output = putKeyFromArray("CHK@", data, 3, true);
+ String output = putKeyFromFile("CHK@", file, true);
System.out.println("GOT OUTPUT " + output + "\n STARTING CHK
GENERATION");
int URIstart = output.indexOf("CHK@");
String substr = output.substring(URIstart);
@@ -589,20 +568,16 @@
//replaces all / with | in url
private String StripSlashes(String uri){
//replacing all / with |
- if (uri.startsWith("KSK@")){
+ if (uri.startsWith("KSK@")) {
String myUri = null;
myUri= uri.replace('/','|');
return myUri;
- }else if (uri.startsWith("SSK@")){
- String sskpart= uri.substring(0,uri.indexOf('/') + 1);
+ } else if (uri.startsWith("SSK@")) {
+ String sskpart= uri.substring(0, uri.indexOf('/') + 1);
String datapart =
uri.substring(uri.indexOf('/')+1).replace('/','|');
-
return sskpart + datapart;
- }else
+ } else {
return uri;
+ }
}
-
- private String FcpDisconnect(String tport) {
- return tport;
- }
}
Modified: trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java 2006-02-12
16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/fcp/FcpInsert.java 2006-02-12
17:03:14 UTC (rev 8025)
@@ -24,13 +24,11 @@
import java.io.*;
import java.net.*;
-import java.util.*;
import java.util.logging.*;
import javax.swing.*;
import frost.*;
-
import frost.fileTransfer.upload.*;
/**
@@ -120,7 +118,6 @@
*/
public static String[] putFile(String uri,
File file,
- int htl,
FrostUploadItem ulItem)
{
if (file.length() == 0) {
@@ -139,8 +136,7 @@
return ERROR;
}
- byte[] data = FileAccess.readByteArray(file);
- String output = connection.putKeyFromArray(uri, data, htl, false);
+ String output = connection.putKeyFromFile(uri, file, false);
return result(output);
@@ -155,7 +151,7 @@
public static String generateCHK(File file) {
if (file.length() == 0) {
- logger.log(Level.SEVERE, "Error: Can't generate CHK empty file:
"+file.getPath());
+ logger.log(Level.SEVERE, "Error: Can't generate CHK for empty
file: "+file.getPath());
System.out.println("Error: Can't generate CHK for empty file:
"+file.getPath());
JOptionPane.showMessageDialog(MainFrame.getInstance(),
"FcpInsert: File
"+file.getPath()+" is empty!", // message
@@ -169,8 +165,7 @@
if( connection == null ) {
return null;
}
- byte[] data = FileAccess.readByteArray(file);
- String generatedCHK = connection.generateCHK(data);
+ String generatedCHK = connection.generateCHK(file);
return generatedCHK;
} catch( UnknownHostException e ) {
Modified: trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java 2006-02-12
16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/fcp/FcpRequest.java 2006-02-12
17:03:14 UTC (rev 8025)
@@ -49,7 +49,6 @@
public static FcpResults getFile(String key,
Long size,
File target,
- int htl,
boolean createTempFile,
FrostDownloadItem dlItem)
{
@@ -66,7 +65,7 @@
}
// First we just download the file, not knowing what lies ahead
- FcpResults results = getKey(key, tempFile, htl);
+ FcpResults results = getKey(key, tempFile);
if( results != null ) {
@@ -96,7 +95,7 @@
}
// used by getFile
- private static FcpResults getKey(String key, File target, int htl) {
+ private static FcpResults getKey(String key, File target) {
if( key == null || key.length() == 0 || key.startsWith("null") ) {
return null;
@@ -110,7 +109,7 @@
int maxtries = 3;
while( tries < maxtries || results != null ) {
try {
- results = connection.getKeyToFile(key, target.getPath(),
htl);
+ results = connection.getKeyToFile(key, target.getPath());
break;
}
catch( java.net.ConnectException e ) {
Modified:
trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadThread.java
2006-02-12 16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadThread.java
2006-02-12 17:03:14 UTC (rev 8025)
@@ -40,9 +40,6 @@
private String filename;
private Long size;
private String key;
-// private String SHA1;
-// private String batch;
- private String owner;
private Board board;
private FrostDownloadItem downloadItem;
@@ -57,24 +54,8 @@
File newFile = new
File(settings.getValue("downloadDirectory") + filename);
// if we don't have the CHK, means the key was not
inserted
- // request it by SHA1
if (key == null) {
logger.severe("Key to download is NULL!");
-// logger.info("FILEDN: Requesting " + filename);
-// System.out.println("FILEDN: Requesting " +
filename);
-//
downloadItem.setState(FrostDownloadItem.STATE_REQUESTING);
-//
-// //request the file itself
-// try {
-// request();
-// logger.info("FILEDN: Uploaded request
for " + filename);
-// System.out.println("FILEDN: Uploaded
request for " + filename);
-// } catch (Throwable t) {
-// logger.log(Level.SEVERE, "FILEDN:
Uploading request failed for " + filename, t);
-// System.out.println("FILEDN: Uploading
request failed for " + filename);
-// }
-//
downloadItem.setState(FrostDownloadItem.STATE_REQUESTED);
-//
downloadItem.setLastDownloadStopTimeMillis(System.currentTimeMillis());
ticker.threadFinished();
@@ -90,12 +71,10 @@
FcpResults success = null;
try {
- // BBACKFLAG: implement increasing htls!
success = FcpRequest.getFile(
key,
size,
newFile,
- 25, // HTL
false, // createTempFile
downloadItem);
} catch (Throwable t) {
@@ -121,41 +100,6 @@
logger.warning("FILEDN: Download of " +
filename + " failed.");
System.out.println("FILEDN: Download of " +
filename + " failed.");
if (inTable == true) {
-// // Upload request to request stack
-// if
(settings.getBoolValue("downloadEnableRequesting")
-// && downloadItem.getRetries()
-// >=
settings.getIntValue("downloadRequestAfterTries")
-// && board != null
-// && board.isFolder() == false
-// && this.owner != null) //
upload requests only if they are NOT manually added
-// {
-// logger.info("FILEDN: Download
failed, uploading request for " + filename);
-// System.out.println("FILEDN:
Download failed, uploading request for " + filename);
-//
downloadItem.setState(FrostDownloadItem.STATE_REQUESTING);
-//
-// // We may not do the request
here due to the synchronize
-// // -> no lock needed, using
models
-// // doing it after this , the
table states Waiting and there are threads running,
-// // so download seems to stall
-// try {
-// request();
-// logger.info("FILEDN:
Uploaded request for " + filename);
-//
System.out.println("FILEDN: Uploaded request for " + filename);
-// } catch (Throwable t) {
-// logger.log(
-// Level.SEVERE,
-// "FILEDN:
Uploading request failed for " + filename,
-// t);
-// System.out.println(
-//
-//
"FILEDN: Uploading request failed for " + filename
-// );
-// }
-// } else {
-// logger.info("FILEDN: Download
failed (file is NOT requested).");
-// System.out.println("FILEDN:
Download failed (file is NOT requested).");
-// }
-
// set new state -> failed or waiting
for another try
if (downloadItem.getRetries()
>
settings.getIntValue("downloadMaxRetries")) {
@@ -175,14 +119,11 @@
// do NOT add manually downloaded files (file
have no SHA1, no owner, no board)
if (board != null
&& board.isFolder() == false)
-// && this.SHA1 != null
-// &&
Core.frostSettings.getBoolValue("shareDownloads"))
{
// Add successful downloaded key to
database
SharedFileObject newKey = new
SharedFileObject(key);
newKey.setFilename(filename);
newKey.setSize(newFile.length());
-// newKey.setSHA1(SHA1);
newKey.setDate(date);
Index index = Index.getInstance();
synchronized(index) {
@@ -198,269 +139,14 @@
System.out.println("FILEDN: Download of " +
filename + " was successful.");
}
} catch (Throwable t) {
- logger.log(Level.SEVERE, "Oo. EXCEPTION in
requestThread.run", t);
- System.out.println("Oo. EXCEPTION in
requestThread.run");
+ logger.log(Level.SEVERE, "Oo. EXCEPTION in
DownloadThread.run", t);
+ System.out.println("Oo. EXCEPTION in
DownloadThread.run");
}
ticker.threadFinished();
downloadItem.setLastDownloadStopTimeMillis(System.currentTimeMillis());
}
- // Request a certain file by SHA1
-// private void request() {
-// int messageUploadHtl = settings.getIntValue("tofUploadHtl");
-// boolean requested = false;
-//
-// logger.info("FILEDN: Uploading request for '" + filename + "'
to board '" + board.getName() + "'");
-// System.out.println("FILEDN: Uploading request for '" + filename
+ "' to board '" + board.getName() + "'");
-//
-// if( batch == null || owner == null ) {
-// logger.severe("FILEDN: NO batch or owner, skipping upload of
request for "+filename);
-// System.out.println("FILEDN: NO batch or owner, skipping upload
of request for "+filename);
-// return;
-// }
-//
-// String destination =
-// new StringBuffer()
-// .append("requests")
-// .append(File.separator)
-// .append(owner)
-// .append("-")
-// .append(batch)
-// .append("-")
-// .append(DateFun.getDate())
-// .toString();
-// File checkDestination = new File(destination);
-// if (!checkDestination.isDirectory()) {
-// checkDestination.mkdirs();
-// }
-//// TODO: put multiple requests into 1 file; do this above downloadthread
-// // Check if file was already requested
-// // ++ check only in req files
-// File[] files = checkDestination.listFiles(new FilenameFilter() {
-// public boolean accept(File dir, String name) {
-// if (name.endsWith(".req.sha"))
-// return true;
-// return false;
-// }
-// });
-// for (int i = 0; i < files.length; i++) {
-// String content = (FileAccess.readFile(files[i])).trim();
-// if (content.equals(SHA1)) {
-// requested = true;
-// logger.info("FILEDN: File '" + filename + "'
was already requested");
-// System.out.println("FILEDN: File '" + filename
+ "' was already requested");
-// break;
-// }
-// }
-//
-// if (!requested) {
-// String date = DateFun.getDate();
-//
-// // Generate file to upload
-// File requestFile = null;
-// try {
-// requestFile = File.createTempFile(
-// "reqUpload_",
-// null,
-// new
File(settings.getValue("temp.dir")));
-// } catch (Exception ex) {
-// requestFile = new File(
-//
settings.getValue("temp.dir")
-// +
System.currentTimeMillis()
-// + ".tmp");
-// }
-// //TOTHINK: we can also encrypt the request
-// FileAccess.writeFile(SHA1, requestFile);
-// // Write requested key to disk
-//
-// // Search empty slot
-// boolean success = false;
-// int index = 0;
-// int tries = 0;
-// boolean error = false;
-// File testMe = null;
-// while (!success) {
-// // Does this index already exist?
-// testMe = new File( new StringBuffer()
-//
.append(destination)
-//
.append(File.separator)
-// .append(index)
-//
.append(".req.sha")
-// .toString());
-// if (testMe.length() > 0) { // already downloaded
-// index++;
-// //if( DEBUG )
Core.getOut().println("FILEDN: File exists, increasing index to " + index);
-// continue; // while
-// } else {
-// // probably empty, check if other
threads currently try to insert to this index
-// File lockRequestIndex = new
File(testMe.getPath() + ".lock");
-// boolean lockFileCreated = false;
-// try {
-// lockFileCreated =
lockRequestIndex.createNewFile();
-// } catch (IOException ex) {
-// logger.log( Level.SEVERE,
-// "ERROR:
requestThread.request(): unexpected IOException, terminating thread ...",
-// ex);
-// System.out.println(
-// "ERROR:
requestThread.request(): unexpected IOException, terminating thread ..."
-// );
-// return;
-// }
-//
-// if (lockFileCreated == false) {
-// // another thread tries to
insert using this index, try next
-// index++;
-// logger.fine("FILEDN: Other
thread tries this index, increasing index to " + index);
-// System.out.println("FILEDN:
Other thread tries this index, increasing index to " + index);
-// continue; // while
-// } else {
-// // we try this index
-// lockRequestIndex.deleteOnExit();
-// }
-//
-// // try to insert
-//
-// String[] result = new String[2];
-// String upKey =
-// new StringBuffer()
-// .append("KSK at
frost/request/")
-//
.append(settings.getValue("messageBase"))
-// .append("/")
-// .append(owner)
-// .append("-")
-// .append(batch)
-// .append("-")
-// .append(date)
-// .append("-")
-// .append(index)
-// .append(".req.sha")
-// .toString();
-// logger.fine(upKey);
-// System.out.println(upKey);
-// result = FcpInsert.putFile(upKey,
requestFile, messageUploadHtl, false);
-// System.out.println("FcpInsert result[0]
= " + result[0] + " result[1] = " + result[1]);
-//
-// if (result[0] == null || result[1] ==
null) {
-// result[0] = "Error";
-// result[1] = "Error";
-// }
-//
-// if (result[0].equals("Success")) {
-// success = true;
-// } else if
(result[0].equals("KeyCollision")) {
-// // Check if the collided key is
perhapes the requested one
-// File compareMe = null;
-// try {
-// compareMe =
-//
File.createTempFile(
-//
"reqUploadCmpDnload_",
-// null,
-// new
File(settings.getValue("temp.dir")));
-// } catch (Exception ex) {
-// compareMe =
-// new File(
-//
settings.getValue("temp.dir")
-//
+ System.currentTimeMillis()
-//
+ ".tmp");
-// }
-// compareMe.deleteOnExit();
-//
-// String requestMe = upKey;
-//
-// if
(FcpRequest.getFile(requestMe, null, compareMe, 25, false) != null) {
-// File numberOne =
compareMe;
-// File numberTwo =
requestFile;
-// String contentOne =
(FileAccess.readFile(numberOne)).trim();
-// String contentTwo =
(FileAccess.readFile(numberTwo)).trim();
-//
-// //if( DEBUG )
Core.getOut().println(contentOne);
-// //if( DEBUG )
Core.getOut().println(contentTwo);
-//
-// if
(contentOne.equals(contentTwo)) {
-//
logger.fine("FILEDN: Key Collision and file was already requested");
-// success = true;
-// } else {
-// index++;
-// logger.fine(
-//
"FILEDN: Request Upload collided, increasing index to "
-//
+ index);
-//
-// if
(settings.getBoolValue(SettingsClass.DISABLE_REQUESTS) == true) {
-// //
uploading is disabled, therefore already existing requests are not
-// //
written to disk, causing key collosions on every request insert.
-//
-// // this
write a .req file to inform others to not try this index again
-// // if
user switches to uploading enabled, this dummy .req files should
-// // be
silently deleted to enable receiving of new requests
-//
FileAccess.writeFile(KEYCOLL_INDICATOR, testMe);
-// }
-// }
-// } else {
-// logger.info(
-// "FILEDN:
Request upload failed ("
-// + tries
-// + "),
retrying index "
-// +
index);
-// System.out.println(
-//
"FILEDN: Request upload failed ("
-//
+ tries
-//
+ "), retrying index "
-//
+ index);
-//
-// if (tries > 5) {
-// success = true;
-// error = true;
-// }
-// tries++;
-// }
-// compareMe.delete();
-// }
-// // finally delete the index lock file
-// lockRequestIndex.delete();
-// }
-// }
-//
-// if (!error) {
-// requestFile.renameTo(testMe);
-// logger.info(
-//
"*********************************************************************\n"
-// + "Request for '"
-// + filename
-// + "' successfully uploaded to
board '"
-// + board
-// + "'.\n"
-// +
"*********************************************************************");
-// System.out.println(
-//
"*********************************************************************\n"
-// + "Request for '"
-// + filename
-// + "' successfully
uploaded to board '"
-// + board
-// + "'.\n"
-// +
"*********************************************************************");
-// } else {
-// logger.warning(
-// "FILEDN: Error while uploading request
for '"
-// + filename
-// + "' to board '"
-// + board
-// + "'.");
-//
-// System.out.println(
-// "FILEDN: Error while uploading
request for '"
-// + filename
-// + "' to board '"
-// + board
-// + "'.");
-//
-// requestFile.delete();
-// }
-// logger.info("FILEDN: Request Upload Thread finished");
-// System.out.println("FILEDN: Request Upload Thread
finished");
-// }
-// }
-
/**Constructor*/
public DownloadThread(
DownloadTicker newTicker,
@@ -473,13 +159,6 @@
size = item.getFileSize();
key = item.getKey();
board = item.getSourceBoard();
-// SHA1 = item.getSHA1();
-// batch = item.getBatch();
- if( item.getOwner() != null ) { // owner is null for manually
added files
- owner = Mixed.makeFilename(item.getOwner());
- } else {
- owner = null;
- }
ticker = newTicker;
downloadItem = item;
downloadModel = model;
Modified:
trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadTicker.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadTicker.java
2006-02-12 16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/fileTransfer/download/DownloadTicker.java
2006-02-12 17:03:14 UTC (rev 8025)
@@ -174,9 +174,6 @@
fireThreadCountChanged();
}
- /**
- *
- */
private void removeFinishedDownloads() {
if (counter % 300 == 0 &&
settings.getBoolValue("removeFinishedDownloads")) {
model.removeFinishedDownloads();
Modified:
trunk/apps/frost-0.7/source/frost/fileTransfer/upload/UploadThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/fileTransfer/upload/UploadThread.java
2006-02-12 16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/fileTransfer/upload/UploadThread.java
2006-02-12 17:03:14 UTC (rev 8025)
@@ -19,15 +19,14 @@
package frost.fileTransfer.upload;
-import java.io.File;
-import java.util.Random;
+import java.io.*;
import java.util.logging.*;
import frost.*;
import frost.fcp.*;
-import frost.fileTransfer.Index;
-import frost.gui.objects.Board;
-import frost.identities.LocalIdentity;
+import frost.fileTransfer.*;
+import frost.gui.objects.*;
+import frost.identities.*;
import frost.messages.*;
class UploadThread extends Thread
@@ -42,25 +41,12 @@
private static Logger logger =
Logger.getLogger(UploadThread.class.getName());
-// public static final int MODE_GENERATE_SHA1 = 1;
-// public static final int MODE_GENERATE_CHK = 2;
public static final int MODE_UPLOAD = 3;
private int nextState; // the state to set on uploadItem when finished, or
-1 for default (IDLE)
- private String destination;
private File file;
- private int htl;
private Board board;
private int mode;
-// private static int fileIndex=1;
- private static Random r = new Random();
- //this is gonna be ugly
-// private static String batchId = Core.getMyBatches().values().size() == 0
?
-// (new Long(r.nextLong())).toString() :
-// (String)
Core.getMyBatches().values().iterator().next();
-// private static final int batchSize = 100; //TODO: get this from options
- //private static final Object putIt =
frame1.getMyBatches().put(batchId,batchId);
- //^^ ugly trick to put the initial batch number
FrostUploadItem uploadItem;
@@ -69,21 +55,7 @@
case MODE_UPLOAD:
ticker.uploadingThreadStarted();
break;
-// case MODE_GENERATE_SHA1:
-// ticker.generatingThreadStarted();
-// break;
-// case MODE_GENERATE_CHK:
-// ticker.generatingThreadStarted();
-// break;
}
-// if (batchId == null) {
-// Exception er = new Exception();
-// er.fillInStackTrace();
-// logger.log(Level.SEVERE, "Exception thrown in run()",
er);
-// }
-// if (Core.getMyBatches().values().size() == 0) {
-// Core.getMyBatches().put(batchId, batchId);
-// }
boolean sign =
MainFrame.frostSettings.getBoolValue("signUploads");
try {
switch (mode) {
@@ -91,14 +63,6 @@
upload(sign);
ticker.uploadingThreadFinished();
break;
-// case MODE_GENERATE_SHA1 :
-// generateSHA1(sign);
-// ticker.generatingThreadFinished();
-// break;
-// case MODE_GENERATE_CHK :
-// generateCHK();
-// ticker.generatingThreadFinished();
-// break;
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Exception thrown in run()",
e);
@@ -106,12 +70,6 @@
case MODE_UPLOAD :
ticker.uploadingThreadFinished();
break;
-// case MODE_GENERATE_SHA1 :
-// ticker.generatingThreadFinished();
-// break;
-// case MODE_GENERATE_CHK :
-// ticker.generatingThreadFinished();
-// break;
}
}
}
@@ -123,12 +81,11 @@
String[] result = { "Error", "Error" };
String currentDate = DateFun.getExtendedDate();
- logger.info("Upload of " + file + " with HTL " + htl + "
started.");
+ logger.info("Upload of " + file + "started.");
result = FcpInsert.putFile(
"CHK@",
file,
- htl,
uploadItem); // provide the uploadItem to indicate that this
upload is contained in table
if (result[0].equals("PutSuccessful") ||
result[0].equals("KeyCollision")) {
@@ -172,8 +129,6 @@
current.setOwner(myId.getUniqueName());
}
current.setFilename(uploadItem.getFileName());
-// current.setSHA1(uploadItem.getSHA1());
-// current.setBatch(uploadItem.getBatch());
current.setSize(uploadItem.getFileSize().longValue());
current.setDate(lastUploadDate);
current.setLastSharedDate(lastUploadDate);
@@ -185,74 +140,6 @@
}
uploadItem.setLastUploadStopTimeMillis(System.currentTimeMillis());
}
-
-// private void generateSHA1(boolean sign) {
-// if (fileIndex % batchSize == 0) {
-// Core.getMyBatches().put(batchId, batchId);
-// while (Core.getMyBatches().contains(batchId)) {
-// batchId = (new Long(r.nextLong())).toString();
-// }
-// Core.getMyBatches().put(batchId, batchId);
-// }
-//
-// long now = System.currentTimeMillis();
-// String SHA1 = Core.getCrypto().digest(file);
-// logger.fine("digest generated in " +
(System.currentTimeMillis() - now) + " " + SHA1);
-//
-// //create new KeyClass
-// SharedFileObject newKey = new SharedFileObject();
-// newKey.setKey(null);
-// newKey.setDate(null);
-// newKey.setLastSharedDate(DateFun.getExtendedDate());
-// newKey.setSHA1(SHA1);
-// newKey.setFilename(destination);
-// newKey.setSize(file.length());
-// newKey.setBatch(batchId);
-// if (sign) {
-// newKey.setOwner(myId.getUniqueName());
-// }
-//
-// //update the gui
-// uploadItem.setSHA1(SHA1);
-// uploadItem.setKey(null);
-// uploadItem.setLastUploadDate(null);
-// uploadItem.setBatch(batchId);
-// fileIndex++;
-// //add to index
-// Index index = Index.getInstance();
-// synchronized(index) {
-// index.addMine(newKey, board);
-// index.add(newKey, board);
-// }
-// uploadItem.setState(this.nextState);
-// }
-//
-// private void generateCHK() {
-// logger.info("CHK generation started for file: " + file);
-// System.out.println("CHK generation started for file: " + file);
-// String chkkey = FcpInsert.getCHK(file);
-//
-//
-// //removes freenet:
-// if (chkkey != null) {
-// String prefix = new String("freenet:");
-// if (chkkey.startsWith(prefix)) {
-// chkkey = chkkey.substring(prefix.length());
-// }
-// } else {
-// logger.warning("Could not generate CHK key for redirect
file.");
-// }
-//
-// uploadItem.setKey(chkkey);
-//
-// // test if the GetRequestsThread did set us the nextState
field...
-// if (uploadItem.getNextState() > 0) {
-// uploadItem.setState(uploadItem.getNextState());
-// uploadItem.setNextState(0); // reset nextState
-// } else {
-// uploadItem.setState(this.nextState);
-// }
-// }
/**Constructor*/
public UploadThread(UploadTicker newTicker, FrostUploadItem ulItem,
SettingsClass settings, int mode, LocalIdentity newMyId)
@@ -267,7 +154,6 @@
int newNextState,
LocalIdentity newMyId) {
- destination = ulItem.getFileName();
file = new File(ulItem.getFilePath());
myId = newMyId;
@@ -275,7 +161,6 @@
uploadItem = ulItem;
this.settings = settings;
- htl = settings.getIntValue("htlUpload");
board = ulItem.getTargetBoard();
mode = newMode;
nextState = newNextState;
Modified: trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java
2006-02-12 16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/threads/MessageDownloadThread.java
2006-02-12 17:03:14 UTC (rev 8025)
@@ -39,7 +39,6 @@
implements BoardUpdateThread
{
private Board board;
- private int downloadHtl;
private String keypool;
private int maxMessageDownload;
private String destination;
@@ -218,7 +217,6 @@
downKey,
null,
testMe,
- downloadHtl,
true, // createTempFile
null); // no DownloadItem
@@ -384,7 +382,6 @@
public MessageDownloadThread(
boolean fn,
Board boa,
- int dlHtl,
String kpool,
String maxmsg,
FrostIdentities newIdentities) {
@@ -393,7 +390,6 @@
this.flagNew = fn;
this.board = boa;
- this.downloadHtl = dlHtl;
this.keypool = kpool;
this.maxMessageDownload = Integer.parseInt(maxmsg);
}
Modified: trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java
2006-02-12 16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/threads/MessageUploadThread.java
2006-02-12 17:03:14 UTC (rev 8025)
@@ -52,7 +52,6 @@
private MessageObject message;
private File unsentMessageFile;
- private int messageUploadHtl;
private String privateKey;
// private String publicKey;
private boolean secure;
@@ -98,7 +97,6 @@
mo.setDate(DateFun.getDate());
}
- messageUploadHtl = frostSettings.getIntValue("tofUploadHtl");
keypool = frostSettings.getValue("keypool.dir");
// this class always creates a new msg file on hd and deletes
the file
@@ -311,7 +309,7 @@
secure = false;
}
- logger.info("TOFUP: Uploading message to board '" +
board.getName() + "' with HTL " + messageUploadHtl);
+ logger.info("TOFUP: Uploading message to board " +
board.getName());
// first save msg to be able to resend on crash
if (!saveMessage(message, unsentMessageFile)) {
@@ -472,7 +470,6 @@
FcpInsert.putFile(
"CHK@",
attachment.getFile(),
- uploadHtl,
new FrostUploadItem(null,
null));
} catch (Exception ex) {
result = new String[1];
@@ -655,7 +652,6 @@
result = FcpInsert.putFile(
upKey,
uploadFile,
- messageUploadHtl,
null); // UploadItem
} catch (Throwable t) {
logger.log(Level.SEVERE, "TOFUP: Error in
run()/FcpInsert.putFile", t);
Modified:
trunk/apps/frost-0.7/source/frost/threads/RunningBoardUpdateThreads.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/RunningBoardUpdateThreads.java
2006-02-12 16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/threads/RunningBoardUpdateThreads.java
2006-02-12 17:03:14 UTC (rev 8025)
@@ -86,7 +86,6 @@
new MessageDownloadThread(
true,
board,
- config.getIntValue("tofDownloadHtl"),
config.getValue("keypool.dir"),
config.getValue("maxMessageDownload"),
identities);
@@ -121,7 +120,6 @@
new MessageDownloadThread(
false,
board,
- config.getIntValue("tofDownloadHtl"),
config.getValue("keypool.dir"),
config.getValue("maxMessageDownload"),
identities);
Modified: trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java
2006-02-12 16:12:44 UTC (rev 8024)
+++ trunk/apps/frost-0.7/source/frost/threads/UpdateIdThread.java
2006-02-12 17:03:14 UTC (rev 8025)
@@ -34,8 +34,6 @@
private static Logger logger =
Logger.getLogger(UpdateIdThread.class.getName());
private String date;
- private int requestHtl;
- private int insertHtl;
private String keypool;
private Board board;
private String publicKey;
@@ -128,7 +126,6 @@
String[] result = FcpInsert.putFile(
insertKey + index + ".idx.sha3.zip", // this format is
sha3 ;)
zippedIndexFile,
- insertHtl,
null); // UploadItem
if( result[0].equals("PutSuccessful") ) {
@@ -191,7 +188,6 @@
requestKey + index + ".idx.sha3.zip", //this format is
sha3 ;)
null,
target,
- requestHtl, // we need it faster, same as for messages
true, // createTempFile
null); // DownloadItem
@@ -438,8 +434,6 @@
this.board = board;
this.date = date;
this.identities = newIdentities;
- requestHtl =
MainFrame.frostSettings.getIntValue("keyDownloadHtl");
- insertHtl = MainFrame.frostSettings.getIntValue("keyUploadHtl");
keypool = MainFrame.frostSettings.getValue("keypool.dir");
// maxKeys = MainFrame.frostSettings.getIntValue("maxKeys");
this.isForToday = isForToday;