-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix missing Spark flow and job info. #198
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,11 +234,12 @@ public static Map<String, String> parseCsKeyValue(String str) { | |
* | ||
* @param field the field to br truncated | ||
* @param limit the truncation limit | ||
* @param context additional context for logging purposes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering why |
||
* @return The truncated field | ||
*/ | ||
public static String truncateField(String field, int limit, String appId) { | ||
public static String truncateField(String field, int limit, String context) { | ||
if (field != null && limit > TRUNCATE_SUFFIX.length() && field.length() > limit) { | ||
logger.info("Truncating " + field + " to " + limit + " characters for " + appId); | ||
logger.info("Truncating " + field + " to " + limit + " characters for " + context); | ||
field = field.substring(0, limit - 3) + "..."; | ||
} | ||
return field; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,16 @@ | |
|
||
package com.linkedin.drelephant.util; | ||
|
||
import com.linkedin.drelephant.analysis.ApplicationType; | ||
import com.linkedin.drelephant.analysis.HadoopApplicationData; | ||
import com.linkedin.drelephant.configurations.scheduler.SchedulerConfigurationData; | ||
import com.linkedin.drelephant.schedulers.AirflowScheduler; | ||
import com.linkedin.drelephant.schedulers.AzkabanScheduler; | ||
import com.linkedin.drelephant.schedulers.OozieScheduler; | ||
import com.linkedin.drelephant.schedulers.Scheduler; | ||
|
||
import java.util.Properties; | ||
import models.AppResult; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
|
@@ -31,14 +35,15 @@ | |
import mockit.Expectations; | ||
import mockit.Mocked; | ||
import mockit.integration.junit4.JMockit; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.apache.oozie.client.OozieClient; | ||
import org.apache.oozie.client.WorkflowJob; | ||
|
||
import play.test.FakeApplication; | ||
import play.test.Helpers; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
|
||
@RunWith(JMockit.class) | ||
public class InfoExtractorTest { | ||
|
@@ -147,4 +152,62 @@ public void testGetSchedulerInstanceNull() { | |
assertEquals(null, scheduler); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
@Test | ||
public void testLoadSchedulerInfo() { | ||
Properties properties = new Properties(); | ||
properties.put(AzkabanScheduler.AZKABAN_JOB_URL, | ||
"https://grid.example.com:9000/manager?project=project-name&flow=flow-name&job=job-name"); | ||
properties.put(AzkabanScheduler.AZKABAN_ATTEMPT_URL, | ||
"https://grid.example.com:9000/executor?execid=123456&job=job-name&attempt=0"); | ||
properties.put(AzkabanScheduler.AZKABAN_WORKFLOW_URL, | ||
"https://grid.example.com:9000/manager?project=project-name&flow=flow-name"); | ||
properties.put(AzkabanScheduler.AZKABAN_EXECUTION_URL, | ||
"https://grid.example.com:9000/executor?execid=123456"); | ||
properties.put(AzkabanScheduler.AZKABAN_JOB_NAME, "job-name"); | ||
|
||
SchedulerConfigurationData schedulerConfigurationData = new SchedulerConfigurationData("azkaban", null, null); | ||
|
||
Scheduler scheduler = new AzkabanScheduler("id", properties, schedulerConfigurationData); | ||
|
||
AppResult result = new AppResult(); | ||
|
||
HadoopApplicationData data = | ||
new HadoopApplicationData() { | ||
String appId = "application_5678"; | ||
Properties conf = new Properties(); | ||
ApplicationType applicationType = new ApplicationType("foo"); | ||
|
||
@Override | ||
public String getAppId() { | ||
return appId; | ||
} | ||
|
||
@Override | ||
public Properties getConf() { | ||
return conf; | ||
} | ||
|
||
@Override | ||
public ApplicationType getApplicationType() { | ||
return applicationType; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
}; | ||
|
||
InfoExtractor.loadSchedulerInfo(result, data, scheduler); | ||
|
||
assertEquals(result.scheduler, "azkaban"); | ||
assertFalse(StringUtils.isEmpty(result.getJobExecId())); | ||
assertFalse(StringUtils.isEmpty(result.getJobDefId())); | ||
assertFalse(StringUtils.isEmpty(result.getFlowExecId())); | ||
assertFalse(StringUtils.isEmpty(result.getFlowDefId())); | ||
assertFalse(StringUtils.isEmpty(result.getJobExecUrl())); | ||
assertFalse(StringUtils.isEmpty(result.getJobDefUrl())); | ||
assertFalse(StringUtils.isEmpty(result.getFlowExecUrl())); | ||
assertFalse(StringUtils.isEmpty(result.getFlowDefUrl())); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's probably a Hamcrest matcher we could use here, but combining |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After #162,
getConf
should be sufficient for bothMapReduceApplicationData
andSparkApplicationData
.