Remove sync_point.[h,cc] It no longer appears to be used, and it was causing a compiler warning:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: lib/libkudu_util_exported.a(sync_point.cc.o) has no symbols Change-Id: I1713c30e77d2227072c4928643733c553d4535e6 Reviewed-on: http://gerrit.cloudera.org:8080/5945 Reviewed-by: Todd Lipcon <[email protected]> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/b7b418b5 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/b7b418b5 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/b7b418b5 Branch: refs/heads/master Commit: b7b418b5e5a74a65e5e07621934c4f8a8a67753c Parents: 67f2486 Author: Dan Burkert <[email protected]> Authored: Wed Feb 8 13:16:47 2017 -0800 Committer: Dan Burkert <[email protected]> Committed: Wed Feb 8 22:02:30 2017 +0000 ---------------------------------------------------------------------- LICENSE.txt | 70 -------------------- build-support/release/rat_exclude_files.txt | 2 - src/kudu/util/CMakeLists.txt | 2 - src/kudu/util/sync_point-test.cc | 59 ----------------- src/kudu/util/sync_point.cc | 75 --------------------- src/kudu/util/sync_point.h | 83 ------------------------ 6 files changed, 291 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/b7b418b5/LICENSE.txt ---------------------------------------------------------------------- diff --git a/LICENSE.txt b/LICENSE.txt index afcb22d..c5ce08d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -291,76 +291,6 @@ Some portions of this module are derived from code from LevelDB -------------------------------------------------------------------------------- -src/kudu/util/sync_point: adapted from the RocksDB project under a 3-clause -BSD license with an additional grant of patent rights: - - Copyright (c) 2014, Facebook, Inc. - All rights reserved. - - Copyright (c) 2011 The LevelDB Authors. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following disclaimer - in the documentation and/or other materials provided with the - distribution. - * Neither the name of Google Inc. nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Additional Grant of Patent Rights Version 2 - - "Software" means the RocksDB software distributed by Facebook, Inc. - - Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software - ("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable - (subject to the termination provision below) license under any Necessary - Claims, to make, have made, use, sell, offer to sell, import, and otherwise - transfer the Software. For avoidance of doubt, no license is granted under - Facebookâs rights in any patent claims that are infringed by (i) modifications - to the Software made by you or any third party or (ii) the Software in - combination with any software or other technology. - - The license granted hereunder will terminate, automatically and without notice, - if you (or any of your subsidiaries, corporate affiliates or agents) initiate - directly or indirectly, or take a direct financial interest in, any Patent - Assertion: (i) against Facebook or any of its subsidiaries or corporate - affiliates, (ii) against any party if such Patent Assertion arises in whole or - in part from any software, technology, product or service of Facebook or any of - its subsidiaries or corporate affiliates, or (iii) against any party relating - to the Software. Notwithstanding the foregoing, if Facebook or any of its - subsidiaries or corporate affiliates files a lawsuit alleging patent - infringement against you in the first instance, and you respond by filing a - patent infringement counterclaim in that lawsuit against that party that is - unrelated to the Software, the license granted hereunder will not terminate - under section (i) of this paragraph due to such counterclaim. - - A "Necessary Claim" is a claim of a patent owned by Facebook that is - necessarily infringed by the Software standing alone. - - A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, - or contributory infringement or inducement to infringe any patent, including a - cross-claim or counterclaim. - --------------------------------------------------------------------------------- - www/d3.v2.js: BSD 3-clause license Copyright (c) 2012, Michael Bostock http://git-wip-us.apache.org/repos/asf/kudu/blob/b7b418b5/build-support/release/rat_exclude_files.txt ---------------------------------------------------------------------- diff --git a/build-support/release/rat_exclude_files.txt b/build-support/release/rat_exclude_files.txt index d1a9b03..566ba19 100644 --- a/build-support/release/rat_exclude_files.txt +++ b/build-support/release/rat_exclude_files.txt @@ -161,8 +161,6 @@ src/kudu/util/slice.h src/kudu/util/status-test.cc src/kudu/util/status.cc src/kudu/util/status.h -src/kudu/util/sync_point.cc -src/kudu/util/sync_point.h src/kudu/util/x509_check_host.cc src/kudu/util/x509_check_host.h src/kudu/util/debug/trace_event.h http://git-wip-us.apache.org/repos/asf/kudu/blob/b7b418b5/src/kudu/util/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/kudu/util/CMakeLists.txt b/src/kudu/util/CMakeLists.txt index f2c0cde..4aecdcf 100644 --- a/src/kudu/util/CMakeLists.txt +++ b/src/kudu/util/CMakeLists.txt @@ -181,7 +181,6 @@ set(UTIL_SRCS string_case.cc striped64.cc subprocess.cc - sync_point.cc test_graph.cc test_util_prod.cc thread.cc @@ -372,7 +371,6 @@ ADD_KUDU_TEST(status-test) ADD_KUDU_TEST(string_case-test) ADD_KUDU_TEST(striped64-test) ADD_KUDU_TEST(subprocess-test) -ADD_KUDU_TEST(sync_point-test) ADD_KUDU_TEST(thread-test) ADD_KUDU_TEST(threadpool-test) ADD_KUDU_TEST(throttler-test) http://git-wip-us.apache.org/repos/asf/kudu/blob/b7b418b5/src/kudu/util/sync_point-test.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/sync_point-test.cc b/src/kudu/util/sync_point-test.cc deleted file mode 100644 index 45e5e5d..0000000 --- a/src/kudu/util/sync_point-test.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you 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 "kudu/util/sync_point.h" - -#include <gtest/gtest.h> - -#include "kudu/gutil/ref_counted.h" -#include "kudu/util/test_util.h" -#include "kudu/util/thread.h" - -using std::string; -using std::vector; - -#ifndef NDEBUG -namespace kudu { - -static void RunThread(bool *var) { - *var = true; - TEST_SYNC_POINT("first"); -} - -TEST(SyncPointTest, TestSyncPoint) { - // Set up a sync point "second" that depends on "first". - vector<SyncPoint::Dependency> dependencies; - dependencies.push_back(SyncPoint::Dependency("first", "second")); - SyncPoint::GetInstance()->LoadDependency(dependencies); - SyncPoint::GetInstance()->EnableProcessing(); - - // Kick off a thread that'll process "first", but not before - // setting 'var' to true, which unblocks the main thread. - scoped_refptr<Thread> thread; - bool var = false; - ASSERT_OK(kudu::Thread::Create("test", "test", - &RunThread, &var, &thread)); - - // Blocked on RunThread to process "first". - TEST_SYNC_POINT("second"); - ASSERT_TRUE(var); - - thread->Join(); -} - -} // namespace kudu -#endif // NDEBUG http://git-wip-us.apache.org/repos/asf/kudu/blob/b7b418b5/src/kudu/util/sync_point.cc ---------------------------------------------------------------------- diff --git a/src/kudu/util/sync_point.cc b/src/kudu/util/sync_point.cc deleted file mode 100644 index ca9cef7..0000000 --- a/src/kudu/util/sync_point.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2014, Facebook, Inc. All rights reserved. -// This source code is licensed under the BSD-style license found in the -// LICENSE.txt file in the root directory of this source tree. An additional grant -// of patent rights can be found in the same file. - -#include "kudu/util/sync_point.h" - -using std::string; -using std::vector; - -#ifndef NDEBUG -namespace kudu { - -SyncPoint::Dependency::Dependency(string predecessor, string successor) - : predecessor_(std::move(predecessor)), successor_(std::move(successor)) {} - -SyncPoint::SyncPoint() - : cv_(&mutex_), - enabled_(false) { -} - -SyncPoint* SyncPoint::GetInstance() { - static SyncPoint sync_point; - return &sync_point; -} - -void SyncPoint::LoadDependency(const vector<Dependency>& dependencies) { - successors_.clear(); - predecessors_.clear(); - cleared_points_.clear(); - for (const Dependency& dependency : dependencies) { - successors_[dependency.predecessor_].push_back(dependency.successor_); - predecessors_[dependency.successor_].push_back(dependency.predecessor_); - } -} - -bool SyncPoint::PredecessorsAllCleared(const string& point) { - for (const string& pred : predecessors_[point]) { - if (cleared_points_.count(pred) == 0) { - return false; - } - } - return true; -} - -void SyncPoint::EnableProcessing() { - MutexLock lock(mutex_); - enabled_ = true; -} - -void SyncPoint::DisableProcessing() { - MutexLock lock(mutex_); - enabled_ = false; -} - -void SyncPoint::ClearTrace() { - MutexLock lock(mutex_); - cleared_points_.clear(); -} - -void SyncPoint::Process(const string& point) { - MutexLock lock(mutex_); - - if (!enabled_) return; - - while (!PredecessorsAllCleared(point)) { - cv_.Wait(); - } - - cleared_points_.insert(point); - cv_.Broadcast(); -} - -} // namespace kudu -#endif // NDEBUG http://git-wip-us.apache.org/repos/asf/kudu/blob/b7b418b5/src/kudu/util/sync_point.h ---------------------------------------------------------------------- diff --git a/src/kudu/util/sync_point.h b/src/kudu/util/sync_point.h deleted file mode 100644 index 85a3c8c..0000000 --- a/src/kudu/util/sync_point.h +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2014, Facebook, Inc. All rights reserved. -// This source code is licensed under the BSD-style license found in the -// LICENSE.txt file in the root directory of this source tree. An additional grant -// of patent rights can be found in the same file. -#pragma once - -#include <string> -#include <unordered_map> -#include <unordered_set> -#include <vector> - -#include "kudu/util/condition_variable.h" -#include "kudu/util/mutex.h" - -#ifdef NDEBUG -#define TEST_SYNC_POINT(x) -#else - -namespace kudu { - -// This class provides facility to reproduce race conditions deterministically -// in unit tests. -// Developer could specify sync points in the codebase via TEST_SYNC_POINT. -// Each sync point represents a position in the execution stream of a thread. -// In the unit test, 'Happens After' relationship among sync points could be -// setup via SyncPoint::LoadDependency, to reproduce a desired interleave of -// threads execution. - -class SyncPoint { - public: - static SyncPoint* GetInstance(); - - struct Dependency { - Dependency(std::string predecessor, std::string successor); - - std::string predecessor_; - std::string successor_; - }; - // call once at the beginning of a test to setup the dependency between - // sync points - void LoadDependency(const std::vector<Dependency>& dependencies); - - // enable sync point processing (disabled on startup) - void EnableProcessing(); - - // disable sync point processing - void DisableProcessing(); - - // remove the execution trace of all sync points - void ClearTrace(); - - // triggered by TEST_SYNC_POINT, blocking execution until all predecessors - // are executed. - void Process(const std::string& point); - - // TODO: it might be useful to provide a function that blocks until all - // sync points are cleared. - - private: - SyncPoint(); - - bool PredecessorsAllCleared(const std::string& point); - - // successor/predecessor map loaded from LoadDependency - std::unordered_map<std::string, std::vector<std::string> > successors_; - std::unordered_map<std::string, std::vector<std::string> > predecessors_; - - Mutex mutex_; - ConditionVariable cv_; - // sync points that have been passed through - std::unordered_set<std::string> cleared_points_; - bool enabled_; -}; - -} // namespace kudu - -// Use TEST_SYNC_POINT to specify sync points inside code base. -// Sync points can have happens-after depedency on other sync points, -// configured at runtime via SyncPoint::LoadDependency. This could be -// utilized to re-produce race conditions between threads. -// TEST_SYNC_POINT is no op in release build. -#define TEST_SYNC_POINT(x) kudu::SyncPoint::GetInstance()->Process(x) -#endif // NDEBUG
