Beispiel #1
0
func (c *Controller) addReplicaNoLock(newBackend types.Backend, address string, snapshot bool) error {
	if ok, err := c.canAdd(address); !ok {
		return err
	}

	if snapshot {
		uuid := util.UUID()

		if err := c.backend.Snapshot(uuid); err != nil {
			newBackend.Close()
			return err
		}
		if err := newBackend.Snapshot(uuid); err != nil {
			newBackend.Close()
			return err
		}
	}

	c.replicas = append(c.replicas, types.Replica{
		Address: address,
		Mode:    types.WO,
	})

	c.backend.AddBackend(address, newBackend)

	return nil
}
Beispiel #2
0
func (c *Controller) Snapshot(name string) (string, error) {
	c.Lock()
	defer c.Unlock()

	if name == "" {
		name = util.UUID()
	}

	return name, c.backend.Snapshot(name)
}
Beispiel #3
0
func (s *Server) SnapshotReplica(rw http.ResponseWriter, req *http.Request) error {
	var input SnapshotInput
	apiContext := api.GetApiContext(req)
	if err := apiContext.Read(&input); err != nil && err != io.EOF {
		return err
	}

	name := input.Name
	if name == "" {
		name = util.UUID()
	}

	return s.doOp(req, s.s.Snapshot(name))
}