forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleResourceManager.cxx
More file actions
42 lines (39 loc) · 1.4 KB
/
SimpleResourceManager.cxx
File metadata and controls
42 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "SimpleResourceManager.h"
#include "ComputingResource.h"
#include <exception>
#include <stdexcept>
namespace o2
{
namespace framework
{
/// The simplest implementation of this allocates mMaxPorts ports starting from
/// the mInitialPort. For now we still consider everything running on a single
/// machine.
std::vector<ComputingResource> SimpleResourceManager::getAvailableResources() {
std::vector<ComputingResource> result;
if ((mInitialPort < 1025) || ((mInitialPort + mMaxPorts) > 65535)) {
throw std::runtime_error("Invalid port number. Valid port range is 1025-65535");
}
// We insert them backwards for compatibility with the previous
// way of assigning them.
for (size_t i = mInitialPort + mMaxPorts - 1; i >= mInitialPort; --i) {
result.push_back(ComputingResource{
1.0,
1.0,
"localhost",
static_cast<unsigned short>(i)
});
};
return result;
}
} // namespace framework
} // namespace o2