Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R3.2.3.x #762

Open
wants to merge 111 commits into
base: R3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
b8eab37
Adding R3.2.3.x branch to CI Closes-Bug: 1696310
vmahuli Jun 7, 2017
6bfa82a
change version info
vmahuli Jun 7, 2017
308b45b
[Config]: Fix VNC openstack
sahilsabharwal May 1, 2017
059b059
Add BGP Notification Flag support in GR
ananth-at-camphor-networks Apr 27, 2017
a12133b
If neutron sends empty body in floatingip-update, vnc_openstack
Apr 25, 2017
eec7e2f
Drop new xmpp connection for existing connection with same name
ananth-at-camphor-networks May 1, 2017
b23a640
Reinitialize total_acl_count for each evaluate
May 1, 2017
5c8b568
Address pairs not allowed with no port security
sahilsabharwal May 1, 2017
949ab9d
Call update during create of logical router too, to check/set ref
May 3, 2017
be17fb3
Fix duplicate alarm delete messages
May 4, 2017
fc71720
[ST]: Fixed get_sandhesh_ref_list function
sahilsabharwal May 2, 2017
5210d09
Send additional fields in VMI UVE
ashoksr May 6, 2017
4b460f3
The syslog collector has issues with handling syslog messages
arvindvis May 5, 2017
b14290b
ECMP load balance is not effective on remote SI compute.
manishsing May 5, 2017
8cdc01c
[VNC openstack]: Added description field
sahilsabharwal May 5, 2017
32b7c29
Fix to raise exception for default SG update
sahilsabharwal May 9, 2017
b692525
Provide Llgr only support
ananth-at-camphor-networks May 5, 2017
7568bd7
Fixing introspect bug
Jan 11, 2017
003fae9
Fix nework-id and device-id filters management
May 2, 2017
4690729
Make BgpPeer buffer size configurable
Apr 28, 2017
d7c97d3
Making keystone auth params optional
Mar 29, 2017
36ee745
Add bgp configured and operational peer lists to control node UVE
May 9, 2017
d84517d
Fix to catch exception when IP addr already in use
sahilsabharwal May 10, 2017
48d4323
vrouter-port-control: remove unused imports and PEP8
eonpatapon Apr 18, 2017
3109120
Fix to check port and router tenant id are same
sahilsabharwal May 15, 2017
669d29b
Merge "[Config]: Fix VNC openstack" into R3.2.3.x
Jun 7, 2017
ca8118e
Merge "Add BGP Notification Flag support in GR" into R3.2.3.x
Jun 7, 2017
5b3991f
Merge "If neutron sends empty body in floatingip-update, vnc_openstac…
Jun 7, 2017
9b143c0
Merge "Drop new xmpp connection for existing connection with same nam…
Jun 7, 2017
894fedd
Merge "Reinitialize total_acl_count for each evaluate" into R3.2.3.x
Jun 7, 2017
24c9b89
Merge "Address pairs not allowed with no port security" into R3.2.3.x
Jun 7, 2017
621c520
Merge "Call update during create of logical router too, to check/set …
Jun 7, 2017
d4446ab
Merge "Fix duplicate alarm delete messages" into R3.2.3.x
Jun 7, 2017
ae3e8ae
Merge "[ST]: Fixed get_sandhesh_ref_list function" into R3.2.3.x
Jun 7, 2017
d90c181
Merge "Send additional fields in VMI UVE" into R3.2.3.x
Jun 7, 2017
4266c8c
Merge "The syslog collector has issues with handling syslog messages …
Jun 7, 2017
4fcf275
Merge "ECMP load balance is not effective on remote SI compute." into…
Jun 7, 2017
4e2ed5e
Merge "[VNC openstack]: Added description field" into R3.2.3.x
Jun 7, 2017
450e5d4
Merge "Fix to raise exception for default SG update" into R3.2.3.x
Jun 7, 2017
7e4d184
Merge "Provide Llgr only support" into R3.2.3.x
Jun 7, 2017
63a62c0
Merge "Fixing introspect bug" into R3.2.3.x
Jun 7, 2017
9fbc62d
Merge "Fix nework-id and device-id filters management" into R3.2.3.x
Jun 7, 2017
f3535ee
Merge "Make BgpPeer buffer size configurable" into R3.2.3.x
Jun 7, 2017
a340ec5
Merge "Making keystone auth params optional" into R3.2.3.x
Jun 7, 2017
9f65c61
Merge "Add bgp configured and operational peer lists to control node …
Jun 7, 2017
27395d9
Merge "Fix to catch exception when IP addr already in use" into R3.2.3.x
Jun 7, 2017
1e7bc69
Merge "vrouter-port-control: remove unused imports and PEP8" into R3.…
Jun 7, 2017
09adeb5
Merge "Fix to check port and router tenant id are same" into R3.2.3.x
Jun 7, 2017
47a0525
ssl and crypto libraries are need for vizd because new librdkafka
arvindvis Jun 2, 2017
ba3def3
Merge "ssl and crypto libraries are need for vizd because new librdka…
Jun 8, 2017
adf5c2e
Fixed contrail-analytics unavailablity issue
ymariappan Jun 8, 2017
35d163a
Currently max_reties is set to 30 in cassandra
cijohnson Jun 11, 2017
9cc6dc1
Ignore errors during flush, similar to the base
cijohnson Jun 12, 2017
fdc0af9
Merge "Currently max_reties is set to 30 in cassandra" into R3.2.3.x
Jun 16, 2017
590e50c
Update release to 3.2.3.2
Jun 16, 2017
719f0f5
Merge "Update release to 3.2.3.2" into R3.2.3.x
Jun 16, 2017
607a742
[VNC OpenStack] Admin can set router interface
Jun 6, 2017
7481eb4
Fix health-check when fat flow enabled on vmi
praveenkv Mar 31, 2017
8b2f9f2
Merge "[VNC OpenStack] Admin can set router interface" into R3.2.3.x
Jun 20, 2017
e729f46
Always generate the global options in named config.
haripk Jun 1, 2017
4e876d7
Enable flow setup when BGPaaS is configured on VMI with policy disabled
haripk Jun 21, 2017
d30fdaf
Merge "Enable flow setup when BGPaaS is configured on VMI with policy…
Jun 22, 2017
4f69b38
If IPAM DNS mode is set to none, consider it as default DNS mode.
haripk Jun 23, 2017
a3cec14
gw_ip and dns_server_address were stored lower case in api database
moghea Jun 23, 2017
89da0f6
Handle NULL AsPaths during remove-private processing
Jun 13, 2017
6a73386
Fix messages for contrail exceptions
pjediny Jun 27, 2017
079d4ea
Fix ZooDelete in zookeeper client
May 24, 2017
95e4001
Merge "Handle NULL AsPaths during remove-private processing" into R3.…
Jun 28, 2017
cb0e9ac
Merge "Fix messages for contrail exceptions" into R3.2.3.x
Jun 28, 2017
61ce426
Merge "Fix ZooDelete in zookeeper client" into R3.2.3.x
Jun 29, 2017
8378c5a
update version.info
vmahuli Jul 3, 2017
7933bca
Disable opserver:test temporarily from running in CI
Aug 2, 2017
1dcb361
Backport cql_if changes needed for newer version of libcassandra
arvindvis Jun 23, 2017
bba3d9c
* Read reverse flow entry after acquiring the lock
naveen-n Oct 4, 2017
207fec1
Add new libraries to be linked to the collector
arvindvis Aug 26, 2017
dae4afd
Fix subnet re-creation
pjediny Oct 11, 2017
fa5e0dd
Allow filter ports by mac_address
Aug 31, 2017
b4115de
Merge "Allow filter ports by mac_address" into R3.2.3.x
Oct 30, 2017
84e20ac
Allow to update vnic_type when port is not bound
Aug 31, 2017
ed6264e
Adding timestamp to UVE structs when they are aggregated and evaluate…
anishmehta Nov 11, 2017
158da92
Do not re-evaluate backrefs for ksync flow entries
haripk Oct 24, 2017
aa81a95
Add task exclusion between agent profile & sandesh tasks
haripk Sep 27, 2017
f3b3049
* Initialize flow entry variable in pkt flow info.
naveen-n Sep 26, 2017
57287c5
Add NULL check
haripk Sep 28, 2017
0405014
* Increase no. of free requests processed in flow queue
naveen-n Nov 7, 2017
243d629
Take only the v4 address for service health check IP.
haripk Oct 18, 2017
692d9e4
Fix port-update API to support mac-address update
Apr 13, 2017
8c974f2
Merge "Add task exclusion between agent profile & sandesh tasks" into…
Dec 8, 2017
f42cd55
Merge "* Initialize flow entry variable in pkt flow info." into R3.2.3.x
Dec 8, 2017
8b706ac
Merge "Add NULL check" into R3.2.3.x
Dec 8, 2017
8182172
Merge "* Increase no. of free requests processed in flow queue" into …
Dec 8, 2017
2a69a12
Merge "Take only the v4 address for service health check IP." into R3…
Dec 8, 2017
c9fca5d
Merge "* Read reverse flow entry after acquiring the lock" into R3.2.3.x
Dec 8, 2017
8b55508
Merge "Fix port-update API to support mac-address update" into R3.2.3.x
Dec 11, 2017
08300ee
Merge "Adding timestamp to UVE structs when they are aggregated and e…
Dec 15, 2017
97cc90b
Fix route target delete ordering
pjediny Feb 5, 2018
5e7be3a
Allow port security to be disabled if aap is present, but empty
Jan 22, 2018
0d5b276
Disable port security on SNAT router_interface
pjediny Feb 21, 2018
64aa2d4
Remove gdb pretty printer for agent.
krharsh Apr 20, 2018
ac4e397
Replace tbb::task::spawn() by tbb::task::enqueue() and also support f…
praveenkv Apr 20, 2017
99d18a2
flow logging task can free the flow entry from flow table free list
Sangarshan Jul 20, 2018
c065431
Check Gen id for processing recompute events for flows
Sangarshan Jul 9, 2018
6af7eff
Merge "flow logging task can free the flow entry from flow table free…
Jul 26, 2018
233a7f2
Increase the task monitor timeout
haripk Sep 6, 2017
ce51242
Merge "Check Gen id for processing recompute events for flows" into R…
Aug 10, 2018
27b9b4a
Merge "Increase the task monitor timeout" into R3.2.3.x
Aug 16, 2018
555d999
Fix build with newer TBB
fpytloun Oct 10, 2016
5095a90
Do not insert already sleeping tbb task back into sleeping list
ananth-at-camphor-networks Sep 19, 2018
bcc20bc
Revert "Fix port-update API to support mac-address update"
jebap Dec 22, 2017
26ff2b4
For scaled config schema re-init is taking time more than 2min withou…
Shivayogi123 Jun 28, 2018
1125ad7
Protect against invalid ICMP, IGMP and ICMPv6 pkts.
anandrao79 Nov 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitreview
Expand Up @@ -13,4 +13,4 @@
host=review.opencontrail.org
port=29418
project=Juniper/contrail-controller.git
defaultbranch=R3.2
defaultbranch=R3.2.3.x
2 changes: 1 addition & 1 deletion ci_unittests.json
Expand Up @@ -10,8 +10,8 @@
],
"scons_test_targets" : [
"controller/src/analytics:test",
"controller/src/opserver:test",
"controller/src/bfd:test",
"controller/src/opserver:test",
"controller/src/query_engine:test",
"controller/src/database/gendb:test",
"controller/src/database/cassandra/cql:test",
Expand Down
6 changes: 1 addition & 5 deletions lib/SConscript
Expand Up @@ -11,6 +11,7 @@ subdirs = [
'rapidjson',
'thrift',
'openvswitch',
'tbb',
]

(distname, version, _) = platform.dist()
Expand All @@ -23,18 +24,13 @@ elif distname == 'centos' and LooseVersion(version) >= LooseVersion('7.0'):
'gperftools',
'log4cplus',
]
elif distname == 'fedora' and LooseVersion(version) >= LooseVersion('20'):
pass
elif distname == 'SuSE' and LooseVersion(version) >= LooseVersion('12'):
subdirs += ['tbb']
else:
subdirs += [
'boost',
'curl-7.24.0',
'gperftools',
'libxml2',
'log4cplus',
'tbb',
'icu',
]

