|
|
|
|||||
|
Can a server close all its connections on request?
Hello. Is it possible to make the server close all its current connections to clients? I read the chapter 35.5 about the connection management. I saw there that I can access the connection object from within each operation, using Ice::Current passed to this operation. But this connection object would be responsible for the connection to this particular operation (handling a particular request as I understand). So I can close the connection to this particular operation using the void close(bool force) function of the connection object. But all the connections to other operations will not be closed.
What I need is some operation which closes all connections to all servants the server is currently maintaining. Regards Ewgenij |
|
|||||
|
Hello.
Quote:
As if somebody has cut the appropriate wires.Quote:
Quote:
The server serves the clients. But if it gets the signal S, then it knows that its information which is used for servicing the client requests, is not up to date. So the clients, served currently, are getting a not up to date service. So the best way would be to close all the connections - the clients would get the ConnectionLostException. After the execution of appropriate routines the server becomes available for the clients again. If any clients attempt to connect in the meanwhile, I could put them on the service queue by a locking mechanism. Quote:
Greetings Ewgenij |
|
||||||
|
Quote:
Quote:
In general, Ice will retry failed requests, but only if it can be sure that doing so will not cause a single operation invocation by the client to cause the operation to execute a second time in the server. In other words, Ice provides at-most-once semantics for invocations: a single invocation by a client will cause the corresponding operation in the server to run, or will not work at all. However, a single invocation by a client is guaranteed not to cause the operation to run a second time in the server. You can modify this behavior with idempotent Slice keyword. If you use that keyword, Ice is more aggressive in its retry behavior and will re-issue a failed request even if there is a chance that doing so might cause a single invocation by the client to invoke the operation more than once in the server. Obviously, you can use the idempotent keyword only for operations that are stateless and free from side-effects. If you use UDP as your transport, Ice does not provide at-most-once semantics because UDP can duplicate packets on the network. Quote:
However, a cleaner way would be to put the adapter in the holding state, throw a user exception from each operation, and then reactivate the adapter once the server is ready. At least, that way, the client gets a proper user exception that indicates why the server is not available at the moment, instead of a ConnectionLostException, which will also be raised for real connection loss (not caused by the server forcefully closing the connection). At any rate, to implement what you want, you need to have active participation in both the operation implementations (which must react to the signal) and the clients (which must react to an exception). If you want to make this completely transparent on the client side, the only other option I can see is to prevent all operations that are executing at the time the signal arrives from completing. In other words, on receipt of the signal, the operations go to "sleep" until the server gets back to its available state. At that point, the operations would use the new state of the server to resume and then return. That way, clients would simply see a normal successful request that just happens to take a longer time than usual. Note though that this approach may not be feasible if the outage time is long. Also, writing your operation implementations to restart in this fashion may not be feasible, depending on what the operations are doing. Cheers, Michi. |
|
|||||
|
Hello!
Quote:
Quote:
Code:
void operation(bool* shouldAbort)
{
code block;
if(*shouldAbort){
put the adaptor in the holding state;
throw Exception;
close the connection;
}
code block;
if(*shouldAbort){
put the adaptor in the holding state;
throw Exception;
close the connection;
}
code block;
}
Regards Ewgenij Last edited by Ewgenijkkg : 07-21-2007 at 02:28 PM. |
|
||||||
|
Quote:
Quote:
Code:
void throwIfUnavailable()
{
IceUtil::Mutex::Lock lock(unavailableMutex);
if(unavailable)
throw UnavailableException;
}
In the operation implementation, yoiu would then insert the throwIfUnavailable() call in a appropriate places. Putting the adapter into the holding state would be done by the thread that sets the flag, not in the operation implementation. There is no need to close any connections and you can just put the adapter into the holding state and activate it again later. (This prevents new client requests from entering servants while the not available condition lasts. Cheers, Michi. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to reduce the connections between client and server? | Pierre.Siron | Help Center | 1 | 03-27-2007 04:31 AM |
| Close a subscriber | marika | Help Center | 2 | 03-01-2007 09:56 AM |
| Is the max connections between client and server 1022? | russule | Help Center | 2 | 10-30-2006 07:57 AM |
| IceStorm message server pauses on new connections | cloudstar | Help Center | 5 | 07-17-2006 11:13 PM |
| server communicate with client without client's request | chunlin | Help Center | 1 | 09-12-2003 08:18 AM |