2016-10-11 03:50:27 -04:00
|
|
|
/*
|
2017-03-18 14:28:41 -04:00
|
|
|
* Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
|
2016-10-11 03:50:27 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cmd
|
|
|
|
|
2017-02-04 02:27:50 -05:00
|
|
|
import "time"
|
2016-10-11 03:50:27 -04:00
|
|
|
|
|
|
|
// SystemLockState - Structure to fill the lock state of entire object storage.
|
|
|
|
// That is the total locks held, total calls blocked on locks and state of all the locks for the entire system.
|
|
|
|
type SystemLockState struct {
|
|
|
|
TotalLocks int64 `json:"totalLocks"`
|
|
|
|
// Count of operations which are blocked waiting for the lock to
|
|
|
|
// be released.
|
|
|
|
TotalBlockedLocks int64 `json:"totalBlockedLocks"`
|
|
|
|
// Count of operations which has successfully acquired the lock but
|
2017-01-04 02:39:22 -05:00
|
|
|
// hasn't unlocked yet (operation in progress).
|
2016-10-11 03:50:27 -04:00
|
|
|
TotalAcquiredLocks int64 `json:"totalAcquiredLocks"`
|
|
|
|
LocksInfoPerObject []VolumeLockInfo `json:"locksInfoPerObject"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// VolumeLockInfo - Structure to contain the lock state info for volume, path pair.
|
|
|
|
type VolumeLockInfo struct {
|
|
|
|
Bucket string `json:"bucket"`
|
|
|
|
Object string `json:"object"`
|
2017-01-13 17:25:34 -05:00
|
|
|
|
2016-10-11 03:50:27 -04:00
|
|
|
// All locks blocked + running for given <volume,path> pair.
|
2017-01-13 17:25:34 -05:00
|
|
|
LocksOnObject int64 `json:"-"`
|
2016-10-11 03:50:27 -04:00
|
|
|
// Count of operations which has successfully acquired the lock
|
|
|
|
// but hasn't unlocked yet( operation in progress).
|
2017-01-13 17:25:34 -05:00
|
|
|
LocksAcquiredOnObject int64 `json:"-"`
|
2016-10-11 03:50:27 -04:00
|
|
|
// Count of operations which are blocked waiting for the lock
|
|
|
|
// to be released.
|
2017-01-13 17:25:34 -05:00
|
|
|
TotalBlockedLocks int64 `json:"-"`
|
|
|
|
|
|
|
|
// Count of all read locks
|
|
|
|
TotalReadLocks int64 `json:"readLocks"`
|
|
|
|
// Count of all write locks
|
|
|
|
TotalWriteLocks int64 `json:"writeLocks"`
|
2016-10-11 03:50:27 -04:00
|
|
|
// State information containing state of the locks for all operations
|
|
|
|
// on given <volume,path> pair.
|
2017-01-13 17:25:34 -05:00
|
|
|
LockDetailsOnObject []OpsLockState `json:"lockOwners"`
|
2016-10-11 03:50:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// OpsLockState - structure to fill in state information of the lock.
|
|
|
|
// structure to fill in status information for each operation with given operation ID.
|
|
|
|
type OpsLockState struct {
|
2017-04-15 14:40:01 -04:00
|
|
|
OperationID string `json:"id"` // String containing operation ID.
|
|
|
|
LockSource string `json:"source"` // Operation type (GetObject, PutObject...)
|
|
|
|
LockType lockType `json:"type"` // Lock type (RLock, WLock)
|
|
|
|
Status statusType `json:"status"` // Status can be Running/Ready/Blocked.
|
|
|
|
Since time.Time `json:"since"` // Time when the lock was initially held.
|
2016-10-11 03:50:27 -04:00
|
|
|
}
|
|
|
|
|
2017-02-01 14:17:30 -05:00
|
|
|
// listLocksInfo - Fetches locks held on bucket, matching prefix held for longer than duration.
|
|
|
|
func listLocksInfo(bucket, prefix string, duration time.Duration) []VolumeLockInfo {
|
2018-03-14 15:01:47 -04:00
|
|
|
locksInfo, _ := newObjectLayerFn().ListLocks(nil, bucket, prefix, duration)
|
2018-01-12 23:34:52 -05:00
|
|
|
return locksInfo
|
2017-01-04 02:39:22 -05:00
|
|
|
}
|