Exemplo n.º 1
0
// Start a single disk subsystem
func Start(paths []string) (chan<- string, <-chan error, drivers.Driver) {
	ctrlChannel := make(chan string)
	errorChannel := make(chan error)

	// Soon to be user configurable, when Management API is available
	// we should remove "default" to something which is passed down
	// from configuration paramters
	var d donut.Donut
	var err error
	if len(paths) == 1 {
		d, err = donut.NewDonut("default", createNodeDiskMap(paths[0]))
		if err != nil {
			err = iodine.New(err, nil)
			log.Error.Println(err)
		}
	} else {
		d, err = donut.NewDonut("default", createNodeDiskMapFromSlice(paths))
		if err != nil {
			err = iodine.New(err, nil)
			log.Error.Println(err)
		}
	}
	s := new(donutDriver)
	s.donut = d
	s.paths = paths

	go start(ctrlChannel, errorChannel, s)
	return ctrlChannel, errorChannel, s
}
Exemplo n.º 2
0
func initialize(d *donutDriver) error {
	// Soon to be user configurable, when Management API is available
	// we should remove "default" to something which is passed down
	// from configuration paramters
	var err error
	d.donut, err = donut.NewDonut("default", createNodeDiskMap(d.paths))
	if err != nil {
		return iodine.New(err, nil)
	}
	buckets, err := d.donut.ListBuckets()
	if err != nil {
		return iodine.New(err, nil)
	}
	for bucketName, metadata := range buckets {
		d.lock.RLock()
		storedBucket := d.storedBuckets[bucketName]
		d.lock.RUnlock()
		if len(storedBucket.multiPartSession) == 0 {
			storedBucket.multiPartSession = make(map[string]multiPartSession)
		}
		if len(storedBucket.objectMetadata) == 0 {
			storedBucket.objectMetadata = make(map[string]drivers.ObjectMetadata)
		}
		if len(storedBucket.partMetadata) == 0 {
			storedBucket.partMetadata = make(map[string]drivers.PartMetadata)
		}
		storedBucket.bucketMetadata = drivers.BucketMetadata{
			Name:    metadata.Name,
			Created: metadata.Created,
			ACL:     drivers.BucketACL(metadata.ACL),
		}
		d.lock.Lock()
		d.storedBuckets[bucketName] = storedBucket
		d.lock.Unlock()
	}
	return nil
}