Lisp HUG Maillist Archive

Can anyone help de-confuse me about CORBA

I'm trying to extend my trivial command-line CORBA LW client program
such that the server can call back to clients to send them logging
information.  I'm doing this by defining a second interface, instances
of which get registered on the server, which then makes calls on
these objects to send them strings.  I've got spectacularly confused
while doing this, mostly because the `clients' actually need to be
servers from the point of view of this logging interface, and I can't
work out how to get that to work.

Does anyone understand CORBA, and particularly the CL bindings, well
enough to be able to help me with this?  I can describe the problem in
more detail (the above description is not enough, obviously), and
provide complete sources to what I'm trying to do (it's free, if
trivial, software though I haven't publicised it very widely yet...).

It might be better to do it by private mail, though if people would
rather see the gory details I don't mind.

Thanks

--tim


Re: Can anyone help de-confuse me about CORBA

>>>>> On Sat, 17 May 2003 16:50:04 +0100, Tim Bradshaw <tfb@cley.com> said:

    Tim> I'm trying to extend my trivial command-line CORBA LW client program
    Tim> such that the server can call back to clients to send them logging
    Tim> information.  I'm doing this by defining a second interface, instances
    Tim> of which get registered on the server, which then makes calls on
    Tim> these objects to send them strings.  I've got spectacularly confused
    Tim> while doing this, mostly because the `clients' actually need to be
    Tim> servers from the point of view of this logging interface, and I can't
    Tim> work out how to get that to work.

    Tim> Does anyone understand CORBA, and particularly the CL bindings, well
    Tim> enough to be able to help me with this?  I can describe the problem in
    Tim> more detail (the above description is not enough, obviously), and
    Tim> provide complete sources to what I'm trying to do (it's free, if
    Tim> trivial, software though I haven't publicised it very widely yet...).

    Tim> It might be better to do it by private mail, though if people would
    Tim> rather see the gory details I don't mind.

Doesn't HCL-ORB have an example of this? 

In any case there are plenty of examples on the net of simple CORBA
programs. You can just adapt one of these?

I'd be happy to inspect your code, but I don't have an installation to
debug it.

__Jason


Re: Can anyone help de-confuse me about CORBA

Unable to parse email body. Email id is 1094

Re: Can anyone help de-confuse me about CORBA

* Jason Trenouth wrote:

> Doesn't HCL-ORB have an example of this? 

Not that I could find.

> In any case there are plenty of examples on the net of simple CORBA
> programs. You can just adapt one of these?

The trouble is that all the examples I can find have a fairly rigid
client-server distinction - the client calls the server, and those
calls return.  What I want is that the `client' registers itself with
the `server', which then spontaneously makes calls back to the
`client'.  I can't find examples of that, and the examples I can find
do hairy things with nameservices which I don't understand.

--tim


Re: Can anyone help de-confuse me about CORBA

* Nick Levine wrote:
> Rather than setting up a second server, how about using a structure
> akin to mailboxes to send logs back to the client. The server adds a
> log event to the mailbox queue, the client has a thread watching the
> mailbox which can pull events off the queue and duspatch them
> appropriately.

The problem is that, to make this work, someone has to tell the
initial application that something has changed.  So (using A and B
rather than client and server):

A: registers interest with B in getting log events.
A: waits on log queue for events, handles them when told
B: gets log event, needs to notify all registered As...

So the problem is that B needs to send some kind of notification to
all the A's who have registered with it, and I'm doing (or trying to)
that by having B make calls back into all the As In fact, I actually
just pass the string back with the call and avoid having the queue at
all.

The problem is that, I think, A and B need to agree about the world
they are in somehow, and I'm not sure how that happens.

--tim






Re: Can anyone help de-confuse me about CORBA

>>>>> On Mon, 19 May 2003 15:11:09 +0100, Tim Bradshaw <tfb@cley.com> said:

    Tim> * Jason Trenouth wrote:
    >> Doesn't HCL-ORB have an example of this? 

    Tim> Not that I could find.

    >> In any case there are plenty of examples on the net of simple CORBA
    >> programs. You can just adapt one of these?

    Tim> The trouble is that all the examples I can find have a fairly rigid
    Tim> client-server distinction - the client calls the server, and those
    Tim> calls return.  What I want is that the `client' registers itself with
    Tim> the `server', which then spontaneously makes calls back to the
    Tim> `client'.  I can't find examples of that, and the examples I can find
    Tim> do hairy things with nameservices which I don't understand.

Just set both programs up as proper servers. You say you can do one so
two must be trivial.

Then have the 'client' call the 'server' and pass an object reference
representing its own 'client' service. You say you have created a pure
client-server system so you must have had to create an object
reference and eg write the stringified form out into a file or
somewhere to pass to the client. Instead of stringifying it you need
to just pass it in a call. Should be even simpler. ( Of course, if you
have been relying on the client magically making up the reference to
the server because you know the port, hostname, and the fact that it
is the same ORB then this will be a new hurdle for you. )

