6. Der Broker
Der Magic Request Broker empfängt und verarbeitet Anfragen aus dem Netzwerk. Anfragen werden an Programme, inclusive Parameter und Optionen, zur Ausführung weiter geleitet. Eine Anfrage kann an ein Magic Runtime gesendet werden.Hier ist eine Basis Broker Dokumentation von Magic.
6.1 Setup
Der Broker wird von Magic in dieses Verzeichnis installiert:/usr/magicadm/brokerUns interessieren drei Dateien
- mgrqmrb - der Broker,
- mgrqcmdl - der Befehlszeilen Interpreter
- mgrb.ini. - die Ini-Datei mit der der Broker eingestellt wird
chmod 4700 mgrqmbrDie Ini-Datei muß bearbeitet werden:
chown magicadm mgrqmbr
[MRB_ENV]PasswordSupervisor = YourBrokerSupervisorPasswd (wird später gebraucht)
[MRB_EXECUTABLES_LIST]HelloWeb=/usr/magicadm/bin/magicrnt , , , 2
6.2 Manueller Start
Vor dem Start des Brokers als "magicadm" einloggen und dann in das Broker Verzeichnis gewechseln. Dadurch kann der Broker "mgbr.ini" finden.cd /usr/magicadm/broker
./mgrqmrb -ReusePorts &
- -ReusePorts - Wenn der Broker schon einmal die Ports für sich registriert hat, muß ihm beim nächsten Start mitgeteilt werden das er sie wieder benutzen soll.
- & - Der Broker soll als Hintergrundprozess ausgeführt werden.
ps -A -l| grep mgrqmrbAls User sehen wir die UID=501, das ist in diesem Beispiel die Benutzernummer von "magicadm" und als Prozess diePID=97132.F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
000 S 501 97132 1 0 60 0 - 1012 rt_sig pts/1 00:00:00 mgrqmrb
040 S 501 97134 97132 0 60 0 - 1012 do_pol pts/1 00:00:00 mgrqmrb
040 S 501 97135 97134 0 60 0 - 1012 do_sel pts/1 00:00:00 mgrqmrb
040 S 501 97136 97134 0 60 0 - 1012 do_sel pts/1 00:00:00 mgrqmrb
040 S 501 97137 97134 0 60 0 - 1012 do_sel pts/1 00:00:00 mgrqmrb
040 S 501 97138 97134 0 60 0 - 1012 do_sel pts/1 00:00:00 mgrqmrb
040 S 501 97139 97134 0 60 0 - 1012 do_sel pts/1 00:00:00 mgrqmrb
Es wird eine Liste von bis zu sieben Prozessen ausgegeben. Es braucht aber nur einer beendet werden. Die Anderen werden dann automatisch beendet.
kill 97132
6.3 Der Befehlszeilen Interpreter
Nachdem der Broker gestartet wurde, kann er mit dem Befehlszeilen Interpreter gesteuert werden. Eine eingebaute Hilfe wird durch den Start ohne Parameter:./mgrqcmdl | lessWenn getestet wird ob der Broker gestartet wurde:
./mgrqcmdl -query=rtsollte die Antwort lauten:
Application Servers of (localhost/2001)Jetzt kann das erste Runtime geladen werden:
--------------------------------------------------
# Engine Pid Status Application
==================================================
./mgrqcmdl -exe=HelloWeb -password=WieWarNochGleichDasPasswortJetzt festellen ob das Runtime gestartet wurde:
./mgrqcmdl -query=rtDie Antwort sollte sein:
Application Servers of (localhost/2001)Die Frage ist, woher bekomme ich eine Anwendung . Gemach. Schritt für Schritt. Alles läuft und der nächste Schritt kann über sprungen werden. Aber nicht vergessen es muß dann bei jedem System-Start der Broker wieder mit der Hand gestartet werden.
--------------------------------------------------
# Engine Pid Status Application
==================================================
1 | localhost/#### 4711 Avail Idle |
6.4 Broker und SuSE.
Die System-Scripte befinden sich in dem Verzeichnis/sbin/init.d/Und es wird ein eigener Algorythmus verwendet. Der Wechsel eines Run-Levels wird mit dem Script
/etc/rc.configkontrolliert. Um den Start des Broker mit diesem Script zu verwalten muß am Ende eine neue Sektion eingefügt werden:
---------- cut ---------Diese Einstellung kann mit "yast" in dem Menuepunkt
#
# Start the magic messaging broker (yes,no).
#
START_MGBROKER="yes"
#
---------- cut ---------
Administration des System -> Konfigurationsdatei verändernbearbeitet werden.
Jetzt muß "mgbrs" aus dem Archiv nach "/sbin/init.d/" kopiert und die Berechtigungen gesetzt werden:
chmod 4700 mgbrsIn welchem Run-Level der Broker gestartet werden soll, wird durch symbolische Links in den Unterverzeichnissen kontrolliert:
chown magicadm mgbrs
- Starte und stoppe den Broker in dem Run-Level 2
ln -s /sbin/init.d/mgbrs /sbin/init.d/rc2.d/K91mgbrs
ln -s /sbin/init.d/mgbrs /sbin/init.d/rc2.d/S92mgbrs - Starte und stoppe den Broker in dem Run-Level 3
ln -s /sbin/init.d/mgbrs /sbin/init.d/rc3.d/K91mgbrs
ln -s /sbin/init.d/mgbrs /sbin/init.d/rc3.d/S92mgbrs
Wenn ein anderes Verzeichnis verwendet wurde, muß der Script angepaßt werden
---------- cut --------------Nun kann der Broker gesteuert werden:
BR_PATH=/usr/magicadm/broker
BR_USER=magicadm
---------- cut --------------
/sbin/init.d/mgbrs start
/sbin/init.d/mgbrs stop
/sbin/init.d/mgbrs status
/sbin/init.d/mgbrs restart
6.5 Broker und Red Hat
Die System Scripte befinden sich in dem Verzeichnis/etc/rc.d/init.d/und dort hin muß auch der Script "mgbrr" aus dem Archiv kopiert und die Berechtigungen gesetzt werden:
chmod 4700 mgbrrDer Start der System-Dienste wird mit dem Tool "chkconfig" gesteuert. Dazu sind in dem Script "mgbrr" am Anfang drei Zeilen (der "\" am Ende der zweiten Zeile verbindet sie mit der dritten Zeile und muß sein):
chown magicadm mgbrr
---------- cut --------------(Der Lizenz Manager (S91mglms) sollte vor dem Broker (S92mgbrs) gestartet werden. Und umgekehrt: der Broker (K91mgbrs) sollte vor dem Lizenz Manager (K92mglms) gestoppt werden. Für mehr Informationen : "man chkconfig".)
# chkconfig: 23 92 91
# description: Start des Dienstes in Run Level 2 & 3 als S92mgbrr \
# und beende ihn in den anderen Leveln mit K91mgbrr
---------- cut --------------
Den Broker als Service hin zufügen:
chkconfig --add mgbrrDen Broker als Service entfernen:
chkconfig --list mgbrrAusgabe: "mgbrr 1:off 2:on 3:on 4:off 5:off 6:off"
chkconfig --del mgbrrDer Script "/etc/rc.d/rc" steuert den Wechsel eines Run-Levels. Der prüft alle symbolischen Links mit einem "K" am Anfang "K92mgbrr" und testet ob in dem Verzeichnis "/var/lock/subsys" eine dazugehörende Lock Datei mit dem Namen "mgbrr" vorhanden ist. Der Script "mgbrr" muß also beim Start eine Datei erstellen und beim Beenden wieder gelöschen. "magicadm" hat aber keine Berechtigung um in diesem Verzeichnis zu schreiben.
chkconfig --list mgbrrAnzeige= "mgbrr 1:off 2:off 3:off 4:off 5:off 6:off"
Um dieses Problem zu beheben muß "root" die Berechtigung für das Verzeichnis "/var/lock/subsys/" auf "search/execute others" ändern:
chmod o+x /var/lock/subsys/Wenn ein anderes Verzeichnis verwendet wurde, muß der Script angepaßt werden
---------- cut --------------Nun kann der Broker gesteuert werden:
BR_PATH=/usr/magicadm/broker
BR_USER=magicadm
---------- cut --------------
/etc/rc.d/init.d/mgbrr start
/etc/rc.d/init.d/mgbrr stop
/etc/rc.d/init.d/mgbrr status
/etc/rc.d/init.d/mgbrr restart
6.6 Broker Error Codes
| 4 | NO-RESULT | The requested task did not return output to the requester output media (IO). |
| 101 | BAD-ARGS | Remote Call Error - Invalid Remote Call Application or program names were not entered for the remote call. |
| 102 | CNCT-MRB-REFUSED | Remote Call Error - Connection to Broker Refused Wrong host name or port for the Broker. Verify that the broker is connected to the port on the specified machine. |
| 103 | APP-NOT-FOUND | Remote Call Error - Application Not Found The engine does not support the Application; or the Appl=entry in MGREQ.ini file was specified and the required application did not appear in the list (not relevant to the Magic 8 Client). |
| 104 | APP-IN-USE | Remote Call Error - Application in Use All the engines that support the application are busy serving other requests; or the engine does not support the application. The Broker Time-out value may have expired. For the Magic Client, the time-out value is in the Server repository. From the MGREQ.ini file, the time out value is in the Timeout parameter. |
| 105 | see remark (*) | |
| 106 | RT-NOT-RESPOND | Remote Call Error - Runtime Not Responding The Server Timeout parameter in the MAGIC.ini file or the MGREQ.ini file has expired. The server engine did not send an I-AM-ALIVE message during the specified time interval. |
| 107 | Connection reset by the AppServer This Magic partitioning message is given when one or the following situations occur: (1) The application server was aborted abnormally during the execution of a request, or (2) The connection was reset due to a network connection failure. |
|
| 110 | REQUEST-TIMEOUT | Remote Call Error - Request Timed-out The Request Timeout entry has expired in the MAGIC.ini or the MGREQ.ini file. The requested task was not completed in the specified time interval. |
| 111 | RQGNRC_ERR_NOT_MRB | |
| 113 | RQGNRC_ERR_NOT_APPNAME_REQUIRED | |
| 114 | RQGNRC_ERR_NOT_PRGNAME_REQUIRED | |
| 115 | RQGNRC_ERR_REPLAY_QUEUE_MISSING | |
| 116 | RQGNRC_ERR_NO_ENGINE_READY | |
| 130 | APP-OPEN-FAIL | Remote Call Error - Failed To Open Application The server engine could not open the application control file. |
| 131 | PRG-NOT-FOUND | Remote Call Error - Program Not Found Cannot find the public name of the program specified in the application. |
| 133 | ACCESS-DENIED | Remote Call Error - Access Denied Invalid user name. No rights assigned to the user. No right to execute program. |
| 135 | LIMITED-LICENSE-HTTP | Remote Call Error - License Limited to Internet
Requests Server engine is licenses to execute requests from internet requesters only. |
| 136 | LIMITED-LICENSE-CS | Remote Call Error - License Limited by Requests
Count Server engine is licensed to execute a limited number of requests. |
| 137 | REQUEST-REJECT | Remote Call Error - Request Rejected Server engine cannot execute the request due to a timing problem of switching from runtime to toolkit modes. |
| 138 | RT-ERROR-MSG | During execution of a request, the executed program, or subprograms, displayed error messages such as SQL or locking errors. If the executed program failed to complete, these error messages were trapped by the AppServer & sent back to the requester. If the executed program was executed successfully, despite the error messages, the program's output is returned, overriding any error messages. When the requester is an Internet requester, the error messages are sent to the remote browser. When the requester is a command line requester, the error messages are displayed in the console. When the requester is a Magic 8 engine, this error message is not displayed. |
| 145 | see remark (*) | |
| 146 | BIND-HOST-NOT-FOUND | Remote Call Error - Bind Failed - Unknown
Host The Local Host entry in the MGREQ. ini file must specify the local internet address. |
| 147 | CNCT-HOST-NOT-FOUND | Remote Call Error - Connection Failed - Unknown
Host The Broker address must explicitly contain the internet address (i.e. 88.0.184/2001) |
| 150 | CNCT-REFUSED-MRB | An application server couldn't connect to
the Broker Check if the Broker was started, and that the host name of the Broker, as known in the computer of the AppServer (ping <mrbhost>), belongs to the correct IP address (as known in the computer of the Broker-ping <mrbhost>). Reproduce the problem with log 'enabled' in mgreq.ini (log = req.log Y R), in the directory of the AppServer. |
| 151 | CNCT-RESET-BY-REQ | During execution of a request, the connection
between the requester & the AppServer was reset As a result, no output was sent back from the AppServer to the requester. Check the requester in the client machine & the AppServer. If possible, reproduce the problem with log 'enabled' in mgreq.ini (log = req.log Y R) in the directories of the requester & of the AppServer. |
| 160 | RQSPAWN_ERR_EXE_NOT_FOUND | These error codes may be returned to the command line requester
and/or displayed in the log file of the Broker when the Broker both attempts
to start executables ([MRB_EXECUTABLES_LIST]), and fails because of bad
setup. A bad setup may be due to any of the following: An unknown executable, a bad directory, wrong username/password (for the OS, see the syntax of [MRB_EXECUTABLES_LIST]), or network problems. |
| 161 | RQSPAWN_ERR_PATH_NOT_FOUND | |
| 163 | RQSPAWN_ERR_BAD_LOGIN | |
| 164 | RQSPAWN_ERR_PRIVILEGE_NOT_HELD | |
| 169 | RQSPAWN_ERR_NET_UNREACHABLE | |
| 200 | RQ-FATAL | Remote Call Fatal Error Misc. Errors. |
| 201 | Code Partitioning | Error - TCP/IP Not Initialized TCP/IP services were not installed. Install TCP/IP. |
| 202 | ERR-OPEN-RESULT-FILE | This is a two-part problem: (1) The requester asked that the output be written into a file (either using a field in the call remote dialog box in a Magic 8 client, or using keywords in mgreq.ini or mgrqcmdl -file=), and (2) The combined file name (directory and/or file name) is illegal. |
| 220 | Out of resources: This error message is displayed when Winsock returns the error -10055 (out of buffers). |
(*) Unexpected Errors: Errors that are not listed in the documentation, such as
-105,
-145,
are best handled by using the log file from mgreq.ini. This log file can show, for example, problems with host name resolution, which are the primary cause of these error messages.
It is important to know the difference between errors from the Web Server (which are not displayed in the blue/aqua error page of Magic) and those from Magic. Web Server errors are, for example, a missing requester or insufficient rights.
6.7 MGBR.INI
| [MRB_ENV] | ||
| BrokerPort = | 2001 | The ports that the MRB listens to and waits for
requests from. Syntax : BrokerPort = port number (default number =2001) |
| EnginesPriority = | A list of up to 9 computer names that are used to provide server engines. This list controls the order that the MRB chooses engines to serve client requests. The Engines Priority list operates sequentially so that the engine for the first computer will execute the client command, if available, before the engines of the second computer, and so on. | |
| ServerTimeout = | The interval, in seconds, that the Broker instructs
the engines to send an I-AM-ALIVE message during the execution of ASYNC
calls. If the value is 0, then the engine will not send the I-AM-ALIVE message to the broker. If the engine crashes or is terminated in an abnormal way during task execution, it will be understood by the broker as a no response from the engine. |
|
| PasswordSupervisor = | superpasswd | An optional value that restricts the user's access
to the MRB. If specified, security checks will occur during the following
broker operations:
|
| PasswordQuery = | An optional value that can be used to restrict
access to the MRB. If specified, a password is checked before allowing a user to query a request of another user Any user can access the Query Queue & log to view their own requests, based on the user name and password when the request was submitted, without any security restrictions. The MRB accepts the user name and password of the service, the user name and password logon to the Magic application, or the user name and password stored in the MGREQ.ini file (for cmdl/internet only). If PasswordQuery is not specified, security validations for user name and password will remain inactive. |
|
| AutoLoad = | WebApp,2 | This new parameter (since v8.2) allows the Broker
a certain level of automatic AppServers activation. The parameter takes a simple format: AutoLoad=<exe_entry_name>,<cnt>. The exe_entry_name is one name that exists either in the [MRB_EXECUTABLES_LIST] or in the [MRB_REMOTE_EXECUTABLES_LIST] sections of the MGRB.INI settings file (for explanations on these 2 sections, refer to the REF.PDF electronic manual). The Broker will automatically activate the specified exe_entry_name, in one of the following 2 cases: A request was submitted by a client, and there are no registered AppServers whatsoever. In this case, the Broker will activate the specified exe_entry_name immediately, so that the activated AppServer will still be able to serve the incoming request. A request was submitted by a client, and there are registered AppServers. In this case, if no AppServer will become available during the request wait time, the request will fail (with an error message of either 'No AppServers' or 'AppServers are busy'). If at this point the number of AppServers is smaller than the value specified by the <cnt> parameter, then a new instance of the exe_entry_name will be loaded, to reduce the possibility that the future requests will fail to receive a matching AppServer. Note: This simple mechanism does not take into consideration the name of the application that the incoming request specified. The Broker simply activates a new instance of the exe_entry_name, regardless of what applications that each AppServer can serve. |
| ReLoad = | N | MGRB.INI: ReLoad parameter This new parameter (Planned to be added in v8.2h) allows the Broker another level of automatic AppServers activation. When this flag is set (ReLoad = Y), the Broker functions as a simple watch dog, meaning that whenever an AppServer that was activated from mgrb.ini crashes (from any reason − OS, Application bug or whatever), the Broker will automatically reload a new instance of the same ExeEntry name listed in mgrb.ini. |
| Log = | /usr/magicadm/broker/mgbr.log Y | A reference to a file that logs high-level MRB activities:
messages sent and received to and from the MRB by both engines and requesters. Syntax : LOG = [file specification] Sync Mode File Name: Any valid name that does not include spaces. Sync:
None - no log file, |
| [MRB_EXECUTABLES_LIST] | ||
| EXE_ENTRY_NAME= |
/usr/magicadm/bin/magicrnt , magicadm , mgpass , 2 |
Optional section containing a list of command
line executables or shell commands that can be activated from a remote
requester, or upon MRB initialization. Syntax: EXE_ENTRY_NAME=<command>[<work dir>],[<username>], [<password>],[<number of times to perform upon broker initialization>] |
| [MRB_REMOTE_EXECUTABLES_LIST] | ||
| Remote = | remote_server/2001,,Background,0 | Section for setting up a multi-computer environment
with engines running on computers independent of the MRB. An instance of the MRB, functioning as a loader, must be active for each computer with engines running on that broker. The local MRB automatically connects to the remote MRB, specified in the exe entry of this section, and will instruct it to load an executable from its list of executables. The PasswordAdmin must be used if the remote broker has its own password (if not specified, use the password for the local MRB). |
| [MRB_ENGINE_CLIENTS_MAP] | ||
| eran:eran,yoram | The purpose of the MRB Engine Clients Map is
to allow the devleoper to control the engine that receives the request.
For example, when several developers are working on the same MCF file,
a developer can check out an object and command the MRB to assign its own
engine. Note: During the remote call execution (when the engine is mapped to this section), The Request Gateway utilizes the logon name and password that are sent with the request. If a devloper is not logged in to the engine, he must specify the user name and password from either the mgreq.ini file for Internet and Command Line requesters, or in the Service repository for the Magic 8 client to view the version of th MCF related to that developer's logon. Example: eran:eran Any AppServer that runs on the computer named eran (left to the ':') will accept requests only from clients that run on the computer named eran (right to the ':'). It is also possible to use this option to restrict access to AppServers, for example: eran:eran,yoram - Any AppServer that runs on eran will accept requests only from clients that run on eran or on yoram. IP addresses can be used only for the clients (for example, eran:88.0.0.84,88.0.0.85). |
|