Sets an EDMdatabase unavailable for new connections. The EDMdatabase will remain unavailable until the edmiRemoteSetAvailable function is invoked. It will remain unavailable even when the database is closed and reopened.
Thick EDMclients trying to connect to an unavailable EDMdatabase will receive an optional message specified by the system administrator in the last call to this function. Use this message to explain to the connecting EDMclients why the EDMdatabase has been set unavailable.
This function is only available for the superuser.
Related function: edmiRemoteSetAvailable
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteSetUnavailable(SdaiServerContext serverContextId,
SdaiString password,
SdaiString unavailableMessage,
SdaiInvocationId *edmiInvocationId);
Arguments:
serverContextId |
Context identification, from edmiDefineServerContext |
password |
The password for the superuser. If the superuser is defined as the calling user in the server context, this argument may be omitted. |
unavailableMessage |
The message that will be returned to any thick EDMclient that tries to connect to the EDMdatabase as long as it remains unavailable. |
edmiInvocationId |
Currently not used. |
Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an _EDMinterface_ error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
int i;
EdmiError rstat;
SdaiServerContext suContext;
tEdmiWhoIsOnServer *pWhoIsOn;
tEdmiConnection *pConnect;
SdaiInteger nConnect;
/* Define Remote Server Context
for the superuser */
rstat = edmiDefineServerContext("SuperUserContext",
"superuser", NULL, "xfx56kl9",
"TCP", "9090", "MyServerHost",
NULL, NULL, NULL, NULL, NULL, &suContext);
/* Set system unavailable */
rstat = edmiRemoteSetUnavailable(suContext,
"System unavailable due to maintenance",
NULL, NULL);
/* Kill all the thick EDMclients except for those
connected as superuser. Do not kill any of the
EDMapplicationServer processes. Other superuser
connections shall be forced to terminate. */
rstat = edmiRemoteWhoIsOn(suContext, &nConnect, &pWhoIsOn, NULL);
pConnect = pWhoIsOn->connections;
for (i=0;i<nConnect;i++) {
SdaiString _hostName, _clientName, _userName;
/* Do not kill your own client connection */
if (pConnect->clientId != pWhoIsOn->myClientId) {
rstat = edmiRemoteGetClientNames(suContext,
pConnect->clientId, &_hostName,
&_clientName, NULL);
/* Do not kill EDMapplicationServer processes */
if (!strstr(_clientName, "EDMapplicationServer-")) {
rstat = edmiRemoteGetAttrs(suContext,
pConnect->userId, 0, 1, NULL,
"NAME", sdaiSTRING, &_userName);
/* Check if superuser owns connection */
if (strcmp(_userName, "superuser")) {
/* No mercy!! Kill any connection
not owned by the superuser */
rstat = edmiRemoteTerminateClient(suContext, NULL,
pConnect->clientId, KILL_CLIENT, NULL);
} else {
/* Handle superuser clients with care,
i.e force them to terminate */
rstat = edmiRemoteTerminateClient(suContext, NULL,
pConnect->clientId, FORCE_TO_TERMINATE,
NULL);
}
}
}
++pConnect;
}
. . .