讀古今文學網 > 程序員必讀之軟件架構 > 軟件架構 >

軟件架構

這個部分提供「技術部落」的軟件架構概覽。

容器

下圖展示了組成「技術部落」系統的邏輯容器。圖並不代表容器的實際數量和位置:這個信息請看基礎設施和部署部分。

  • Web服務器 :Apache Tomcat 7 Web服務器,從互聯網訪問「技術部落」網站的單一訪問點。
  • 內容更新器 :從Twitter、GitHub和博客更新信息的獨立的Java 7應用程序。
  • 關係型數據庫 :存儲了「技術部落」網站背後大部分數據的MySQL數據庫。
  • NoSQL數據存儲 :存儲微博和博文的MongoDB數據庫。
  • 文件系統 :文件系統存儲了Lucene搜索索引。

組件:內容更新器

下圖展示了組成獨立的內容更新器的組件。

techtribes.js-Containers-content Updater:「技術部落」-組件-內容更新器
Standalone Java Process:獨立Java進程

除了一些核心組件(稍後詳述),獨立的內容更新器進程由以下組件構成。

  • 計劃內容更新器 :該組件安排從Twitter、GitHub和博客的計劃(即,每15分鐘)信息更新。它還重新計算「最近活躍」,每小時發放一次徽章獎勵。它是一個使用Spring調度註釋的Spring Bean。代碼請看je.techtribes.component.scheduledcontentupdater6 。
  • Twitter連接器 :該組件負責連接到Twitter,以便刷新檔案信息和取回微博。它是一個使用Twitter4J類庫7 的Spring Bean。REST8 和Streaming API9 都採用了。代碼請看je.techtribes.component.twitterconnector10 。
  • GitHub連接器 :該組件負責連接到GitHub,以便刷新倉庫信息。它是一個使用Eclipse Mylyn GitHub連接器11 的Spring Bean。代碼請看je.techtribes.component.githubconnector12 。
  • 新聞訂閱連接器 :該組件負責連接到RSS/Atom訂閱,以便刷新聚合到「技術部落」網站的新聞和博文。它是一個使用ROME類庫13 的Spring Bean。代碼請看je.techtribes.component.newsfeedconnector14 。

6 https://github.com/techtribesje/techtribesje/tree/master/techtribes-updater/src/je/techtribes/component/scheduledcontentupdater

7 http://twitter4j.org

8 https://dev.twitter.com/docs/api ——譯者注

9 https://dev.twitter.com/docs/api/streaming ——譯者注

10 https://github.com/techtribesje/techtribesje/tree/master/techtribes-updater/src/je/techtribes/component/twitterconnector

11 http://www.eclipse.org/mylyn/

12 https://github.com/techtribesje/techtribesje/tree/master/techtribes-updater/src/je/techtribes/component/githubconnector

13 http://rometools.github.io/rome/

14 https://github.com/techtribesje/techtribesje/tree/master/techtribes-updater/src/je/techtribes/component/newsfeedconnector

組件:核心

下圖展示了Web服務器和獨立的內容更新器共用的通用組件。

這是對每個核心組件的小結。

  • 內容源組件 :該組件提供對MySQL中存儲的人和部落(合指「信息源」)信息的訪問。代碼請看je.techtribes.component.contentsource15 。
  • 新聞訂閱項組件 :該組件提供對MongoDB中存儲的新聞和博文的訪問。代碼請看je.techtribes.component.newsfeedentry16 。
  • 微博組件 :該組件提供對MongoDB中存儲的微博的訪問。代碼請看je.techtribes.component.tweet17 。
  • 講座組件 :該組件提供對MySQL中存儲的本地演講者的講座信息的訪問。代碼請看je.techtribes.component.talk18 。
  • 活動組件 :該組件提供對MySQL中存儲的本地活動(比如,聚會、研討會、代碼道場,等)信息的訪問。代碼請看je.techtribes.component.event19 。
  • 工作組件 :該組件提供對MySQL中存儲的本地工作機會信息的訪問。代碼請看je.techtribes.component.job20 。
  • GitHub組件 :該組件提供對MySQL中存儲的屬於本地人/部落的代碼倉庫信息的訪問。代碼請看je.techtribes.component.github21 。
  • 搜索組件 :該組件為新聞、博文和微博提供搜索工具。使用Apache Lucene進行索引和搜索。代碼請看je.techtribes.component.search22 。
  • 活躍度組件 :該組件提供對MySQL中存儲的,內容更新器計算得到的「最近活躍」信息的訪問。代碼請看je.techtribes.component.activity23 。
  • 徽章組件 :該組件提供對人/部落因活躍度而被獎勵的徽章的訪問。代碼請看je.techtribes.component.badge24 。
  • 日誌組件 :該組件只是對Commons Logging25 和log4j的包裝。所有其他組件都會使用它。代碼請看je.techtribes.component.log26 。

15 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/contentsource

16 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/newsfeedentry

17 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/tweet

18 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/talk

19 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/event

20 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/job

21 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/github

22 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/search

23 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/activity

24 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/badge

25 Commons Logging提供一個統一的日誌接口,從而不依賴於具體的日誌實現,http://commons.apache.org/proper/commons-logging/ 。——譯者注

26 https://github.com/techtribesje/techtribesje/tree/master/techtribes-core/src/je/techtribes/component/log