数据重构服务概述
数据重构服务的组成要素
数据重构服务 (DRS) 的一个实现包含以下模块: 连接协议模块、处理服务所收到的若干请求的处理器、对这些请求进行处理的编译器和/或解释器 (称为 Form Machine), 以及用于保存和取回数据重构定义 (form) 的文件存储模块。
本节描述连接协议与请求。下一节较详细地介绍 Form Machine 语言。本文档不描述文件存储, 因为它对服务的使用是透明的, 且其实现因 DRS 主机而异。
概念性网络连接
DRS 有三种概念性网络连接, 见图 1。
- 控制连接 (CC) 位于发起用户与 DRS 之间。规定数据重构的 form 通过该连接定义。用户 (一次性地) 指明要应用到下面所述两种连接上传送的数据上的 form。
- 用户连接 (UC) 位于用户进程与 DRS 之间。
- 服务连接 (SC) 位于 DRS 与服务进程之间。
由于目标是让网络去适应用户进程与服务进程, 因此对 UC 和 SC 只施加最少的要求。
+------------+ +------+ +---------+
| ORIGINATING| CC | DRS | SC | SERVER |
| USER |--------------| |----------| PROCESS |
+------------+ ^ +------+ ^ +---------+
| / |
| UC/ <-----\ |
| / \ |
| +-----------+ \|
TELNET ---------+ | USER | +-- Simplex or Duplex
Protocol | PROCESS | Connections
Connection +-----------+
Figure 1. DRS Network Connections
连接协议与消息格式
在控制连接上, 对话直接在发起用户与 DRS 之间进行。此时用户在定义 form, 或把预定义的 form 分配给连接做重新格式化。
用户通过标准的初始连接协议 (ICP) 连接到 DRS。用户不经过 logger, 而是直接呼叫 DRS 一直在监听的某个特定套接字。(实验性的套接字号稍后公布。) DRS 随后把用户切换到另一对套接字。
在控制连接上发送的消息采用为 TELNET 规定的类型与格式。(数据类型代码应指定 ASCII —— 即默认值。) 因此, 终端前的用户应当能够通过其本地 TELNET 连接到 DRS, 如图 2 所示。
+---------+ CC +---------+
+---------| TELNET |-------| DRS |
| +---------+ +---------+
+-----------------------+
| USER |
| (TERMINAL OR PROGRAM) |
+-----------------------+
Figure 2. A TELNET Connection to DRS
用户连接到 DRS 时要提供一个六字符的用户 ID (UID) 作为限定符, 以保证其 form 名字的唯一性。用户最初将拥有以下命令:
1. DEFFORM (form)
2. ENDFORM (form)
These two commands define a form, the text of which is
chronologically entered between them. The form is stored
in the DRS local file system.
3. PURGE (form)
The named form, as qualified by the current UID, is purged
from the DRS file system.
4. LISTNAMES (UID)
The unqualified names of all forms assigned to UID are
returned.
5. LISTFORM (form)
The source text of a named form is returned.
6. DUPLEXCONNECT (user site, user receive socket, user method,
server site, server receive socket, server method, user-
to-server form name, server-to-user form name)
A duplex connection is made between two processes using the
receive sockets and the sockets one greater. Method is
defined below. The forms define the transformations on
these connections.
7. SIMPLEXCONNECT (user site, user socket, user method, server
site, server socket, server method, form)
A simplex connection is made between the two sockets as
specified by method.
8. ABORT (site, receive socket)
The reconfiguration of data is terminated by closing both
the UC and SC specified in part in the command.
第 6、7 条中指定的两方中的一个、两个或零个, 可以与发出请求的一方位于同一主机。site 与 socket 为该连接指定用户方与服务方。method 指示建立连接的方式。
以下规则适用于这些命令:
1) Commands may be abbreviated to the minimum number of
characters to identify them uniquely.
2) All commands should be at the start of a line.
3) Parameters are enclosed in parentheses and separated by
commas.
4) Imbedded blanks are ignored.
5) The parameters are:
form name 1-6 characters
UID 1-6 characters
Site 1-2 characters specifying
the hexadecimal host number
Socket 1-8 characters specifying the
hexadecimal socket number
Method A single character
6) Method has the following values:
C The site/socket is already connected
to the DRS as a dummy control connection
(should not be the real control connection).
I Connect via the standard ICP (does not
apply to SIMPLEXCONNECT).
D Connect directly via STR, RTS.
The DRS will make at least the following minimal
responses to the user:
1) A positive or negative acknowledgement after
each line (CR/LF)
2) If a form fails or terminates
TERMINATE, ASCII Host # as hex, ASCII Socket # as hex,
ASCII Return Code as decimal
thus identifying at least one end of the connection.
连接配置示例
DRS 的工作方式基本上有两种: 1) 用户希望在程序之间建立 DRS 的 UC/SC 连接; 2) 用户希望建立同样的连接, 但他 (他的终端) 位于 UC 或 SC 的一端。当用户想从自己的终端与服务进程 (例如 logger) 交互时, 适于采用后一种方式。
在第一种情形下 (图 1, 发起用户既可以是终端也可以是程序), 用户发出相应的 CONNECT 命令。UC/SC 可以是单工或双工的。
第二种情形有两种可能的配置, 如图 3 和图 4 所示。
+-------+ +--------+ CC +-----+ +----+
| |----| |---------| | SC | |
| USER | | TELNET | UC | DRS |--------| SP |
| |----| |---------| | | |
+-------+ +--------+ +-----+ +----+
Figure 3. Use of Dummy Control Connection
+---------+
+------+ /| USER | CC +-----+
| |---/ | SIDE |--------| | SC +----+
| USER | +---------+ UC | DRS |--------| SP |
| |---\ | SERVING |--------| | +----+
+------+ \| SIDE | +-----+
+---------+
Figure 4. Use of Server TELNET
在图 3 中, 用户指示其 TELNET 建立两条到 DRS 的双工连接。一条用于控制信息 (即 CC), 另一条是哑连接。发出 CONNECT 时, 用户使用 "已连接" (already connected) 选项来引用这条哑双工连接 (UC)。
在图 4 中, 用户的 TELNET (用户侧) 呼叫 DRS。发出 CONNECT 时, DRS 回呼 TELNET (服务侧), 由其代表控制台接受呼叫。这一区别只有用户知道, 因为对 DRS 而言, 图 4 的配置与图 1 完全相同。有两点需要注意:
- 只有在定义 form 和指挥建立连接时才需要 TELNET 协议。使用进程与服务进程并不需要它。
- 使用进程与服务进程为接入网络所需做的修改极少, 即只需一个 NCP 接口。