探索 Starfish:分布式队列与 MapReduce 的实践指南
1. Starfish 分布式队列服务
Starfish 在分布式队列服务方面表现出色,它并非该领域唯一的工具,但却是较易使用的系统之一。下面我们通过一个简单示例来展示如何使用 Starfish 创建一个分布式队列服务。
1.1 服务器端代码
# If we don't make sure there is at least 1
# thing in the ARGV array an Exception will be raised!
# This has to happen before we require 'starfish'
ARGV.unshift('server.rb')
require 'rubygems'
require 'starfish'
require 'fileutils'
class TaskServer
def each(&block)
Dir.glob(File.join(File.dirname(__FILE__),
'tasks', '*.task')).each do |file_path|
yield Task.new(file_path)
end
end
end
class Task
include DRbUndumped
attr_accessor :file_path
def initialize(file_path)
self.file_path = file_path
end
超级会员免费看
订阅专栏 解锁全文
1479

被折叠的 条评论
为什么被折叠?



