jabberd2架构

1. jabber网络结构:
   jabber
的网络中包含了3类关系:
      jabber
客户端-jabber服务器
      jabber
服务器-jabber服务器
      jabber
服务器-外部IM网关
             PC 2                      SVR 2                     PC 3
      .-----------------.       .-----------------.       .-----------------.
      |                 |       |                 |       |                 |
      |   ,---------.   |       |   ,---------.   |       |   ,---------.   |
      | ,'           `. |       | ,'           `. |       | ,'           `. |
      |( Jabber
客户端 -+-------+- Jabber 服务器 -+-------+- Jabber 客户端 )|
      | `.           ,' |       | `.           ,' |       | `.           ,' |
      |   `---------'   |       |   `----+----'   |       |   `---------'   |
      `-----------------'       `--------+--------'       `-----------------'
                                         |
             PC 1                        |
      .-----------------.       .--------+--------.
      |                 |       |        |        | SVR 1
      |   ,---------.   |       |   ,----+----.   |
      | ,'           `. |       | ,'           `. |
      |( Jabber
客户端 -+-------+- Jabber 服务器 )|
      | `.           ,' |       | `.           ,' |
      |   `---------'   |       |   `----+----'   |
      `-----------------'       |        |        |
                                |   ,----+----.   |
                                | ,'  
外部    `. |
                                |(      IM       )|
                                | `.  
网关    ,' |
                                |   `----+----'   |
                                `--------+--------'
                                         |
                                         |
                                .--------+--------.       .-----------------.
                                |        |        |       |                 |
                                |   ,----+----.   |       |   ,---------.   |
                                | ,'  
外部    `. |       | ,'   外部    `. |
                                |(      IM       -+-------+-      IM       )|
                                | `. 
服务器   ,' |       | `.   客户端  ,' |
                                |   `---------'   |       |   `---------'   |
                                `-----------------'       `-----------------'
                                       SVR 3                     PC 4

              
图例
      +--------------------------------------------+
      |                                            |
      |      +-------------+  TCP/IP
连接          |
      |                                            |
      |       ,---------.                          |
      |     ,'           `.                        |
      |    (               ) 
软件包或者模块       |
      |     `.           ,'                        |
      |       `---------'                          |
      |                                            |
      |    .---------------.                       |
      |    |               |                       |
      |    |               |   
计算机:            |
      |    |               |  PC
或者物理服务器    |
      |    |               |                       |
      |    `---------------'                       |
      |                                            |
      +--------------------------------------------+ 

1.1 jabber
客户端-jabber服务器
   
如果两个jabber客户端(PC1,PC2)的帐户在同一服务器上,他们就可以通过一个服务器进行交流。这种情况被称为一个闭合(close)

系统或者私有(private)系统
1.2 jabber
服务器-jabber服务器
   
对于两个帐户在不同服务器的客户端(PC1-PC2,PC2-PC3,该模式提供了一种桥方法,服务器与服务器之间建立一个桥来实现连接
1.3 jabber
服务器和外部网关的连接
   
一个外部网关就像一个适配器,将不同格式的数据相互转换

2.
jabberd的组件结构:
  
jabberd 2 的组件都是依靠TCP/IP协议通讯的:
     *
路由(Router)
     *
服务器-服务器(s2s)
     *
分解器(Resolver)
     *
会话管理(SM)
     *
客户端-服务器(C2S)
  
jabberd 2 还使用了一些第3方组件
     *
应用数据存储(Application Data Store)
     *
验证数据存储(Authentication DAta Store)
     *
外部IM网关
  
jabberd 2组件示意图
                                PC 1                   SVR 2                  SVR 3
                         .-----------------.    .-----------------.    .-----------------.
                         |                 |    |                 |    |                 |
                         |   ,---------.   |    |   ,---------.   |    |   ,---------.   |
                         | ,'           `. |    | ,'           `. |    | ,'   
