Module: ZK::Server

Defined in:
lib/zk-server.rb,
lib/zk-server/config.rb,
lib/zk-server/process.rb,
lib/zk-server/version.rb

Defined Under Namespace

Classes: Config, Process

Constant Summary

ZK_JAR_GEM =
'slyphon-zookeeper_jar'
LOG4J_GEM =
'slyphon-log4j'
VERSION =
"0.0.1"

Class Method Summary (collapse)

Class Method Details

+ (Object) default_log4j_props_path



72
73
74
# File 'lib/zk-server.rb', line 72

def self.default_log4j_props_path
  File.expand_path('../zk-server/log4j.properties', __FILE__)
end

+ (Object) get_jar_paths_from_gem(gem_name)



43
44
45
46
47
48
49
# File 'lib/zk-server.rb', line 43

def self.get_jar_paths_from_gem(gem_name)
  glob = "#{get_spec_for(gem_name).lib_dirs_glob}/**/*.jar"

  Dir[glob].tap do |ary|
    raise "gem #{gem_name} did not contain any jars (using glob: #{glob.inspect})" if ary.empty?
  end
end

+ (Object) get_spec_for(gem_name)



51
52
53
54
55
56
57
# File 'lib/zk-server.rb', line 51

def self.get_spec_for(gem_name)
  not_found = proc do
    raise "could not locate the #{gem_name} Gem::Specification! wtf?!"
  end

  Bundler.load.specs.find(not_found) { |s| s.name == gem_name }
end

+ (Object) java_binary_path



63
64
65
# File 'lib/zk-server.rb', line 63

def self.java_binary_path
  @java_binary_path ||= which('java')
end

+ (Object) java_binary_path=(path)



59
60
61
# File 'lib/zk-server.rb', line 59

def self.java_binary_path=(path)
  @java_binary_path = path
end

+ (Object) log4j_jar_path



39
40
41
# File 'lib/zk-server.rb', line 39

def self.log4j_jar_path
  @log4j_jar_path ||= get_jar_paths_from_gem(LOG4J_GEM).first
end

+ (Object) new(opts = {}) {|Config| ... }

Create a new Process instance. if a block is given then yield the Config object to the block

Yields:

  • (Config)

    server config instance if block given



25
26
27
28
29
# File 'lib/zk-server.rb', line 25

def self.new(opts={})
  Server::Process.new(opts).tap do |server|

  end
end

+ (Object) which(bin_name)



67
68
69
70
# File 'lib/zk-server.rb', line 67

def self.which(bin_name)
  if_none = proc { "Could not find #{bin_name} in PATH: #{ENV['PATH'].inspect}" }
  ENV['PATH'].split(':').map{|n| File.join(n, bin_name) }.find(if_none) {|x| File.executable?(x) }
end

+ (Object) zk_jar_path



31
32
33
34
35
36
37
# File 'lib/zk-server.rb', line 31

def self.zk_jar_path
  # in future revisions of the zookeeper jar, we'll make it easier to get
  # at this information without needing rubygems and bundler to get at it,
  # but for now this is the best way

  @zk_jar_path ||= get_jar_paths_from_gem(ZK_JAR_GEM).first
end