Just run the Azureus, give me the feeling that this interface is really not like Java wrote, swear to read this set of code!

Source: Internet
Author: User
Tags interface log thread

Recently in learning peer-to-peer knowledge, so have the analysis of Peer-to-peer software source of the impulse Ah!

Oh, in fact, I see azureus There are two reasons, one is that he is written in Java, and emule is written in C + +, I am not very familiar with C + +,

Afraid of understanding on no azureus understand the quick, two is to see Crmky blog on the Azureus analysis, he said yes, well, that's

Look at that! Oh



Crmky's evaluation of Azureus is as follows:

Read Azureus source code
Because to frame the company's Peer-to-peer framework, you want to first read the existing Java Peer-to-peer software code to see what can be used for reference. The first one is worth learning is azureus, very successful BT download software, and we want to achieve the function and BT is not much, can be said to be BT streaming media version:).

In the process of looking at the Azureus code there are some interesting things, some friends told me not to look at the Azureus code, said poorly written; we also said Azureus interface too much, he did not like ... However, I looked at the part and found that the Azureus code is good to write. Interface is not much, but the implementation is too tightly written, a realization of thousands of lines of code, if there is no definition of interface, I would expect to see Dizzy. Not that Azureus code is not a problem, but I believe that and I said the Azureus code to write the poor friend did not carefully read its code, in short, I learned from its code to learn a lot:

I mainly look at the Org.gudy.azureus2.core3 package, plugin package and UI package I have ignored, and mainly research its architecture, implementation did not see. The role of the next Org.gudy.azureus2.core3 package is as follows:
Category, classification management, embodied in the interface displayed as a row of buttons in the upper right corner, you can according to different categories of BT Seed Classification config, configuration management, runtime maintenance of all configuration information in memory, and can be persisted disk management, can be asynchronous or synchronous I/O request Download, download management, each BT download corresponds to one of the Downloadmanager Global, global management, manage all BT downloads, that is, manage all Downloadmanager html,html downloads and analytics, Seems to be mainly used to determine whether the software needs to update Internat, internationalization processing ipchecker, check IP, seems to be mainly used to judge the NAT external IP address IPFILTER,IP filtering, for blacklist logging, log processing peer, node management, BT download is to download security from multiple nodes, secure management, with SSL encryption to ensure security stats, statistical management, the statistical information recorded into the disk Torrent,torrent file resolution torrentdownloader,torrent seed file download, Embodied in the interface for file--> open-->url, download directly from the network to the hard disk tracker, with the BT Tracker communication Util, tool class Xml,xml processing related tools
Suggested reading order

The Azureus document does not recommend in what order the developer understands Azureus's architecture and code. My personal view is to look at the util package, a little understanding can read the global package, look at the download package, and then read the rest of the related package. Because the structure of the Azureus is a Globalmanager manages multiple downloadmanager, each downloadmanager is associated to a diskmanager, a peermanager.

Highlight

Util. SystemTime, using independent thread to read the system time, and to determine whether the system time for callback, to record. But only in the log to record the change, did not make a deal. You can consider extending the class to ensure that the system time is increasing forward since the program started. (Otherwise, in the case of average speed calculations, because time callbacks can cause some exceptions)

Util. Average, the average speed is obtained.

Util. Debug, to get the class to call when logging, you can throw an exception and catch the exception to get its call sequence.

Util. Directbytebufferpool, run-time capture OutOfMemoryError, do some memory cleanup work, such as remove some cache, if not again, throw an exception, initialize all the key/value in the map (value is a collection), The map is read-only when run so that it can be accessed without synchronization. (change is only the value set in the map)

Disk, which enables you to queue I/O operations, which can be done in an asynchronous manner, so that all I/O operations can be placed on a single thread. For example, a write request can be added to a write queue, and an event notification is made when the write is completed.

Azureus is a very careful procedure, even systemtime this class are out, let me have to admire it conceived of thoughtful; some I do not understand the place, I would like to believe that my level is not enough to understand the author's design intentions. Azureus is a very good program, hope to Azureus skeptical friend to read the code carefully, may have a different impression:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.