Skip to content

Commit

Permalink
[MR] Check for invalid Progressable
Browse files Browse the repository at this point in the history
In Hadoop-like envs, Progressable might be invalid causing exceptions
when going through the MR layer.

Fix #330
  • Loading branch information
costin committed Dec 10, 2014
1 parent da47ce8 commit 945ccca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -225,7 +225,10 @@ void init(ShardInputSplit esSplit, Configuration cfg, Progressable progressable)
scrollReader = new ScrollReader(reader, mapping);

// heart-beat
beat = new HeartBeat(progressable, cfg, settings.getHeartBeatLead(), log);
// in Hadoop-like envs (Spark) the progressable might be null and thus the heart-beat is not needed
if (progressable != null) {
beat = new HeartBeat(progressable, cfg, settings.getHeartBeatLead(), log);
}

// initialize REST client
client = new RestRepository(settings);
Expand Down Expand Up @@ -308,7 +311,9 @@ public void close() throws IOException {
@Override
public boolean next(K key, V value) throws IOException {
if (scrollQuery == null) {
beat.start();
if (beat != null) {
beat.start();
}

scrollQuery = queryBuilder.build(client, scrollReader);
size = scrollQuery.getSize();
Expand Down
Expand Up @@ -184,8 +184,11 @@ protected void init() throws IOException {
// select the appropriate nodes first, to spread the load before-hand
SettingsUtils.pinNode(settings, nodes.get(currentInstance % nodes.size()));

beat = new HeartBeat(progressable, cfg, settings.getHeartBeatLead(), log);
beat.start();
// in Hadoop-like envs (Spark) the progressable might be null and thus the heart-beat is not needed
if (progressable != null) {
beat = new HeartBeat(progressable, cfg, settings.getHeartBeatLead(), log);
beat.start();
}

resource = new Resource(settings, false);

Expand Down

0 comments on commit 945ccca

Please sign in to comment.