Report
Haiyong Wang
Outline
• A brief introduction to Chef• A brief introduction to Ruby• Latching VS Locking
A brief Introduction to Chef
Haiyong Wang
Outline
• What is chef• Architecture and installing• Using chef
What is Chef
With Chef, you write abstract definitions as source code to describe how you want each part of your infrastructure to be built, and then apply those descriptions to individual servers.
Chef Provides
• Provisioning– Kickstart Jumpstart
• Configuration Management– Recipes , knife, cookbook
• Systems Integration
Chef Provides
Different Flavors of Chef
• Chef Solo• Chef Client and Chef Server• Hosted Chef
Chef Client and Chef Server
Installing
• Servers and Workstation– http://
wiki.opscode.com/display/chef/Installing+Chef+Server+on+Debian+or+Ubuntu+using+Packages
Installing
• Clients– http://
wiki.opscode.com/display/chef/Installing+Chef+Client+on+Ubuntu+or+Debian
Installing
• Important files– Validation.pem– client.pem– knife.rb– Client.rb
Using chef
• Important concepts– Git– Cookbook– Recipe– Run_list
Using chef
cookbook Recipes
configure
bootstrap
Using Chef
• Useful links– Cookbook fast start• http://wiki.opscode.com/display/chef/Cookbook+Fast+
Start+Guide
– Github cookbook• https://github.com/opscode-cookbooks• https://github.com/infochimps-cookbooks
– Cookbook community• http://community.opscode.com/
Using Chef
• Hbase
Question ?
A brief introduction to Ruby
Check the syntax
• ruby –c
• rake test
Assignment#assigning a local variable#no type declaration#no semicolonx = 1x, y, z = “100”, 200, 300# global variable$amout = 1#const variableName = “Floydene Wallup”name = “Floydene Wallup”
Basic Arithmetic
5/2 #=> 25/2.0 #=> 2.5(1+2)* 3 #=> 9
irb(main):001:0>3+4 #=> 7irb(main):002:0> 7-3 #=>4irb(main):005:0>3**4 #=> 81irb(main):007:0> x= 12 #=> 12irb(main):008:0> x+=1 irb(main):012:0> Math.sqrt(16) #=> 4
strings'single quoted' # => "single quoted" "double quoted" # => "double quoted" 'It\'s alive' # => "It's alive!" "1 + 2 = 5" # => "1 + 2 = 5"
th = "Hello world“th[0..5] #=>Helloth[-5..-1] #=>world
Embedded
x = "Bob""Hi, #{x}" # => "Hi, Bob"'Hello, #{x}' # => "Hello, #{x}"
Bool variables
true # => true false # => false nil # => nil !true # => false !false # => true !nil # => true !!true # => true !!false # => false !!nil # => false!!0 # => true
Arrays
x = ["a", "b", "c"]# => ["a", "b", "c"] x[0] # => "a" (zero is the first index) x.first # => "a" x.last # => "c" x + ["d"] # => ["a", "b", "c", "d"]x # => ["a", "b", "c"] x = x + ["d"] # => ["a", "b", "c", "d"] x # => ["a", "b", "c", "d"]
Hash
# => { "first_name => "Bob", "last_name" => "Jones" }h = { "first_name" => "Bob", "last_name" => "Jones"}
h.keys # => ["first_name", "last_name"] h["first_name"] # => "Bob" h["last_name"] # => "Jones" h["age"] = 23h.keys # => ["first_name", "age", "last_name"] h.values # => ["Jones", "Bob", 23]
perl-style regular expressions
"I believe" =~ /I/ # => 0"I believe" =~ /lie/ # => 4"I am human" =~ /bacon/ # => nil"I am human" !~ /bacon/ # => true/give me a ([0-9]+)/ =~ "give me a 7" # => 0
Conditional statement
if false # this won't happen else if nil # this won't either else # code here will runend
x = "dog"case x when "fish" # this won't happen when "dog", "cat", "monkey" # this will run else # the else is an optional catch-all end
Method
def do_something_useless( first, second) puts "You gave me #{first} and #{second}"
end
do_something_useless( "apple", "banana") # => "You gave me apple and banana"
do_something_useless 1, 2# => "You gave me 1 and 2"
Function of the following code?
n=120 primes = Array.new for i in 0..n-2
primes[i] = i+2 end index = 0 while primes[index]**2 <= primes.last
prime = primes[index] primes = primes.select { |x| x == prime || x%prime != 0 } index += 1
end p primes
Question ?
Locking and Latching
Locking and Latching
Latching• Purpose
– exclusive access to memory structures
Locking• Purpose
– share the same resource if compatible
– enforce exclusive access if incompatible.
Locking and Latching
Latching• Jurisdiction
– temporary memory objects– B-Tree index
Locking• Jurisdiction
– database objects – tables, data blocks
Locking and Latching
Latching• Acquisition
– willing-to-wait – no-wait
Locking• Acquisition
– Null– row share– row exclusive– Share– share row exclusive– exclusive
Locking and Latching
Latching• Scope
– instance level– Information kept in memory– visible to the local instance
Locking• Scope
– database-level– Information kept in database– visible to all instances
accessing the database
Locking and Latching
Latching• Complexity
– Lightweight– Simple instructions– port specific
Locking• Complexity
– Heavyweight– series of instructions with
context switches
Locking and Latching
Latching• Duration
– briefly – microseconds
Locking• Duration
– an extended period of time– transactional duration
Locking and Latching
Latching• Queue
– not queued
Locking• Queue
– queued
Locking and Latching
Latching• Deadlock
– No deadlocks
Locking• Deadlock
– deadlocks
Thank you
Top Related