eclipsed 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +8 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/eclipsed.gemspec +28 -0
- data/exe/eclipsed +5 -0
- data/lib/eclipsed/version.rb +3 -0
- data/lib/eclipsed.rb +287 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b4f70c005d67c21a1d3353fea853d40edecf0893
|
4
|
+
data.tar.gz: 6032d9df663bcab6b50f91c8bba89726e9b19b96
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3dd8100fb25cb79f677e6901e5136b893efd36dbeb9b315c444b3b8c0c0b2efb779ca6c6730255d48bcc9dde0b729e8cdf021909410f3ec763f6c48282ca265e
|
7
|
+
data.tar.gz: 3a538aca81687a45fb5503865213b211533bbf11beb97b683bbce711a862aaac52205f63e253a02c84910265d3e8058ab92689a27c8c38eaf013ad0c7245e325
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Eclipsed
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/eclipsed`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'eclipsed'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install eclipsed
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/eclipsed/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "eclipsed"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/eclipsed.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eclipsed/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "eclipsed"
|
8
|
+
spec.version = Eclipsed::VERSION
|
9
|
+
spec.authors = ["Vicente Adolfo Bolea Sanchez"]
|
10
|
+
spec.email = ["vicente.bolea@gmail.com"]
|
11
|
+
|
12
|
+
if spec.respond_to?(:metadata)
|
13
|
+
#spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
14
|
+
end
|
15
|
+
|
16
|
+
spec.summary = %q{EclipseMR governor}
|
17
|
+
spec.description = %q{Controls EclipseMR.}
|
18
|
+
spec.homepage = "http://dicl.unist.ac.kr"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
data/exe/eclipsed
ADDED
data/lib/eclipsed.rb
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
require "eclipsed/version"
|
2
|
+
require 'optparse' # For parsing the options
|
3
|
+
require 'json' #
|
4
|
+
require 'ffi' # For loading C functions, in this case the hash functions
|
5
|
+
require 'awesome_print' # Pretty-printer
|
6
|
+
require 'table_print' # Pretty-printer
|
7
|
+
|
8
|
+
module Eclipsed
|
9
|
+
CONFPATH = "@sysconfdirfull@/eclipse.json"
|
10
|
+
BINDIR = "@bindirfull@"
|
11
|
+
LIBDIR = "@libdirfull@"
|
12
|
+
CXX = "@CXX@"
|
13
|
+
module EclipseAPI #{{{
|
14
|
+
extend FFI::Library
|
15
|
+
ffi_lib "#{LIBDIR}/libecfs.so"
|
16
|
+
attach_function :hash_ruby, [ :string ], :uint32
|
17
|
+
end
|
18
|
+
#}}}
|
19
|
+
# print_async {{{
|
20
|
+
def print_async(msg)
|
21
|
+
Thread.new(msg) do |m|
|
22
|
+
print "#{m} "
|
23
|
+
loop do
|
24
|
+
print "\b\\"
|
25
|
+
sleep 0.3
|
26
|
+
print "\b-"
|
27
|
+
sleep 0.3
|
28
|
+
print "\b/"
|
29
|
+
sleep 0.3
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
#}}}
|
34
|
+
# find_confpath {{{
|
35
|
+
def find_confpath
|
36
|
+
home = "#{ENV['HOME']}/.eclipse.json"
|
37
|
+
etc = "/etc/.eclipse.json"
|
38
|
+
|
39
|
+
if File.exists? home
|
40
|
+
return home
|
41
|
+
elsif File.exists? etc
|
42
|
+
return etc
|
43
|
+
else
|
44
|
+
return CONFPATH
|
45
|
+
end
|
46
|
+
end
|
47
|
+
# }}}
|
48
|
+
|
49
|
+
class Core
|
50
|
+
include EclipseDaemon
|
51
|
+
# Initialize {{{
|
52
|
+
def initialize
|
53
|
+
@nodelist = File.open(find_confpath) { |f| JSON.parse(f.read) }['network']['nodes']
|
54
|
+
@verbose = false
|
55
|
+
end
|
56
|
+
|
57
|
+
# }}}
|
58
|
+
# launch {{{
|
59
|
+
def launch
|
60
|
+
thr = print_async "Initializing framework..."
|
61
|
+
`#{BINDIR}/master &>/dev/null &`
|
62
|
+
sleep 1
|
63
|
+
@nodelist.each do |node|
|
64
|
+
system "ssh #{node} 'nohup #{BINDIR}/slave </dev/null &>/dev/null & exit'"
|
65
|
+
end
|
66
|
+
thr.exit
|
67
|
+
print "\r"
|
68
|
+
end
|
69
|
+
|
70
|
+
#}}}
|
71
|
+
# show {{{
|
72
|
+
def show
|
73
|
+
msg_handler = print_async "Collecting information..."
|
74
|
+
|
75
|
+
instance = [ ]
|
76
|
+
in_english = { true => "Running", false => "Stopped" }
|
77
|
+
|
78
|
+
status = in_english[system "pgrep -u #{`whoami`.chomp} master &>/dev/null"]
|
79
|
+
instance << { :host => "localhost", :status => status, :role => "master" }
|
80
|
+
|
81
|
+
@nodelist.each do |node|
|
82
|
+
mr_status = in_english[system "ssh #{node} pgrep -u #{`whoami`.chomp} -x slave &>/dev/null"]
|
83
|
+
instance << { :host => node, :status => mr_status, :role => "worker" }
|
84
|
+
end
|
85
|
+
|
86
|
+
msg_handler.exit
|
87
|
+
print "\r"
|
88
|
+
tp instance, "host", "role", "status"
|
89
|
+
end
|
90
|
+
|
91
|
+
#}}}
|
92
|
+
# close {{{
|
93
|
+
def close
|
94
|
+
thr = print_async "Stopping framework..."
|
95
|
+
`pkill -u #{`whoami`.chomp} master`
|
96
|
+
@nodelist.each do |node|
|
97
|
+
`ssh #{node} pkill -u #{`whoami`.chomp} slave`
|
98
|
+
end
|
99
|
+
thr.exit
|
100
|
+
print "\r"
|
101
|
+
end #}}}
|
102
|
+
# submit {{{
|
103
|
+
def submit(input)
|
104
|
+
# @instance[:app]= input
|
105
|
+
# File.open(@fs_tmpfile, 'w') { |f| f.write(JSON.generate(@instance)) }
|
106
|
+
|
107
|
+
system input.join(' ')
|
108
|
+
end #}}}
|
109
|
+
# kill {{{
|
110
|
+
def kill(input)
|
111
|
+
@nodelist.each do |node|
|
112
|
+
cmd = "ssh #{node} \'pkill -u #{`whoami`.chomp} #{input.join}\'"
|
113
|
+
puts cmd if @verbose
|
114
|
+
system cmd
|
115
|
+
end
|
116
|
+
end #}}}
|
117
|
+
# pry {{{
|
118
|
+
def pry
|
119
|
+
require 'pry'
|
120
|
+
binding.pry
|
121
|
+
end #}}}
|
122
|
+
end
|
123
|
+
|
124
|
+
class Fs < Core
|
125
|
+
include EclipseAPI
|
126
|
+
def initialize #{{{
|
127
|
+
@files = {}
|
128
|
+
@config = File.open(find_confpath) { |f| JSON.parse(f.read) }
|
129
|
+
@fs_path = @config['path']['filesystem']
|
130
|
+
@fs_scratch_path = @config['path']['scratch']
|
131
|
+
@fs_tmpfile = @fs_path + "/.list"
|
132
|
+
@files = File.open(@fs_tmpfile) { |f| JSON.parse(f.read) } if File.exist? @fs_tmpfile
|
133
|
+
alias :hash :hash_ruby
|
134
|
+
super()
|
135
|
+
end
|
136
|
+
|
137
|
+
def node_containing(fn); @nodelist[hash(fn) % @nodelist.length] end
|
138
|
+
|
139
|
+
#}}}
|
140
|
+
# put {{{
|
141
|
+
def put(input)
|
142
|
+
input.each do |fn|
|
143
|
+
node = node_containing(fn)
|
144
|
+
@files[fn] = node
|
145
|
+
|
146
|
+
File.open(@fs_tmpfile, 'w') { |f| f.write(JSON.generate(@files)) }
|
147
|
+
cmd = "scp #{@fs_path}/#{fn} #{node}:#{@fs_scratch_path}/#{fn}"
|
148
|
+
puts cmd if @verbose
|
149
|
+
system cmd
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
#}}}
|
154
|
+
# cat {{{
|
155
|
+
def cat(input)
|
156
|
+
input.each do |fn|
|
157
|
+
system "ssh #{node_containing(fn)} cat #{@fs_scratch_path}/#{fn}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
#}}}
|
162
|
+
# get {{{
|
163
|
+
def get(input)
|
164
|
+
input.each do |fn|
|
165
|
+
cmd = "scp #{node_containing(fn)}:#{@fs_scratch_path}/#{fn} ."
|
166
|
+
puts cmd if @verbose
|
167
|
+
system cmd
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
#}}}
|
172
|
+
# rm {{{
|
173
|
+
def rm(input)
|
174
|
+
input = @files.keys.grep(%r[#{@regex}]) if @regex
|
175
|
+
|
176
|
+
input.each do |fn|
|
177
|
+
# raise "\'#{fn}\' not found in Eclipse FS" unless @files[fn]
|
178
|
+
|
179
|
+
node = node_containing(fn)
|
180
|
+
pathtofile = @fs_scratch_path + "/" + fn
|
181
|
+
cmd = "ssh #{node} rm -f #{pathtofile}"
|
182
|
+
puts cmd if @verbose
|
183
|
+
system cmd
|
184
|
+
@files.delete(fn)
|
185
|
+
File.open(@fs_tmpfile, 'w') { |f| f.write(JSON.generate(@files)) }
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
#}}}
|
190
|
+
def list #{{{
|
191
|
+
thr = print_async "Collecting information..."
|
192
|
+
output = [ ]
|
193
|
+
@files.each{|k, v| output << { :filename => k, :location => v} }
|
194
|
+
|
195
|
+
@nodelist.each do |node|
|
196
|
+
`ssh #{node} ls #{@fs_scratch_path}`.each_line do |l|
|
197
|
+
l.chomp!
|
198
|
+
output << { :filename => l, :location => node} unless @files.has_key?(l)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
thr.exit
|
203
|
+
print "\r\e[K"
|
204
|
+
tp output, :filename, :location
|
205
|
+
end
|
206
|
+
|
207
|
+
#}}}
|
208
|
+
def config #{{{
|
209
|
+
ap self.instance_variables.map{|var| [var, self.instance_variable_get(var)]}.to_h
|
210
|
+
end #}}}
|
211
|
+
# compile {{{
|
212
|
+
def compile(input)
|
213
|
+
sources = input.join(' ')
|
214
|
+
raise 'Need to specify output file (-o File)' unless @outputfile
|
215
|
+
|
216
|
+
cmd = "#{CXX} -static -o #{@outputfile} #{sources} -l ecfs"
|
217
|
+
puts cmd if @verbose
|
218
|
+
system cmd
|
219
|
+
end
|
220
|
+
|
221
|
+
#}}}
|
222
|
+
def clear #{{{
|
223
|
+
rm @files.keys
|
224
|
+
@nodelist.each do |node|
|
225
|
+
cmd = "ssh #{node} rm -rf #{@fs_scratch_path}/.job* #{@fs_scratch_path}/*"
|
226
|
+
puts cmd if @verbose
|
227
|
+
system cmd
|
228
|
+
end
|
229
|
+
end
|
230
|
+
#}}}
|
231
|
+
end
|
232
|
+
|
233
|
+
class CLI_driver < Fs
|
234
|
+
def initialize input: #{{{
|
235
|
+
@options = {}
|
236
|
+
super()
|
237
|
+
OptionParser.new do |opts|
|
238
|
+
opts.banner = "ecfs (Eclipse FileSystem) is an script to manage the fs\n" +
|
239
|
+
"Usage: ecfs [options] <actions> [FILE]..."
|
240
|
+
opts.version = 1.0
|
241
|
+
opts.program_name = "Eclipse Launcher"
|
242
|
+
opts.separator "Core actions"
|
243
|
+
opts.separator " launch Create new Eclipse network"
|
244
|
+
opts.separator " close Close the network"
|
245
|
+
opts.separator " status Check the status of the network"
|
246
|
+
opts.separator " submit Submit application"
|
247
|
+
opts.separator " kill kill application in each node"
|
248
|
+
opts.separator ""
|
249
|
+
opts.separator "Filesystem actions"
|
250
|
+
opts.separator " put FILE... insert FILE..."
|
251
|
+
opts.separator " get FILE... copy the FILES to the current directory"
|
252
|
+
opts.separator " rm FILE... remove FILE..."
|
253
|
+
opts.separator " cat FILE... \'cat\' the FILE..."
|
254
|
+
opts.separator " clear remove all the files in the FS"
|
255
|
+
opts.separator " ls list all the files in the FS"
|
256
|
+
opts.separator " config list all the internal variables"
|
257
|
+
opts.separator " cc -o OUTPUT INPUT... Compile file with EclipseFS API using OUTPUT name"
|
258
|
+
opts.separator ""
|
259
|
+
opts.separator "Options"
|
260
|
+
opts.on_tail("-h", "--help" , "recursive this") { puts opts; exit}
|
261
|
+
opts.on_tail("-v", "--verbose" , "printout verbose info") { @verbose = true }
|
262
|
+
opts.on_tail("-V", "--version" , "printout version") { puts opts.ver; exit }
|
263
|
+
opts.on_tail("-o FILE", "output file, for mcc") { |f| @outputfile = f }
|
264
|
+
opts.on_tail("-r REGEX", "regex for remove or ls") { |r| @regex = r }
|
265
|
+
end.parse! input
|
266
|
+
|
267
|
+
case input.shift
|
268
|
+
when 'launch' then launch
|
269
|
+
when 'close' then close
|
270
|
+
when 'status' then show
|
271
|
+
when 'submit' then submit input
|
272
|
+
when 'kill' then kill input
|
273
|
+
when 'put' then put input
|
274
|
+
when 'get' then get input
|
275
|
+
when 'cat' then cat input
|
276
|
+
when 'rm' then rm input
|
277
|
+
when 'clear' then clear
|
278
|
+
when 'ls' then list
|
279
|
+
when 'config' then config
|
280
|
+
when 'cc' then compile(input)
|
281
|
+
when 'pry' then pry
|
282
|
+
else raise "Not action given"
|
283
|
+
end
|
284
|
+
end #}}}
|
285
|
+
end
|
286
|
+
|
287
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eclipsed
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vicente Adolfo Bolea Sanchez
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Controls EclipseMR.
|
42
|
+
email:
|
43
|
+
- vicente.bolea@gmail.com
|
44
|
+
executables:
|
45
|
+
- eclipsed
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- CODE_OF_CONDUCT.md
|
51
|
+
- Gemfile
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- eclipsed.gemspec
|
57
|
+
- exe/eclipsed
|
58
|
+
- lib/eclipsed.rb
|
59
|
+
- lib/eclipsed/version.rb
|
60
|
+
homepage: http://dicl.unist.ac.kr
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.4.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: EclipseMR governor
|
84
|
+
test_files: []
|