blob: a356b2c01450317354c7475e635ec3bac0c354c3 [file] [log] [blame]
// Copyright 2012 Cloudera, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <boost/thread/locks.hpp>
#include <string>
#include "kudu/gutil/stringprintf.h"
#include "kudu/util/oid_generator.h"
namespace kudu {
string ObjectIdGenerator::Next() {
boost::lock_guard<LockType> l(oid_lock_);
boost::uuids::uuid oid = oid_generator_();
const uint8_t *uuid = oid.data;
return StringPrintf("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
uuid[0], uuid[1], uuid[2], uuid[3], uuid[4], uuid[5], uuid[6], uuid[7],
uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14], uuid[15]);
}
} // namespace kudu