[BACK]Return to control.tex CVS log [TXT][DIR] Up to [local] / OpenXM / doc / OpenXM-specs

Annotation of OpenXM/doc/OpenXM-specs/control.tex, Revision 1.5

1.5     ! noro        1: %% $OpenXM: OpenXM/doc/OpenXM-specs/control.tex,v 1.4 2000/01/24 02:48:24 noro Exp $
1.2       noro        2: \section{Session Management}
1.1       noro        3:
1.2       noro        4: \subsection{Control server}
1.1       noro        5: /*&jp
1.2       noro        6: OpenXM では, 次に述べるような単純かつロバストなサーバの制御方法
                      7: を採用している.
                      8:
                      9: OpenXM サーバは論理的に 2 つの I/O channel をもつ: 一方は計算データ
                     10: 用であり, 他方は計算制御用である. 制御 channel はサーバを制御する
                     11: ためのコマンドを送るために使われる.
                     12: サンプルサーバ ({\tt oxmain.c}) では, そのようなコントロールメッセージ
                     13: は別のプロセスが行っている. 以下, そのプロセスをコントロールサーバ
                     14: と呼ぶ. これに対して, 計算用サーバをエンジンと呼ぶ.
                     15: コントロールサーバとエンジンは同一のマシン上で動作する.
                     16: このため, コントロールサーバからエンジンに signal を送ることは容易である.
                     17: コントロールサーバ自体も OX スタックマシンであり
                     18: {\tt SM\_control\_*} コマンドを受け取る. それらはエンジンへの
                     19: signal 送信, engine process の終了などの request のためのコマンドである.
                     20: */
                     21:
                     22: /*&eg
                     23: In OpenXM we adopted the following simple and robust method to
                     24: control servers.
                     25:
                     26: An OpenXM server has logically two I/O channels: one for exchanging
                     27: data for computations and the other for controlling computations. The
                     28: control channel is used to send commands to control execution on the
                     29: server. The sample server ({\tt oxmain.c}) processes such control
                     30: messages on another process. We call such a process a {\it
                     31: control server}. In contrast, we call a server for computation an {\it
                     32: engine}. As the control server and the engine runs on the
                     33: same machine, it is easy to send a signal from the control server.
                     34: A control server is also an
                     35: OpenXM stack machine and it accepts {\tt SM\_control\_*} commands
                     36: to send signals to a server or to terminate a server.
                     37: */
                     38:
                     39: \subsection{OpenXM reset protocol}
                     40:
                     41: /*&jp
                     42: クライアントはコントロールサーバ経由でいつでもエンジンに signal を
                     43: 送ることができる. しかし, I/O 操作は通常バッファリングされている
                     44: ため, トラブルが生ずる場合がある. エンジンを安全にリセットするため
                     45: 次が必要である.
                     46:
1.1       noro       47: \begin{enumerate}
1.2       noro       48: \item 全ての OX メッセージは Java の意味で synchronized object である.
                     49:
                     50: \item エンジンのリセット後に送られるクライアントからの計算要求メッセージと
                     51: エンジンからの返答が正しく対応していなければならない.
                     52: \end{enumerate}
                     53:
                     54: {\tt SM\_control\_reset\_connection} は, エンジンの安全なリセットを
                     55: 行う一連の手続きを開始するための SM コマンドである.
                     56: クライアントから {\tt SM\_control\_reset\_connection} がコントロール
                     57: サーバに送られると, コントロールサーバは {\tt SIGUSR1} をエンジンに
                     58: 送る. 以後の手続きは次の通りである.
                     59:
                     60: \vskip 2mm
                     61: \noindent
                     62: {\it クライアント側}
                     63: \begin{enumerate}
                     64: \item {\tt SM\_control\_reset\_connection} をコントロールサーバに
                     65: 送った後, クライアントはリセット状態に入る. リセット状態では,
                     66: {\tt OX\_SYNC\_BALL} を受け取るまですべてのメッセージを読みとばす.
                     67: \item {\tt OX\_SYNC\_BALL} を受け取ったあと, クライアントは
                     68: {\tt OX\_SYNC\_BALL} をエンジンに送り, 通常状態に戻る.
                     69: \end{enumerate}
                     70:
                     71: \noindent
                     72: {\it エンジン側}
                     73: \begin{enumerate}
                     74: \item
                     75: {\tt SIGUSR1} をコントロールサーバから受け取ったら, エンジンは
                     76: リセット状態に入る. {\tt OX\_SYNC\_BALL} をクライアントに送る.
                     77: この時点でクライアントは既にリセット状態にあるので, この送信が
                     78: ブロックされることはない.
                     79: \item エンジンは
                     80: {\tt OX\_SYNC\_BALL} を受け取るまですべてのメッセージを読みとばす.
                     81: {\tt OX\_SYNC\_BALL} を受け取ったら通常状態に戻る.
                     82: \end{enumerate}
                     83: */
                     84: /*&eg
                     85: A client can send a signal to an engine by using the control channel
                     86: at any time. However, I/O operations are usually buffered,
                     87: which may cause troubles.
                     88: To reset an engine safely the following are required.
                     89:
                     90: \begin{enumerate}
                     91: \item Any OX message must be a synchronized object in the sense of Java.
                     92:
                     93: \item After restarting an engine, a request from a client
                     94: must correctly corresponds to the response from the engine.
                     95: \end{enumerate}
                     96:
                     97: {\tt SM\_control\_reset\_connection} is a stack machine command to
                     98: initiate a safe resetting of an engine.
                     99: The control server sends {\tt SIGUSR1} to the engine if it receives
                    100: {\tt SM\_control\_reset\_connection} from the client.
                    101: Under the OpenXM reset protocol, an engine and a client act as follows.
                    102:
                    103: \vskip 2mm
                    104: \noindent
                    105: {\it Client side}
                    106: \begin{enumerate}
                    107: \item After sending {\tt SM\_control\_reset\_connection} to the
                    108: control server, the client enters the resetting state. It discards all {\tt
                    109: OX} messages from the engine until it receives {\tt OX\_SYNC\_BALL}.
                    110: \item After receiving {\tt OX\_SYNC\_BALL} the client sends
                    111: {\tt OX\_SYNC\_BALL} to the engine and returns to the usual state.
                    112: \end{enumerate}
                    113:
                    114: \noindent
                    115: {\it Engine side}
                    116: \begin{enumerate}
                    117: \item
                    118: After receiving {\tt SIGUSR1} from the control server,
                    119: the engine enters the resetting state.
                    120: The engine sends {\tt OX\_SYNC\_BALL} to the client.
                    121: The operation does not block because
                    122: the client is now in the resetting state.
                    123: \item The engine discards all OX messages from the engine until it
                    124: receives {\tt OX\_SYNC\_BALL}. After receiving {\tt OX\_SYNC\_BALL}
                    125: the engine returns to the usual state.
                    126: \end{enumerate}
                    127: */
                    128:
                    129: /*&eg
                    130: Figure \ref{reset} illustrates the flow of data.
                    131: {\tt OX\_SYNC\_BALL} is a special OX message and
                    132: is used to mark the end of data remaining in the
                    133: I/O streams. After reading it, it is assured that each stream is empty
                    134: and that the subsequent request from a client correctly
                    135: corresponds to the response from the engine.
                    136: */
                    137: /*&jp
                    138: 図 \ref{reset} はデータの流れを示す.
                    139: {\tt OX\_SYNC\_BALL} は特殊な OX メッセージであり,
                    140: I/O stream に残るデータの終りを示す.
                    141: {\tt OX\_SYNC\_BALL} を読んだ後, それぞれの stream は空であり,
                    142: 後に続くクライアントからのリクエストと, エンジンからの返答が
                    143: 正しく対応する.
                    144: */
