func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.GenericResponse) error {
	if done, err := n.srv.forward("Node.UpdateAlloc", args, args, reply); done {
		return err
	}
	defer metrics.MeasureSince([]string{"nomad", "client", "update_alloc"}, time.Now())

	// Ensure at least a single alloc
	if len(args.Alloc) == 0 {
		return fmt.Errorf("must update at least one allocation")
	}

	// Add this to the batch
	n.updatesLock.Lock()
	n.updates = append(n.updates, args.Alloc...)

	// Start a new batch if none
	future := n.updateFuture
	if future == nil {
		future = NewBatchFuture()
		n.updateFuture = future
		n.updateTimer = time.AfterFunc(batchUpdateInterval, func() {
			// Get the pending updates
			n.updatesLock.Lock()
			updates := n.updates
			future := n.updateFuture
			n.updates = nil
			n.updateFuture = nil
			n.updateTimer = nil
			n.updatesLock.Unlock()

			// Perform the batch update
			n.batchUpdate(future, updates)
		})
	}
	n.updatesLock.Unlock()

	// Wait for the future
	if err := future.Wait(); err != nil {
		return err
	}

	// Setup the response
	reply.Index = future.Index()
	return nil
}
// UpdateAlloc is used to update the client status of an allocation
UpdateAlloc is used to update the client status of an allocation
// UpdateAlloc is used to update the client status of an allocation
func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.GenericResponse) error {
	if done, err := n.srv.forward("Node.UpdateAlloc", args, args, reply); done {
		return err
	}
	defer metrics.MeasureSince([]string{"nomad", "client", "update_alloc"}, time.Now())
	if len(args.Alloc) == 0 {
		return fmt.Errorf("must update at least one allocation")
	}
	n.updatesLock.Lock()
	n.updates = append(n.updates, args.Alloc...)
	future := n.updateFuture
	if future == nil {
		future = NewBatchFuture()
		n.updateFuture = future
		n.updateTimer = time.AfterFunc(batchUpdateInterval, func() {
			n.updatesLock.Lock()
			updates := n.updates
			future := n.updateFuture
			n.updates = nil
			n.updateFuture = nil
			n.updateTimer = nil
			n.updatesLock.Unlock()
			n.batchUpdate(future, updates)
		})
	}
	n.updatesLock.Unlock()
	if err := future.Wait(); err != nil {
		return err
	}
	reply.Index = future.Index()
	return nil
}
func ( n * Node ) UpdateAlloc ( args * structs . AllocUpdateRequest , reply * structs . GenericResponse ) error { if done , err := n . srv . forward ( " " , args , args , reply ) ; done { return err } defer metrics . MeasureSince ( [ ] string { " " , " " , " " } , time . Now ( ) ) if len ( args . Alloc ) == 0 { return fmt . Errorf ( " " ) } n . updatesLock . Lock ( ) n . updates = append ( n . updates , args . Alloc ... ) future := n . updateFuture if future == nil { future = NewBatchFuture ( ) n . updateFuture = future n . updateTimer = time . AfterFunc ( batchUpdateInterval , func ( ) { n . updatesLock . Lock ( ) updates := n . updates future := n . updateFuture n . updates = nil n . updateFuture = nil n . updateTimer = nil n . updatesLock . Unlock ( ) n . batchUpdate ( future , updates ) } ) } n . updatesLock . Unlock ( ) if err := future . Wait ( ) ; err != nil { return err } reply . Index = future . Index ( ) return nil }
UpdateAlloc is used to update the client status of an allocation
UpdateAlloc is used to update the client status of an allocation
// Ensure at least a single alloc // Add this to the batch // Start a new batch if none // Get the pending updates // Perform the batch update // Wait for the future // Setup the response