MCPcopy Create free account
hub / github.com/Tencent/phxpaxos / CheckOptions

Method CheckOptions

src/node/pnode.cpp:129–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129int PNode :: CheckOptions(const Options & oOptions)
130{
131 //init logger
132 if (oOptions.pLogFunc != nullptr)
133 {
134 LOGGER->SetLogFunc(oOptions.pLogFunc);
135 }
136 else
137 {
138 LOGGER->InitLogger(oOptions.eLogLevel);
139 }
140
141 if (oOptions.poLogStorage == nullptr && oOptions.sLogStoragePath.size() == 0)
142 {
143 PLErr("no logpath and logstorage is null");
144 return -2;
145 }
146
147 if (oOptions.iUDPMaxSize > 64 * 1024)
148 {
149 PLErr("udp max size %zu is too large", oOptions.iUDPMaxSize);
150 return -2;
151 }
152
153 if (oOptions.iGroupCount > 200)
154 {
155 PLErr("group count %d is too large", oOptions.iGroupCount);
156 return -2;
157 }
158
159 if (oOptions.iGroupCount <= 0)
160 {
161 PLErr("group count %d is small than zero or equal to zero", oOptions.iGroupCount);
162 return -2;
163 }
164
165 for (auto & oFollowerNodeInfo : oOptions.vecFollowerNodeInfoList)
166 {
167 if (oFollowerNodeInfo.oMyNode.GetNodeID() == oFollowerNodeInfo.oFollowNode.GetNodeID())
168 {
169 PLErr("self node ip %s port %d equal to follow node",
170 oFollowerNodeInfo.oMyNode.GetIP().c_str(), oFollowerNodeInfo.oMyNode.GetPort());
171 return -2;
172 }
173 }
174
175 for (auto & oGroupSMInfo : oOptions.vecGroupSMInfoList)
176 {
177 if (oGroupSMInfo.iGroupIdx >= oOptions.iGroupCount)
178 {
179 PLErr("SM GroupIdx %d large than GroupCount %d",
180 oGroupSMInfo.iGroupIdx, oOptions.iGroupCount);
181 return -2;
182 }
183 }
184
185 return 0;
186}

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected