Skip to content

Commit

Permalink
calling it a night -- bumping to version 0.2.0 -- set timeouts for Re…
Browse files Browse the repository at this point in the history
…stClient requests, and put some light validation on S3Store configuration
  • Loading branch information
jashkenas committed Sep 17, 2009
1 parent ea9fdb9 commit 7acbc49
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cloud-crowd.gemspec
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'cloud-crowd'
s.version = '0.1.1' # Keep version in sync with cloud-cloud.rb
s.date = '2009-09-15'
s.version = '0.2.0' # Keep version in sync with cloud-cloud.rb
s.date = '2009-09-17'

s.homepage = "http://wiki.github.com/documentcloud/cloud-crowd"
s.summary = "Parallel Processing for the Rest of Us"
Expand Down
20 changes: 15 additions & 5 deletions lib/cloud-crowd.rb
Expand Up @@ -43,7 +43,7 @@ module CloudCrowd
autoload :WorkUnit, 'cloud_crowd/models'

# Keep this version in sync with the gemspec.
VERSION = '0.1.1'
VERSION = '0.2.0'

# Increment the schema version when there's a backwards incompatible change.
SCHEMA_VERSION = 2
Expand Down Expand Up @@ -104,10 +104,20 @@ def configure_database(config_path, validate_schema=true)
# Get a reference to the central server, including authentication if
# configured.
def central_server
return @central_server if @central_server
params = [CloudCrowd.config[:central_server]]
params += [CloudCrowd.config[:login], CloudCrowd.config[:password]] if CloudCrowd.config[:http_authentication]
@central_server = RestClient::Resource.new(*params)
@central_server ||= RestClient::Resource.new(CloudCrowd.config[:central_server], CloudCrowd.client_options)
end

# The standard RestClient options for the central server talking to nodes,
# as well as the other way around. There's a timeout of 5 seconds to open
# a connection, and a timeout of 30 to finish reading it.
def client_options
return @client_options if @client_options
@client_options = {:timeout => 30, :open_timeout => 5}
if CloudCrowd.config[:http_authentication]
@client_options[:user] = CloudCrowd.config[:login]
@client_options[:password] = CloudCrowd.config[:password]
end
@client_options
end

# Return the displayable status name of an internal CloudCrowd status number.
Expand Down
2 changes: 2 additions & 0 deletions lib/cloud_crowd/asset_store/s3_store.rb
Expand Up @@ -10,6 +10,8 @@ def setup
@use_auth = CloudCrowd.config[:s3_authentication]
bucket_name = CloudCrowd.config[:s3_bucket]
key, secret = CloudCrowd.config[:aws_access_key], CloudCrowd.config[:aws_secret_key]
valid_conf = [bucket_name, key, secret].all? {|s| s.is_a? String }
raise Error::MissingConfiguration, "An S3 account must be configured in 'config.yml' before 's3' storage can be used" unless valid_conf
protocol = @use_auth ? 'https' : 'http'
port = @use_auth ? 443 : 80
@s3 = RightAws::S3.new(key, secret, :protocol => protocol, :port => port)
Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_crowd/command_line.rb
Expand Up @@ -92,8 +92,8 @@ def run_install
install_path = ARGV.shift || '.'
FileUtils.mkdir_p install_path unless File.exists?(install_path)
install_file "#{CC_ROOT}/config/config.example.yml", "#{install_path}/config.yml"
install_file "#{CC_ROOT}/config/database.example.yml", "#{install_path}/database.yml"
install_file "#{CC_ROOT}/config/config.example.ru", "#{install_path}/config.ru"
install_file "#{CC_ROOT}/config/database.example.yml", "#{install_path}/database.yml"
install_file "#{CC_ROOT}/actions", "#{install_path}/actions", true
end

Expand Down
5 changes: 5 additions & 0 deletions lib/cloud_crowd/exceptions.rb
Expand Up @@ -25,6 +25,11 @@ class StorageNotWritable < Error
class StatusUnspecified < Error
end

# MissingConfiguration is raised when we're trying to run a method that
# needs configuration not present in config.yml.
class MissingConfiguration < Error
end

end

end
5 changes: 1 addition & 4 deletions lib/cloud_crowd/models/node_record.rb
Expand Up @@ -59,10 +59,7 @@ def url
# Keep a RestClient::Resource handy for contacting the Node, including
# HTTP authentication, if configured.
def node
return @node if @node
params = [url]
params += [CloudCrowd.config[:login], CloudCrowd.config[:password]] if CloudCrowd.config[:http_authentication]
@node = RestClient::Resource.new(*params)
@node ||= RestClient::Resource.new(url, CloudCrowd.client_options)
end

# The printable status of the Node.
Expand Down

0 comments on commit 7acbc49

Please sign in to comment.