Expand Down
2 changes: 1 addition & 1 deletion lib/hiredis/SConscript
Expand Up @@ -8,7 +8,7 @@ hiredis_path = '#/third_party/hiredis-0.11.0'
hiredis_asio_adapter_path = '#/third_party/hiredis-boostasio-adapter'

include = [ third_party_path, hiredis_path, hiredis_path + '/adapters',
'#/build/include', '#/third_party/tbb40_20111130oss/include' ]
'#/build/include', '#/third_party/tbb-2018_U5/include' ]

env.Append(CPPPATH = include)
env.Append(CCFLAGS = ['-g'])
Expand Down
3 changes: 2 additions & 1 deletion lib/tbb/SConscript
Expand Up @@ -5,7 +5,8 @@ import re
import subprocess
import sys

vpath = '#/third_party/tbb40_20111130oss'
#vpath = '#/third_party/tbb40_20111130oss'
vpath = '#/third_party/tbb-2018_U5'

env = DefaultEnvironment()

Expand Down
7 changes: 1 addition & 6 deletions src/SConscript
Expand Up @@ -45,15 +45,10 @@ include = ['#/controller/src', '#/build/include', '#controller/lib']

libpath = ['#/build/lib']

libs = ['boost_system', 'log4cplus', 'pthread']
libs = ['boost_system', 'log4cplus', 'pthread', 'tbb']

common = DefaultEnvironment().Clone()

if common['OPT'] == 'production' or common.UseSystemTBB():
libs.append('tbb')
else:
libs.append('tbb_debug')

common.Append(LIBPATH = libpath)
common.Prepend(LIBS = libs)
common.Append(CCFLAGS = '-Wall -Werror -Wsign-compare')
Expand Down
12 changes: 7 additions & 5 deletions src/analytics/SConscript
Expand Up @@ -58,14 +58,16 @@ AnalyticsEnv.Prepend(LIBS=['cpuinfo',
'protobuf',
'zookeeper_client',
'zookeeper_mt',
'ssl',
'crypto',
'boost_filesystem',
'boost_program_options'])
'boost_program_options',
'libdl',
'sasl2'])

(PLATFORM, VERSION, EXTRA) = platform.linux_distribution()
if PLATFORM.lower() != 'ubuntu':
AnalyticsEnv.Prepend(LIBS=['ssl',
'crypto',
'sasl2'])
if PLATFORM.lower() != 'ubuntu' or (PLATFORM.lower() == 'ubuntu' and VERSION.find('16.') == 0):
AnalyticsEnv.Prepend(LIBS=['lz4'])

database_libs = ['cassandra_cql', 'cassandra']

Expand Down
5 changes: 3 additions & 2 deletions src/analytics/syslog_collector.cc
Expand Up @@ -585,8 +585,9 @@ void SyslogTcpListener::Shutdown ()
}
void SyslogTcpListener::Start (std::string ipaddress, int port)
{
Initialize (port);
LOG(DEBUG, __func__ << " Initialization of TCP syslog listener @" << port);
//Initialize (port);
//LOG(DEBUG, __func__ << " Initialization of TCP syslog listener @" << port);
LOG(ERROR, __func__ << " TCP syslog listener not supported");
}

void SyslogTcpListener::ReadMsg(SyslogQueueEntry *sqe) {
Expand Down
2 changes: 2 additions & 0 deletions src/base/SConscript
Expand Up @@ -36,6 +36,7 @@ libcpuinfo = env.Library('cpuinfo', ['cpuinfo.cc'] + cpuinfo_sandesh_files_)

task = except_env.Object('task.o', 'task.cc')
timer = timer_env.Object('timer.o', 'timer.cc')
task_monitor = timer_env.Object('task_monitor.o', 'task_monitor.cc')

ProcessInfoSandeshGenFiles = env.SandeshGenCpp('sandesh/process_info.sandesh')
ProcessInfoSandeshGenSrcs = env.ExtractCpp(ProcessInfoSandeshGenFiles)
Expand Down Expand Up @@ -66,6 +67,7 @@ libbase = env.Library('base',
'proto.cc',
task,
'task_annotations.cc',
task_monitor,
'task_sandesh.cc',
'task_trigger.cc',
'tdigest.c',
Expand Down
19 changes: 19 additions & 0 deletions src/base/sandesh/task.sandesh
Expand Up @@ -33,6 +33,7 @@ struct SandeshTaskGroup {

response sandesh SandeshTaskScheduler {
1: bool running;
5: bool use_spawn;
2: u64 total_count;
3: i32 thread_count;
4: list <SandeshTaskGroup> task_group_list;
Expand All @@ -56,3 +57,21 @@ trace sandesh TaskTrace {
4: u32 latency;
5: string description;
}

response sandesh SandeshMonitorResponse {
1: bool running;
2: u64 inactivity_time_msec;
3: u64 poll_interval_msec;
4: u64 poll_count;
5: u64 last_activity;
6: u64 last_enqueue_count;
7: u64 last_done_count;
8: u64 tbb_keepawake_time;
}

/**
* @description: sandesh request to get task monitoring status
* @cli_name: read task monitor
*/
request sandesh SandeshTaskMonitorRequest {
}
60 changes: 47 additions & 13 deletions src/base/task.cc
Expand Up @@ -14,6 +14,7 @@
#include "base/logging.h"
#include "base/task.h"
#include "base/task_annotations.h"
#include "base/task_monitor.h"

#include <sandesh/sandesh_types.h>
#include <sandesh/sandesh.h>
Expand Down Expand Up @@ -245,6 +246,7 @@ class TaskGroup {
tbb::task *TaskImpl::execute() {
TaskInfo::reference running = task_running.local();
running = parent_;
parent_->SetTbbState(Task::TBB_EXEC);
try {
uint64_t t = 0;
if (parent_->enqueue_time() != 0) {
Expand Down Expand Up @@ -331,6 +333,13 @@ int TaskScheduler::GetThreadCount(int thread_count) {
return num_cores_ * ThreadAmpFactor_;
}

bool TaskScheduler::ShouldUseSpawn() {
if (getenv("TBB_USE_SPAWN"))
return true;

return false;
}

////////////////////////////////////////////////////////////////////////////
// Implementation for class TaskScheduler
////////////////////////////////////////////////////////////////////////////
Expand All @@ -340,10 +349,10 @@ int TaskScheduler::GetThreadCount(int thread_count) {
// for task scheduling. But, in our case we dont want "main" thread to be
// part of tbb. So, initialize TBB with one thread more than its default
TaskScheduler::TaskScheduler(int task_count) :
task_scheduler_(GetThreadCount(task_count) + 1),
use_spawn_(ShouldUseSpawn()), task_scheduler_(GetThreadCount(task_count) + 1),
running_(true), seqno_(0), id_max_(0), log_fn_(), track_run_time_(false),
measure_delay_(false), schedule_delay_(0), execute_delay_(0),
enqueue_count_(0), done_count_(0), cancel_count_(0) {
enqueue_count_(0), done_count_(0), cancel_count_(0), task_monitor_(NULL) {
hw_thread_count_ = GetThreadCount(task_count);
task_group_db_.resize(TaskScheduler::kVectorGrowSize);
stop_entry_ = new TaskEntry(-1);
Expand Down Expand Up @@ -378,6 +387,18 @@ void TaskScheduler::Initialize(uint32_t thread_count) {
singleton_.reset(new TaskScheduler((int)thread_count));
}

void TaskScheduler::EnableMonitor(EventManager *evm,
uint64_t tbb_keepawake_time_msec,
uint64_t inactivity_time_msec,
uint64_t poll_interval_msec) {
if (task_monitor_ != NULL)
return;

task_monitor_ = new TaskMonitor(this, tbb_keepawake_time_msec,
inactivity_time_msec, poll_interval_msec);
task_monitor_->Start(evm);
}

void TaskScheduler::Log(const char *file_name, uint32_t line_no,
const Task *task, const char *description,
uint32_t delay) {
Expand Down Expand Up @@ -621,6 +642,7 @@ void TaskScheduler::OnTaskExit(Task *t) {
tbb::mutex::scoped_lock lock(mutex_);
done_count_++;

t->SetTbbState(Task::TBB_DONE);
TaskEntry *entry = QueryTaskEntry(t->GetTaskId(), t->GetTaskInstance());
entry->TaskExited(t, GetTaskGroup(t->GetTaskId()));

Expand All @@ -641,7 +663,8 @@ void TaskScheduler::OnTaskExit(Task *t) {
// Task is being recycled, reset the state, seq_no and TBB task handle
t->task_impl_ = NULL;
t->SetSeqNo(0);
t->state_ = Task::INIT;
t->SetState(Task::INIT);
t->SetTbbState(Task::TBB_INIT);
EnqueueUnLocked(t);
}

Expand Down Expand Up @@ -869,6 +892,12 @@ void TaskScheduler::WaitForTerminateCompletion() {
}

void TaskScheduler::Terminate() {
if (task_monitor_) {
task_monitor_->Terminate();
delete task_monitor_;
task_monitor_ = NULL;
}

for (int i = 0; i < 10000; i++) {
if (IsEmpty()) break;
usleep(1000);
Expand Down Expand Up @@ -1194,7 +1223,7 @@ void TaskEntry::RunTask (Task *t) {
TaskGroup *group = scheduler->QueryTaskGroup(t->GetTaskId());
group->TaskStarted();

t->StartTask();
t->StartTask(scheduler);
}

void TaskEntry::RunWaitQ() {
Expand Down Expand Up @@ -1346,32 +1375,36 @@ int TaskEntry::GetTaskDeferEntrySeqno() const {
// Implementation for class Task
////////////////////////////////////////////////////////////////////////////
Task::Task(int task_id, int task_instance) : task_id_(task_id),
task_instance_(task_instance), task_impl_(NULL), state_(INIT), seqno_(0),
task_recycle_(false), task_cancel_(false), enqueue_time_(0),
schedule_time_(0), execute_delay_(0), schedule_delay_(0) {
task_instance_(task_instance), task_impl_(NULL), state_(INIT),
tbb_state_(TBB_INIT), seqno_(0), task_recycle_(false), task_cancel_(false),
enqueue_time_(0), schedule_time_(0), execute_delay_(0), schedule_delay_(0) {
}

Task::Task(int task_id) : task_id_(task_id),
task_instance_(-1), task_impl_(NULL), state_(INIT), seqno_(0),
task_recycle_(false), task_cancel_(false), enqueue_time_(0),
task_instance_(-1), task_impl_(NULL), state_(INIT), tbb_state_(TBB_INIT),
seqno_(0), task_recycle_(false), task_cancel_(false), enqueue_time_(0),
schedule_time_(0), execute_delay_(0), schedule_delay_(0) {
}

// Start execution of task
void Task::StartTask() {
void Task::StartTask(TaskScheduler *scheduler) {
if (enqueue_time_ != 0) {
schedule_time_ = ClockMonotonicUsec();
TaskScheduler *scheduler = TaskScheduler::GetInstance();
if ((schedule_time_ - enqueue_time_) >
scheduler->schedule_delay(this)) {
TASK_TRACE(scheduler, this, "Schedule delay(in usec) ",
(schedule_time_ - enqueue_time_));
}
}
assert(task_impl_ == NULL);
state_ = RUN;
SetState(RUN);
SetTbbState(TBB_ENQUEUED);
task_impl_ = new (task::allocate_root())TaskImpl(this);
task::spawn(*task_impl_);
if (scheduler->use_spawn()) {
task::spawn(*task_impl_);
} else {
task::enqueue(*task_impl_);
}
}

Task *Task::Running() {
Expand Down Expand Up @@ -1437,6 +1470,7 @@ void TaskScheduler::GetSandeshData(SandeshTaskScheduler *resp, bool summary) {
tbb::mutex::scoped_lock lock(mutex_);

resp->set_running(running_);
resp->set_use_spawn(use_spawn_);
resp->set_total_count(seqno_);
resp->set_thread_count(hw_thread_count_);

Expand Down
25 changes: 24 additions & 1 deletion src/base/task.h
Expand Up @@ -44,6 +44,9 @@
class TaskGroup;
class TaskEntry;
class SandeshTaskScheduler;
class EventManager;
class TaskMonitor;
class TaskScheduler;

struct TaskStats {
int wait_count_; // #Entries in waitq
Expand Down Expand Up @@ -72,6 +75,13 @@ class Task {
RUN
};

enum TbbState {
TBB_INIT,
TBB_ENQUEUED,
TBB_EXEC,
TBB_DONE
};

const static int kTaskInstanceAny = -1;
Task(int task_id, int task_instance);
Task(int task_id);
Expand Down Expand Up @@ -109,15 +119,17 @@ class Task {
friend class TaskScheduler;
friend class TaskImpl;
void SetSeqNo(uint64_t seqno) {seqno_ = seqno;};
void SetTbbState(TbbState s) { tbb_state_ = s; };
void SetState(State s) { state_ = s; };
void SetTaskRecycle() { task_recycle_ = true; };
void SetTaskComplete() { task_recycle_ = false; };
void StartTask();
void StartTask(TaskScheduler *scheduler);

int task_id_; // The code path executed by the task.
int task_instance_; // The dataset id within a code path.
tbb::task *task_impl_;
State state_;
TbbState tbb_state_;
uint64_t seqno_;
bool task_recycle_;
bool task_cancel_;
Expand Down Expand Up @@ -198,6 +210,7 @@ class TaskScheduler {

// Get number of tbb worker threads.
static int GetThreadCount(int thread_count = 0);
static bool ShouldUseSpawn();

uint64_t enqueue_count() const { return enqueue_count_; }
uint64_t done_count() const { return done_count_; }
Expand All @@ -223,6 +236,13 @@ class TaskScheduler {
uint32_t schedule_delay(Task *task) const;
uint32_t execute_delay(Task *task) const;

// Enable Task monitoring
void EnableMonitor(EventManager *evm, uint64_t tbb_keepawake_time_msec,
uint64_t inactivity_time_msec,
uint64_t poll_interval_msec);
const TaskMonitor *task_monitor() const { return task_monitor_; }
bool use_spawn() const { return use_spawn_; }

// following function allows one to increase max num of threads used by
// TBB
static void SetThreadAmpFactor(int n);
Expand All @@ -245,6 +265,8 @@ class TaskScheduler {

int CountThreadsPerPid(pid_t pid);

// Use spawn() to run a tbb::task instead of enqueue()
bool use_spawn_;
TaskEntry *stop_entry_;

tbb::task_scheduler_init task_scheduler_;
Expand Down Expand Up @@ -273,6 +295,7 @@ class TaskScheduler {
// following variable allows one to increase max num of threads used by
// TBB
static int ThreadAmpFactor_;
TaskMonitor *task_monitor_;
DISALLOW_COPY_AND_ASSIGN(TaskScheduler);
};

Expand Down