You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hama.apache.org by Tommaso Teofili <to...@gmail.com> on 2011/11/29 18:43:04 UTC

LocalBSPRunner and multiple messages to the same peer

Hi all,
I just noticed the line 331 of LocalBSPRunner contains a warning which may
result in bugs with multiple messages.
In fact

LinkedList<BSPMessage> msgs = localOutgoingMessages.get(peerName);

is trying to get a List of BSPMessage instances from a
localOutgoingMessages of type HashMap<InetSocketAddress,
LinkedList<BSPMessage>>.

It seems to me there is problem as peerName is a String, not a
InetSocketAddress and in fact my debugging session highlighted that get()
method to result always to return a null object.

The quick fix seems to be putting the lines 337-341 :

      InetSocketAddress inetSocketAddress = socketCache.get(peerName);
      if (inetSocketAddress == null) {
        inetSocketAddress = BSPNetUtils.getAddress(peerName);
        socketCache.put(peerName, inetSocketAddress);
      }

upmost in the method and then call

LinkedList<BSPMessage> msgs = localOutgoingMessages.get(inetSocketAddress);

This was highlighted when dealing with multiple messages sent to a same
peer in local mode (only the last msg was actually stored in the
outGoingMessages item for that peer).

Please let me know if this sounds completely wrong but it seems this fixes
my scenario.
Cheers,
Tommaso

Re: LocalBSPRunner and multiple messages to the same peer

Posted by Tommaso Teofili <to...@gmail.com>.
Thanks Thomas, it should be fixed now in HAMA-482.
Tommaso

2011/11/29 Thomas Jungblut <th...@googlemail.com>

> Yes this is a bug. I deem these guys who did the backward compatibility
> without generics. HashMap.get(Object o)....
> In fact those twos never return the same hashcode or aren't equal. So the
> result will always be null.
> Sorry for this.
>
> I guess you can fix this right away.
>
> 2011/11/29 Tommaso Teofili <to...@gmail.com>
>
> > Hi all,
> > I just noticed the line 331 of LocalBSPRunner contains a warning which
> may
> > result in bugs with multiple messages.
> > In fact
> >
> > LinkedList<BSPMessage> msgs = localOutgoingMessages.get(peerName);
> >
> > is trying to get a List of BSPMessage instances from a
> > localOutgoingMessages of type HashMap<InetSocketAddress,
> > LinkedList<BSPMessage>>.
> >
> > It seems to me there is problem as peerName is a String, not a
> > InetSocketAddress and in fact my debugging session highlighted that get()
> > method to result always to return a null object.
> >
> > The quick fix seems to be putting the lines 337-341 :
> >
> >      InetSocketAddress inetSocketAddress = socketCache.get(peerName);
> >      if (inetSocketAddress == null) {
> >        inetSocketAddress = BSPNetUtils.getAddress(peerName);
> >        socketCache.put(peerName, inetSocketAddress);
> >      }
> >
> > upmost in the method and then call
> >
> > LinkedList<BSPMessage> msgs =
> localOutgoingMessages.get(inetSocketAddress);
> >
> > This was highlighted when dealing with multiple messages sent to a same
> > peer in local mode (only the last msg was actually stored in the
> > outGoingMessages item for that peer).
> >
> > Please let me know if this sounds completely wrong but it seems this
> fixes
> > my scenario.
> > Cheers,
> > Tommaso
> >
>
>
>
> --
> Thomas Jungblut
> Berlin <th...@gmail.com>
>

Re: LocalBSPRunner and multiple messages to the same peer

Posted by Thomas Jungblut <th...@googlemail.com>.
Yes this is a bug. I deem these guys who did the backward compatibility
without generics. HashMap.get(Object o)....
In fact those twos never return the same hashcode or aren't equal. So the
result will always be null.
Sorry for this.

I guess you can fix this right away.

2011/11/29 Tommaso Teofili <to...@gmail.com>

> Hi all,
> I just noticed the line 331 of LocalBSPRunner contains a warning which may
> result in bugs with multiple messages.
> In fact
>
> LinkedList<BSPMessage> msgs = localOutgoingMessages.get(peerName);
>
> is trying to get a List of BSPMessage instances from a
> localOutgoingMessages of type HashMap<InetSocketAddress,
> LinkedList<BSPMessage>>.
>
> It seems to me there is problem as peerName is a String, not a
> InetSocketAddress and in fact my debugging session highlighted that get()
> method to result always to return a null object.
>
> The quick fix seems to be putting the lines 337-341 :
>
>      InetSocketAddress inetSocketAddress = socketCache.get(peerName);
>      if (inetSocketAddress == null) {
>        inetSocketAddress = BSPNetUtils.getAddress(peerName);
>        socketCache.put(peerName, inetSocketAddress);
>      }
>
> upmost in the method and then call
>
> LinkedList<BSPMessage> msgs = localOutgoingMessages.get(inetSocketAddress);
>
> This was highlighted when dealing with multiple messages sent to a same
> peer in local mode (only the last msg was actually stored in the
> outGoingMessages item for that peer).
>
> Please let me know if this sounds completely wrong but it seems this fixes
> my scenario.
> Cheers,
> Tommaso
>



-- 
Thomas Jungblut
Berlin <th...@gmail.com>