MCPcopy Create free account
hub / github.com/apache/cloudberry / InitConfig

Function InitConfig

gpcontrib/gpcloud/src/s3conf.cpp:34–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32struct sockaddr_in s3ext_logserveraddr;
33
34S3Params InitConfig(const string& urlWithOptions) {
35#ifdef S3_STANDALONE
36 s3ext_segid = 0;
37 s3ext_segnum = 1;
38#else
39 s3ext_segid = GpIdentity.segindex;
40 s3ext_segnum = getgpsegmentCount();
41#endif
42
43 if (s3ext_segid == -1 && s3ext_segnum > 0) {
44 s3ext_segid = 0;
45 s3ext_segnum = 1;
46 }
47
48 string sourceUrl = TruncateOptions(urlWithOptions);
49 S3_CHECK_OR_DIE(!sourceUrl.empty(), S3RuntimeError, "URL not found from location string");
50
51 string httpUrl = GetOptS3(urlWithOptions, "config_server");
52 string configPath = GetOptS3(urlWithOptions, "config");
53 if (configPath.empty()) {
54 S3WARN("The 'config' parameter is not provided, use default value 's3/s3.conf'.");
55 configPath = "s3/s3.conf";
56 }
57
58 string configSection = GetOptS3(urlWithOptions, "section");
59 if (configSection.empty()) {
60 configSection = "default";
61 }
62
63 // region could be empty
64 string urlRegion = GetOptS3(urlWithOptions, "region");
65
66 // read configurations from file
67
68#if !defined(S3_STANDALONE)
69 Config s3Cfg(configPath, httpUrl, DataDir);
70#else
71 Config s3Cfg(configPath);
72#endif
73
74 S3_CHECK_OR_DIE(s3Cfg.Handle() != NULL, S3RuntimeError,
75 "Failed to parse config file '" + configPath + "', or it doesn't exist(or http failed)");
76
77 S3_CHECK_OR_DIE(s3Cfg.SectionExist(configSection), S3ConfigError,
78 "Selected section '" + configSection +
79 "' does not exist, please check your configuration file",
80 configSection);
81
82 bool useHttps = s3Cfg.GetBool(configSection, "encryption", "true");
83
84 string version = s3Cfg.Get(configSection, "version", "");
85
86 S3Params params(sourceUrl, useHttps, version, urlRegion);
87
88 string content = s3Cfg.Get(configSection, "loglevel", "WARNING");
89 s3ext_loglevel = getLogLevel(content.c_str());
90
91 content = s3Cfg.Get(configSection, "logtype", "INTERNAL");

Callers 6

reader_initFunction · 0.70
writer_initFunction · 0.70
TESTFunction · 0.50
TESTFunction · 0.50
TEST_FFunction · 0.50
TEST_FFunction · 0.50

Calls 15

getgpsegmentCountFunction · 0.85
TruncateOptionsFunction · 0.85
GetOptS3Function · 0.85
getLogLevelFunction · 0.85
getLogTypeFunction · 0.85
CheckEssentialConfigFunction · 0.85
HandleMethod · 0.80
SectionExistMethod · 0.80
GetBoolMethod · 0.80
setDebugCurlMethod · 0.80
setCredMethod · 0.80
SafeScanMethod · 0.80

Tested by 4

TESTFunction · 0.40
TESTFunction · 0.40
TEST_FFunction · 0.40
TEST_FFunction · 0.40