外部   `. |
                         |( Jabber
客户端 )|    |( Jabber 服务器 )|    |(      IM       )|
                         | `.           ,' |    | `.           ,' |    | `.   
系统   ,' |
                         |   `----+----'   |    |   `----+----'   |    |   `----+----'   |
                         `--------+--------'    `--------+--------'    `--------+--------'
                                  |                      |                      |
                                  |                      |                      |
.---------------------------------+----------------------+----------------------+----------.
|                                 |                      |                      |          |
|      ,---------.           ,----+----.            ,----+----.                 |          |
|    ,'  
验证    `.       ,' 客户端 -  `.        ,' 服务器 -  `.               |          |
|   (   
数据软    +-----+    服务器     )   +--+    服务器      )              |          |
|    `.  
件包    ,'       `.   (C2S)   ,'    |   `.   (S2S)   ,'               |          |
|      `---------'           `----+----'      |     `---------'                 |          |
|                                 |           |                                 |          |
|                                 |           |                                 |          |
|                                 |           |                                 |          |
|                            ,----+----.      |     ,---------.                 |          |
|                          ,'           `+----+   ,'           `.               |          |
|                         (   
路由器     +------+   分解器      )              |          |
|                          `.            +----+   `.           ,'               |          |
|                            `----+----'      |     `---------'                 |          |
|                                 |           |                                 |          |
|                                 |           |                                 |          |
|                                 |           |                                 |          |
|                                 |           |                                 |          |
|      ,---------.           ,----+----.      |                            ,----+----.     |
|    ,'  
应用    `.       ,'  会话     `.    |                          ,'  外部     `.   |
|   (   
数据软     +-----+    管理      )   +-------------------------+      IM        )  |
|    `.  
件包    ,'       `.   (SM)    ,'                               `.    网关   ,'   |
|      `---------'           `---------'                                   `---------'     |
`------------------------------------------------------------------------------------------'
                                             SVR 1
注意: 外部IM网关是一个可选的组件,它并不在jabberd 2的软件包里面。 它依靠第三方的软件

2.1
路由器(Router)
   
路由器是jabberd的核心组件,它从其他组件接受信息,并把各个组件间传递xml数据包
2.2 S2S
    S2S
控制和其他服务器的通信,并实现服务器回呼和远程jabber服务器的验证
2.3
分解器(Resolver)
   
分解器是为支持S2S工作的.他为S2S回呼中验证部分提供分解主机名服务
2.4 SM
    SM(
会话管理)实现了即时消息的大部分
      *
消息传送
      *
状态管理(Presence)
      *
帐户管理(Rosters)
      *
订阅(Subscriptions)
    SM
连接应用数据软件包(Application Data Package(db))”保存状态数据。另外,SM组件控制jabber扩展的发现和私有列表

(jabber extensions of disco(discovery)and privacy lists*).
2.5 C2S
    C2S组件控制与客户端的通信
      *
jabbar客户端连接
      *
传递包给SM
      *
验证客户端
      *
注册用户
      *
SM引发活动
    C2S
组件连接验证数据包(Authentication Data Package(authreg))以便实现用户注册和验证

3.
jabberd 2 模块分解

4.
jabberd 2 数据控制
  
jabberd 使用数据控制(data handing)的概念以便适应各类数据处理包。数据控制(data handling)的核心是收集器(Collection)对象概念。

每个收集器(Collection)都有类型(Type)和拥有者(Owner)两个属性.类型(Type)指明什么类型的数据正在被处理,,队列(queue),vcard,名册

条目(roster-item). 拥有者(Owner)表明谁拥有这个收集器(collection).对于和用户相关的数据,拥有者(Owner)jabber ID(JID).
  
每个收集器(collection)管理了一个至多个数据对象(collection data)。每个数据对象(collection data)是包含了关键字(key),值(value)

类型(type).关键字(key)是一个字符串,表明被处理数据的种类。值(value)是被处理的数据值。类型(type)是数据的存储格式,

如,boolean,integer,string,等。如下表
              
  +--------------+
                  |  Collection  |
              +--------------+---+
              |  Collection  |   |
          +--------------+---+   |
          |  Collection  |   |   |                     Key for Object Diagram
          +--------------+   |   |            +-------------------------------------+
          | Type         |   |---+            |                                     |
          | Owner        |   |                |   +-------+                         |
          |              |---+                |   |       |                         |
          |              |                    |   +-------+   Object                |
          +--------------+                    |   |       |                         |
                 |                            |   |       |                         |
                 |                            |   +-------+                         |
                 |                            |       |                             |
                 |                            |       |  1-
多关系           |
                 ^ (1
个收集器管理多个数据)    |       |                             |
        +-------------------+                 |       ^                             |
        |  Collection Data  |                 |                                     |
        +-------------------+                 +-------------------------------------+
        | Key               |
        | Value             |
        | Type              |
        |                   |
        +-------------------+              

5.
jabberd 2 数据结构(针对MySQL)
  
MySQLjabberd 数据控制(Data handlling)变得更加具体和清晰.在关系数据库中,每个收集器(collection)就是一个表,每个数据

对象 (collection data)的关键字 (key)就是一个域 (field),而每一行包含一个收集器拥有者 (collection owner)(JID)和一个或多个数据域 (field).
   1.
表清单 (MySQL)
      active
         
保存每个帐户最近活动时间
      authreg
         
包含了验证信息 ,包括 : 用户名 (username),真实名 (realm)和密码 (password)
      disco-items
         
保存即时状态的信息 (persistent discovery information),以便在离线状态下存取
      logout
         
保存 JID和时间戳 ,表明最近登出的时间
      motd-message
          
保存 XML格式的当天的消息 (Message Of The Day)
      motd-times
          
保存与收到的 MOTD相关联的 JID和时间戳
      privacy-default
          
保存当前使用列表的名称 ,以便在用户登录时激活
      privacy-items
          
保存用户的私有列表 (黑名单 /白名单 )
      private
          
XML格式存储一些用户相关的信息 ,如用户偏好 ,书签等
      queue
          
XML格式保存排过队的信息
      roster-groups
          
保存那些仅仅和某个组关联的名册条目
      roster-items
          
保存所有的名册 ,包括验证的信息
      vacation-settings
           Handles vacation settings, including start, end and message
      vcard
          
保存 vcard信息

    2.
表描述 :
                                            MySQL
表描述
+------------------------------------------------------------------------------------------------------------+
|                                                                                                            |
|  +-------------------------------+       +-----------------------+       +------------------------------+  |
|  | active                        |       | authreg               |       | disco-items                  |  |
|  +-------------------------------+       +-----------------------+       +------------------------------+  |
|  |                               |       |                       |       |                              |  |
|  +-------------------------------+       +-----------------------+       +------------------------------+  |
|  | collection-owner: TEXT        |       | username: TINYTEXT    |       | collection-owner: TEXT       |  |
|  | object-sequence:  BIGINT(20)  |       | realm:    TINYTEXT    |       | object-sequence:  BIGINT(20) |  |
|  | time:             INTEGER(11) |       | password: TINYTEXT    |       | jid:              TEXT       |  |
|  |                               |       | token:    VARCHAR(10) |       | name:             TEXT       |  |
|  +-------------------------------+       | sequence: INTEGER(11) |       | node:             TEXT       |  |
|  |                               |       | hash:     VARCHAR(40) |       |                              |  |
|  +-------------------------------+       |                       |       +------------------------------+  |
|                                          +-----------------------+       |                              |  |
|                                          |                       |       +------------------------------+  |
|                                          +-----------------------+                                         |
|                                                                                                            |
|                                                                                                            |
|  +-------------------------------+   +------------------------------+    +-------------------------------+ |
|  | logout                        |   | motd-message                 |    | motd-times                    | |
|  +-------------------------------+   +------------------------------+    +-------------------------------+ |
|  |                               |   |                              |    |                               | |
|  +-------------------------------+   +------------------------------+    +-------------------------------+ |
|  | collection-owner: TEXT        |   | collection-owner: TEXT       |    | collection-owner: TEXT        | |
|  | object-sequence:  BIGINT(20)  |   | object-sequence:  BIGINT(20) |    | object-sequence:  BIGINT(20)  | |
|  | time:             INTEGER(11) |   | xml:              TEXT       |    | time:             INTEGER(11) | |
|  |                               |   |                              |    |                               | |
|  +-------------------------------+   +------------------------------+    +-------------------------------+ |
|  |                               |   |                              |    |                               | |
|  +-------------------------------+   +------------------------------+    +-------------------------------+ |
|                                                                                                            |
|                                                                                                            |
|  +------------------------------+    +-------------------------------+   +------------------------------+  |
|  | privacy-default              |    | privacy-items                 |   | private                      |  |
|  +------------------------------+    +-------------------------------+   +------------------------------+  |
|  |                              |    |                               |   |                              |  |
|  +------------------------------+    +-------------------------------+   +------------------------------+  |
|  | collection-owner: TEXT       |    | collection-owner: TEXT        |   | collection-owner: TEXT       |  |
|  | object-sequence:  BIGINT(20) |    | object-sequence:  BIGINT(20)  |   | object-sequence:  BIGINT(20) |  |
|  | default:          TEXT       |    | list:             TEXT        |   | ns:               TEXT       |  |
|  |                              |    | type:             TEXT        |   | xml:              TEXT       |  |
|  +------------------------------+    | value:            TEXT        |   |                              |  |
|  |                              |    | deny:             TINYTEXT(4) |   +------------------------------+  |
|  +------------------------------+    | order:            INTEGER(11) |   |                              |  |
|                                      | block:            INTEGER(11) |   +------------------------------+  |
|                                      |                               |                                     |
|                                      +-------------------------------+                                     |
|                                      |                               |                                     |
|                                      +-------------------------------+                                     |
|                                                                                                            |
|                                                                                                            |
|  +------------------------------+    +------------------------------+    +-------------------------------+ |
|  | queue                        |    | roster-groups                |    | roster-items                  | |
|  +------------------------------+    +------------------------------+    +-------------------------------+ |
|  |                              |    |                              |    |                               | |
|  +------------------------------+    +------------------------------+    +-------------------------------+ |
|  | collection-owner: TEXT       |    | collection-owner: TEXT       |    | collection-owner: TEXT        | |
|  | object-sequence:  BIGINT(20) |    | object-sequence:  BIGINT(20) |    | object-sequence:  BIGINT(20)  | |
|  | xml:              TEXT       |    | jid:              TEXT       |    | jid:              TEXT        | |
|  |                              |    | group:            TEXT       |    | name:             TEXT        | |
|  +------------------------------+    |                              |    | to:               TINYTEXT(4) | |
|  |                              |    +------------------------------+    | from:             TINYTEXT(4) | |
|  +------------------------------+    |                              |    | ask:              INTEGER(11) | |
|                                      +------------------------------+    |                               | |
|                                                                          +-------------------------------+ |
|                                                                          |                               | |
|                                                                          +-------------------------------+ |
|                                                                                                            |
|                                                                                                            |
|  +-------------------------------+   +------------------------------+                                      |
|  | vacation-settings             |   | vcard                        |                                      |
|  +-------------------------------+   +------------------------------+                                      |
|  |                               |   |                              |                                      |
|  +-------------------------------+   +------------------------------+                                      |
|  | collection-owner: TEXT        |   | collection-owner: TEXT       |                                      |
|  | object-sequence:  BIGINT(20)  |   | object-sequence:  BIGINT(20) |                                      |
|  | start:            INTEGER(11) |   | fn:               TEXT       |                                      |
|  | end:              INTEGER(11) |   | nickname:         TEXT       |                                      |
|  | message:          TEXT        |   | url:              TEXT       |                                      |
|  |                               |   | tel:              TEXT       |                                      |
|  +-------------------------------+   | email:            TEXT       |                                      |
|  |                               |   | title:            TEXT       |                                      |
|  +-------------------------------+   | role:             TEXT       |                                      |
|                                      | bday:             TEXT       |                                      |
|                                      | desc:             TEXT       |                                      |
|                                      | n-given:          TEXT       |                                      |
|                                      | n-family:         TEXT       |                                      |
|                                      | adr-street:       TEXT       |                                      |
|                                      | adr-extadd:       TEXT       |                                      |
|                                      | adr-locality:     TEXT       |                                      |
|                                      | adr-region:       TEXT       |                                      |
|                                      | adr-pcode:        TEXT       |                                      |
|                                      | adr-country:      TEXT       |                                      |
|                                      | org-orgname:      TEXT       |                                      |
|                                      | org-orgunit:      TEXT       |                                      |
|                                      |                              |                                      |
|                                      +------------------------------+                                      |
|                                      |                              |                                      |
|                                      +------------------------------+                                      |
|                                                                                                            |
+------------------------------------------------------------------------------------------------------------+

你可能感兴趣的:(jabberd2)