Make the server record this object reference in a table of
'listeners'. Trivial non-CORBA issue.

When something happens on the 'server', it can invoke the callback
operation on the registered object references of the
'clients'. Trivial non-CORBA issue.

Each 'client' is subsequently called and can do what it likes. Trivial
non-CORBA issue.

So my wild guess is that you are having trouble with creating and/or
passing object references?

__Jason


Re: Can anyone help de-confuse me about CORBA

Unable to parse email body. Email id is 1099

Re: Can anyone help de-confuse me about CORBA

* Nick Levine wrote:

> How about this for another daft idea. If threading works properly on
> both side it may be sufficient:

>   Each A makes a call into B: gimmeNextEvent(). These calls are made
>   from the awaitingNextEvent thread, which will in general hang
>   because there is no next event yet. When B has something to say to
>   an A, it sends its message as the return value for the appropriate
>   gimmeNextEvent() call.

Yes, that would work.  I kind of hate it though.

> This whole thing strikes me as a typical problem with client-server
> relationships. You need a callback mechanism. 

Yes.

--tim


Re: Can anyone help de-confuse me about CORBA

>>>>> On Mon, 19 May 2003 18:09:40 +0100, Tim Bradshaw <tfb@cley.com> said:

    Tim> * Nick Levine wrote:
    >> How about this for another daft idea. If threading works properly on
    >> both side it may be sufficient:

    >> Each A makes a call into B: gimmeNextEvent(). These calls are made
    >> from the awaitingNextEvent thread, which will in general hang
    >> because there is no next event yet. When B has something to say to
    >> an A, it sends its message as the return value for the appropriate
    >> gimmeNextEvent() call.

    Tim> Yes, that would work.  I kind of hate it though.

    >> This whole thing strikes me as a typical problem with client-server
    >> relationships. You need a callback mechanism. 

This is all a solved problem with CORBA. I still don't know what the
problem is.

CORBA isn't client-server except with respect to an individual
operation call. Callbacks are pretty simple to set up. There are later
issues you will encounter around things like persistence and liveness
and gc of dead references across a distributed system, but the basic
call-me-on-this-object-if-something-happens mechanism is fairly
trivial.

__Jason


Re: Can anyone help de-confuse me about CORBA

* Jason Trenouth wrote:
> Just set both programs up as proper servers. You say you can do one so
> two must be trivial.

Well, no.  Or rather, maybe.  The server sits on a port at some level,
and it's not completely clear how to get it to sit on another port
(since they generally are on the same host) although this may be the
right thing to do.

> Then have the 'client' call the 'server' and pass an object reference
> representing its own 'client' service. You say you have created a pure
> client-server system so you must have had to create an object
> reference and eg write the stringified form out into a file or
> somewhere to pass to the client. Instead of stringifying it you need
> to just pass it in a call. Should be even simpler. ( Of course, if you
> have been relying on the client magically making up the reference to
> the server because you know the port, hostname, and the fact that it
> is the same ORB then this will be a new hurdle for you. )

I currently create an IOR, and stringify it in the initial server,
dumping it to a file.  the client then snarfs that IOR and talks in
the normal way.  I think I can pass object references around OK - at
least I've done this for other things, what I can't do is make it be
the case that the two servers (two ORBs, I guess) understand each
other.

The rest of what I'm trying to do is exactly what you describe - the
server maintains a list of listeners, and calls them back (removing
any that are no longer extant, either on request or because of an
error in the call).

