Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Avoid NPE when tackling timeout action (#1780)
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE authored Jun 1, 2018
1 parent fd65209 commit e322d02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
*/
public class CmdletManager extends AbstractService {
private static final Logger LOG = LoggerFactory.getLogger(CmdletManager.class);
public static final long TIMEOUT_MULTIPLIER = 60;
public static final int TIMEOUT_MULTIPLIER = 100;
public static final int TIMEOUT_MIN_MILLISECOND = 30000;
public static final String TIMEOUTLOG =
"Timeout error occurred for getting this action's status report.";
public static final String ACTION_SKIP_LOG =
Expand Down Expand Up @@ -137,9 +138,12 @@ public CmdletManager(ServerContext context) throws IOException {
SmartConfKeys.SMART_CMDLET_CACHE_BATCH_DEFAULT);

int reportPeriod = context.getConf().getInt(SmartConfKeys.SMART_STATUS_REPORT_PERIOD_KEY,
SmartConfKeys.SMART_STATUS_REPORT_PERIOD_DEFAULT);
this.timeout =
TIMEOUT_MULTIPLIER * reportPeriod < 30000 ? 30000 : TIMEOUT_MULTIPLIER * reportPeriod;
SmartConfKeys.SMART_STATUS_REPORT_PERIOD_DEFAULT);
int maxInterval = reportPeriod * context.getConf().getInt(
SmartConfKeys.SMART_STATUS_REPORT_PERIOD_MULTIPLIER_KEY,
SmartConfKeys.SMART_STATUS_REPORT_PERIOD_MULTIPLIER_DEFAULT);
this.timeout = TIMEOUT_MULTIPLIER * maxInterval < TIMEOUT_MIN_MILLISECOND
? TIMEOUT_MIN_MILLISECOND : TIMEOUT_MULTIPLIER * maxInterval;
}

@VisibleForTesting
Expand Down Expand Up @@ -1181,6 +1185,8 @@ public void run() {
LOG.error(e.getMessage());
} catch (IOException e) {
LOG.error(e.getMessage());
} catch (Throwable t) {
LOG.error("Unexpected exception occurs.", t);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ public void onCmdletFinished(long cmdletId) {
synchronized (dispatchedToSrvs) {
if (dispatchedToSrvs.containsKey(cmdletId)) {
LaunchCmdlet cmdlet = idToLaunchCmdlet.get(cmdletId);
regNodes.get(cmdlet.getNodeId()).incrementAndGet();
if (regNodes.get(cmdlet.getNodeId()) != null) {
regNodes.get(cmdlet.getNodeId()).incrementAndGet();
}
ExecutorType t = dispatchedToSrvs.remove(cmdletId);
updateSlotsLeft(t.ordinal(), 1);
completeOn[t.ordinal()] = cmdlet.getNodeId();
Expand Down

0 comments on commit e322d02

Please sign in to comment.