mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
Implement GetBucketACL - fixes #893
This commit is contained in:
@@ -23,7 +23,8 @@ type Command uint8
|
||||
const (
|
||||
// CmdNOOP does nothing. It is a default placeholder. Uninitialized variable of this type will point to NOOP command by default.
|
||||
CmdNOOP Command = iota
|
||||
// CmdSignalEnd gracefully ends current task. Never ending tasks (loop over) or Batched jobs will not take the next iteration, but may finish the current state to completion.
|
||||
// CmdSignalEnd gracefully ends current task. Never ending tasks (loop over) or Batched jobs will not take the next iteration,
|
||||
// but may finish the current state to completion.
|
||||
CmdSignalEnd
|
||||
// CmdSignalAbort ends the current task at hand immediately. It may still cleanup dangling issues quickly.
|
||||
CmdSignalAbort
|
||||
@@ -37,6 +38,7 @@ const (
|
||||
CmdPriorityMedium
|
||||
// CmdPriorityHigh is optimized for speed. This option is ideal for short lived tasks (like meta-data related) that are latency sensitive. Use this option wisely.
|
||||
CmdPriorityHigh
|
||||
// CmdPrioritySuper is an exclusive priority. All tasks with priority lower than Super (including High) are paused temporarily until this task completes. Anytime you consider using this priority level, please seek for approval.
|
||||
// CmdPrioritySuper is an exclusive priority. All tasks with priority lower than Super (including High) are paused
|
||||
// temporarily until this task completes. Anytime you consider using this priority level, please seek for approval.
|
||||
CmdPrioritySuper
|
||||
)
|
||||
|
||||
@@ -21,20 +21,18 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
/* NOTE:
|
||||
Task is a private entity. It is created and managed by TaskCtl
|
||||
entirely. Only TaskCtl and Handle objects are exposed outside.
|
||||
*/
|
||||
// NOTE: Task is a private entity. It is created and managed by TaskCtl
|
||||
// entirely. Only TaskCtl and Handle objects are exposed outside.
|
||||
|
||||
/* taskRef is a unique reference ID to a task. It is assigned by the
|
||||
TaskCtl during the creation of a task. All tasfRef variables are
|
||||
named "this". */
|
||||
// taskRef is a unique reference ID to a task. It is assigned by the
|
||||
// TaskCtl during the creation of a task. All tasfRef variables are
|
||||
// named "this".
|
||||
type taskRef *list.Element
|
||||
|
||||
/* Task is an abstract concept built on top of Go routines and
|
||||
channels. Tasks themselves are expected to co-operate and comply with
|
||||
the TaskCtl commands.
|
||||
*/
|
||||
// Task is an abstract concept built on top of Go routines and
|
||||
// channels. Tasks themselves are expected to co-operate and comply with
|
||||
// the TaskCtl commands.
|
||||
|
||||
type task struct {
|
||||
mutex *sync.Mutex
|
||||
|
||||
@@ -46,14 +44,13 @@ type task struct {
|
||||
closeCh chan taskRef // Channel to notify the TaskCtl about ending this task.
|
||||
}
|
||||
|
||||
/* NewTask creates a new task structure and returns a handle to
|
||||
it. Only the task controller has access to the task structure. The
|
||||
caller routine only receives a handle to its task structure. Task
|
||||
handle is like a reference to task self. Caller is expected to listen
|
||||
for commands from the task controller and comply with it
|
||||
co-operatively.
|
||||
this: Task reference is unique identifier assigned by the TaskCtl.
|
||||
name: Free form name of the task. Eg. "Late Night Disk Scrubber". */
|
||||
// NewTask creates a new task structure and returns a handle to
|
||||
// it. Only the task controller has access to the task structure. The
|
||||
// caller routine only receives a handle to its task structure. Task
|
||||
// handle is like a reference to task self. Caller is expected to listen
|
||||
// for commands from the task controller and comply with it co-operatively.
|
||||
// this: Task reference is unique identifier assigned by the TaskCtl.
|
||||
// name: Free form name of the task. Eg. "Late Night Disk Scrubber".
|
||||
func newTask(name string) task {
|
||||
return task{
|
||||
// this: Is set by the TaskCtl's NewTask function.
|
||||
|
||||
@@ -29,7 +29,8 @@ type TaskCtl struct {
|
||||
tasks *list.List
|
||||
}
|
||||
|
||||
// New creates a new TaskCtl to create and control a collection of tasks. Single application can create multiple task controllers to manage different set of tasks separately.
|
||||
// New creates a new TaskCtl to create and control a collection of tasks.
|
||||
// Single application can create multiple task controllers to manage different set of tasks separately.
|
||||
func New(name string) *TaskCtl {
|
||||
return &TaskCtl{
|
||||
mutex: &sync.Mutex{},
|
||||
@@ -37,7 +38,10 @@ func New(name string) *TaskCtl {
|
||||
}
|
||||
}
|
||||
|
||||
// NewTask creates a new task structure and returns a handle to it. Only the task controller has access to the task structure. The caller routine only receives a handle to its task structure. Task handle is like a reference to task self. Caller is expected to listen for commands from the task controller and comply with it co-operatively.
|
||||
// NewTask creates a new task structure and returns a handle to it. Only the task controller
|
||||
// has access to the task structure. The caller routine only receives a handle to its task structure.
|
||||
// Task handle is like a reference to task self. Caller is expected to listen for commands from
|
||||
// the task controller and comply with it co-operatively.
|
||||
func (tc *TaskCtl) NewTask(name string) Handle {
|
||||
tc.mutex.Lock()
|
||||
defer tc.mutex.Unlock()
|
||||
@@ -45,7 +49,7 @@ func (tc *TaskCtl) NewTask(name string) Handle {
|
||||
// Create a new task.
|
||||
tsk := newTask(name)
|
||||
|
||||
//Register this task in the TaskCtl's tasklist and save the reference.
|
||||
// Register this task in the TaskCtl's tasklist and save the reference.
|
||||
tsk.this = tc.tasks.PushBack(tsk)
|
||||
|
||||
// Free task from the tasklist upon close call.
|
||||
@@ -79,7 +83,10 @@ func (tc *TaskCtl) Shutdown() {
|
||||
wg.Add(1)
|
||||
thisTask := e.Value.(task) // Make a local copy for go routine.
|
||||
// End tasks in background. Flow of events from here is as follows: thisTask.handle.Close() -> tc.NewTask() -> this.task.close().
|
||||
go func() { thisTask.getHandle().Close(); wg.Done() }()
|
||||
go func() {
|
||||
thisTask.getHandle().Close()
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
wg.Wait() // Wait for all tasks to end gracefully.
|
||||
@@ -105,10 +112,10 @@ func (tc *TaskCtl) Suspend() bool {
|
||||
locTask := e.Value.(task) // Make a local copy for go routine.
|
||||
locI := i // local i
|
||||
// Suspend a task in background.
|
||||
go func() {
|
||||
go func(locI int) {
|
||||
defer wg.Done()
|
||||
statusAll[locI] = locTask.command(CmdSignalSuspend)
|
||||
}()
|
||||
}(locI)
|
||||
i++
|
||||
}
|
||||
|
||||
@@ -139,10 +146,10 @@ func (tc *TaskCtl) Resume() bool {
|
||||
locTask := e.Value.(task) // Make a local copy for go routine.
|
||||
locI := i // local i
|
||||
// Resume a task in background.
|
||||
go func() {
|
||||
go func(locI int) {
|
||||
defer wg.Done()
|
||||
statusAll[locI] = locTask.command(CmdSignalResume)
|
||||
}()
|
||||
}(locI)
|
||||
i++
|
||||
}
|
||||
wg.Wait() // Wait for all tasks to resume.
|
||||
|
||||
Reference in New Issue
Block a user