Skip to main content

Get Pipe ID of source

11 replies [Last post]
galato
Offline
Joined: 2007-07-06
Points: 0

Hi all,

before I migrated to 2.5 I was using the following (in 2.4.x) to get the ID of the remote server pipe to which
my client peer was connected:

JxtaBiDiPipe myjxtabidipipe = (JxtaBiDiPipe) event.getSource();
clientPipeID = myjxtabidipipe.getPipeAdvertisement().getID().toString();

and someone told me NOT to use this for the reason listed in the comments:

// Don't use this one as it will return the ephemeral pipe instead of
// the client pipe ID - this is due to the fact that there could be
// multiple connections
out.println( event.getPipeID().toString() );

However when I migrated to 2.5 someone made a change in the baseline and told me to use this - which
is similar to what I was told not to use as shown abobe. I tested this and low and behold the returned Pipe
ID is the Pipe ID of client and NOT of the remote server peer I am connected to.

PipeID clientPipeID2 = event.getPipeID();
clientPipeID = clientPipeID2.toString();

Anyone knows what I can do here to get this ID?

Thanks very much in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bondolo
Offline
Joined: 2003-06-11
Points: 0

I am not sure I understand what you are looking for. If you connected to the remote server pipe you must have known it's pipe id.

What Id value are you looking for and what do you plan to use it for?

galato
Offline
Joined: 2007-07-06
Points: 0

Hey Mike,

may be I am making this a bit tougher than it is but this is the setup:

I have a set of client pipes from a client peer connected a set of distinct server pipes (I used JXTABiDiPipes). When a message comes in to any of the client pipes and I get a Pipe Event notification I want to get the Pipe ID of the pipe to which the EVENT came in and then I pass it on to higher layers - at a later time the higher layer will perform some processing on the incoming messages and then send the reply back to the pipe that the message came into.

The way I used to obtain that Pipe ID was using the Pipe event to extract it - is there another/better way of doing this? You said if a client pipe is connected to a server pipe then you know its ID - (i) how do you get that - I may be missing something basic here and (ii) can I use the EVENT to get that pipe as I showed in the code earlier on? The code I show in 2.4.1 worked pretty good and Mohamed said he included the equivalent change into 2.5.

Thanks very much

bondolo
Offline
Joined: 2003-06-11
Points: 0

> The way I used to obtain that Pipe ID was using the
> Pipe event to extract it - is there another/better
> way of doing this?

Does that method no longer work?

You said if a client pipe is
> connected to a server pipe then you know its ID - (i)
> how do you get that - I may be missing something
> basic here and

When you created the bidi-pipe to the server you had to provide an advertisement or pipe id. Are you using the same event handler for every pipe? You may need to make an adapter that holds the server pipe reference. and pass that as the event handler. This adapter would serve only to remember what pipe it's being called for and add that information before calling the upper layers.

(ii) can I use the EVENT to get that
> pipe as I showed in the code earlier on?

Sure, why not?

JxtaBiDiPipe myjxtabidipipe = (JxtaBiDiPipe) event.getSource();
clientPipeID = myjxtabidipipe.getPipeAdvertisement().getID().toString();

seems to be entirely correct.

galato
Offline
Joined: 2007-07-06
Points: 0

I tested that when I was migrating to 2.5 it seemed to have been returning the client pipe's ID (local pipe) - I am going to double-check and let you know if the method is not working anymore.

I think the idea of an adapter to hold th server pipe ref is good so if the above is not working I will see if I can follow up.

Thanks very much

galato
Offline
Joined: 2007-07-06
Points: 0

Mike -

the code I showed that worked in 2.4.1 for getting the server Pipe ID I just verified does not work in 2.5 - that's why Mohamed gave me the other code that now also shows it does not work. Both of them return to Pipe ID of the local (client) pipe and NOT of the pipe it is connected to ..

Any ideas?

Thanks very much

galato
Offline
Joined: 2007-07-06
Points: 0

I also noticed the following with the original code from 2.4.1 in place - the
first line I show here gives the following exception in 2.5: I am pretty surprised such a straightforward action cause so much trouble -

JxtaBiDiPipe myjxtabidipipe = (JxtaBiDiPipe) event.getSource();
clientPipeID = myjxtabidipipe.getPipeAdvertisement().getID().toString();

Exception in run ()
[java] java.lang.ClassCastException: net.jxta.impl.pipe.InputPipeImpl
[java] at PeerToPeerAdapter$ClientConnectionHandler.pipeMsgEvent(PeerToPeerAdapter.java:5120)
[java] at net.jxta.util.JxtaBiDiPipe.push(JxtaBiDiPipe.java:939)
[java] at net.jxta.util.JxtaBiDiPipe.pipeMsgEvent(JxtaBiDiPipe.java:786)
[java] at net.jxta.impl.pipe.InputPipeImpl.processIncomingMessage(InputPipeImpl.java:219)
[java] at net.jxta.impl.endpoint.EndpointServiceImpl.processIncomingMessage(EndpointServiceImpl.java:989)
[java] at net.jxta.impl.endpoint.EndpointServiceImpl.demux(EndpointServiceImpl.java:1053)
[java] at net.jxta.impl.endpoint.EndpointServiceInterface.demux(EndpointServiceInterface.java:345)
[java] at net.jxta.impl.endpoint.tcp.TcpMessenger$MessageProcessor.run(TcpMessenger.java:1067)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
[java] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
[java] at java.lang.Thread.run(Thread.java:595)

galato
Offline
Joined: 2007-07-06
Points: 0

And using this fix in 2.5:

PipeID clientPipeID2 = event.getPipeID();
clientPipeID = clientPipeID2.toString();

does not give the ClassCastException HOWEVER it returns
this pipe = urn:jxta:uuid-59616261646162614E504720503250338FD3D273952741CE9611B5BC5659D7E804

once the message arrives from
the server pipe=urn:jxta:uuid-59D0F2E95C9F42A0AD9AB88C62AE178D1FC62C8E1AF04A59B3438DEE878B7CB204
to the client pipe=urn:jxta:uuid-030690165BA645D6B24BA0BED9681439F32EDEA2DF434623ACFC82AD0A8D6B1504

which is neither the server or the client pipe - where did this pipe come from?? Any ideas please?

Thanks

galato
Offline
Joined: 2007-07-06
Points: 0

One more thing to add to the left posting - it seems to me that I may need to cross ref the pipe ID I receive from the event.getPipeID() with the corresponding client JXTABidiPipe but I can't find an accessor method anywhere in that class that can provide it. If anyone has any ideas on this I will greatly appreciate it.

Thanks again

galato
Offline
Joined: 2007-07-06
Points: 0

Mohamed - I found the email we exchanged on figuring out this JxtaBiDiPipe source ID issue in JXSE 2.5 that I describe in this thread - it reads:

> I committed a change in pipe message event and bidi pipe which will allow you to > retrieve the JxtaBiDiPipeID, which you can use to as a cross reference a JxtaBiDiPipe

> PipeID id = event.getPipeID()

I am still not able to get this to function properly - the ID returned by this method is not the JxtaBiDiPipe that received the sent the message (and its corresponding receiver end). How is this ID cross referenced into a JxtaBiDiPipe ID as you say above?

Thanks again

utvikler
Offline
Joined: 2007-06-15
Points: 0

Was there a confirmed bug here? If so, did someone confirm that it's fixed in trunk?

galato
Offline
Joined: 2007-07-06
Points: 0

I am not sure if it is a bug or something got changed between versions (2.4.1 to 2.5). I have not gotten a response that helped me resolve this issue and currently working on a couple of other issues until I hear back about this one. Again, I understand I can use other workarounds to get the Pipe ID of the course BUT I do not want to change the architecture that we have built and which works for us. Any ideas will be greatly appreciated.

Thanks again