Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > RightScale Grid Technical User Guide > Data Passing and Data Structures

Data Passing and Data Structures

 


Overview

Data is passed between six data structures.

diag-DataWorkflow-v1.png

 


Work Unit Data Structure

'work_unit' is the structure of the data stored in the input queue.

work_unit = {  
	:created_at 	=> Time.now.utc.strftime('%Y-%m-%d %H:%M:%S %Z'),  
	:s3_download 	=> [File.join(jobspec[:bucket], filename)],  
	:worker_name 	=> jobspec[:worker_name],  
}  

The Work Unit should contain :created_at.  It must also include the s3_download element which contains one or more file names that you have placed in S3. You should include the :worker_name which corresponds to your worker class code on the worker instance. If you do not include a :worker_name, the worker daemon will use its default_worker_name setting from the rightworker.yml. You can also include any other key/value pair you would like to pass to the worker code.

 


Message Env Data Structure

message_env(for worker): {
	:created_at		=>	work_unit[:created_at] 
	:s3_download		=>	work_unit[:s3_download] 
	:worker_name		=>	work_unit[:worker_name] 
	:anykey  		=>	work_unit[:anyvalue] 
	message_id		=>	SQS message ID 
	:s3_in	        	=>	$s3_in as specified in the rightworker.yml
	:user		        =>	{key, value pairs} as specified in the rightworker.yml
	:controller		=>	RightWorkersDaemon 
	:tmp_dir		=>	/mnt/tmp/%{message_id} 
	:log_dir		=>	%{tmp_dir} /log
	:output_dir		=>	%{tmp_dir} /output
	:s3_downloaded_list	=>	{ files-that-were-downloaded, %{s3_in}/filename}
 	:log_file		=>	%{log_dir}/user_worker.log
	:s3_out		        =>	%{output_dir
} 
 
created at: The time the work_unit was created
s3_download: The list of files the daemon should download
worker_name: The name of the Ruby WorkerClass the Daemon will call on the Worker Instance
message_id: The SQS message ID corresponding to the retrieved work_unit
s3_in: The local directory to store downloaded files
User: Data in the user section of the rightworker.yml passed by the daemon
custom_entry_a: This is an example of a parameter that is retrieved from the rightworker.yml that will only be used by the worker code
custom_entry_b: This is an example of a parameter that is retrieved from the rightworker.yml that will only be used by the worker code
Controller: Name of the Daemon executing this Ruby WorkerClass
tmp_dir: The location of temporary files on the local instance
log_dir: The location of log files on the local instance
output_dir: The location of output files on the local instance
s3_downloaded_list: The list of files actually downloaded
log_file: The name of the log file to place WorkerDaemon debug messages
s3_out: Deprecated, same as output_dir

 

 


Error Data Structure

Error { 
	:s3_download 		=> %{work_unit[:s3_download]}
	:worker_name 	=> %{work_unit[:worker_name]}
	:serial			=> %{work_unit[:serial]}
	:conversion_type	=> %{work_unit[:conversion_type]}
	:id			=> %{work_unit[:id]}  
	:created_at		=> %{work_unit[: created_at]}
 	result			=> %{results[:result]}
 	right_grid_status	=> %{daemon[:right_grid_status]}
	startime		=> %{results[:starttime]}
	finishtime		=> %{results[: finishtime]}
	id			=> %{results[:id]}
	audit_info		=> %{results[:audit_info]} 
}
s3_download: The list of files the daemon should download
worker_name: The name of the Ruby WorkerClass the Daemon will call on the Worker Instance
Serial: This is an example of a user specific key/value pair
conversion_type: This is an example of a user specific key/value pair
id: This is an example of a user specific key/value pair
created_at: The work unit create time as specified in the work unit message
Result: Will begin with the words “exception” or “aborted” as passed by the worker code
right_grid_status: The return results of the worker DaemonThe return results of the worker Daemon
finishtime Generated by the worker code, time work completed
starttime Generated by the worker code, time work completed
work_item_id The AWS message id
Audit_info This is an example of a user specific audit info

 

 


Audit Data Structure

Audit {	
	worker_result      	= 0 # integer/string value with exit result from RightWorker 
	result 	                = %{results[:result]}
	queue_url 	        = http://queue.amazonaws.com/ZZZZZZZZZZZZZ/queue-name
	work_item_id         	= message id
	result_item_id  	= message id

work_unit_created_at = %{work_unit[: created_at]} start_timestamp = %{results[:starttime]} end_timestamp = %{results[: finishtime]} secs_to_work = 3 # Amount of seconds right worker worked s3_dowloaded_list = %{message_env[:s3_downloaded_list]} s3_downloaded_bytes = integer (bytes) secs_to_download = integer (seconds) s3_uploaded_list = ["bucket1/key1/file1", ..., "bucketN/keyN/fileN"] s3_uploaded_bytes = integer (bytes) secs_to_upload = integer (seconds) s3_log_path = 'bucket/key' errors = {} audit_info ={ key pairs} }

created at:

The time the work_unit was created
queue_url https://queue.amazonaws.com/1269532628378_RightGrid_Example_Input
secs_to_work Number of seconds worker code spent on the work
work_unit_created_at The time the work was created, as originally placed in the work_unit
Result The worker Daemon result status
End_timestamp The time the work completed, as generated in the worker code
secs_to_download Duration of download time
work_item_id The aws message ID
secs_to_upload Duration of upload time
s3_uploaded_bytes Number of bytes uploaded
s3_log_path The bucket/path for where log files are stored on S3
s3_uploaded_list The list of files the daemon has uploaded (found in ouput directory)
start_timestamp The time the work started, as generated in the worker code
audit_info This is an example of a user specific audit info
Serial This is an example of a user specific data
S3_downloaded_List The list of files actually downloaded
worker_result The worker code’s returned result
Errors  
result_item_id The AWS message id of the output message

 

 


Right Results Data Structure

This is the data structure passed back from the worker code to the worker daemon. If the result element begins with 'exception' or 'aborted', the worker daemon will consider this an error result from the worker code. The worker code is free to put in any additional key/value pairs that it wants to pass back.

results {
 	created_at	=> %{message_env[:created_at]
	id	        => %{message_env[:id]
	serial	        => %{message_env[:serial]
	result      	=> 0	
	startime	=> Time.now  //beginning of processing
	finishtime	=> Time.now  //end of processing
	audit_info'	=> {Any_Key_name => “any data to appear in the audit message” }
} 
created_at: The time the work_unit was created, copied from the message_env
id: Example of an optional element passed by the worker code0
serial: Example of an optional element passed by the worker code0
result: If this begins with “exception” or “aborted”, the worker daemon will interpret the results as an error
startime:  <<verify. not starttime?>> The time that processing the work has begun. Used for statistics
finishtime: The time that processing the work has finished. Used for statistics
Audit_info: This is an example of a optional audit info the worker code is passing to the worker daemon to place in the audit message

 

 


Output Data Structure

Output {
 	s3_upload 	        => { local_path/filename, s3_bucket/filename}
 	result	                => %{results[:result]}
 	right_grid_status	=> %{daemon[:right_grid_status]}
	startime	        => %{results[:starttime]}
	finishtime	        => %{results[: finishtime]}
	created_at	        => %{results[: created_at]}
	work_item_id            => message id
	id              	=> %{results[:id]}
	audit_info         	=> %{results[:audit_info]} 
	serial	                => %{results[:serial]}
} 
s3_upload: The list of files the daemon has uploaded (found in output directory)
Result: 0
right_grid_status: success
finishtime The time that the work unit was completed
starttime The time that the work unit began to be processed
Created_at Time the work unit was created
work_item_id The AWS message id for the input message
Audit_info Any information the worker code would like to pass to the audit message

 

 

You must to post a comment.
Last modified
23:19, 16 May 2013

Tags

This page has no custom tags.

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.