But it may be that this comes down to a Windows lossage problem.  I've
just tried it on Linux, and now I get a `cannot bind port' error,
which is what I should get, I think, since the two ORBs can't coexist
on the same port.  What I got on Windows was ... nothing: initialising
the ORB worked fine, but then on the `client' it got completely mutant
errors (`this object does not exist') when trying to pass the
reference.  So I probably need to (a) give up on Windows (*how* are
you meant to tell, in Windows, if a port is in use or not?), and do
the `look for a free port' thing on Linux.

--tim



Re: Can anyone help de-confuse me about CORBA

>>>>> Tim Bradshaw writes:

Tim> But it may be that this comes down to a Windows lossage problem.  I've
Tim> just tried it on Linux, and now I get a `cannot bind port' error,
Tim> which is what I should get, I think, since the two ORBs can't coexist
Tim> on the same port.  

I've seen this before, and in fact, got Xanalys to put in a patch so
we got a sensible error early on.  A couple of things:

* You can specify which port your ORB should listen on, e.g.
  #+LispWorks4.2			; In 4.1, they do automatic port scanning.
  (when corba-port
    (setf corba:*poa-service-port* corba-port)
    (log-message :info "Launching CORBA service on port ~A" corba-port))

* instead of nameservice complications, to bootstrap yourself, you can
  get each application to write a file with the IOR to the entry
  object of that application, or get each app to open a trivial socket
  app to respond to requests for that IOR; once you've got this, you
  can have arbitrary N way comms between your various CORBA apps.

I have apps which basically do what you're asking for working here, so
inquire further if this isn't clear enough or sufficient.

Good luck.
--
			Alain Picard
			Memetrics


Re: Can anyone help de-confuse me about CORBA

>>>>> On Mon, 19 May 2003 18:34:16 +0100, Tim Bradshaw <tfb@cley.com> said:

    Jason> Just set both programs up as proper servers. You say you
    Jason> can do one so two must be trivial.

    Tim> Well, no.  Or rather, maybe.  The server sits on a port at some level,
    Tim> and it's not completely clear how to get it to sit on another port
    Tim> (since they generally are on the same host) although this may be the
    Tim> right thing to do.

Yes, each server will need it own port. See the doc, or the replies
from AlainP and DavidY.

    Jason> Then have the 'client' call the 'server' and pass an object
    Jason> reference representing its own 'client' service. You say
    Jason> you have created a pure client-server system so you must
    Jason> have had to create an object reference and eg write the
    Jason> stringified form out into a file or somewhere to pass to
    Jason> the client. Instead of stringifying it you need to just
    Jason> pass it in a call. Should be even simpler. ( Of course, if
    Jason> you have been relying on the client magically making up the
    Jason> reference to the server because you know the port,
    Jason> hostname, and the fact that it is the same ORB then this
    Jason> will be a new hurdle for you. )

    Tim> I currently create an IOR, and stringify it in the initial
    Tim> server, dumping it to a file.  the client then snarfs that
    Tim> IOR and talks in the normal way.  I think I can pass object
    Tim> references around OK - at least I've done this for other
    Tim> things, what I can't do is make it be the case that the two
    Tim> servers (two ORBs, I guess) understand each other.

Okay. It just sounds like the services port numbers are clashing.

    Tim> The rest of what I'm trying to do is exactly what you
    Tim> describe - the server maintains a list of listeners, and
    Tim> calls them back (removing any that are no longer extant,
    Tim> either on request or because of an error in the call).

You might also want to later add regular liveness pings on the
registered consumers so that you can clean them up more eagerly. 

    Tim> But it may be that this comes down to a Windows lossage
    Tim> problem.  I've just tried it on Linux, and now I get a
    Tim> `cannot bind port' error, which is what I should get, I
    Tim> think, since the two ORBs can't coexist on the same port.
    Tim> What I got on Windows was ... nothing: initialising the ORB
    Tim> worked fine, but then on the `client' it got completely
    Tim> mutant errors (`this object does not exist') when trying to
    Tim> pass the reference.  So I probably need to (a) give up on
    Tim> Windows (*how* are you meant to tell, in Windows, if a port
    Tim> is in use or not?), and do the `look for a free port' thing
    Tim> on Linux.

It should work once you assign separate ports.

In other CORBA implementations there are Implementation Repositories
(activation daemons) which sit on the one and only fixed port in the
system and which manage the starting of all the other services on
OS-assigned port numbers.

__Jason


Re: Can anyone help de-confuse me about CORBA

* Alain Picard wrote:

* You can specify which port your ORB should listen on, e.g.
>   #+LispWorks4.2			; In 4.1, they do automatic port scanning.
>   (when corba-port
>     (setf corba:*poa-service-port* corba-port)
>     (log-message :info "Launching CORBA service on port ~A" corba-port))

I'm currently trying (in some kind of ill-conceived attempt at
portability) to use the -ORBport 0 arguments, via:

(op:orb_init '("-ORBport" "0") "...")

But this seems to fail when trying to create the POA.  Am I confused
about what the arglist should be?  Or does it not work like that...

--tim


Re: Can anyone help de-confuse me about CORBA

* Jason Trenouth wrote:

> It should work once you assign separate ports.

It turns out that I had also subclassed an x rather than an x-SERVANT
class, resulting in wonderful obscurity - registering the (narrowed)
object as a callback actually worked, but the callback then died with
a `something bad happened, somewhere, but I'm not going to tell you
what' error, made more exciting to debug by my code which catches
errors and deletes callback objects whose owners have gone away.

If anyone wants to look at the resulting horror, it lives at
http://www.tfeb.org/programs/clc.tar.gz.  What it is, is a command
line client for LW (or other Lisp with CORBA bindings), for which you
can define handlers within a Lisp.  We use it really a lot, as it lets
you drive things from Makefiles &c.  It's fairly rudimentary use of
CORBA though, to say the least.

Thanks for everyone's help.

--tim


Updated at: 2020-12-10 09:00 UTC