|
|
@ -35,6 +35,8 @@ import protocolP2P.FilePart;
|
|
|
|
import protocolP2P.SizeRequest;
|
|
|
|
import protocolP2P.SizeRequest;
|
|
|
|
import protocolP2P.SizeResponse;
|
|
|
|
import protocolP2P.SizeResponse;
|
|
|
|
import protocolP2P.ProtocolP2PPacket;
|
|
|
|
import protocolP2P.ProtocolP2PPacket;
|
|
|
|
|
|
|
|
import protocolP2P.DiscoverRequest;
|
|
|
|
|
|
|
|
import protocolP2P.DiscoverResponse;
|
|
|
|
import protocolP2P.UpdateRatio;
|
|
|
|
import protocolP2P.UpdateRatio;
|
|
|
|
import clientP2P.ClientDownloadPart;
|
|
|
|
import clientP2P.ClientDownloadPart;
|
|
|
|
import tools.HostItem;
|
|
|
|
import tools.HostItem;
|
|
|
@ -391,6 +393,24 @@ public abstract class ClientDownload extends ServeErrors implements Runnable {
|
|
|
|
// get size
|
|
|
|
// get size
|
|
|
|
setSize();
|
|
|
|
setSize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get hostlist from tracker
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
ProtocolP2PPacket<?> req = createProtocolP2PPacket(new DiscoverRequest(filename));
|
|
|
|
|
|
|
|
req.sendRequest(getHostItemSocket(tracker));
|
|
|
|
|
|
|
|
Payload resp = req.receiveResponse().getPayload();
|
|
|
|
|
|
|
|
if (!(resp instanceof DiscoverResponse)) {
|
|
|
|
|
|
|
|
throw new InternalError();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DiscoverResponse p = (DiscoverResponse)resp;
|
|
|
|
|
|
|
|
hostList = p.getHostList();
|
|
|
|
|
|
|
|
} catch(IOException e) {
|
|
|
|
|
|
|
|
throw new InternalError();
|
|
|
|
|
|
|
|
} catch(RemoteException e) {
|
|
|
|
|
|
|
|
throw new InternalError();
|
|
|
|
|
|
|
|
} catch(LocalException e) {
|
|
|
|
|
|
|
|
throw new InternalError();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// get hashsum from 1st server in list
|
|
|
|
// get hashsum from 1st server in list
|
|
|
|
hash512 = getHashSum512(hostList.get(0));
|
|
|
|
hash512 = getHashSum512(hostList.get(0));
|
|
|
|
if (hash512.length == 0) {
|
|
|
|
if (hash512.length == 0) {
|
|
|
|