Skip to content
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

P/mike/job history upstream #402

Merged
merged 1 commit into from Mar 27, 2015

Conversation

mngo87
Copy link
Contributor

@mngo87 mngo87 commented Mar 24, 2015

No description provided.

@mngo87
Copy link
Contributor Author

mngo87 commented Mar 24, 2015

Single successful job run
successful_schedule_job

Currently executing job
running_job

If there is no past data, no UI block is shown for this. This makes this feature backwards compatible.
no_past_data_job

If there is a data outage (cassandra down), no data is also shown.
cassandra_data_outage

Number of past job runs are limited by a parameter, the default value is 5.
expanded_job_view

If the screen is shrunk, the UI adapts appropriately
ui_overflow

@mngo87
Copy link
Contributor Author

mngo87 commented Mar 24, 2015

The purpose of this feature is to show the past task executions for each job (if data exists). Data is extracted from the existing Cassandra setup. The tasks are reverse sorted by date, with the most recent at the top.

There are two commits for this request. The commits are separated to show the initial change to the cassandra table schema by changing the indexing scheme. To adapt to the existing schema that upstream uses, I changed to go from a partition key to a secondary index. After getting feedback, I'll squash the commits and merge the final version.

@mngo87
Copy link
Contributor Author

mngo87 commented Mar 24, 2015

@brndnmtthws @elingg - since this is the same area as the last pull request, can you please review again? thanks :)


json.writeEndObject()
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No newline at EOF.

@brndnmtthws
Copy link
Member

Looks great, minus some minor comments. Can you also squash & rebase into 1 commit, please.

Thanks!

@brndnmtthws
Copy link
Member

Another thing: can you update the README to explain how this works? I'm worried some folks (who don't use the C* stuff) will be confused as to why they don't have this data.

@mngo87 mngo87 force-pushed the p/mike/job_history_upstream branch 3 times, most recently from 90e0a1a to 1e47bc7 Compare March 25, 2015 23:55
@mngo87
Copy link
Contributor Author

mngo87 commented Mar 25, 2015

@brndnmtthws - comments addressed. can you review again?

val query = s"SELECT * FROM ${config.cassandraTable()} WHERE ${JOB_NAME}='${jobName}';"
val prepared = statements.getOrElseUpdate(query, {
var level = ConsistencyLevel.ANY
if (ConsistencyLevel.ANY.name().equalsIgnoreCase(config.cassandraConsistency())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe pull this check out into a separate method like readConsistencyLevel()? Then have:

            session.prepare(
              new SimpleStatement(query)
                .setConsistencyLevel(readConsistencyLevel())
                .asInstanceOf[RegularStatement]
            )

@brndnmtthws
Copy link
Member

One minor nit pick.

Any comments from @elingg?

@elingg
Copy link
Member

elingg commented Mar 26, 2015

Thanks for the contribution @mngo87 and for the review @brndnmtthws, I'll take a final look at this ASAP.

@mngo87 mngo87 force-pushed the p/mike/job_history_upstream branch from 1e47bc7 to 166d145 Compare March 26, 2015 00:10
@mngo87
Copy link
Contributor Author

mngo87 commented Mar 26, 2015

Sure no problem. I updated once more to address @brndnmtthws 's comments

@@ -310,4 +447,15 @@ class JobStats @Inject()(clusterBuilder: Option[Cluster.Builder], config: Cassan
}

}

private def readConsistencyLevel() : ConsistencyLevel = {
var level = ConsistencyLevel.ANY
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit this level var altogether. The last statement in the function will be the return value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. will update

@mngo87 mngo87 force-pushed the p/mike/job_history_upstream branch from 166d145 to e6bd023 Compare March 26, 2015 00:18
@brndnmtthws
Copy link
Member

Looks great now, thanks.

var slaveId = row.getString(SLAVE_ID)
var isFailure = row.getBool(IS_FAILURE)

var taskStats = taskMap.getOrElseUpdate(taskId, new TaskStat(taskId, jobName, slaveId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this variable should probably be named taskStat

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah good catch. will update.

@elingg
Copy link
Member

elingg commented Mar 26, 2015

This is really great work, @mngo87! My main concern at this point is with clean code, specifically in the method, getParsedJobStatsByName. I want to make sure we have a clean way of updating the appropriate fields in TaskStat and loading and saving the object to DB. Right now we modify different fields at different times, which is not ideal and difficult to read.

@mngo87
Copy link
Contributor Author

mngo87 commented Mar 26, 2015

Thanks @elingg for the review. Let me know your thoughts on what I said. Just to re-iterate, TaskStat is just merely a object representation of the chronos table. It will pull all the data at once and then parse. It will not get the subsequent updates during parsing. That can be a feature for later.

@elingg
Copy link
Member

elingg commented Mar 26, 2015

Thanks for the quick response @mngo87! I left my reply above. That's fine that we don't persist the TaskStat or the Map, but I would like to clean up that method for simplicity and readability.

@mngo87 mngo87 force-pushed the p/mike/job_history_upstream branch 2 times, most recently from 694f41c to bd6c68c Compare March 27, 2015 00:18
@mngo87
Copy link
Contributor Author

mngo87 commented Mar 27, 2015

@elingg - I just updated the request. Instead of dealing with when to clear the taskMap, I decided to go back to the disposable map model and use it for temporary storage. i separated out the code. Let me know what you think

@elingg
Copy link
Member

elingg commented Mar 27, 2015

@mngo87, with the cleaner logic, the disposable map makes more sense. I think it is a reasonable design. Nice work! I just made one comment to address, but it LGTM

@mngo87
Copy link
Contributor Author

mngo87 commented Mar 27, 2015

@elingg - let me know your thoughts on my comments and I'll address if needed. Thanks for the review.

@elingg
Copy link
Member

elingg commented Mar 27, 2015

Responded, thanks!

@mngo87 mngo87 force-pushed the p/mike/job_history_upstream branch from bd6c68c to 1f72b4d Compare March 27, 2015 21:28
@mngo87
Copy link
Contributor Author

mngo87 commented Mar 27, 2015

@elingg - updated and tested.

@elingg
Copy link
Member

elingg commented Mar 27, 2015

Sweet! 💯

elingg added a commit that referenced this pull request Mar 27, 2015
@elingg elingg merged commit 887ec7e into mesos:master Mar 27, 2015
@mngo87 mngo87 deleted the p/mike/job_history_upstream branch March 27, 2015 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants