OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResourceGrantPolicy.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
20 
21 namespace ExecutorResourceMgr_Namespace {
22 
29 
31  size_t constant;
34  ResourceGrantSizeInfo(const size_t constant) : constant(constant) {}
35  ResourceGrantSizeInfo(const double ratio_to_total) : ratio_to_total(ratio_to_total) {}
36 };
37 
51 
53 
57 
73  size_t get_grant_quantity(const size_t total_resource_quantity) const;
74 
97  size_t get_grant_quantity(const size_t total_resource_quantity,
98  const bool cap_at_total_available) const;
99 
100  std::string to_string() const;
101 };
102 
110 ResourceGrantPolicy gen_unlimited_resource_grant_policy(
111  const ResourceSubtype resource_subtype);
112 
120 ResourceGrantPolicy gen_constant_resource_grant_policy(
121  const ResourceSubtype resource_subtype,
122  size_t constant_grant);
123 
132 ResourceGrantPolicy gen_ratio_resource_grant_policy(
133  const ResourceSubtype resource_subtype,
134  const double ratio_grant);
135 
154 };
155 
157  const ResourceConcurrencyPolicy& resource_concurrency_policy);
158 
177 
184 
191 
193 
198  : resource_type(resource_type)
199  , concurrency_policy(concurrency_policy)
200  , oversubscription_concurrency_policy(oversubscription_concurrency_policy) {}
201 
202  bool operator==(const ConcurrentResourceGrantPolicy& rhs) const;
203 
204  std::string to_string() const;
205 };
206 
207 } // namespace ExecutorResourceMgr_Namespace
bool operator==(const ConcurrentResourceGrantPolicy &rhs) const
ResourceConcurrencyPolicy
Specifies whether grants for a specified resource can be made concurrently (ALLOW_CONCURRENT_REQEUSTS...
size_t get_grant_quantity(const size_t total_resource_quantity) const
Used to calculate the maximum quantity that can be granted of the resource.
ResourceType resource_type
The type of a resource this concurrent resource grant policy pertains to.
ResourceGrantPolicySizeType
The sizing type for a ResourceGrantPolicy of a given resource type, specifying whether resource grant...
ResourceType
Stores the resource type for a ExecutorResourcePool request.
Specifies the policies for resource grants in the presence of other requests, both under situations o...
ResourceGrantPolicy gen_unlimited_resource_grant_policy(const ResourceSubtype resource_subtype)
Generates a ResourceGrantPolicy with ResourceGrantPolicySizeType::UNLIMITED
ResourceSubtype
Stores the resource sub-type for a ExecutorResourcePool request.
ResourceConcurrencyPolicy concurrency_policy
The grant policy in effect when there are concurrent requests for the resource specified by resource_...
std::string get_resouce_concurrency_policy_string(const ResourceConcurrencyPolicy &resource_concurrency_policy)
ResourceGrantPolicy gen_ratio_resource_grant_policy(const ResourceSubtype resource_subtype, const double ratio_grant)
Generates a ResourceGrantPolicy with ResourceGrantPolicySizeType::RATIO_TO_TOTAL
ResourceConcurrencyPolicy oversubscription_concurrency_policy
The grant policy in effect when there are concurrent requests for the resource specified by resource_...
Specifies the policy for granting a resource of a specific ResourceSubtype. Note that this policy onl...
ResourceGrantPolicy gen_constant_resource_grant_policy(const ResourceSubtype resource_subtype, const size_t constant_grant)
Generates a ResourceGrantPolicy with ResourceGrantPolicySizeType::CONSTANT
ConcurrentResourceGrantPolicy(const ResourceType resource_type, const ResourceConcurrencyPolicy concurrency_policy, const ResourceConcurrencyPolicy oversubscription_concurrency_policy)