Replace one more deprecated peerDeparture in Protocol.transferIndex()

by moving/using interfaceDeparture() in transferRWI()
pull/149/head
reger 7 years ago
parent 37f44941fb
commit ed36b47bec

@ -1603,8 +1603,8 @@ public final class Protocol {
Map<String, String> in = transferRWI(targetSeed, indexes, gzipBody, timeout);
if ( in == null ) {
// targetSeed interface departure is already handled within transferRWI() for no response situation
String errorCause = "no connection from transferRWI";
seeds.peerActions.peerDeparture(targetSeed, errorCause); // disconnect unavailable peer
return errorCause;
}
@ -1665,13 +1665,25 @@ public final class Protocol {
return null;
}
/**
* Transfer Reverse Word Index entries to remote peer.
* If the used IP is not responding, this IP (interface) is removed from
* targtSeed IP list.
* Remote peer responds with list of unknown url hashes
*
* @param targetSeed
* @param indexes
* @param gzipBody
* @param timeout
* @return peer response or null if transfer failed
*/
private static Map<String, String> transferRWI(
final Seed targetSeed,
final ReferenceContainerCache<WordReference> indexes,
boolean gzipBody,
final int timeout) {
String ip = targetSeed.getIP();
if ( ip == null ) {
for (String ip : targetSeed.getIPs()) {
if (ip == null) {
Network.log.warn("no address for transferRWI");
return null;
}
@ -1713,7 +1725,6 @@ public final class Protocol {
parts.put("wordc", UTF8.StringBody(Integer.toString(indexes.size())));
parts.put("entryc", UTF8.StringBody(Integer.toString(indexcount)));
parts.put("indexes", UTF8.StringBody(entrypost.toString()));
// final byte[] content = HTTPConnector.getConnector(MultiProtocolURI.yacybotUserAgent).post(new MultiProtocolURI("http://" + address + "/yacy/transferRWI.html"), timeout, targetSeed.getHexHash() + ".yacyh", parts, gzipBody);
final HTTPClient httpClient = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent, timeout);
final byte[] content =
httpClient.POSTbytes(
@ -1730,8 +1741,11 @@ public final class Protocol {
return result;
} catch (final Exception e ) {
Network.log.info("yacyClient.transferRWI to " + address + " error: " + e.getMessage());
return null;
// disconnect unavailable peer ip
Switchboard.getSwitchboard().peers.peerActions.interfaceDeparture(targetSeed, ip);
}
}
return null;
}
private static Map<String, String> transferURL(

Loading…
Cancel
Save