neptune 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,6 +29,7 @@ class AppControllerClient
29
29
 
30
30
  @conn = SOAP::RPC::Driver.new("https://#{@ip}:17443")
31
31
  @conn.add_method("neptune_start_job", "job_data", "secret")
32
+ @conn.add_method("neptune_put_input", "job_data", "secret")
32
33
  @conn.add_method("neptune_get_output", "job_data", "secret")
33
34
  @conn.add_method("neptune_get_acl", "job_data", "secret")
34
35
  @conn.add_method("neptune_set_acl", "job_data", "secret")
@@ -87,12 +88,26 @@ class AppControllerClient
87
88
  return result
88
89
  end
89
90
 
91
+ # Stores a file stored on the user's local file system in the underlying
92
+ # database. The user can specify to use either the underlying database
93
+ # that AppScale is using, or alternative storage mechanisms (as of writing,
94
+ # Google Storage, Amazon S3, and Eucalyptus Walrus are supported) via the
95
+ # storage parameter.
96
+ def put_input(job_data)
97
+ result = ""
98
+ make_call(NO_TIMEOUT, false) {
99
+ result = conn.neptune_put_input(job_data, @secret)
100
+ }
101
+ abort(result) if result =~ /Error:/
102
+ return result
103
+ end
104
+
90
105
  # Retrieves the output of a Neptune job, stored in an underlying
91
106
  # database. Within AppScale, a special application runs, referred to as the
92
107
  # Repository, which provides a key-value interface to Neptune job data.
93
108
  # Data is stored as though it were on a file system, therefore output
94
109
  # be of the usual form /folder/filename . Currently the contents of the
95
- # file is returned as a string to the caller, but as this is inefficient
110
+ # file is returned as a string to the caller, but as this may be inefficient
96
111
  # for non-trivial output jobs, the next version of Neptune will add an
97
112
  # additional call to directly copy the output to a file on the local
98
113
  # filesystem. See start_neptune_job for conditions by which this method
data/lib/neptune.rb CHANGED
@@ -21,7 +21,11 @@ $VERBOSE = nil
21
21
 
22
22
  # A list of Neptune jobs that do not require nodes to be spawned
23
23
  # up for computation
24
- NO_NODES_NEEDED = ["acl", "output", "compile"]
24
+ NO_NODES_NEEDED = ["acl", "input", "output", "compile"]
25
+
26
+ # A list of Neptune jobs that do not require the output to be
27
+ # specified beforehand
28
+ NO_OUTPUT_NEEDED = ["input"]
25
29
 
26
30
  # A list of storage mechanisms that we can use to store and retrieve
27
31
  # data to for Neptune jobs.
@@ -184,17 +188,20 @@ def neptune(params)
184
188
 
185
189
  job_data["@job"] = nil
186
190
  job_data["@keyname"] = keyname || "appscale"
191
+ type = job_data["@type"]
187
192
 
188
193
  if job_data["@nodes_to_use"].class == Hash
189
194
  job_data["@nodes_to_use"] = job_data["@nodes_to_use"].to_a.flatten
190
195
  end
191
196
 
192
- if (job_data["@output"].nil? or job_data["@output"] == "")
193
- abort("Job output must be specified")
194
- end
197
+ if !NO_OUTPUT_NEEDED.include?(type)
198
+ if (job_data["@output"].nil? or job_data["@output"] == "")
199
+ abort("Job output must be specified")
200
+ end
195
201
 
196
- if job_data["@output"][0].chr != "/"
197
- abort("Job output must begin with a slash ('/')")
202
+ if job_data["@output"][0].chr != "/"
203
+ abort("Job output must begin with a slash ('/')")
204
+ end
198
205
  end
199
206
 
200
207
  if job_data["@storage"]
@@ -250,8 +257,26 @@ def neptune(params)
250
257
 
251
258
  do_preprocessing(job_data)
252
259
 
253
- type = job_data["@type"]
254
- if type == "output"
260
+ ssh_args = "-i ~/.appscale/#{keyname}.key -o StrictHostkeyChecking=no 2>&1"
261
+
262
+ if type == "input"
263
+ # copy file to remote
264
+ # set location
265
+ local_file = File.expand_path(job_data["@local"])
266
+ if !File.exists?(local_file)
267
+ msg = "the file you specified to copy, #{local_file}, doesn't exist." +
268
+ " Please specify a file that exists and try again."
269
+ abort(msg)
270
+ end
271
+
272
+ remote = "/tmp/neptune-input-#{rand(100000)}"
273
+ scp_cmd = "scp #{ssh_args} #{local_file} root@#{shadow_ip}:#{remote}"
274
+ puts scp_cmd
275
+ `#{scp_cmd}`
276
+
277
+ job_data["@local"] = remote
278
+ return controller.put_input(job_data)
279
+ elsif type == "output"
255
280
  return controller.get_output(job_data)
256
281
  elsif type == "get-acl"
257
282
  job_data["@type"] = "acl"
@@ -262,11 +287,10 @@ def neptune(params)
262
287
  elsif type == "compile"
263
288
  compiled_location = controller.compile_code(job_data)
264
289
 
265
- ssh_args = "-i ~/.appscale/#{keyname}.key -o StrictHostkeyChecking=no 2>&1 root@#{shadow_ip}"
266
290
  copy_to = job_data["@copy_to"]
267
291
 
268
292
  loop {
269
- ssh_command = "ssh #{ssh_args} 'ls #{compiled_location}'"
293
+ ssh_command = "ssh #{ssh_args} root@#{shadow_ip} 'ls #{compiled_location}'"
270
294
  #puts ssh_command
271
295
  result = `#{ssh_command}`
272
296
  #puts "result was [#{result}]"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neptune
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Bunch
@@ -15,7 +15,7 @@ autorequire: neptune
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-18 00:00:00 -07:00
18
+ date: 2011-03-28 00:00:00 -07:00
19
19
  default_executable: neptune
20
20
  dependencies: []
21
21