s243a

BaseManifestPutter$PutHandler.start

Jun 6th, 2015
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. // From line 419 of https://github.com/freenet/fred/blob/next/src/freenet/client/async/BaseManifestPutter.java
  2.         public void start(ClientContext context) throws InsertException {
  3. 420             //new Error("trace start "+this).printStackTrace();
  4. 421             if (logDEBUG)
  5. 422                 Logger.debug(this, "Starting a PutHandler for '"+this.itemName+"' "+ this);
  6. 423
  7.  
  8. 424             if (origSFI == null) {
  9. 425                 fail(new IllegalStateException("origSFI is null on start(), impossible"), context);
  10. 426             }
  11. 427
  12.  
  13. 428             if ((!(this instanceof MetaPutHandler)) && (metadata != null)) {
  14. 429                 fail(new IllegalStateException("metdata=" + metadata + " on start(), impossible"), context);
  15. 430             }
  16. 431
  17.  
  18. 432             boolean ok;
  19. 433             if ((this instanceof ContainerPutHandler) || (this instanceof ArchivePutHandler)) {
  20. 434                 if (this != rootContainerPutHandler) {
  21. 435                     synchronized (containerPutHandlers) {
  22. 436                         ok = containerPutHandlers.contains(this);
  23. 437                     }
  24. 438                     if (!ok) {
  25. 439                         throw new IllegalStateException("Starting a PutHandler thats not in 'containerPutHandlers'! "+this);
  26. 440                     }
  27. 441                 }
  28. 442             } else {
  29. 443                 if (this != rootMetaPutHandler) {
  30. 444                     synchronized (runningPutHandlers) {
  31. 445                         ok = runningPutHandlers.contains(this);
  32. 446                     }
  33. 447                     if (!ok) {
  34. 448                         throw new IllegalStateException("Starting a PutHandler thats not in 'runningPutHandlers'! "+this);
  35. 449                     }
  36. 450                 }
  37. 451             }
  38. 452
  39.  
  40. 453             synchronized (putHandlerWaitingForBlockSets) {
  41. 454                 ok = putHandlerWaitingForBlockSets.contains(this);
  42. 455             }
  43. 456             if (!ok) {
  44. 457                 Logger.error(this, "Starting a PutHandler thats not in 'waitingForBlockSets'! "+this, new Error("error"));
  45. 458                 //throw new IllegalStateException("Starting a PutHandler thats not in 'waitingForBlockSets'! "+this);
  46. 459             }
  47. 460
  48.  
  49. 461             ClientPutState sfi;
  50. 462             synchronized(this) {
  51. 463                 sfi = origSFI;
  52. 464                 currentState = sfi;
  53. 465                 origSFI = null;
  54. 466             }
  55. 467             sfi.schedule(context);
  56. 468         }
  57. 469
  58.  
  59. 470         @Override
Advertisement
Add Comment
Please, Sign In to add comment