github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/api/apc/query.go (about)

     1  // Package apc: API control messages and constants
     2  /*
     3   * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package apc
     6  
     7  // URL Query "?name1=val1&name2=..."
     8  // User query params.
     9  const (
    10  	QparamWhat = "what" // "smap" | "bmd" | "config" | "stats" | "xaction" ... (enum below)
    11  
    12  	QparamProps = "props" // e.g. "checksum, size"|"atime, size"|"cached"|"bucket, size"| ...
    13  
    14  	QparamUUID    = "uuid"     // xaction
    15  	QparamJobID   = "jobid"    // job
    16  	QparamETLName = "etl_name" // etl
    17  
    18  	QparamRegex      = "regex"       // dsort: list regex
    19  	QparamOnlyActive = "only_active" // dsort: list only active
    20  
    21  	// remove existing custom keys and store new custom metadata
    22  	// NOTE: making an s/_/-/ naming exception because of the namesake CLI usage
    23  	QparamNewCustom = "set-new-custom"
    24  
    25  	// Main bucket query params.
    26  	QparamProvider  = "provider" // aka backend provider or, simply, backend
    27  	QparamNamespace = "namespace"
    28  
    29  	// e.g., usage: copy bucket
    30  	QparamBckTo = "bck_to"
    31  
    32  	// Do not add remote bucket to cluster's BMD e.g. when checking existence
    33  	// via api.HeadBucket
    34  	// By default, when existence of a remote buckets is confirmed the bucket's
    35  	// metadata gets automatically (and transactionally) added to the cluster's BMD.
    36  	// This query parameter can be used to override the default behavior.
    37  	QparamDontAddRemote = "dont_add_remote_bck_md"
    38  
    39  	// Add remote bucket to BMD _unconditionally_ and without executing HEAD request
    40  	// (to check access and load the bucket's properties)
    41  	// NOTE: usage is limited to setting up bucket properties with alternative
    42  	// profile and/or endpoint
    43  	// See also:
    44  	// - `LsDontHeadRemote`
    45  	// - docs/bucket.md
    46  	// - docs/cli/aws_profile_endpoint.md
    47  	QparamDontHeadRemote = "dont_head_remote_bck"
    48  
    49  	// When evicting, keep remote bucket in BMD (i.e., evict data only)
    50  	QparamKeepRemote = "keep_bck_md"
    51  
    52  	// (api.GetBucketInfo)
    53  	// NOTE: non-empty value indicates api.GetBucketInfo; "true" value further requires "with remote obj-s"
    54  	QparamBinfoWithOrWithoutRemote = "bsumm_remote"
    55  
    56  	// "presence" in a given cluster shall not be be confused with "existence" (possibly, remote).
    57  	// See also:
    58  	// - Flt* enum below
    59  	// - ListObjsMsg flags, docs/providers.md (for terminology)
    60  	QparamFltPresence = "presence"
    61  
    62  	// APPEND(object) operation - QparamAppendType enum below
    63  	QparamAppendType   = "append_type"
    64  	QparamAppendHandle = "append_handle"
    65  
    66  	// HTTP bucket support.
    67  	QparamOrigURL = "original_url"
    68  
    69  	// Get logs
    70  	QparamLogSev  = "severity" // see { LogInfo, ...} enum
    71  	QparamLogOff  = "offset"
    72  	QparamAllLogs = "all"
    73  
    74  	// The following 4 (four) QparamArch* parameters are all intended for usage with sharded datasets,
    75  	// whereby the shards are (.tar, .tgz (or .tar.gz), .zip, and/or .tar.lz4) formatted objects.
    76  	//
    77  	// For the most recently updated list of supported serialization formats, please see cmn/archive package.
    78  	//
    79  	// "archpath" and "archmime", respectively, specify archived pathname and expected format (mime type)
    80  	// of the containing shard; the latter is especially usable with non-standard shard name extensions;
    81  	QparamArchpath = "archpath"
    82  	QparamArchmime = "archmime"
    83  
    84  	// In addition, the following two closely related parameters can be used to select multiple matching files
    85  	// from a given shard.
    86  	//
    87  	// In particular, "archregx" specifies prefix, suffix, WebDataset key, _or_ general-purpose regular expression
    88  	// that can be used to match archived filenames, and select possibly multiple files
    89  	// (that will be then archived as a TAR and returned in one shot);
    90  	QparamArchregx = "archregx"
    91  
    92  	// "archmode", on the other hand, tells aistore whether to interpret "archregx" (above) as a
    93  	// a general-purpose regular expression or, alternatively, use it for a simple and fast string comparison;
    94  	// the latter is further formalized as `MatchMode` enum in the cmn/archive package,
    95  	// with enumerated values including: "regexp", "prefix", "suffix", "substr", "wdskey".
    96  	//
    97  	// for example:
    98  	// - given a shard containing (subdir/aaa.jpg, subdir/aaa.json, subdir/bbb.jpg, subdir/bbb.json, ...)
    99  	//   and "wdskey" = "subdir/aaa", aistore will match and return (subdir/aaa.jpg, subdir/aaa.json).
   100  	QparamArchmode = "archmode" // see `MatchMode` enum in cmn/archive/read
   101  
   102  	// See also:
   103  	// - https://github.com/webdataset/webdataset                     - for WebDataset
   104  	// - docs/cli/archive.md                                          - for usage and examples
   105  	// - docs/cli/archive.md#get-archived-content-multiple-selection  - multi-selection usage and examples
   106  	// - cmn/archive                                                  - the most recently updated "archmode" enumeration
   107  
   108  	// Skip loading existing object's metadata, in part to
   109  	// compare its Checksum and update its existing Version (if exists).
   110  	// Can be used to reduce PUT latency when:
   111  	// - we massively write new content into a bucket, and/or
   112  	// - we simply don't care.
   113  	QparamSkipVC = "skip_vc"
   114  
   115  	// force operation
   116  	// used to overcome certain restrictions, e.g.:
   117  	// - shutdown the primary and the entire cluster
   118  	// - attach invalid mountpath
   119  	QparamForce = "frc"
   120  
   121  	// same as `Versioning.ValidateWarmGet` (cluster config and bucket props)
   122  	// - usage: GET and (copy|transform) x (bucket|multi-object) operations
   123  	// - implies remote backend
   124  	QparamLatestVer = "latest-ver"
   125  
   126  	// in addition to the latest-ver (above), also entails removing remotely
   127  	// deleted objects
   128  	QparamSync = "synchronize"
   129  
   130  	// when true, skip nlog.Error and friends
   131  	// (to opt-out logging too many messages and/or benign warnings)
   132  	QparamSilent = "sln"
   133  
   134  	// (see api.AttachMountpath vs. LocalConfig.FSP)
   135  	QparamMpathLabel = "mountpath_label"
   136  )
   137  
   138  // QparamFltPresence enum.
   139  //
   140  // Descibes both buckets and objects with respect to their existence/presence (or non-existence/non-presence)
   141  // in AIS cluster.
   142  //
   143  // "FltPresent*" refers to availability ("presence") in the cluster. For details, see the values and comments below.
   144  //
   145  // Remote object or bucket that is currently not present can still be accessed with
   146  // the very first access making it "present", etc.
   147  const (
   148  	FltExists         = iota // (object | bucket) exists inside and/or outside cluster
   149  	FltExistsNoProps         // same as above but no need to return props/info
   150  	FltPresent               // bucket: is present | object: present and properly located
   151  	FltPresentNoProps        // same as above but no need to return props/info
   152  	FltPresentCluster        // objects: present anywhere/anyhow _in_ the cluster as: replica, ec-slices, misplaced
   153  	FltExistsOutside         // not present - exists _outside_ cluster (NOTE: currently, only list-buckets)
   154  )
   155  
   156  func IsFltPresent(v int) bool {
   157  	return v == FltPresent || v == FltPresentNoProps || v == FltPresentCluster
   158  }
   159  
   160  func IsFltNoProps(v int) bool {
   161  	return v == FltExistsNoProps || v == FltPresentNoProps
   162  }
   163  
   164  // QparamAppendType enum.
   165  const (
   166  	AppendOp = "append"
   167  	FlushOp  = "flush"
   168  )
   169  
   170  // health
   171  const (
   172  	QparamHealthReadiness = "readiness" // to be used by external watchdogs (e.g. K8s)
   173  	QparamAskPrimary      = "apr"       // true: the caller is directing health request to primary
   174  	QparamPrimaryReadyReb = "prr"       // true: check whether primary is ready to start rebalancing cluster
   175  )
   176  
   177  // Internal query params.
   178  const (
   179  	QparamProxyID          = "pid" // ID of the redirecting proxy.
   180  	QparamPrimaryCandidate = "can" // ID of the candidate for the primary proxy.
   181  	QparamPrepare          = "prp" // true: request belongs to the "prepare" phase of the primary proxy election
   182  	QparamNonElectable     = "nel" // true: proxy is non-electable for the primary role
   183  	QparamUnixTime         = "utm" // Unix time since 01/01/70 UTC (nanoseconds)
   184  	QparamIsGFNRequest     = "gfn" // true if the request is a Get-From-Neighbor
   185  	QparamRebStatus        = "rbs" // true: get detailed rebalancing status
   186  	QparamRebData          = "rbd" // true: get EC rebalance data (pulling data if push way fails)
   187  	QparamClusterInfo      = "cii" // true: /Health to return cluster info and status
   188  	QparamOWT              = "owt" // object write transaction enum { OwtPut, ..., OwtGet* }
   189  
   190  	QparamDontResilver = "dntres" // true: do not resilver data off of mountpaths that are being disabled/detached
   191  
   192  	// dsort
   193  	QparamTotalCompressedSize       = "tcs"
   194  	QparamTotalInputShardsExtracted = "tise"
   195  	QparamTotalUncompressedSize     = "tunc"
   196  
   197  	// 2PC transactions - control plane
   198  	QparamNetwTimeout  = "xnt" // [begin, start-commit] timeout
   199  	QparamHostTimeout  = "xht" // [begin, txn-done] timeout
   200  	QparamWaitMetasync = "xwm" // true: wait for metasync (used only when there's an alternative)
   201  
   202  	// promote
   203  	QparamConfirmFshare = "confirm-fshr" // confirm file share
   204  	QparamActNoXact     = "act-no-xact"  // execute synchronously, i.e. without xaction
   205  
   206  	// Notification target's node ID (usually, the node that initiates the operation).
   207  	QparamNotifyMe = "nft"
   208  )
   209  
   210  // QparamWhat enum.
   211  const (
   212  	// cluster meta
   213  	WhatSmap = "smap"
   214  	WhatBMD  = "bmd"
   215  	// config
   216  	WhatNodeConfig    = "config" // query specific node for (cluster config + overrides, local config)
   217  	WhatClusterConfig = "cluster_config"
   218  
   219  	// stats and status
   220  	WhatNodeStatsV322          = "stats"  // [ backward compatibility ]
   221  	WhatNodeStatsAndStatusV322 = "status" // [ ditto ]
   222  	WhatNodeStats              = "node_stats"
   223  	WhatNodeStatsAndStatus     = "node_status"
   224  
   225  	WhatMetricNames = "metrics"
   226  	WhatDiskStats   = "disk"
   227  	// assorted
   228  	WhatMountpaths = "mountpaths"
   229  	WhatRemoteAIS  = "remote"
   230  	WhatSmapVote   = "smapvote"
   231  	WhatSysInfo    = "sysinfo"
   232  	WhatTargetIPs  = "target_ips" // comma-separated list of all target IPs (compare w/ GetWhatSnode)
   233  	// log
   234  	WhatLog = "log"
   235  	// xactions
   236  	WhatOneXactStatus   = "status"      // IC status by uuid (returns a single matching xaction or none)
   237  	WhatAllXactStatus   = "status_all"  // ditto - all matching xactions
   238  	WhatXactStats       = "getxstats"   // stats: xaction by uuid
   239  	WhatQueryXactStats  = "qryxstats"   // stats: all matching xactions
   240  	WhatAllRunningXacts = "running_all" // e.g. e.g.: put-copies[D-ViE6HEL_j] list[H96Y7bhR2s] ...
   241  	// internal
   242  	WhatSnode    = "snode"
   243  	WhatICBundle = "ic_bundle"
   244  )
   245  
   246  // QparamLogSev enum.
   247  const (
   248  	LogInfo = "info"
   249  	LogWarn = "warning"
   250  	LogErr  = "error"
   251  )