Sha256: 81fbbb392c47acd82e9e04ea4a3c1077e240c4d9fae5c10d31f4adefb6129a9e

Contents?: true

Size: 1.55 KB

Versions: 15

Compression:

Stored size: 1.55 KB

Contents

require 'rake/clean'

namespace :zookeeper do
  ZK_VERSION = "3.3.3"
  ZK_TARBALL = "zookeeper-#{ZK_VERSION}.tar.gz"

  task :download => "tmp/#{ZK_TARBALL}"
  directory 'tmp'

  file "tmp/#{ZK_TARBALL}" => "tmp" do
    puts "*** Downloading Zookeeper"
    sh "curl http://archive.apache.org/dist/zookeeper/zookeeper-#{ZK_VERSION}/#{ZK_TARBALL} -o tmp/#{ZK_TARBALL}"
  end

  task :install => :download do
    puts "*** Unpacking Zookeeper"

    rm_rf "zookeeper" if File.exists? "zookeeper"
    sh "tar -zxvf tmp/#{ZK_TARBALL}"
    mv "zookeeper-#{ZK_VERSION}", "zookeeper"
    home = File.expand_path("../../zookeeper", __FILE__)
    
    # Create base configuration
    data = File.join(home, "data")
    mkdir_p data
    config = File.join(home, "conf", "zoo.cfg")
    rm_r File.join(home, "conf", "zoo_sample.cfg")
    
    File.open(config, "w") do |file|
      # Maybe some kind soul will move this ugly heredoc into a template
      file << <<-ZK_CONFIG
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=#{data}
# the port at which the clients will connect
clientPort=2181
ZK_CONFIG
    end
  end
  
  task :start => :zookeeper do
    puts "*** Starting Zookeeper"
    sh "cd zookeeper && bin/zkServer.sh start"
  end
end

file 'zookeeper' do
  Rake::Task['zookeeper:install'].invoke
end

CLEAN.include "tmp", "zookeeper"

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
dcell-0.16.1 tasks/zookeeper.task
stn-dcell-0.16.0 tasks/zookeeper.task
dcell-0.16.0 tasks/zookeeper.task
dcell-0.16.0.pre tasks/zookeeper.task
dcell-0.15.0 tasks/zookeeper.task
dcell-0.15.0.pre tasks/zookeeper.task
dcell-0.14.0 tasks/zookeeper.task
dcell-0.13.0 tasks/zookeeper.task
dcell-0.13.0.pre tasks/zookeeper.task
dcell-0.12.0.pre tasks/zookeeper.task
dcell-0.10.0 tasks/zookeeper.task
dcell-0.9.0 tasks/zookeeper.task
dcell-0.8.0 tasks/zookeeper.task
dcell-0.7.1 tasks/zookeeper.task
dcell-0.0.1 tasks/zookeeper.task