BufferedWriter writer = new BufferedWriter(new FileWriter(fileToSend));
for(int i = 0; i < 1000; i++) {
writer.write(FOO_CONTENT + "\n");
}
SploutConfiguration conf = SploutConfiguration.getTestConfig();
conf.setProperty(FetcherProperties.DOWNLOAD_BUFFER, 16);
conf.setProperty(FetcherProperties.TEMP_DIR, TMP_DOWNLOAD_DIR);
final AtomicInteger failed = new AtomicInteger(0);
HttpFileExchanger exchanger = new HttpFileExchanger(conf, new ReceiveFileCallback() {
@Override
public void onProgress(String tablespace, Integer partition, Long version, File file,
long totalSize, long sizeDownloaded) {
}
@Override
public void onFileReceived(String tablespace, Integer partition, Long version, File file) {
}
@Override
public void onBadCRC(String tablespace, Integer partition, Long version, File file) {
}
@Override
public void onError(Throwable t, String tablespace, Integer partition, Long version, File file) {
if(t.getMessage().contains("Incoming file already being transferred")) {
failed.incrementAndGet();
}
}
});
exchanger.init();
exchanger.run();
String dnodeHost = conf.getString(DNodeProperties.HOST);
int httpPort = conf.getInt(HttpFileExchangerProperties.HTTP_PORT);
exchanger.send("t1", 1, 1l, fileToSend, "http://" + dnodeHost + ":" + httpPort, true);
exchanger.send("t1", 1, 1l, fileToSend, "http://" + dnodeHost + ":" + httpPort, true);
final File downloadedFile = new File(new File(TMP_DOWNLOAD_DIR,