add attempt id for hadoop

This commit is contained in:
tqchen 2014-12-22 04:12:38 -08:00
parent 6e6031cbe9
commit 0dd51d5dd0

View File

@ -33,7 +33,7 @@ AllreduceBase::AllreduceBase(void) {
void AllreduceBase::Init(void) {
// setup from enviroment variables
{// handling for hadoop
const char *task_id = getenv("mapred_task_id");
const char *task_id = getenv("mapred_tip_id");
if (hadoop_mode != 0) {
utils::Check(task_id != NULL, "hadoop_mode is set but cannot find mapred_task_id");
}
@ -41,6 +41,14 @@ void AllreduceBase::Init(void) {
this->SetParam("rabit_task_id", task_id);
this->SetParam("rabit_hadoop_mode", "1");
}
const char *attempt_id = getenv("mapred_task_id");
if (attempt_id != 0) {
const char *att = strrchr(attempt_id, '_');
int num_trial;
if (att != NULL && sscanf(att+1, "%d", &num_trial) == 1) {
this->SetParam("rabit_num_trial", att + 1);
}
}
// handling for hadoop
const char *num_task = getenv("mapred_map_tasks");
if (num_task == NULL) {