コード例 #1
0
 @Override
 public void onSuccess(FetchResult result, ClientGetter state, ObjectContainer container) {
   try {
     mFreenetMessageParser.addMessage(
         "announce", "", new String(result.asByteArray()).trim(), state.getURI().toString());
     startRequestForNewEdition();
   } catch (IOException e) {
     System.err.println("[Async_AnnounceFetcher]::onSuccess() IOException. " + e.getMessage());
     e.printStackTrace();
   }
 }
コード例 #2
0
 @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;
   }
 }