version 1.12, 2016/08/27 02:11:01 |
version 1.13, 2020/03/14 01:21:56 |
|
|
%% $OpenXM: OpenXM/doc/OpenXM-specs/control.tex,v 1.11 2016/08/22 09:23:31 takayama Exp $ |
%% $OpenXM: OpenXM/doc/OpenXM-specs/control.tex,v 1.12 2016/08/27 02:11:01 takayama Exp $ |
\section{Session Management} |
\section{Session Management} |
|
|
\subsection{Control server} |
\subsection{Control server} |
/*&jp |
/*&jp |
OpenXM では, 次に述べるような単純かつロバストなサーバの制御方法 |
OpenXM с, 罨<菴違鴻膣ゃ鴻泣若九勝号 |
を採用している. |
。. |
|
|
OpenXM サーバは論理的に 2 つの I/O channel をもつ: 一方は計算データ |
OpenXM 泣若茫 2 ゃ I/O channel : 筝鴻荐膊若 |
用であり, 他方は計算制御用である. 制御 channel はサーバを制御する |
с, 篁鴻荐膊九勝с. 九勝 channel 泣若九勝 |
ためのコマンドを送るために使われる. |
潟潟篏帥. |
サンプルサーバ ({\tt oxmain.c}) では, そのようなコントロールメッセージ |
泣潟泣若 ({\tt oxmain.c}) с, 潟潟若<祉若 |
は別のプロセスが行っている. 以下, そのプロセスをコントロールサーバ |
ャ祉鴻茵c. 篁ヤ, 祉鴻潟潟若泣若 |
と呼ぶ. これに対して, 計算用サーバをエンジンと呼ぶ. |
若. 絲障, 荐膊泣若潟吾潟若. |
コントロールサーバとエンジンは同一のマシン上で動作する. |
潟潟若泣若潟吾潟筝激割у篏. |
このため, コントロールサーバからエンジンに signal を送ることは容易である. |
, 潟潟若泣若潟吾潟 signal 絎号с. |
コントロールサーバ自体も OX スタックマシンであり |
潟潟若泣若篏 OX 鴻帥激潟с |
{\tt SM\_control\_*} コマンドを受け取る. それらはエンジンへの |
{\tt SM\_control\_*} 潟潟. 潟吾潟吾 |
signal 送信, engine process の終了などの request のためのコマンドである. |
signal 篆, engine process 腟篋 request 潟潟с. |
*/ |
*/ |
|
|
/*&eg |
/*&eg |
Line 38 to send signals to a server or to terminate a server. |
|
Line 38 to send signals to a server or to terminate a server. |
|
|
|
\subsection{New OpenXM control servers} |
\subsection{New OpenXM control servers} |
/*&jp |
/*&jp |
OpenXM RFC 101 Draft を見よ |
OpenXM RFC 101 Draft 荀 |
\htmladdnormallink{http://www.math.kobe-u.ac.jp/OpenXM/OpenXM-RFC.html}{http://www.math.kobe-u.ac.jp/OpenXM/OpenXM-RFC.html}. |
\htmladdnormallink{http://www.math.kobe-u.ac.jp/OpenXM/OpenXM-RFC.html}{http://www.math.kobe-u.ac.jp/OpenXM/OpenXM-RFC.html}. |
*/ |
*/ |
/*&eg |
/*&eg |
Line 49 See OpenXM RFC 101 Draft. |
|
Line 49 See OpenXM RFC 101 Draft. |
|
\subsection{OpenXM reset protocol} |
\subsection{OpenXM reset protocol} |
|
|
/*&jp |
/*&jp |
クライアントはコントロールサーバ経由でいつでもエンジンに signal を |
ゃ≪潟潟潟若泣若腟宴сゃс潟吾潟 signal |
送ることができる. しかし, I/O 操作は通常バッファリングされている |
с. , I/O 篏絽吾<潟違 |
ため, トラブルが生ずる場合がある. エンジンを安全にリセットするため |
, 翫. 潟吾潟絎祉 |
次が必要である. |
罨<綽荀с. |
|
|
\begin{enumerate} |
\begin{enumerate} |
\item 全ての OX メッセージは Java の意味で synchronized object である. |
\item OX <祉若吾 Java 潟 synchronized object с. |
|
|
\item エンジンのリセット後に送られるクライアントからの計算要求メッセージと |
\item 潟吾潟祉緇ゃ≪潟荐膊荀羆<祉若吾 |
エンジンからの返答が正しく対応していなければならない. |
潟吾潟菴膈罩c鎛上違. |
\end{enumerate} |
\end{enumerate} |
|
|
{\tt SM\_control\_reset\_connection} は, エンジンの安全なリセットを |
{\tt SM\_control\_reset\_connection} , 潟吾潟絎祉 |
行う一連の手続きを開始するための SM コマンドである. |
茵筝c膓紮 SM 潟潟с. |
クライアントから {\tt SM\_control\_reset\_connection} がコントロール |
ゃ≪潟 {\tt SM\_control\_reset\_connection} 潟潟若 |
サーバに送られると, コントロールサーバは {\tt SIGUSR1} をエンジンに |
泣若, 潟潟若泣若 {\tt SIGUSR1} 潟吾潟 |
送る. 以後の手続きは次の通りである. |
. 篁ュ膓罨<с. |
|
|
\vskip 2mm |
\vskip 2mm |
\noindent |
\noindent |
{\it クライアント側} |
{\it ゃ≪潟} |
\begin{enumerate} |
\begin{enumerate} |
\item {\tt SM\_control\_reset\_connection} をコントロールサーバに |
\item {\tt SM\_control\_reset\_connection} 潟潟若泣若 |
送った後, クライアントはリセット状態に入る. リセット状態では, |
c緇, ゃ≪潟祉倶ャ. 祉倶с, |
{\tt OX\_SYNC\_BALL} を受け取るまですべてのメッセージを読みとばす. |
{\tt OX\_SYNC\_BALL} 障с鴻<祉若吾茯帥違. |
\item {\tt OX\_SYNC\_BALL} を受け取ったあと, クライアントは |
\item {\tt OX\_SYNC\_BALL} c, ゃ≪潟 |
{\tt OX\_SYNC\_BALL} をエンジンに送り, 通常状態に戻る. |
{\tt OX\_SYNC\_BALL} 潟吾潟, 絽悟倶祉. |
\end{enumerate} |
\end{enumerate} |
|
|
\noindent |
\noindent |
{\it エンジン側} |
{\it 潟吾喝} |
\begin{enumerate} |
\begin{enumerate} |
\item |
\item |
{\tt SIGUSR1} をコントロールサーバから受け取ったら, エンジンは |
{\tt SIGUSR1} 潟潟若泣若c, 潟吾潟 |
リセット状態に入る. {\tt OX\_SYNC\_BALL} をクライアントに送る. |
祉倶ャ. {\tt OX\_SYNC\_BALL} ゃ≪潟. |
この時点でクライアントは既にリセット状態にあるので, この送信が |
鴻сゃ≪潟≪祉倶, 篆< |
ブロックされることはない. |
. |
\item エンジンは |
\item 潟吾潟 |
{\tt OX\_SYNC\_BALL} を受け取るまですべてのメッセージを読みとばす. |
{\tt OX\_SYNC\_BALL} 障с鴻<祉若吾茯帥違. |
{\tt OX\_SYNC\_BALL} を受け取ったら通常状態に戻る. |
{\tt OX\_SYNC\_BALL} c絽悟倶祉. |
\end{enumerate} |
\end{enumerate} |
*/ |
*/ |
/*&eg |
/*&eg |
Line 145 and that the subsequent request from a client correctl |
|
Line 145 and that the subsequent request from a client correctl |
|
corresponds to the response from the engine. |
corresponds to the response from the engine. |
*/ |
*/ |
/*&jp |
/*&jp |
図 \ref{reset} はデータの流れを示す. |
\ref{reset} 若帥羌腓冴. |
{\tt OX\_SYNC\_BALL} は特殊な OX メッセージであり, |
{\tt OX\_SYNC\_BALL} 号 OX <祉若吾с, |
I/O stream に残るデータの終りを示す. |
I/O stream 罧若帥腟腓冴. |
{\tt OX\_SYNC\_BALL} を読んだ後, それぞれの stream は空であり, |
{\tt OX\_SYNC\_BALL} 茯緇, stream 腥冴с, |
後に続くクライアントからのリクエストと, エンジンからの返答が |
緇膓ゃ≪潟鴻, 潟吾潟菴膈 |
正しく対応する. |
罩c鎛上. |
*/ |
*/ |
\begin{figure}[htbp] |
\begin{figure}[htbp] |
\epsfxsize=10cm |
\epsfxsize=10cm |
Line 169 I/O stream に残るデータの終りを示す. |
|
Line 169 I/O stream に残るデータの終りを示す. |
|
SM_control_reset_connection |
SM_control_reset_connection |
\end{verbatim} |
\end{verbatim} |
/*&jp |
/*&jp |
コントロールサーバに, {\tt SIGUSR1} をエンジンに送るよう要求する. |
潟潟若泣若, {\tt SIGUSR1} 潟吾潟荀羆. |
*/ |
*/ |
/*&eg |
/*&eg |
It requests a control server to send {\tt SIGUSR1} to the engine. |
It requests a control server to send {\tt SIGUSR1} to the engine. |
|
|
\end{tabular} |
\end{tabular} |
Result: none. \\ |
Result: none. \\ |
/*&jp |
/*&jp |
すべてエンジンは reset protocol を実装することが推奨されるが, |
鴻潟吾潟 reset protocol 絎茖ィ絅, |
実装していない場合は, mathcap の第4引数の option list で |
絎茖翫, mathcap 膃鐚綣違 option list |
{\tt no\_ox\_reset} を送信すべきである (参照: oxpari). \\ |
{\tt no\_ox\_reset} 篆<鴻с (: oxpari). \\ |
*/ |
*/ |
/*&eg |
/*&eg |
All engines are encouraged to install the reset protocol, |
All engines are encouraged to install the reset protocol, |
Line 194 but when it is not implemented, |
|
Line 194 but when it is not implemented, |
|
(option list) of the mathcap (ref: oxpari). \\ |
(option list) of the mathcap (ref: oxpari). \\ |
*/ |
*/ |
/*&jp |
/*&jp |
注意: 古い実装(2000年以前)の control server, client では, |
羈: ゃ絎茖(2000綛岩札) control server, client с, |
次の形式の result code が戻ることを仮定している場合がある. |
罨<綵√ result code 祉篁絎翫. |
これら古い実装は更新することが必要である. \\ |
ゃ絎茖贋違綽荀с. \\ |
*/ |
*/ |
/*&eg |
/*&eg |
Note: Some old implementations of control servers and clients (before 2000) |
Note: Some old implementations of control servers and clients (before 2000) |
Line 213 These obsolete implementations should be updated.\\ |
|
Line 213 These obsolete implementations should be updated.\\ |
|
SM_control_kill |
SM_control_kill |
\end{verbatim} |
\end{verbatim} |
/*&jp |
/*&jp |
サーバはこのメッセージを受信したら |
泣若<祉若吾篆< |
%ただちに返答をおくり, |
%<菴膈, |
すべてのファイルをクローズして終了する. |
鴻<ゃ若冴腟篋. |
*/ |
*/ |
/*&eg |
/*&eg |
It requests a control server to terminate the engine and the control server |
It requests a control server to terminate the engine and the control server |
|
|
|
|
\medbreak |
\medbreak |
\noindent |
\noindent |
//&jp {\bf 例}: (シリアル番号は省略してある.) |
//&jp {\bf 箴}: (激≪垩ャ.) |
//&eg {\bf Example}: (serial numbers are omitted.) |
//&eg {\bf Example}: (serial numbers are omitted.) |
\begin{verbatim} |
\begin{verbatim} |
0 0 2 01 (OX_COMMAND) |
0 0 2 01 (OX_COMMAND) |
0 0 4 06 (SM_control_reset_connection) |
0 0 4 06 (SM_control_reset_connection) |
\end{verbatim} |
\end{verbatim} |
|
|
%//&jp Reset に対する返事. |
%//&jp Reset 絲障菴篋. |
%//&eg Reply to the reset request |
%//&eg Reply to the reset request |
%\begin{verbatim} |
%\begin{verbatim} |
%0 0 2 02 (OX_DATA) |
%0 0 2 02 (OX_DATA) |
|
|
%\end{verbatim} |
%\end{verbatim} |
|
|
|
|
//&jp 第1のチャンネルでは次の {\tt OX\_SYNC\_BALL} が交換されて同期が取られる. |
//&jp 膃1c潟с罨< {\tt OX\_SYNC\_BALL} 篋ゆ. |
//&eg {\tt OX\_SYNC\_BALL} are exchanged on the data channel for synchronization. |
//&eg {\tt OX\_SYNC\_BALL} are exchanged on the data channel for synchronization. |
|
|
\begin{verbatim} |
\begin{verbatim} |
|
|
\subsection{Notification from servers} |
\subsection{Notification from servers} |
|
|
/*&jp |
/*&jp |
OpenXM サーバは, 可能であるかぎり寡黙である. |
OpenXM 泣若, 純с絲♂с. |
たとえばエラーをおこしても, エラーはサーバのエンジンスタックにつまれる |
違若, 若泣若潟吾潟鴻帥ゃ障 |
だけであり, サーバはクライアントが {\tt pop\_cmo} メッセージをおくらない |
с, 泣若ゃ≪潟 {\tt pop\_cmo} <祉若吾 |
かぎり何も送信しない. |
篏篆<. |
*/ |
*/ |
/*&eg |
/*&eg |
OpenXM servers try to be as quiet as possible. |
OpenXM servers try to be as quiet as possible. |
Line 273 the engine does not send error packets unless the clie |
|
Line 273 the engine does not send error packets unless the clie |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
OpenXM はこの原則をやぶる例外的な方法を一つ用意している. |
OpenXM 吟箴紊号筝ょ. |
コントロールサーバは, |
潟潟若泣若, |
{\tt OX\_NOTIFY} ヘッダおよびそれにつづく {\tt OX\_DATA} パケットを送る |
{\tt OX\_NOTIFY} 潟ゃャ {\tt OX\_DATA} 宴 |
ことができる. |
с. |
この機能は mathcap で禁止することも可能である. |
罘純 mathcap х罩≪純с. |
*/ |
*/ |
/*&eg |
/*&eg |
OpenXM provides a method to notify events. |
OpenXM provides a method to notify events. |
Line 286 This transmission may be prohibited by mathcap. |
|
Line 286 This transmission may be prohibited by mathcap. |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
この機能をどのように使うか例をあげて説明しよう. |
罘純篏帥箴茯. |
{\tt Asir} の {\tt ox\_plot} サーバは, quit ボタンをもっている. |
{\tt Asir} {\tt ox\_plot} 泣若, quit 帥潟c. |
quit ボタンがおされると canvas が消滅するが, エンジン自体は存在を |
quit 帥潟 canvas 羔羯, 潟吾活篏絖 |
つづける. この状態で描画命令がくると, |
ゃャ. 倶ф糸巡擦, |
エンジンスタックに, ``canvas does not exist'' というエラーがつまれる. |
潟吾潟鴻帥, ``canvas does not exist'' 若ゃ障. |
エンジンがこのエラーが生じたことを緊急に知らせたいときに |
潟吾潟若膩ャャ |
{\tt OX\_NOTIFY} を用いる. |
{\tt OX\_NOTIFY} . |
*/ |
*/ |
/*&eg |
/*&eg |
Let us explain how to use {\tt OX\_NOTIFY} by an example. |
Let us explain how to use {\tt OX\_NOTIFY} by an example. |
Line 307 the {\tt OX\_NOTIFY} message should be used. |
|
Line 307 the {\tt OX\_NOTIFY} message should be used. |
|
*/ |
*/ |
|
|
/*&jp |
/*&jp |
ここで, {\tt OX\_NOTIFY} をおくるのは, コントロールプロセスで |
, {\tt OX\_NOTIFY} , 潟潟若祉鴻 |
あることに注意しよう. |
羈. |
したがってエンジンはなんらかの方法で, コントロールサーバに |
c潟吾潟号, 潟潟若泣若 |
{\tt OX\_NOTIFY} をおくることを依頼しないといけない. |
{\tt OX\_NOTIFY} 箴若. |
この方法は, OS によりいろいろな方法が可能だか, |
号, OS 号純, |
たとえば, unix では |
, unix с |
ファイル {\tt /tmp/.ox\_notify.pid} に touch することでこれを |
<ゃ {\tt /tmp/.ox\_notify.pid} touch с |
一つの実現することが可能である. |
筝ゃ絎憗純с. |
ここで {\tt pid} はエンジンのプロセス番号である. |
{\tt pid} 潟吾潟祉合垩с. |
コントロールサーバはファイル {\tt /tmp/.ox\_notify.pid} が |
潟潟若泣若<ゃ {\tt /tmp/.ox\_notify.pid} |
touch されたことを検出したら, クライアントに |
touch 罎冴, ゃ≪潟 |
{\tt OX\_NOTIFY} パケットおよび {\tt OX\_DATA} で {\tt cmo\_null} を送る. |
{\tt OX\_NOTIFY} 宴 {\tt OX\_DATA} {\tt cmo\_null} . |
エンジンはファイルを用いてコントロールサーバに急を知らせる以外に, |
潟吾潟<ゃ潟潟若泣若ャャ篁ュ, |
共有メモリやシグナルを用いてしらせてもよい. |
掩<≪激違. |
*/ |
*/ |
/*&eg |
/*&eg |
Let us note that only the control process is allowed to send {\tt OX\_NOTIFY}. |
Let us note that only the control process is allowed to send {\tt OX\_NOTIFY}. |