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

Avoid NPE when tackling timeout action #1780

Merged
merged 2 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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