1.3       noro      145: \begin{figure}[htbp]
1.5     ! noro      146: \epsfxsize=10cm
        !           147: \begin{center}
1.3       noro      148: \epsffile{reset.eps}
1.5     ! noro      149: \end{center}
1.3       noro      150: \caption{OpenXM reset procedure}
                    151: \label{reset}
                    152: \end{figure}
                    153:
1.2       noro      154: \subsection{Control message (SMObject/TCPIP/Control)}
                    155:
                    156: \begin{enumerate}
                    157: \item
                    158: \begin{verbatim}
                    159: SM_control_reset_connection
                    160: \end{verbatim}
                    161: /*&jp
                    162: コントロールサーバに, {\tt SIGUSR1} をエンジンに送るよう要求する.
                    163: */
                    164: /*&eg
                    165: It requests a control server to send {\tt SIGUSR1} to the engine.
                    166: The control server should immediately reply an acknowledgment to
                    167: the client.
                    168: */
                    169: Request:
1.1       noro      170: \begin{tabular}{|c|c|}  \hline
                    171: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_control\_reset\_connection}  \\
                    172: \hline
                    173: \end{tabular}
1.2       noro      174: Result:
1.1       noro      175: \begin{tabular}{|c|c|}  \hline
                    176: {\tt int32 OX\_DATA} & {\tt CMO\_INT32} {\rm result} \\
                    177: \hline
                    178: \end{tabular}
                    179:
                    180: \item
1.2       noro      181: \begin{verbatim}
                    182: SM_control_kill
                    183: \end{verbatim}
                    184: /*&jp
                    185: サーバはこのメッセージを受信したら
                    186: %ただちに返答をおくり,
                    187: すべてのファイルをクローズして終了する.
                    188: */
                    189: /*&eg
                    190: It requests a control server to terminate the engine and the control server
                    191: itself.
                    192: %The control server should immediately reply an acknowledgment to
                    193: %the client.
                    194: All files and streams should be closed before the termination of servers.
                    195: */
                    196: Request:
1.1       noro      197: \begin{tabular}{|c|c|}  \hline
                    198: {\tt int32 OX\_COMMAND} & {\tt int32 SM\_control\_kill}  \\
                    199: \hline
1.4       noro      200: \end{tabular}\\
1.2       noro      201: Result: none.
1.1       noro      202: \end{enumerate}
                    203:
                    204: \medbreak
                    205: \noindent
1.2       noro      206: //&jp {\bf 例}: (シリアル番号は省略してある.)
                    207: //&eg {\bf Example}: (serial numbers are omitted.)
1.1       noro      208: \begin{verbatim}
                    209: 0  0 2 01 (OX_COMMAND)
                    210: 0  0 4 06 (SM_control_reset_connection)
                    211: \end{verbatim}
                    212:
1.2       noro      213: //&jp Reset に対する返事.
                    214: //&eg Reply to the reset request
1.1       noro      215: \begin{verbatim}
                    216: 0  0 2 02 (OX_DATA)
                    217: 0  0 0  2 (CMO_INT32)
                    218: 0  0 0  0 (  0   )
                    219: \end{verbatim}
                    220:
                    221:
1.2       noro      222: //&jp 第1のチャンネルでは次の {\tt OX\_SYNC\_BALL} が交換されて同期が取られる.
                    223: //&eg {\tt OX\_SYNC\_BALL} are exchanged on the data channel for synchronization.
                    224:
1.1       noro      225: \begin{verbatim}
                    226: 0   0   2   03   (OX_SYNC_BALL)
                    227: \end{verbatim}
                    228:
                    229:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>