MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / getRandomDeviceSegment

Method getRandomDeviceSegment

libminifi/src/utils/Id.cpp:214–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214uint64_t IdGenerator::getRandomDeviceSegment(int numBits) const {
215 uint64_t deviceSegment = 0;
216 Identifier::Data random_uuid{};
217 for (int word = 0; word < 2; word++) {
218#ifdef WIN32
219 windowsUuidGenerateRandom(random_uuid);
220#else
221 uuid temp_uuid;
222 temp_uuid.make(UUID_MAKE_V4);
223 void* uuid_bin = temp_uuid.binary();
224 memcpy(random_uuid.data(), uuid_bin, 16);
225 free(uuid_bin);
226#endif
227 for (int i = 0; i < 4; i++) {
228 deviceSegment += random_uuid[i];
229 deviceSegment <<= 8;
230 }
231 }
232 deviceSegment >>= 64 - numBits;
233 logging::LOG_DEBUG(logger_) << "Using random defined device segment:" << deviceSegment;
234 deviceSegment <<= 64 - numBits;
235 return deviceSegment;
236}
237
238void IdGenerator::initialize(const std::shared_ptr<Properties>& properties) {
239 std::string implementation_str;

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected