gridgain / gridgain-old

267 stars 85 forks source link

GridStreamerRandomEventRouter don't handle possible exception of ThreadLocalRandom #37

Closed alkersan closed 10 years ago

alkersan commented 10 years ago

Recently I played with possible implementation of Routing based on Node Role as proposed here and noticed one weakness of current GridStreamerRandomEventRouter.

While it is possible to initialize this router with predicate, that will filter out all routees, then during nextInt() call with illegal 0 argument we'll get unhandled IllegalArgumentException.

I think this is absolutely valid state of system (while nodes can dynamically leave and join), but I expected to be notified with GridException in place of addEvent(s) method usage as defined in GridStreamer

try {
  streamer.addEvent(bundle)
} catch {
  case e: GridException =>
}
airinev commented 10 years ago

Dmytro, thanks for your bug report. We fixed IllegalArgumentException in master branch.

You can handle route failures with GridStreamerFailureListener for now:

grid.streamer(null).addStreamerFailureListener(new GridStreamerFailureListener() {
    @Override public void onFailure(String stageName, Collection<Object> evts, Throwable err) {
        // ...
    }
});