Created
June 19, 2012 07:08
-
-
Save wiseleyb/2952721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Job | |
add_column :current_batch_job_id # current batch job running | |
# This represents batch job runs - and provides history | |
create_table "batch_jobs", :force => true do |t| | |
t.integer "job_id" # job this is related to | |
t.string "state" # state: create, processed, running, failed, stopped, finished | |
t.integer "instances_to_create" # count of the planned number of instances to create | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
end | |
# This represents sections of a job that need to be run and provides history | |
create_table "batch_job_instances", :force => true do |t| | |
t.integer "batch_job_id" # batch job this is part of | |
t.string "state" # new, assigned_to_ec2, running, failed, stopped, finished | |
t.string "current_ec2_instance_id" # refernce to current ec2_instance | |
t.text "row_ids" # all ids to process | |
t.text "ids_processing" # ids waiting to be processed | |
t.text "ids_failed" # ids that failed to be processed | |
t.text "ids_processed" # ids finished processing | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
end | |
# This represents actual ec2-instances | |
create_table "ec2_instances", :force => true do |t| | |
t.integer "batch_job_instance_id" | |
t.string "aws_ec2_instance_id" | |
t.string "state" # building, running, failed, deleted | |
t.datetime "created_at" | |
t.datetime "updated_at" | |
end | |
Scenario: Running a job | |
1) create batch_job row | |
2) create batch_job_instaces | |
Out of process: something running sees a batch_job_instance.state = new | |
1) in a transaction - grabs row, changes state to assigned_to_ec2 | |
2) creates ec2 instance - creates ec2_instance row with information | |
3) does whatever makes sense for state machine in ec2_instance row | |
4) when everythings running changes state of batch_job_instance to running |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment