Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial import

  • Loading branch information...
commit c391e61ab70b210d10dc44ba7c172aeb96fd9d13 0 parents
Michael Piatek authored
Showing with 42,053 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +91 −0 GPL.txt
  3. +8 −0 README.md
  4. +85 −0 ant-custom/edu/washington/cs/oneswarm/ant/GWTRecompileCheck.java
  5. +2 −0  az_src/ChangeLog.txt
  6. +178 −0 az_src/src/com/aelitis/azureus/core/AzureusCore.java
  7. +33 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreComponent.java
  8. +48 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreException.java
  9. +67 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreFactory.java
  10. +82 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreLifecycleAdapter.java
  11. +77 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreLifecycleListener.java
  12. +42 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreListener.java
  13. +44 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreOperation.java
  14. +37 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreOperationListener.java
  15. +31 −0 az_src/src/com/aelitis/azureus/core/AzureusCoreOperationTask.java
  16. +61 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/ClientMessageService.java
  17. +46 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/ClientMessageServiceClient.java
  18. +220 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/AEClientService.java
  19. +299 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/ClientConnection.java
  20. +89 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/ClientMessage.java
  21. +52 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/ClientMessageHandler.java
  22. +307 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/NonBlockingReadWriteService.java
  23. +56 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/secure/SecureMessageServiceClient.java
  24. +59 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/secure/SecureMessageServiceClientAdapter.java
  25. +43 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/secure/SecureMessageServiceClientFactory.java
  26. +41 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/secure/SecureMessageServiceClientListener.java
  27. +44 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/secure/SecureMessageServiceClientMessage.java
  28. +186 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/secure/impl/SecureMessageServiceClientHelper.java
  29. +469 −0 az_src/src/com/aelitis/azureus/core/clientmessageservice/secure/impl/SecureMessageServiceClientImpl.java
  30. +88 −0 ...rc/src/com/aelitis/azureus/core/clientmessageservice/secure/impl/SecureMessageServiceClientMessageImpl.java
  31. +33 −0 az_src/src/com/aelitis/azureus/core/content/AzureusContent.java
  32. +36 −0 az_src/src/com/aelitis/azureus/core/content/AzureusContentDirectory.java
  33. +51 −0 az_src/src/com/aelitis/azureus/core/content/AzureusContentDirectoryManager.java
  34. +195 −0 az_src/src/com/aelitis/azureus/core/dht/DHT.java
  35. +49 −0 az_src/src/com/aelitis/azureus/core/dht/DHTFactory.java
  36. +52 −0 az_src/src/com/aelitis/azureus/core/dht/DHTLogger.java
  37. +75 −0 az_src/src/com/aelitis/azureus/core/dht/DHTOperationAdapter.java
  38. +62 −0 az_src/src/com/aelitis/azureus/core/dht/DHTOperationListener.java
  39. +133 −0 az_src/src/com/aelitis/azureus/core/dht/DHTStorageAdapter.java
  40. +46 −0 az_src/src/com/aelitis/azureus/core/dht/DHTStorageBlock.java
  41. +44 −0 az_src/src/com/aelitis/azureus/core/dht/DHTStorageKey.java
  42. +39 −0 az_src/src/com/aelitis/azureus/core/dht/DHTStorageKeyStats.java
  43. +178 −0 az_src/src/com/aelitis/azureus/core/dht/control/DHTControl.java
  44. +52 −0 az_src/src/com/aelitis/azureus/core/dht/control/DHTControlActivity.java
  45. +51 −0 az_src/src/com/aelitis/azureus/core/dht/control/DHTControlAdapter.java
  46. +36 −0 az_src/src/com/aelitis/azureus/core/dht/control/DHTControlContact.java
  47. +63 −0 az_src/src/com/aelitis/azureus/core/dht/control/DHTControlFactory.java
  48. +37 −0 az_src/src/com/aelitis/azureus/core/dht/control/DHTControlListener.java
  49. +51 −0 az_src/src/com/aelitis/azureus/core/dht/control/DHTControlStats.java
  50. +85 −0 az_src/src/com/aelitis/azureus/core/dht/control/impl/DHTControlContactImpl.java
  51. +273 −0 az_src/src/com/aelitis/azureus/core/dht/control/impl/DHTControlStatsImpl.java
  52. +104 −0 az_src/src/com/aelitis/azureus/core/dht/control/impl/Test.java
  53. +139 −0 az_src/src/com/aelitis/azureus/core/dht/db/DHTDB.java
  54. +50 −0 az_src/src/com/aelitis/azureus/core/dht/db/DHTDBFactory.java
  55. +38 −0 az_src/src/com/aelitis/azureus/core/dht/db/DHTDBLookupResult.java
  56. +48 −0 az_src/src/com/aelitis/azureus/core/dht/db/DHTDBStats.java
  57. +43 −0 az_src/src/com/aelitis/azureus/core/dht/db/DHTDBValue.java
  58. +1,004 −0 az_src/src/com/aelitis/azureus/core/dht/db/impl/DHTDBMapping.java
  59. +224 −0 az_src/src/com/aelitis/azureus/core/dht/db/impl/DHTDBValueImpl.java
  60. +347 −0 az_src/src/com/aelitis/azureus/core/dht/impl/DHTImpl.java
  61. +282 −0 az_src/src/com/aelitis/azureus/core/dht/impl/DHTLog.java
  62. +1,097 −0 az_src/src/com/aelitis/azureus/core/dht/impl/Test.java
  63. +91 −0 az_src/src/com/aelitis/azureus/core/dht/nat/DHTNATPuncher.java
  64. +35 −0 az_src/src/com/aelitis/azureus/core/dht/nat/DHTNATPuncherAdapter.java
  65. +38 −0 az_src/src/com/aelitis/azureus/core/dht/nat/DHTNATPuncherFactory.java
  66. +2,099 −0 az_src/src/com/aelitis/azureus/core/dht/nat/impl/DHTNATPuncherImpl.java
  67. +70 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/DHTNetworkPosition.java
  68. +425 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/DHTNetworkPositionManager.java
  69. +66 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/DHTNetworkPositionProvider.java
  70. +31 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/DHTNetworkPositionProviderInstance.java
  71. +48 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/Coordinates.java
  72. +57 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/VivaldiPosition.java
  73. +36 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/VivaldiPositionFactory.java
  74. +95 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/VivaldiPositionProvider.java
  75. +133 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/impl/HeightCoordinatesImpl.java
  76. +232 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/impl/VivaldiPositionImpl.java
  77. +76 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/impl/tests/VivaldiTest.java
  78. +121 −0 az_src/src/com/aelitis/azureus/core/dht/netcoords/vivaldi/ver1/impl/tests/VivaldiVisualTest.java
  79. +179 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouter.java
  80. +46 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouterAdapter.java
  81. +93 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouterContact.java
  82. +45 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouterContactAttachment.java
  83. +80 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouterFactory.java
  84. +31 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouterFactoryObserver.java
  85. +60 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouterObserver.java
  86. +54 −0 az_src/src/com/aelitis/azureus/core/dht/router/DHTRouterStats.java
  87. +230 −0 az_src/src/com/aelitis/azureus/core/dht/router/impl/DHTRouterContactImpl.java
  88. +1,261 −0 az_src/src/com/aelitis/azureus/core/dht/router/impl/DHTRouterImpl.java
  89. +569 −0 az_src/src/com/aelitis/azureus/core/dht/router/impl/DHTRouterNodeImpl.java
  90. +50 −0 az_src/src/com/aelitis/azureus/core/dht/router/impl/DHTRouterStatsImpl.java
  91. +142 −0 az_src/src/com/aelitis/azureus/core/dht/router/impl/Test.java
  92. +42 −0 az_src/src/com/aelitis/azureus/core/dht/speed/DHTSpeedTester.java
  93. +58 −0 az_src/src/com/aelitis/azureus/core/dht/speed/DHTSpeedTesterContact.java
  94. +40 −0 az_src/src/com/aelitis/azureus/core/dht/speed/DHTSpeedTesterContactListener.java
  95. +37 −0 az_src/src/com/aelitis/azureus/core/dht/speed/DHTSpeedTesterFactory.java
  96. +36 −0 az_src/src/com/aelitis/azureus/core/dht/speed/DHTSpeedTesterListener.java
  97. +776 −0 az_src/src/com/aelitis/azureus/core/dht/speed/impl/DHTSpeedTesterImpl.java
  98. +130 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransport.java
  99. +137 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportContact.java
  100. +48 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportException.java
  101. +81 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportFactory.java
  102. +53 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportFindValueReply.java
  103. +111 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportFullStats.java
  104. +44 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportListener.java
  105. +44 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportProgressListener.java
  106. +80 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportReplyHandler.java
  107. +84 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportRequestHandler.java
  108. +97 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportStats.java
  109. +39 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportStoreReply.java
  110. +47 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportTransferHandler.java
  111. +53 −0 az_src/src/com/aelitis/azureus/core/dht/transport/DHTTransportValue.java
  112. +231 −0 az_src/src/com/aelitis/azureus/core/dht/transport/loopback/DHTTransportLoopbackContactImpl.java
  113. +729 −0 az_src/src/com/aelitis/azureus/core/dht/transport/loopback/DHTTransportLoopbackImpl.java
  114. +83 −0 az_src/src/com/aelitis/azureus/core/dht/transport/loopback/DHTTransportLoopbackStatsImpl.java
  115. +90 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/DHTTransportUDP.java
  116. +47 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/DHTTransportUDPContact.java
  117. +420 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTTransportUDPContactImpl.java
  118. +3,777 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTTransportUDPImpl.java
  119. +110 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTTransportUDPStatsImpl.java
  120. +33 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacket.java
  121. +187 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketData.java
  122. +240 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketHelper.java
  123. +226 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReply.java
  124. +160 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReplyError.java
  125. +176 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReplyFindNode.java
  126. +189 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReplyFindValue.java
  127. +68 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReplyKeyBlock.java
  128. +79 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReplyPing.java
  129. +145 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReplyStats.java
  130. +94 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketReplyStore.java
  131. +318 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketRequest.java
  132. +100 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketRequestFindNode.java
  133. +141 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketRequestFindValue.java
  134. +130 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketRequestKeyBlock.java
  135. +81 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketRequestPing.java
  136. +110 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketRequestStats.java
  137. +156 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPPacketRequestStore.java
  138. +991 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/DHTUDPUtils.java
  139. +368 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/Test.java
  140. +297 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/packethandler/DHTUDPPacketHandler.java
  141. +50 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/packethandler/DHTUDPPacketHandlerException.java
  142. +209 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/packethandler/DHTUDPPacketHandlerFactory.java
  143. +133 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/packethandler/DHTUDPPacketHandlerStats.java
  144. +75 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/packethandler/DHTUDPPacketNetworkHandler.java
  145. +41 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/packethandler/DHTUDPPacketReceiver.java
  146. +34 −0 az_src/src/com/aelitis/azureus/core/dht/transport/udp/impl/packethandler/DHTUDPRequestHandler.java
  147. +141 −0 az_src/src/com/aelitis/azureus/core/dht/transport/util/DHTTransportRequestCounter.java
  148. +501 −0 az_src/src/com/aelitis/azureus/core/dht/transport/util/DHTTransportStatsImpl.java
  149. +236 −0 az_src/src/com/aelitis/azureus/core/diskmanager/MemoryMappedFile.java
  150. +47 −0 az_src/src/com/aelitis/azureus/core/diskmanager/access/DiskAccessController.java
  151. +41 −0 az_src/src/com/aelitis/azureus/core/diskmanager/access/DiskAccessControllerFactory.java
  152. +49 −0 az_src/src/com/aelitis/azureus/core/diskmanager/access/DiskAccessRequest.java
  153. +54 −0 az_src/src/com/aelitis/azureus/core/diskmanager/access/DiskAccessRequestListener.java
  154. +260 −0 az_src/src/com/aelitis/azureus/core/diskmanager/access/impl/DiskAccessControllerImpl.java
  155. +966 −0 az_src/src/com/aelitis/azureus/core/diskmanager/access/impl/DiskAccessControllerInstance.java
  156. +265 −0 az_src/src/com/aelitis/azureus/core/diskmanager/access/impl/DiskAccessRequestImpl.java
  157. +178 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/CacheFile.java
  158. +55 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/CacheFileManager.java
  159. +81 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/CacheFileManagerException.java
  160. +90 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/CacheFileManagerFactory.java
  161. +80 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/CacheFileManagerStats.java
  162. +53 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/CacheFileOwner.java
  163. +151 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/impl/CacheEntry.java
  164. +971 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/impl/CacheFileManagerImpl.java
  165. +202 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/impl/CacheFileManagerStatsImpl.java
  166. +1,697 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/impl/CacheFileWithCache.java
  167. +390 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/impl/CacheFileWithoutCache.java
  168. +521 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/impl/CacheFileWithoutCacheMT.java
  169. +357 −0 az_src/src/com/aelitis/azureus/core/diskmanager/cache/impl/Test.java
  170. +146 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/FMFile.java
  171. +55 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/FMFileManager.java
  172. +47 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/FMFileManagerException.java
  173. +40 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/FMFileManagerFactory.java
  174. +44 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/FMFileOwner.java
  175. +70 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileAccess.java
  176. +503 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileAccessCompact.java
  177. +388 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileAccessController.java
  178. +409 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileAccessLinear.java
  179. +991 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileImpl.java
  180. +304 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileLimited.java
  181. +464 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileManagerImpl.java
  182. +130 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileTestImpl.java
  183. +230 −0 az_src/src/com/aelitis/azureus/core/diskmanager/file/impl/FMFileUnlimited.java
  184. +106 −0 az_src/src/com/aelitis/azureus/core/diskmanager/test/MemoryMappedFileTester.java
  185. +300 −0 az_src/src/com/aelitis/azureus/core/helpers/TorrentFolderWatcher.java
  186. +132 −0 az_src/src/com/aelitis/azureus/core/impl/AzureusCoreSingleInstanceClient.java
  187. +50 −0 az_src/src/com/aelitis/azureus/core/instancemanager/AZInstance.java
  188. +96 −0 az_src/src/com/aelitis/azureus/core/instancemanager/AZInstanceManager.java
  189. +37 −0 az_src/src/com/aelitis/azureus/core/instancemanager/AZInstanceManagerFactory.java
  190. +44 −0 az_src/src/com/aelitis/azureus/core/instancemanager/AZInstanceManagerListener.java
  191. +38 −0 az_src/src/com/aelitis/azureus/core/instancemanager/AZInstanceTracked.java
  192. +70 −0 az_src/src/com/aelitis/azureus/core/instancemanager/impl/AZInstanceImpl.java
  193. +1,367 −0 az_src/src/com/aelitis/azureus/core/instancemanager/impl/AZInstanceManagerImpl.java
  194. +379 −0 az_src/src/com/aelitis/azureus/core/instancemanager/impl/AZMyInstanceImpl.java
  195. +188 −0 az_src/src/com/aelitis/azureus/core/instancemanager/impl/AZOtherInstanceImpl.java
  196. +139 −0 az_src/src/com/aelitis/azureus/core/instancemanager/impl/AZPortClashHandler.java
  197. +33 −0 az_src/src/com/aelitis/azureus/core/nat/NATTraversal.java
  198. +35 −0 az_src/src/com/aelitis/azureus/core/nat/NATTraversalException.java
  199. +41 −0 az_src/src/com/aelitis/azureus/core/nat/NATTraversalHandler.java
  200. +51 −0 az_src/src/com/aelitis/azureus/core/nat/NATTraversalObserver.java
  201. +262 −0 az_src/src/com/aelitis/azureus/core/nat/NATTraverser.java
  202. +30 −0 az_src/src/com/aelitis/azureus/core/networkmanager/ConnectionAttempt.java
  203. +177 −0 az_src/src/com/aelitis/azureus/core/networkmanager/ConnectionEndpoint.java
  204. +79 −0 az_src/src/com/aelitis/azureus/core/networkmanager/EventWaiter.java
  205. +130 −0 az_src/src/com/aelitis/azureus/core/networkmanager/IncomingMessageQueue.java
  206. +34 −0 az_src/src/com/aelitis/azureus/core/networkmanager/LimitedRateGroup.java
  207. +117 −0 az_src/src/com/aelitis/azureus/core/networkmanager/NetworkConnection.java
  208. +98 −0 az_src/src/com/aelitis/azureus/core/networkmanager/NetworkConnectionBase.java
  209. +57 −0 az_src/src/com/aelitis/azureus/core/networkmanager/NetworkConnectionFactory.java
Sorry, we could not display the entire diff because too many files (3,289) changed.
6 .gitignore
@@ -0,0 +1,6 @@
+*.class
+.classpath
+.project
+.DS_Store
+.settings
+.svn
91 GPL.txt
@@ -0,0 +1,91 @@
+The GNU General Public License (GPL)
+Version 2, June 1991
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
+
+b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
+
+c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
+
+c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+END OF TERMS AND CONDITIONS
8 README.md
@@ -0,0 +1,8 @@
+
+This README is written in [Markdown](http://en.wikipedia.org/wiki/Markdown "Markdown"). This [live preview](http://github.github.com/github-flavored-markdown/preview.html) tool is useful for debugging presentation issues.
+
+# OneSwarm
+
+* [WWW](http://oneswarm.org/)
+* [Forum](http://forum.oneswarm.org/)
+* [Wiki](http://wiki.oneswarm.org/)
85 ant-custom/edu/washington/cs/oneswarm/ant/GWTRecompileCheck.java
@@ -0,0 +1,85 @@
+package edu.washington.cs.oneswarm.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.*;
+
+import java.util.*;
+import java.io.*;
+import java.text.*;
+
+public class GWTRecompileCheck extends Task {
+
+ String directory = null;
+ String lastBuilt = null;
+ boolean done = false;
+
+ public void execute() throws BuildException {
+
+ if (directory == null) {
+ throw new BuildException("Directory not specified.");
+ }
+
+ if (lastBuilt == null) {
+ log("No prior built record, building...");
+ doBuild(null);
+ return;
+ }
+
+ File dirFile = new File(directory);
+ if (dirFile.isDirectory() == false) {
+ throw new BuildException("Provided GWT source root is not a directory!");
+ }
+
+ log("Scanning directory: " + directory + " for changes since " + lastBuilt);
+
+ Date last = new SimpleDateFormat("MM/dd/yyyy HH:mm").parse(lastBuilt, new ParsePosition(0));
+
+ recursiveScan(dirFile, last);
+ }
+
+ private void recursiveScan(File f, Date thresh) {
+
+ log(f.getAbsolutePath(), Project.MSG_DEBUG);
+
+ if (f.isFile() && f.getName().endsWith(".java")) {
+ if (thresh.before(new Date(f.lastModified()))) {
+ doBuild(f);
+ }
+ }
+
+ if( !done && f.isDirectory()) {
+
+ if (f.getName().startsWith(".svn")) {
+ return;
+ }
+
+ for (File kid : f.listFiles()) {
+ recursiveScan(kid, thresh);
+
+ if (done) {
+ break;
+ }
+ }
+ }
+ }
+
+ private void doBuild(File f) {
+ getProject().setProperty("gwt.recompile", "true");
+ done = true;
+ log("Performing build");
+ if (f != null) {
+ log(f.getName() + " modified " + (new Date(f.lastModified())));
+ }
+ }
+
+ public void setDirectory(String directory) {
+ this.directory = directory;
+ }
+
+ public void setLastBuild(String lastBuilt) {
+ if (lastBuilt.startsWith("${")) {
+ return;
+ }
+ this.lastBuilt = lastBuilt;
+ }
+}
2  az_src/ChangeLog.txt
@@ -0,0 +1,2 @@
+OneSwarm is based on Azureus Vuze version 3.0.5.0. Subsequent changes are listed at:
+http://wiki.oneswarm.org/index.php/Changelog
178 az_src/src/com/aelitis/azureus/core/AzureusCore.java
@@ -0,0 +1,178 @@
+/*
+ * Created on 13-Jul-2004
+ * Created by Paul Gardner
+ * Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+/**
+ * @author parg
+ *
+ */
+
+import org.gudy.azureus2.core3.tracker.host.TRHost;
+import org.gudy.azureus2.core3.global.GlobalManager;
+import org.gudy.azureus2.core3.ipfilter.IpFilterManager;
+import org.gudy.azureus2.core3.internat.LocaleUtil;
+
+import org.gudy.azureus2.plugins.*;
+
+import com.aelitis.azureus.core.instancemanager.AZInstanceManager;
+import com.aelitis.azureus.core.nat.NATTraverser;
+import com.aelitis.azureus.core.security.CryptoManager;
+import com.aelitis.azureus.core.speedmanager.SpeedManager;
+
+public interface
+AzureusCore
+{
+ public void
+ start()
+
+ throws AzureusCoreException;
+
+ public boolean
+ isStarted();
+
+ /**
+ * stop the core and inform lifecycle listeners of stopping
+ * @throws AzureusCoreException
+ */
+
+ public void
+ stop()
+
+ throws AzureusCoreException;
+
+ /**
+ * ask lifecycle listeners to perform a stop. they may veto this by throwing an exception, or do nothing
+ * if nothing is done then it will be stopped as per "stop" above
+ * @throws AzureusCoreException
+ */
+
+ public void
+ requestStop()
+
+ throws AzureusCoreException;
+
+ /**
+ * checks if restart operation is supported - if not an alert will be raised and an exception thrown
+ * @throws AzureusCoreException
+ */
+
+ public void
+ checkRestartSupported()
+
+ throws AzureusCoreException;
+
+ /**
+ * restart the system
+ */
+
+ public void
+ restart();
+
+ /**
+ * request a restart of the system - currently only available for swt based systems
+ * @throws AzureusCoreException
+ */
+
+ public void
+ requestRestart()
+
+ throws AzureusCoreException;
+
+ public LocaleUtil
+ getLocaleUtil();
+
+ public GlobalManager
+ getGlobalManager()
+
+ throws AzureusCoreException;
+
+ public PluginManagerDefaults
+ getPluginManagerDefaults()
+
+ throws AzureusCoreException;
+
+ public PluginManager
+ getPluginManager()
+
+ throws AzureusCoreException;
+
+ public TRHost
+ getTrackerHost()
+
+ throws AzureusCoreException;
+
+ public IpFilterManager
+ getIpFilterManager()
+
+ throws AzureusCoreException;
+
+ public AZInstanceManager
+ getInstanceManager();
+
+ public SpeedManager
+ getSpeedManager();
+
+ public CryptoManager
+ getCryptoManager();
+
+ public NATTraverser
+ getNATTraverser();
+
+ public AzureusCoreOperation
+ createOperation(
+ int type );
+
+ public void
+ createOperation(
+ int type,
+ AzureusCoreOperationTask task );
+
+ public void
+ addLifecycleListener(
+ AzureusCoreLifecycleListener l );
+
+ public void
+ removeLifecycleListener(
+ AzureusCoreLifecycleListener l );
+
+ public void
+ addListener(
+ AzureusCoreListener l );
+
+ public void
+ removeListener(
+ AzureusCoreListener l );
+
+ public void
+ addOperationListener(
+ AzureusCoreOperationListener l );
+
+ public void
+ removeOperationListener(
+ AzureusCoreOperationListener l );
+
+ /**
+ * @param component
+ */
+ void triggerLifeCycleComponentCreated(AzureusCoreComponent component);
+}
33 az_src/src/com/aelitis/azureus/core/AzureusCoreComponent.java
@@ -0,0 +1,33 @@
+/*
+ * Created on 14-Jul-2004
+ * Created by Paul Gardner
+ * Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+/**
+ * @author parg
+ *
+ */
+
+public interface
+AzureusCoreComponent
+{
+}
48 az_src/src/com/aelitis/azureus/core/AzureusCoreException.java
@@ -0,0 +1,48 @@
+/*
+ * Created on 13-Jul-2004
+ * Created by Paul Gardner
+ * Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+/**
+ * @author parg
+ *
+ */
+
+public class
+AzureusCoreException
+ extends RuntimeException
+{
+ public
+ AzureusCoreException(
+ String str )
+ {
+ super(str);
+ }
+
+ public
+ AzureusCoreException(
+ String str,
+ Throwable cause )
+ {
+ super( str, cause );
+ }
+}
67 az_src/src/com/aelitis/azureus/core/AzureusCoreFactory.java
@@ -0,0 +1,67 @@
+/*
+ * Created on 13-Jul-2004
+ * Created by Paul Gardner
+ * Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+/**
+ * @author parg
+ *
+ */
+
+import com.aelitis.azureus.core.impl.*;
+
+public class
+AzureusCoreFactory
+{
+ /**
+ * Azureus core is a singleton that must be initially created by someone, and initialised
+ * @return
+ * @throws AzureusCoreException
+ */
+
+ public static AzureusCore
+ create()
+
+ throws AzureusCoreException
+ {
+ return( AzureusCoreImpl.create());
+ }
+
+ public static boolean
+ isCoreAvailable()
+ {
+ return( AzureusCoreImpl.isCoreAvailable());
+ }
+ /**
+ * Once created the singleton can be accessed via this method
+ * @return
+ * @throws AzureusCoreException
+ */
+
+ public static AzureusCore
+ getSingleton()
+
+ throws AzureusCoreException
+ {
+ return( AzureusCoreImpl.getSingleton());
+ }
+}
82 az_src/src/com/aelitis/azureus/core/AzureusCoreLifecycleAdapter.java
@@ -0,0 +1,82 @@
+/*
+ * Created on 14-Jul-2004
+ * Created by Paul Gardner
+ * Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+/**
+ * @author parg
+ *
+ */
+
+public class
+AzureusCoreLifecycleAdapter
+ implements AzureusCoreLifecycleListener
+{
+ public void
+ componentCreated(
+ AzureusCore core,
+ AzureusCoreComponent component )
+ {
+ }
+
+ public void
+ started(
+ AzureusCore core )
+ {
+ }
+
+ public void
+ stopping(
+ AzureusCore core )
+ {
+ }
+
+ public void
+ stopped(
+ AzureusCore core )
+ {
+ }
+
+ public boolean
+ stopRequested(
+ AzureusCore core )
+
+ throws AzureusCoreException
+ {
+ return( true );
+ }
+
+ public boolean
+ restartRequested(
+ AzureusCore core )
+
+ throws AzureusCoreException
+ {
+ return( true );
+ }
+
+ public boolean
+ syncInvokeRequired()
+ {
+ return( false );
+ }
+}
77 az_src/src/com/aelitis/azureus/core/AzureusCoreLifecycleListener.java
@@ -0,0 +1,77 @@
+/*
+ * Created on 14-Jul-2004
+ * Created by Paul Gardner
+ * Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+/**
+ * @author parg
+ *
+ */
+
+public interface
+AzureusCoreLifecycleListener
+{
+ public void
+ componentCreated(
+ AzureusCore core,
+ AzureusCoreComponent component );
+
+ public void
+ started(
+ AzureusCore core );
+
+ public void
+ stopping(
+ AzureusCore core );
+
+ public void
+ stopped(
+ AzureusCore core );
+
+ /**
+ * return true if the request has been accepted (and hence the listener will arrange for a stop to occur
+ * @param core
+ * @return
+ */
+
+ public boolean
+ stopRequested(
+ AzureusCore core )
+
+ throws AzureusCoreException;
+
+ public boolean
+ restartRequested(
+ AzureusCore core )
+
+ throws AzureusCoreException;
+
+ /**
+ * Some listeners must be invoked on the same thread that initiates a core closedown. In particular
+ * the show-alerts-raised-during-closedown logic requires that it is invoked on the swt thread that
+ * initiated the closedown.
+ * @return
+ */
+
+ public boolean
+ syncInvokeRequired();
+}
42 az_src/src/com/aelitis/azureus/core/AzureusCoreListener.java
@@ -0,0 +1,42 @@
+/*
+ * Created on 14-Jul-2004
+ * Created by Paul Gardner
+ * Copyright (C) 2004, 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+/**
+ * @author parg
+ *
+ */
+
+public interface
+AzureusCoreListener
+{
+ public void
+ reportCurrentTask(
+ AzureusCoreOperation operation,
+ String currentTask );
+
+ public void
+ reportPercent(
+ AzureusCoreOperation operation,
+ int percent );
+}
44 az_src/src/com/aelitis/azureus/core/AzureusCoreOperation.java
@@ -0,0 +1,44 @@
+/*
+ * Created on 27 Jul 2006
+ * Created by Paul Gardner
+ * Copyright (C) 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+public interface
+AzureusCoreOperation
+{
+ public static final int OP_INITIALISATION = 1;
+ public static final int OP_FILE_MOVE = 2;
+
+ public int
+ getOperationType();
+
+ public AzureusCoreOperationTask
+ getTask();
+
+ public void
+ reportCurrentTask(
+ String currentTask );
+
+ public void
+ reportPercent(
+ int percent );
+}
37 az_src/src/com/aelitis/azureus/core/AzureusCoreOperationListener.java
@@ -0,0 +1,37 @@
+/*
+ * Created on 27 Jul 2006
+ * Created by Paul Gardner
+ * Copyright (C) 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+public interface
+AzureusCoreOperationListener
+{
+ /**
+ *
+ * @param operation
+ * @return true if the listener has taken responsibility for running an operation task
+ */
+
+ public boolean
+ operationCreated(
+ AzureusCoreOperation operation );
+}
31 az_src/src/com/aelitis/azureus/core/AzureusCoreOperationTask.java
@@ -0,0 +1,31 @@
+/*
+ * Created on 27 Jul 2006
+ * Created by Paul Gardner
+ * Copyright (C) 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+
+package com.aelitis.azureus.core;
+
+public interface
+AzureusCoreOperationTask
+{
+ public void
+ run(
+ AzureusCoreOperation operation );
+}
61 az_src/src/com/aelitis/azureus/core/clientmessageservice/ClientMessageService.java
@@ -0,0 +1,61 @@
+/*
+ * Created on Oct 31, 2005
+ * Created by Alon Rohter
+ * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+package com.aelitis.azureus.core.clientmessageservice;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ *
+ */
+public interface ClientMessageService {
+
+ /**
+ * Send the given message to the server service.
+ * NOTE: blocking op
+ * @param message (bencode-able) to send
+ * @throws IOException on error
+ */
+ public void sendMessage( Map message ) throws IOException;
+
+
+ /**
+ * Receive the next message from the server.
+ * NOTE: blocking op
+ * @return message received
+ * @throws IOException on error
+ */
+ public Map receiveMessage() throws IOException;
+
+
+ /**
+ * Drop and closedown the connection with the server.
+ */
+ public void close();
+
+ /**
+ * Override the default max message size
+ * @param max_bytes
+ */
+ public void
+ setMaximumMessageSize( int max_bytes );
+}
46 az_src/src/com/aelitis/azureus/core/clientmessageservice/ClientMessageServiceClient.java
@@ -0,0 +1,46 @@
+/*
+ * Created on Oct 31, 2005
+ * Created by Alon Rohter
+ * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+package com.aelitis.azureus.core.clientmessageservice;
+
+
+import com.aelitis.azureus.core.clientmessageservice.impl.AEClientService;
+
+/**
+ *
+ */
+public class ClientMessageServiceClient {
+
+ /**
+ * Create a new message server service connection.
+ * @param server_address of service
+ * @param server_port of service
+ * @param message type id to use for messages
+ * @return server service connection
+ */
+ public static ClientMessageService getServerService( String server_address, int server_port, int timeout_secs, String msg_type_id ) {
+ return new AEClientService( server_address, server_port, timeout_secs, msg_type_id );
+ }
+
+ public static ClientMessageService getServerService( String server_address, int server_port, String msg_type_id ) {
+ return new AEClientService( server_address, server_port, msg_type_id );
+ }
+}
220 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/AEClientService.java
@@ -0,0 +1,220 @@
+/*
+ * Created on Oct 31, 2005
+ * Created by Alon Rohter
+ * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+package com.aelitis.azureus.core.clientmessageservice.impl;
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.gudy.azureus2.core3.util.*;
+
+import com.aelitis.azureus.core.clientmessageservice.*;
+import com.aelitis.azureus.core.networkmanager.*;
+import com.aelitis.azureus.core.networkmanager.impl.tcp.ProtocolEndpointTCP;
+import com.aelitis.azureus.core.networkmanager.impl.tcp.TCPTransportImpl;
+import com.aelitis.azureus.core.peermanager.messaging.MessageException;
+import com.aelitis.azureus.core.peermanager.messaging.azureus.*;
+
+
+/**
+ *
+ */
+public class AEClientService implements ClientMessageService {
+
+ private final String address;
+ private final int port;
+ private final String msg_type_id;
+ private final int timeout_secs;
+ private int max_message_bytes = -1;
+ private ClientConnection conn;
+
+ private final AESemaphore read_block = new AESemaphore( "AEClientService:R" );
+ private final AESemaphore write_block = new AESemaphore( "AEClientService:W" );
+
+ private final ArrayList received_messages = new ArrayList();
+
+ private final NonBlockingReadWriteService rw_service;
+
+ private volatile Throwable error;
+
+
+ public AEClientService( String server_address, int server_port, String _msg_type_id ) {
+
+ this( server_address, server_port, 30, _msg_type_id );
+ }
+
+ public AEClientService( String server_address, int server_port, int timeout, String _msg_type_id ) {
+ this.address = server_address;
+ this.port = server_port;
+ this.timeout_secs = timeout;
+ this.msg_type_id = _msg_type_id;
+
+ try {
+ AZMessageFactory.registerGenericMapPayloadMessageType( msg_type_id ); //register for incoming type decoding
+ }
+ catch( MessageException me ) { /*ignore, since message type probably already registered*/ }
+
+ rw_service = new NonBlockingReadWriteService( msg_type_id, timeout, 0, new NonBlockingReadWriteService.ServiceListener() {
+ public void messageReceived( ClientMessage message ) {
+ received_messages.add( message.getPayload() );
+ read_block.release();
+ }
+
+ public void connectionError( ClientConnection connection, Throwable msg ) {
+ error = msg;
+ read_block.releaseForever();
+ write_block.releaseForever();
+ }
+ });
+ }
+
+
+
+
+ //NOTE: blocking op
+ private void connect() throws IOException {
+
+ InetSocketAddress tcp_target = new InetSocketAddress( address, port );
+
+ ConnectionEndpoint ce = new ConnectionEndpoint( tcp_target );
+
+ new ProtocolEndpointTCP( ce, tcp_target );
+
+ final AESemaphore connect_block = new AESemaphore( "AEClientService:C" );
+
+ ce.connectOutbound( false, false, null, null, true, new Transport.ConnectListener() { //NOTE: async operation!
+ public void connectAttemptStarted() { /*nothing*/ }
+
+ public void connectSuccess(Transport transport, ByteBuffer remaining_initial_data ){
+ conn = new ClientConnection((TCPTransportImpl)transport );
+ if ( max_message_bytes != -1 ){
+ conn.setMaximumMessageSize( max_message_bytes );
+ }
+ connect_block.release();
+ }
+
+ public void connectFailure( Throwable failure_msg ) {
+ error = failure_msg;
+ connect_block.release();
+ }
+ });
+
+ if ( !connect_block.reserve( timeout_secs*1000 )){
+ throw new IOException( "connect op failed: timeout" );
+ }
+
+ //connect op finished
+
+ if( error != null ) { //connect failure
+ close();
+ throw new IOException( "connect op failed: " + error.getMessage() == null ? "[]" : error.getMessage() );
+ }
+
+ rw_service.addClientConnection( conn ); //register for read/write handling
+ }
+
+
+
+
+ public void sendMessage( Map message ) throws IOException {
+ if( conn == null ) { //not yet connected
+ connect();
+ }
+
+ if( error != null ) {
+ close();
+ throw new IOException( "send op failed: " + error.getMessage() == null ? "[]" : error.getMessage() );
+ }
+
+ ClientMessage client_msg = new ClientMessage( msg_type_id, conn, message, new ClientMessageHandler() {
+ public String getMessageTypeID(){ return msg_type_id; }
+
+ public void processMessage( ClientMessage message ) {
+ Debug.out( "ERROR: should never be called" );
+ }
+
+ public void sendAttemptCompleted( ClientMessage message ){
+ write_block.release();
+ }
+ public void sendAttemptFailed( ClientMessage message, Throwable cause) {
+ error = cause;
+ write_block.release();
+ }
+ });
+
+ rw_service.sendMessage( client_msg ); //queue message for sending
+
+ write_block.reserve(); //block until send completes
+
+ //send op finished
+
+ if( error != null ) { //connect failure
+ close();
+ throw new IOException( "send op failed: " + error.getMessage() == null ? "[]" : error.getMessage() );
+ }
+ }
+
+
+
+
+ public Map receiveMessage() throws IOException {
+ if( conn == null ) { //not yet connected
+ connect();
+ }
+
+ read_block.reserve(); //block until receive completes
+
+ if( !received_messages.isEmpty() ) { //there were still read messages left from the previous read call
+ Map recv_msg = (Map)received_messages.remove( 0 );
+ return recv_msg;
+ }
+
+ //receive op finished
+
+ if (error == null ){
+ error = new IOException( "receive op inconsistent" );
+ }
+
+ close();
+ throw new IOException( "receive op failed: " + error.getMessage() == null ? "[]" : error.getMessage() );
+ }
+
+
+
+ //no handler notification
+ public void close() {
+ if( conn != null ) {
+ rw_service.removeClientConnection( conn );
+ conn.close( new Exception( "Connection closed" ));
+ }
+ rw_service.destroy();
+ }
+
+ public void
+ setMaximumMessageSize( int max_bytes )
+ {
+ max_message_bytes = max_bytes;
+ }
+}
299 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/ClientConnection.java
@@ -0,0 +1,299 @@
+/*
+ * Created on Oct 28, 2005
+ * Created by Alon Rohter
+ * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+package com.aelitis.azureus.core.clientmessageservice.impl;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.channels.SocketChannel;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.gudy.azureus2.core3.util.AEMonitor;
+
+import com.aelitis.azureus.core.networkmanager.*;
+import com.aelitis.azureus.core.networkmanager.impl.OutgoingMessageQueueImpl;
+import com.aelitis.azureus.core.networkmanager.impl.tcp.ProtocolEndpointTCP;
+import com.aelitis.azureus.core.networkmanager.impl.tcp.TCPTransportImpl;
+import com.aelitis.azureus.core.networkmanager.impl.tcp.TransportEndpointTCP;
+import com.aelitis.azureus.core.peermanager.messaging.Message;
+import com.aelitis.azureus.core.peermanager.messaging.azureus.*;
+
+
+/**
+ *
+ */
+public class ClientConnection {
+
+ private Transport parent_transport;
+ private final Transport light_transport;
+ private final OutgoingMessageQueue out_queue;
+ private final AZMessageDecoder decoder;
+ private static final AZMessageEncoder encoder = new AZMessageEncoder( false );
+ private long last_activity_time;
+
+ private final AEMonitor msg_mon = new AEMonitor( "ClientConnection" );
+ private final ArrayList sending_msgs = new ArrayList();
+
+ private Map user_data;
+ private boolean close_pending;
+ private boolean closed;
+
+ private boolean last_write_made_progress;
+ private String debug_string = "<>";
+
+ private Throwable closing_reason;
+
+ /**
+ * Create a new connection based on an incoming socket.
+ * @param channel
+ */
+ public ClientConnection( SocketChannel channel ) {
+ decoder = new AZMessageDecoder();
+
+ InetSocketAddress remote = null; // unfortunately we don't have an address at this point (see NATTestService)
+
+ ProtocolEndpointTCP pe = new ProtocolEndpointTCP( remote );
+
+ light_transport = pe.connectLightWeight( channel );
+
+ out_queue = new OutgoingMessageQueueImpl( encoder );
+ out_queue.setTransport( light_transport );
+ last_activity_time = System.currentTimeMillis();
+ }
+
+
+ /**
+ * Create a new connection based on an already-established outgoing socket.
+ * @param transport parent
+ */
+ public ClientConnection( TCPTransportImpl transport ) {
+ this( transport.getSocketChannel() ); //run as a lightweight
+ parent_transport = transport; //save parent for close
+ }
+
+
+
+ /**
+ * Get any messages read from the client.
+ * @return read messages, or null of no new messages were read
+ * @throws IOException on error
+ */
+ public Message[] readMessages() throws IOException {
+ int bytes_read = decoder.performStreamDecode( light_transport, 1024*1024 );
+ if( bytes_read > 0 ) last_activity_time = System.currentTimeMillis();
+
+ return decoder.removeDecodedMessages();
+ }
+
+ public boolean
+ getLastReadMadeProgress()
+ {
+ return( decoder.getLastReadMadeProgress());
+ }
+
+ public boolean
+ getLastWriteMadeProgress()
+ {
+ return( last_write_made_progress );
+ }
+
+ public void sendMessage( final ClientMessage client_msg, final Message msg ) {
+ try{ msg_mon.enter();
+ sending_msgs.add( client_msg );
+ }
+ finally{ msg_mon.exit(); }
+
+ out_queue.registerQueueListener( new OutgoingMessageQueue.MessageQueueListener() {
+ public boolean messageAdded( Message message ){ return true; }
+ public void messageQueued( Message message ){}
+ public void messageRemoved( Message message ){}
+ public void protocolBytesSent( int byte_count ){}
+ public void dataBytesSent( int byte_count ){}
+ public void flush() {}
+ public void messageSent( Message message ){
+ if( message.equals( msg ) ) {
+ try{ msg_mon.enter();
+ sending_msgs.remove( client_msg );
+ }
+ finally{ msg_mon.exit(); }
+
+ client_msg.reportComplete();
+ }
+ }
+ });
+
+ out_queue.addMessage( msg, false );
+
+ }
+
+
+ /**
+ * Write any queued messages back to the client.
+ * @return true if more writing is required, false if all message data has been sent
+ * @throws IOException on error
+ */
+ public boolean writeMessages() throws IOException {
+ int bytes_written = out_queue.deliverToTransport( 1024*1024, false );
+ if( bytes_written > 0 ) last_activity_time = System.currentTimeMillis();
+
+ last_write_made_progress = bytes_written > 0;
+
+ return out_queue.getTotalSize() > 0;
+ }
+
+
+ //public boolean hasDataToSend() {
+ // return out_queue.getTotalSize() > 0;
+ //}
+
+
+ public void close( Throwable reason ) {
+ ClientMessage[] messages = null;
+
+ try{ msg_mon.enter();
+ if ( closed ){
+ return;
+ }
+ closed = true;
+ if( !sending_msgs.isEmpty() ) {
+ messages = (ClientMessage[])sending_msgs.toArray( new ClientMessage[sending_msgs.size()] );
+ }
+ }
+ finally{ msg_mon.exit(); }
+
+ if( messages != null ) {
+ if ( reason == null ){
+ reason = new Exception( "Connection closed" );
+ }
+ for( int i=0; i < messages.length; i++ ) {
+ ClientMessage msg = messages[i];
+ msg.reportFailed( reason );
+ }
+ }
+
+ decoder.destroy();
+ out_queue.destroy();
+
+ if( parent_transport != null ) {
+ parent_transport.close( "Tidy close"); //have the parent do the close if possible
+ }
+ else {
+ light_transport.close("Tidy close");
+ }
+ }
+
+ /**
+ * Marks the socket as complete and ready to undergo any close-delay prior to it being closed
+ * by the server
+ */
+
+ public void
+ closePending()
+ {
+ last_activity_time = System.currentTimeMillis();
+ close_pending = true;
+ }
+
+ public boolean
+ isClosePending()
+ {
+ return( close_pending );
+ }
+
+ public SocketChannel getSocketChannel(){ return ((TransportEndpointTCP)light_transport.getTransportEndpoint()).getSocketChannel(); }
+
+
+ /**
+ * Get the last time this connection had read or write activity.
+ * @return system time of last activity
+ */
+ public long getLastActivityTime() { return last_activity_time; }
+
+
+ /**
+ * Reset the last activity time to the current time.
+ */
+ public void resetLastActivityTime() { last_activity_time = System.currentTimeMillis(); }
+
+ public void
+ setClosingReason(
+ Throwable r )
+ {
+ closing_reason = r;
+ }
+
+ public Throwable
+ getClosingReason()
+ {
+ return( closing_reason );
+ }
+
+ public Object
+ getUserData(
+ Object key )
+ {
+ Map m = user_data;
+
+ if ( m == null ){
+
+ return( null );
+ }
+
+ return( m.get(key));
+ }
+
+ public void
+ setUserData(
+ Object key,
+ Object data )
+ {
+ try{
+ msg_mon.enter();
+
+ // assumption is write infrequently, read often -> copy-on-write
+
+ Map m = (user_data==null)?new HashMap():new HashMap( user_data );
+
+ m.put( key, data );
+
+ user_data = m;
+ }finally{
+
+ msg_mon.exit();
+ }
+ }
+
+
+ public void setDebugString( String debug ) { debug_string = debug; }
+
+ public String getDebugString() { return debug_string; }
+
+ public void
+ setMaximumMessageSize(
+ int max_bytes )
+ {
+ if ( decoder != null ){
+ decoder.setMaximumMessageSize( max_bytes );
+ }
+ }
+}
89 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/ClientMessage.java
@@ -0,0 +1,89 @@
+/*
+ * Created on Oct 29, 2005
+ * Created by Alon Rohter
+ * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+package com.aelitis.azureus.core.clientmessageservice.impl;
+
+import java.util.Map;
+
+import com.aelitis.azureus.core.clientmessageservice.impl.ClientConnection;
+
+
+
+/**
+ *
+ */
+public class ClientMessage {
+ private final String message_id;
+ private final ClientConnection client;
+ private final Map payload;
+ private ClientMessageHandler handler;
+
+ private boolean outcome_reported;
+
+ public ClientMessage( String msg_id, ClientConnection _client, Map msg_payload, ClientMessageHandler _handler ) {
+ this.message_id = msg_id;
+ this.client = _client;
+ this.payload = msg_payload;
+ this.handler = _handler;
+ }
+
+
+ public String getMessageID(){ return message_id; }
+
+ public ClientConnection getClient(){ return client; }
+
+ public Map getPayload(){ return payload; }
+
+ public ClientMessageHandler getHandler(){ return handler; }
+
+ public void setHandler( ClientMessageHandler new_handler ) { this.handler = new_handler; }
+
+ public void
+ reportComplete()
+ {
+ synchronized( this ){
+ if ( outcome_reported ){
+
+ return;
+ }
+
+ outcome_reported = true;
+ }
+
+ handler.sendAttemptCompleted( this );
+ }
+
+ public void
+ reportFailed(
+ Throwable error )
+ {
+ synchronized( this ){
+ if ( outcome_reported ){
+
+ return;
+ }
+
+ outcome_reported = true;
+ }
+
+ handler.sendAttemptFailed( this, error );
+ }
+}
52 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/ClientMessageHandler.java
@@ -0,0 +1,52 @@
+/*
+ * Created on Oct 24, 2005
+ * Created by Alon Rohter
+ * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+package com.aelitis.azureus.core.clientmessageservice.impl;
+
+
+
+public interface ClientMessageHandler {
+
+ /**
+ * Get the message type id that this handler handles.
+ * @return
+ */
+ public String getMessageTypeID();
+
+
+ /**
+ * Process the given message received from a client.
+ * @param message from client to process
+ */
+ public void processMessage( ClientMessage message );
+
+
+ /**
+ * Notification of reply message send attempt completion.
+ * NOTE: This method will always be called once for every preceeding ClientMessageServer.sendReplyMessage() call.
+ * @param message sent
+ * @param success true if reply send was successful, false if reply send failed
+ */
+ public void sendAttemptCompleted( ClientMessage message );
+
+ public void sendAttemptFailed( ClientMessage message, Throwable error );
+
+}
307 az_src/src/com/aelitis/azureus/core/clientmessageservice/impl/NonBlockingReadWriteService.java
@@ -0,0 +1,307 @@
+/*
+ * Created on Nov 3, 2005
+ * Created by Alon Rohter
+ * Copyright (C) 2005, 2006 Aelitis, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * AELITIS, SAS au capital de 46,603.30 euros
+ * 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.
+ *
+ */
+package com.aelitis.azureus.core.clientmessageservice.impl;
+
+import java.nio.channels.SocketChannel;
+import java.util.*;
+
+import org.gudy.azureus2.core3.util.*;
+
+import com.aelitis.azureus.core.networkmanager.VirtualChannelSelector;
+import com.aelitis.azureus.core.peermanager.messaging.Message;
+import com.aelitis.azureus.core.peermanager.messaging.azureus.AZGenericMapPayload;
+
+
+/**
+ *
+ */
+public class NonBlockingReadWriteService {
+
+ private final VirtualChannelSelector read_selector;
+ private final VirtualChannelSelector write_selector;
+
+ private final ArrayList connections = new ArrayList();
+ private final AEMonitor connections_mon = new AEMonitor( "connections" );
+
+ private final ServiceListener listener;
+ private final String service_name;
+ private volatile boolean destroyed;
+
+ private long last_timeout_check_time = 0;
+ private static final int TIMEOUT_CHECK_INTERVAL_MS = 10*1000; //check for timeouts every 10sec
+ private final int activity_timeout_period_ms;
+ private final int close_delay_period_ms;
+
+
+ public NonBlockingReadWriteService( String _service_name, int timeout, ServiceListener _listener ) {
+ this( _service_name, timeout, 0, _listener );
+ }
+
+ public NonBlockingReadWriteService( String _service_name, int timeout, int close_delay, ServiceListener _listener ) {
+ this.service_name = _service_name;
+ this.listener = _listener;
+
+ read_selector = new VirtualChannelSelector( service_name, VirtualChannelSelector.OP_READ, false );
+ write_selector = new VirtualChannelSelector( service_name, VirtualChannelSelector.OP_WRITE, true );
+
+ if( timeout < TIMEOUT_CHECK_INTERVAL_MS /1000 ) timeout = TIMEOUT_CHECK_INTERVAL_MS /1000;
+ this.activity_timeout_period_ms = timeout *1000;
+ close_delay_period_ms = close_delay * 1000;
+
+ AEThread select_thread = new AEThread( "[" +service_name+ "] Service Select" ) {
+ public void runSupport() {
+ while( true ) {
+
+ boolean stop_after_select = destroyed;
+
+ if ( stop_after_select ){
+ read_selector.destroy();
+ write_selector.destroy();
+ }
+
+ try{
+ read_selector.select( 50 );
+ write_selector.select( 50 );
+ }
+ catch( Throwable t ) {
+ Debug.out( "[" +service_name+ "] SelectorLoop() EXCEPTION: ", t );
+ }
+
+ if (stop_after_select){
+ break;
+ }
+
+ doConnectionTimeoutChecks();
+
+ // check this at the end so we have one last run through the selectors to do cancels
+ // before exiting
+ }
+ }
+ };
+ select_thread.setDaemon( true );
+ select_thread.start();
+ }
+
+
+
+ public void
+ destroy()
+ {
+ try {
+ connections_mon.enter();
+
+ connections.clear();
+
+ destroyed = true;
+
+ }finally{
+ connections_mon.exit();
+ }
+ }
+
+
+
+ public void addClientConnection( ClientConnection connection ) {
+ //add to active list
+
+ try { connections_mon.enter();
+
+ if ( destroyed ){
+
+ Debug.out( "connection added after destroy" );
+ }
+
+ connections.add( connection );
+ }finally {
+ connections_mon.exit();
+ }
+
+ registerForSelection( connection );
+ }
+
+
+
+ public void removeClientConnection( ClientConnection connection ) {
+ read_selector.cancel( connection.getSocketChannel() );
+ write_selector.cancel( connection.getSocketChannel() );
+
+ //remove from active list
+ try { connections_mon.enter();
+ connections.remove( connection );
+ }
+ finally { connections_mon.exit(); }
+ }
+
+
+
+
+
+ private void registerForSelection( final ClientConnection client ) {
+ //READS
+ VirtualChannelSelector.VirtualSelectorListener read_listener = new VirtualChannelSelector.VirtualSelectorListener() {
+ //SUCCESS
+ public boolean selectSuccess( VirtualChannelSelector selector, SocketChannel sc, Object attachment ) {
+ try{
+ Message[] messages = client.readMessages();
+
+ if( messages != null ) {
+ for( int i=0; i < messages.length; i++ ) {
+ AZGenericMapPayload msg = (AZGenericMapPayload)messages[i];
+ ClientMessage client_msg = new ClientMessage( msg.getID(), client, msg.getMapPayload(), null ); //note no handler. we let the listener attach it
+ listener.messageReceived( client_msg );
+ }
+ }
+
+ return( client.getLastReadMadeProgress());
+ }
+ catch( Throwable t ) {
+ if ( !client.isClosePending()){
+
+ System.out.println( "[" +new Date()+ "] Connection read error [" +sc.socket().getInetAddress()+ "] [" +client.getDebugString()+ "]: " +t.getMessage() );
+ }
+
+ listener.connectionError( client, t );
+ return( false );
+ }
+ }
+
+ //FAILURE
+ public void selectFailure( VirtualChannelSelector selector, SocketChannel sc, Object attachment, Throwable msg ) {
+ if ( !destroyed ){
+ msg.printStackTrace();
+ }
+ listener.connectionError( client, msg );
+ }
+ };
+
+
+ //WRITES
+ final VirtualChannelSelector.VirtualSelectorListener write_listener = new VirtualChannelSelector.VirtualSelectorListener() {
+ public boolean selectSuccess( VirtualChannelSelector selector, SocketChannel sc, Object attachment ) {
+ try{
+ boolean more_writes_needed = client.writeMessages();
+
+ if( more_writes_needed ) {
+ write_selector.resumeSelects( client.getSocketChannel() ); //we need to resume since write selects are auto-paused after select op
+ }
+
+ return( client.getLastWriteMadeProgress());
+ }
+ catch( Throwable t ) {
+ System.out.println( "[" +new Date()+ "] Connection write error [" +sc.socket().getInetAddress()+ "] [" +client.getDebugString()+ "]: " +t.getMessage() );
+ listener.connectionError( client, t );
+ return( false );
+ }
+ }
+
+ public void selectFailure( VirtualChannelSelector selector, SocketChannel sc, Object attachment, Throwable msg ) {
+ if ( !destroyed ){
+ msg.printStackTrace();
+ }
+ listener.connectionError( client, msg );
+ }
+ };
+
+ write_selector.register( client.getSocketChannel(), write_listener, null ); //start writing back to the connection
+ write_selector.pauseSelects( client.getSocketChannel() ); //wait until we've got something to send before selecting
+
+ read_selector.register( client.getSocketChannel(), read_listener, null ); //start reading from the connection
+ }
+
+
+ private void doConnectionTimeoutChecks() {