xrootd
Loading...
Searching...
No Matches
XrdEcConfig.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN)
3// Author: Michal Simon <michal.simon@cern.ch>
4//------------------------------------------------------------------------------
5// This file is part of the XRootD software suite.
6//
7// XRootD is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// XRootD is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
19//
20// In applying this licence, CERN does not waive the privileges and immunities
21// granted to it by virtue of its status as an Intergovernmental Organization
22// or submit itself to any jurisdiction.
23//------------------------------------------------------------------------------
24
25#ifndef SRC_XRDEC_XRDECCONFIG_HH_
26#define SRC_XRDEC_XRDECCONFIG_HH_
27
29#include "XrdEc/XrdEcObjCfg.hh"
30
31#include <string>
32#include <unordered_map>
33
34namespace XrdEc
35{
36 //---------------------------------------------------------------------------
38 //---------------------------------------------------------------------------
39 class Config
40 {
41 public:
42
43 //-----------------------------------------------------------------------
45 //-----------------------------------------------------------------------
46 static Config& Instance()
47 {
48 static Config config;
49 return config;
50 }
51
52 //-----------------------------------------------------------------------
54 //-----------------------------------------------------------------------
56 {
57 std::string key;
58 key += std::to_string( objcfg.nbchunks );
59 key += ':';
60 key += std::to_string( objcfg.nbparity );
61 key += '-';
62 key += std::to_string( uint8_t( objcfg.datasize ) );
63
64 std::unique_lock<std::mutex> lck( mtx );
65 auto itr = redundancies.find( key );
66 if( itr == redundancies.end() )
67 {
68 auto p = redundancies.emplace( std::piecewise_construct,
69 std::forward_as_tuple(key),
70 std::forward_as_tuple(objcfg) );
71 return p.first->second;
72 }
73 else
74 return itr->second;
75 }
76
78
79 private:
80
81 std::unordered_map<std::string, RedundancyProvider> redundancies;
82 std::mutex mtx;
83
84 //-----------------------------------------------------------------------
86 //-----------------------------------------------------------------------
88 {
89 }
90
91 Config( const Config& ) = delete; //< Copy constructor
92 Config( Config&& ) = delete; //< Move constructor
93 Config& operator=( const Config& ) = delete; //< Move assigment operator
94 Config& operator=( Config&& ) = delete; //< Copy assigment operator
95 };
96}
97
98
99#endif /* SRC_XRDEC_XRDECCONFIG_HH_ */
Class for computing parities and recovering data.
Global configuration for the EC module.
Definition XrdEcConfig.hh:40
Config()
Constructor.
Definition XrdEcConfig.hh:87
Config(Config &&)=delete
Config & operator=(const Config &)=delete
bool enable_plugins
Definition XrdEcConfig.hh:77
std::unordered_map< std::string, RedundancyProvider > redundancies
Definition XrdEcConfig.hh:81
Config & operator=(Config &&)=delete
Config(const Config &)=delete
std::mutex mtx
Definition XrdEcConfig.hh:82
static Config & Instance()
Singleton access.
Definition XrdEcConfig.hh:46
RedundancyProvider & GetRedundancy(const ObjCfg &objcfg)
Get redundancy provider for given data object configuration.
Definition XrdEcConfig.hh:55
Definition XrdEcRedundancyProvider.hh:41
Definition XrdClZipArchive.hh:45
Definition XrdEcObjCfg.hh:34
const uint8_t nbchunks
Definition XrdEcObjCfg.hh:85
const uint8_t nbparity
Definition XrdEcObjCfg.hh:86
const uint64_t datasize
Definition XrdEcObjCfg.hh:88