Refactor the way messages are retrieved from an upr producer

This cahnge adds in a ready queue that contains message waiting
to be sent over the wire for a given connection.

Change-Id: I1f60c2c37a98b6f9df9965e6803836ac4c0c7862
Reviewed-on: http://review.couchbase.org/30766
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Get num backfill items from the kvstore

This should be much more accurate and I also found some
underflow issues with the old implementation.

Change-Id: I3f90c04dac0fbe103d4016e666a03edb31061eff
Reviewed-on: http://review.couchbase.org/30763
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Refactor table scan in couchkvstore

We no longer use the code that allows us to schedule a table scan
for all vbuckets. This code should be especially removed since we
have multiple couchkvstore instances per bucket and doing a table
scan for all vbucket means all 1024 vbucket.

Change-Id: Ib0aee0ca9621a123ee0d46906448c9a08bd72dc0
Reviewed-on: http://review.couchbase.org/30762
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Use ConnMap in backfill task

This will allow us to specify different behavior based on whether
or not the connection is for tap or upr.

Change-Id: I6f799e68e3d62902e913919126707cb482bc454b
Reviewed-on: http://review.couchbase.org/30764
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Allow specification of start/end seqno ids when doing backfills

This will allow upr clients to specify a range of data they they
want to receive when doing a backfill. Note that we can likely
refactor the backfill logic in the future to make it simpler.

Change-Id: Ib95d0693838cd405bbc532f50cf7386cc94ffaac
Reviewed-on: http://review.couchbase.org/30765
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Add 'stats vbucket-seqno' command

This command lists all of the high sequence numbers for all
vbuckets.

Change-Id: Ie007d9549857a2b485d7df43931be23a04b2c23c
Reviewed-on: http://review.couchbase.org/30778
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
CBD-1148: Migrate all NonIO tasks into Common Pool

This removes per-bucket threads from the NonIO dispatcher
into the global thread pool shared by all buckets
Following tasks handled by the non-io thread are now migrated
into the common shared thread pool...
1) Backfill task
2) Hash Table Resizer
3) Checkpoint remover
4) ExpiredItemPager
5) Item Pager
6) VBCBAdaptor (async task spawned by daemon tasks 1-4)
7) Tap Connection Notification (daemon task)
8) Tap Resume
9) Tap Connection Reaper
10) VBucket Memory Deletion
11) FlushAll task
12) Checkpoint Stats
Also removed isDaemon and makes GlobalTask's starttime internal
Allow new api in ExecutorPool to stop a task group entirely
Change-Id: Ic5cbbfb6d1a140335b0ff1a7c7dc31e20ca47186
Reviewed-on: http://review.couchbase.org/30775
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9692 Handle MutationLog lseek errors gracefully

Instead of asserting throw appropriate exception with logs.

Change-Id: Id84fc20bd04170d455bbb2afcfaf0790168df749
Reviewed-on: http://review.couchbase.org/30901
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Update stats vbucket-seqno response to match spec

We will be sending both the high seqno and vbucket uuid in the
future. As a result we need a way to differentiate the two.

Change-Id: I3a318c835ae65d0747c46103d83dd0d0d7aa1c01
Reviewed-on: http://review.couchbase.org/30872
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Remove the dispatcher

All tasks have been migrated over to the global scheduler so
we no longer need the dispatcher.

Change-Id: Ie9e0973e66c0d998d7f603ca169c14d2b0c447da
Reviewed-on: http://review.couchbase.org/30898
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9484: Move all functions out of TapProducer class

Change-Id: I1332619f132b2980962e21d6eb43984f7a4bbb51
Reviewed-on: http://review.couchbase.org/30846
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9484: Move most of Producer logic into TapProducer

A lot of the logic in the Producer class will not be used
by the UprProducer. This change moves that logic back into
the TapProducer class.

Change-Id: If04715468340e848d857e8641407eaa75e6035aa
Reviewed-on: http://review.couchbase.org/30847
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9484: Allow upr to schedule backfills and send mutations/deleted

Change-Id: I1c8edf8f809626a56ff648c83799253c81a5410a
Reviewed-on: http://review.couchbase.org/30848
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Remove unused upr response codes

Change-Id: I1944365f77703d18027310d70904b7a5aa4008f3
Reviewed-on: http://review.couchbase.org/30977
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
MB-9585: Add support for upr stats

This change refactors the TAP stats related functions and added
UPR support. Client such as cbstats should be able to retrieve
"upr" or "upragg" stats. We'll add comprehensive stats for UPR
later on. Also modified some upr test cases that depends on stats.

Change-Id: I1526c37700a11251d6bbcb8eb4d253e12455a722
Reviewed-on: http://review.couchbase.org/30855
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
MB-9695: idle cpu usage reduction optimizations

optimize scheduler's fetchNextTask loop
reduce sleeptime in tapconnmap

Change-Id: If90eda0b862527b7f8d3d78a8dd5022d02394490
Reviewed-on: http://review.couchbase.org/31008
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Don't convert the opaque to host order when decoding upr responses

Change-Id: I14aedb0de89f62a949260a3a5d3b692c5622152c
Reviewed-on: http://review.couchbase.org/31032
Reviewed-by: Artem Stemkovski <artem@couchbase.com>
Tested-by: Artem Stemkovski <artem@couchbase.com>
Fix broken upr add stream test cases

Change-Id: Ib1178345a9b4aa7067f63618b10f7bfce1fbe7b1
Reviewed-on: http://review.couchbase.org/31043
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>
Schedule Conns / pending ops notifications through thread pool

This change removes a notification thread and schedules its tasks
(i.e., paused connection notification and pending ops
notification tasks) through NON-IO threads in the global
thread pool.

Change-Id: Ia8f20d14cc1878c5a702f34dd0a3f726d26b2190
Reviewed-on: http://review.couchbase.org/30906
Reviewed-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Tested-by: Sundararaman Sridharan <sundar.sridharan@gmail.com>
Fix timed wait in syncobject

Change-Id: Ia09bfb7ac539229287e31b5fdb5b4058429c39b0
Reviewed-on: http://review.couchbase.org/30968
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>