Ejemplo n.º 1
0
func NewWorker(options *WorkerOptions) *Worker {
	copied := *options
	options = &copied
	if options.ReapCount == 0 {
		options.ReapCount = 4
	}
	if options.ReportInterval == 0 {
		options.ReportInterval = 60 * time.Second
	}
	if options.LameDuckPeriod == 0 {
		options.LameDuckPeriod = 5 * time.Second
	}

	if fi, _ := os.Stat(options.TempDir); fi == nil || !fi.IsDir() {
		log.Fatalf("directory %s does not exist, or is not a dir", options.TempDir)
	}
	// TODO - check that we can do renames from temp to cache.

	cache := cba.NewStore(&options.StoreOptions)

	me := &Worker{
		content:    cache,
		pending:    NewPendingConnections(),
		rpcServer:  rpc.NewServer(),
		stats:      stats.NewServerStats(),
		options:    &copied,
		accepting:  true,
		canRestart: true,
	}
	me.stats.PhaseOrder = []string{"run", "fuse", "reap"}
	me.mirrors = NewWorkerMirrors(me)
	me.stopListener = make(chan int, 1)
	me.rpcServer.Register(me)
	return me
}
Ejemplo n.º 2
0
func (me *mirrorConnections) refreshStats() {
	me.stats = stats.NewServerStats()
	me.stats.PhaseOrder = []string{"run", "send", "remote", "filewait"}
}