private void startRequestForNewEdition() { try { concurrentFetchCount -= 1; mStorage.setAnnounceEdition(mStorage.getAnnounceEdition() + 1); addRequest(new FreenetURI(mStorage.getAnnounceKey())); concurrentFetchCount += 1; } catch (MalformedURLException e) { System.err.println( "[Async_AnnounceFetcher]::startRequestForNewEdition() MalformedURLException: " + e.getMessage()); e.printStackTrace(); } }
public void startFetching() { this.isRunning = true; try { for (short i = 0; i < mStorage.config.concurrentAnnounceFetcher; i++) { mStorage.setAnnounceEdition(mStorage.getAnnounceEdition() + 1); addRequest(new FreenetURI(mStorage.getAnnounceKey())); concurrentFetchCount += 1; } } catch (MalformedURLException e) { System.err.println( "[Async_AnnounceFetcher]::startFetching() MalformedURLException: " + e.getMessage()); e.printStackTrace(); } }
@Override public void onFailure(FetchException e, ClientGetter state, ObjectContainer container) { switch (e.getMode()) { case FetchException.RECENTLY_FAILED: // pretty normal for polling.. just add the request again if (state.getURI().toString().contains(mStorage.getCurrentDateString())) { restartRequest(state.getURI()); } else { startRequestForNewEdition(); } break; case FetchException.DATA_NOT_FOUND: // pretty normal for polling.. just add the request again if (state.getURI().toString().contains(mStorage.getCurrentDateString())) { restartRequest(state.getURI()); } else { startRequestForNewEdition(); } break; case FetchException.ALL_DATA_NOT_FOUND: // should not possible while fetching KSKs without following redirects. ? System.err.println( "[Async_AnnounceFetcher] ALL_DATA_NOT_FOUND. you should not see me. ignoring this announce. " + e.getMessage() + " " + state.getURI().toString()); startRequestForNewEdition(); break; case FetchException.ROUTE_NOT_FOUND: // if hit it we are trying to fetch something but the node does not have a proper // connection. // just add the request again if (state.getURI().toString().contains(mStorage.getCurrentDateString())) { restartRequest(state.getURI()); } else { startRequestForNewEdition(); } break; case FetchException.REJECTED_OVERLOAD: // just add the request again if (state.getURI().toString().contains(mStorage.getCurrentDateString())) { restartRequest(state.getURI()); } else { startRequestForNewEdition(); } break; case FetchException.INVALID_METADATA: // wtf? mStorage.announce_ddos += 1; System.err.println( "[Async_AnnounceFetcher] INVALID_METADATA. you should not see me. ignoring this announce. " + e.getMessage() + " " + state.getURI().toString()); startRequestForNewEdition(); break; case FetchException.TOO_BIG_METADATA: // wtf? mStorage.announce_ddos += 1; System.err.println( "[Async_AnnounceFetcher] TOO_BIG_METADATA. you should not see me. ignoring this announce. " + e.getMessage() + " " + state.getURI().toString()); startRequestForNewEdition(); break; case FetchException.TOO_BIG: // should not be possible while polling KSK's without following redirects mStorage.announce_ddos += 1; System.err.println( "[Async_AnnounceFetcher] TOO_BIG. you should not see me. ignoring this announce. " + e.getMessage() + " " + state.getURI().toString()); startRequestForNewEdition(); break; case FetchException.TOO_MANY_REDIRECTS: mStorage.announce_ddos += 1; System.err.println( "[Async_AnnounceFetcher] TOO_MANY_REDIRECTS. you should not see me. ignoring this announce. " + e.getMessage() + " " + state.getURI().toString()); startRequestForNewEdition(); break; case FetchException.TOO_MUCH_RECURSION: // FIXME: wtf? mStorage.announce_ddos += 1; System.err.println( "[Async_AnnounceFetcher] TOO_MUCH_RECURSION. you should not see me. ignoring this announce. " + e.getMessage() + " " + state.getURI().toString()); startRequestForNewEdition(); break; case FetchException.PERMANENT_REDIRECT: mStorage.announce_ddos += 1; System.err.println( "[Async_AnnounceFetcher] TOO_MUCH_RECURSION. you should not see me. ignoring this announce. " + e.getMessage() + " " + state.getURI().toString()); startRequestForNewEdition(); break; default: // now we have a serious problem. mStorage.announce_ddos += 1; System.err.println( "[Async_AnnounceFetcher]::onFailure() unknown error: " + e.getMessage() + " mode=" + e.getMode() + " ignoring this announce. uri=" + state.getURI().toString()); e.printStackTrace(); startRequestForNewEdition(); break; } }