- next try to fix the networking problem:

set the maximum transfer size to less than MTU=1500-52: buffer size <= 1448
- some refactoring of transfer methods (naming)

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4558 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent f63bd26268
commit fa1090113d

@ -262,7 +262,7 @@ public class WatchCrawler_p {
htmlFilterContentScraper scraper = new htmlFilterContentScraper(new yacyURL(file));
//OutputStream os = new htmlFilterOutputStream(null, scraper, null, false);
Writer writer = new htmlFilterWriter(null,null,scraper,null,false);
serverFileUtils.write(fileString,writer);
serverFileUtils.copy(fileString, writer);
writer.close();
//String headline = scraper.getHeadline();

@ -88,7 +88,7 @@ public class getpageinfo_p {
htmlFilterContentScraper scraper = new htmlFilterContentScraper(u);
//OutputStream os = new htmlFilterOutputStream(null, scraper, null, false);
Writer writer = new htmlFilterWriter(null,null,scraper,null,false);
serverFileUtils.write(contentString,writer);
serverFileUtils.copy(contentString,writer);
writer.close();
// put the document title

@ -137,7 +137,7 @@ public final class transfer {
File file = new File(path, filename);
try {
if (file.getCanonicalPath().toString().startsWith(path.getCanonicalPath().toString())){
serverFileUtils.write(fileString.getBytes(), file);
serverFileUtils.copy(fileString.getBytes(), file);
String md5t = serverCodings.encodeMD5Hex(file);
if (md5t.equals(md5)) {
prop.put("response", "ok");

@ -435,7 +435,7 @@ public final class httpTemplate {
}
*/
serverFileUtils.write(replacement, out);
serverFileUtils.copy(replacement, out);
} else {
// inconsistency, simply finalize this
serverFileUtils.copy(pis, out);
@ -479,7 +479,7 @@ public final class httpTemplate {
byte[] tmp=new byte[2];
tmp[0]=hash;
tmp[1]=(byte)bb;
serverFileUtils.write(tmp, out);
serverFileUtils.copy(tmp, out);
}
}
//System.out.println(structure.toString()); //DEBUG

@ -1236,7 +1236,7 @@ public final class httpd implements serverHandler {
if (! method.equals(httpHeader.METHOD_HEAD)) {
// write the array to the client
serverFileUtils.write(result, respond);
serverFileUtils.copy(result, respond);
}
respond.flush();
} catch (Exception e) {

@ -768,7 +768,7 @@ public final class httpdFileHandler {
httpVersion, 200, null, mimeType, result.length,
targetDate, null, tp.getOutgoingHeader(),
contentEncoding, null, nocache);
serverFileUtils.write(result, out);
serverFileUtils.copy(result, out);
}
}
} else { // no html

@ -178,7 +178,7 @@ public final class indexRAMRI implements indexRI {
if (writeBuffer != null) {
serverByteBuffer bb = writeBuffer.getBuffer();
//System.out.println("*** byteBuffer size = " + bb.length());
serverFileUtils.write(bb.getBytes(), indexDumpFile);
serverFileUtils.copy(bb.getBytes(), indexDumpFile);
writeBuffer.close();
}
dumpArray.close();

@ -204,7 +204,7 @@ public class kelondroAttrSeq {
if (out.toString().endsWith(".gz")) {
serverFileUtils.writeAndGZip((new String(sb)).getBytes(), out);
} else {
serverFileUtils.write((new String(sb)).getBytes(), out);
serverFileUtils.copy((new String(sb)).getBytes(), out);
}
}

@ -183,7 +183,7 @@ public class kelondroRowCollection {
}
public void saveCollection(File file) throws IOException {
serverFileUtils.write(exportCollection(), file);
serverFileUtils.copy(exportCollection(), file);
}
public kelondroRow row() {

@ -81,7 +81,7 @@ public class odtDetector implements MagicDetector {
File dstFile = null;
try {
dstFile = File.createTempFile("mimeTypeParser",".tmp");
serverFileUtils.write(data,dstFile);
serverFileUtils.copy(data,dstFile);
return process(dstFile, offset, length, bitmask, comparator, mimeType, params);
} catch (IOException e) {
return null;

@ -373,7 +373,7 @@ public final class plasmaHTCache {
try {
deleteFile(file);
file.getParentFile().mkdirs();
serverFileUtils.write(array, file);
serverFileUtils.copy(array, file);
} catch (FileNotFoundException e) {
// this is the case of a "(Not a directory)" error, which should be prohibited
// by the shallStoreCache() property. However, sometimes the error still occurs

@ -422,6 +422,9 @@ public final class serverCore extends serverAbstractThread implements serverThre
// set a non-zero linger, that means that a socket.close() blocks until all data is written
controlSocket.setSoLinger(true, this.timeout);
// ensure that MTU-48 is not exceeded to prevent that routers cannot handle large data packets
controlSocket.setSendBufferSize(1440);
// create session
Session connection = new Session(sessionThreadGroup, controlSocket, this.timeout);
this.busySessions.add(connection);

@ -72,10 +72,10 @@ import de.anomic.tools.nxTools;
public final class serverFileUtils {
private static final int DEFAULT_BUFFER_SIZE = 512;
private static final int DEFAULT_BUFFER_SIZE = 1024; // this is also the maximum chunk size
public static long copy(InputStream source, OutputStream dest) throws IOException {
return copy(source,dest, -1);
return copy(source, dest, -1);
}
/**
@ -133,7 +133,7 @@ public final class serverFileUtils {
}
public static int copy(Reader source, Writer dest) throws IOException {
char[] buffer = new char[4096];
char[] buffer = new char[DEFAULT_BUFFER_SIZE];
int count = 0;
int n = 0;
try {
@ -151,7 +151,7 @@ public final class serverFileUtils {
public static void copy(InputStream source, File dest) throws IOException {
copy(source,dest,-1);
}
/**
* Copies an InputStream to a File.
* @param source InputStream
@ -213,10 +213,6 @@ public final class serverFileUtils {
}
}
public static void copy(File source, File dest) throws IOException {
copy(source,dest,-1);
}
/**
* Copies a File to a File.
* @param source File
@ -227,19 +223,28 @@ public final class serverFileUtils {
* @see #copyRange(File source, OutputStream dest, int start)
* @see #copy(File source, OutputStream dest)
*/
public static void copy(File source, File dest, long count) throws IOException {
public static void copy(File source, File dest) throws IOException {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(source);
fos = new FileOutputStream(dest);
copy(fis, fos, count);
copy(fis, fos, -1);
} finally {
if (fis != null) try {fis.close();} catch (Exception e) {}
if (fos != null) try {fos.close();} catch (Exception e) {}
}
}
public static void copy(byte[] source, OutputStream dest) throws IOException {
dest.write(source, 0, source.length);
dest.flush();
}
public static void copy(byte[] source, File dest) throws IOException {
copy(new ByteArrayInputStream(source), dest);
}
public static byte[] read(InputStream source) throws IOException {
return read(source,-1);
}
@ -297,27 +302,13 @@ public final class serverFileUtils {
GZIPOutputStream zipOut = null;
try {
zipOut = new GZIPOutputStream(dest);
write(source, zipOut);
copy(source, zipOut);
zipOut.close();
} finally {
if (zipOut != null) try { zipOut.close(); } catch (Exception e) {}
}
}
public static void write(String source, Writer dest) throws IOException {
dest.write(source);
dest.flush();
}
public static void write(byte[] source, OutputStream dest) throws IOException {
dest.write(source, 0, source.length);
dest.flush();
}
public static void write(byte[] source, File dest) throws IOException {
copy(new ByteArrayInputStream(source), dest);
}
/**
* This function determines if a byte array is gzip compressed and uncompress it
* @param source properly gzip compressed byte array

@ -328,7 +328,7 @@ public final class serverSystem {
}
public static void deployScript(File scriptFile, String theScript) throws IOException {
serverFileUtils.write(theScript.getBytes(), scriptFile);
serverFileUtils.copy(theScript.getBytes(), scriptFile);
try {
Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();
} catch (InterruptedException e) {

@ -286,7 +286,7 @@ public final class yacy {
} catch (IOException e) {}
final File htdocsReadme = new File(htDocsPath, "readme.txt");
if (!(htdocsReadme.exists())) try {serverFileUtils.write((
if (!(htdocsReadme.exists())) try {serverFileUtils.copy((
"This is your root directory for individual Web Content\r\n" +
"\r\n" +
"Please place your html files into the www subdirectory.\r\n" +

Loading…
Cancel
Save