-
Notifications
You must be signed in to change notification settings - Fork 105
/
nsqd.go
773 lines (683 loc) · 18.5 KB
/
nsqd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
package nsqd
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net"
"os"
"path"
"strings"
"sync"
"sync/atomic"
"time"
"github.com/absolute8511/nsq/internal/clusterinfo"
"github.com/absolute8511/nsq/internal/dirlock"
"github.com/absolute8511/nsq/internal/http_api"
"github.com/absolute8511/nsq/internal/protocol"
"github.com/absolute8511/nsq/internal/statsd"
"github.com/absolute8511/nsq/internal/util"
"github.com/absolute8511/nsq/internal/version"
"github.com/bitly/go-simplejson"
)
const (
TLSNotRequired = iota
TLSRequiredExceptHTTP
TLSRequired
)
type errStore struct {
err error
}
var (
ErrTopicPartitionMismatch = errors.New("topic partition mismatch")
ErrTopicNotExist = errors.New("topic does not exist")
)
type NSQD struct {
sync.RWMutex
opts atomic.Value
dl *dirlock.DirLock
isLoading int32
errValue atomic.Value
startTime time.Time
topicMap map[string]map[int]*Topic
magicCodeMutex sync.Mutex
poolSize int
MetaNotifyChan chan interface{}
OptsNotificationChan chan struct{}
exitChan chan int
waitGroup util.WaitGroupWrapper
ci *clusterinfo.ClusterInfo
exiting bool
persisting int32
}
func New(opts *Options) *NSQD {
dataPath := opts.DataPath
if opts.DataPath == "" {
cwd, _ := os.Getwd()
dataPath = cwd
opts.DataPath = dataPath
}
err := os.MkdirAll(dataPath, 0755)
if err != nil {
nsqLog.LogErrorf("failed to create directory: %v ", err)
os.Exit(1)
}
nsqLog.Logger = opts.Logger
n := &NSQD{
startTime: time.Now(),
topicMap: make(map[string]map[int]*Topic),
exitChan: make(chan int),
MetaNotifyChan: make(chan interface{}),
OptsNotificationChan: make(chan struct{}, 1),
ci: clusterinfo.New(opts.Logger, http_api.NewClient(nil)),
dl: dirlock.New(dataPath),
}
n.SwapOpts(opts)
n.errValue.Store(errStore{})
err = n.dl.Lock()
if err != nil {
nsqLog.LogErrorf("FATAL: --data-path=%s in use (possibly by another instance of nsqd)", dataPath)
os.Exit(1)
}
if opts.MaxDeflateLevel < 1 || opts.MaxDeflateLevel > 9 {
nsqLog.LogErrorf("FATAL: --max-deflate-level must be [1,9]")
os.Exit(1)
}
if opts.ID < 0 || opts.ID >= MAX_NODE_ID {
nsqLog.LogErrorf("FATAL: --worker-id must be [0,%d)", MAX_NODE_ID)
os.Exit(1)
}
if opts.StatsdPrefix != "" {
var port string
_, port, err = net.SplitHostPort(opts.HTTPAddress)
if err != nil {
nsqLog.LogErrorf("failed to parse HTTP address (%s) - %s", opts.HTTPAddress, err)
os.Exit(1)
}
statsdHostKey := statsd.HostKey(net.JoinHostPort(opts.BroadcastAddress, port))
prefixWithHost := strings.Replace(opts.StatsdPrefix, "%s", statsdHostKey, -1)
if prefixWithHost[len(prefixWithHost)-1] != '.' {
prefixWithHost += "."
}
opts.StatsdPrefix = prefixWithHost
}
if opts.TLSClientAuthPolicy != "" && opts.TLSRequired == TLSNotRequired {
opts.TLSRequired = TLSRequired
}
return n
}
func (n *NSQD) GetOpts() *Options {
return n.opts.Load().(*Options)
}
func (n *NSQD) SwapOpts(opts *Options) {
nsqLog.SetLevel(opts.LogLevel)
n.opts.Store(opts)
}
func (n *NSQD) TriggerOptsNotification() {
select {
case n.OptsNotificationChan <- struct{}{}:
default:
}
}
func (n *NSQD) SetHealth(err error) {
n.errValue.Store(errStore{err: err})
}
func (n *NSQD) IsHealthy() bool {
return n.GetError() == nil
}
func (n *NSQD) GetError() error {
errValue := n.errValue.Load()
return errValue.(errStore).err
}
func (n *NSQD) GetHealth() string {
err := n.GetError()
if err != nil {
return fmt.Sprintf("NOK - %s", err)
}
return "OK"
}
func (n *NSQD) GetStartTime() time.Time {
return n.startTime
}
// should be protected by read lock
func (n *NSQD) GetTopicMapRef() map[string]map[int]*Topic {
return n.topicMap
}
func (n *NSQD) GetTopicPartitions(topicName string) map[int]*Topic {
tmpMap := make(map[int]*Topic)
n.RLock()
parts, ok := n.topicMap[topicName]
if ok {
for p, t := range parts {
tmpMap[p] = t
}
}
n.RUnlock()
return tmpMap
}
func (n *NSQD) GetTopicMapCopy() map[string]map[int]*Topic {
tmpMap := make(map[string]map[int]*Topic)
n.RLock()
for k, topics := range n.topicMap {
var tmpTopics map[int]*Topic
var ok bool
tmpTopics, ok = tmpMap[k]
if !ok {
tmpTopics = make(map[int]*Topic, len(topics))
tmpMap[k] = tmpTopics
}
for p, t := range topics {
tmpTopics[p] = t
}
}
n.RUnlock()
return tmpMap
}
func (n *NSQD) Start() {
n.waitGroup.Wrap(func() { n.queueScanLoop() })
}
func (n *NSQD) LoadMetadata(disabled int32) {
atomic.StoreInt32(&n.isLoading, 1)
defer atomic.StoreInt32(&n.isLoading, 0)
fn := fmt.Sprintf(path.Join(n.GetOpts().DataPath, "nsqd.%d.dat"), n.GetOpts().ID)
data, err := ioutil.ReadFile(fn)
if err != nil {
if !os.IsNotExist(err) {
nsqLog.LogErrorf("failed to read channel metadata from %s - %s", fn, err)
}
return
}
js, err := simplejson.NewJson(data)
if err != nil {
nsqLog.LogErrorf("failed to parse metadata - %s", err)
return
}
topics, err := js.Get("topics").Array()
if err != nil {
nsqLog.LogErrorf("failed to parse metadata - %s", err)
return
}
for ti := range topics {
topicJs := js.Get("topics").GetIndex(ti)
topicName, err := topicJs.Get("name").String()
if err != nil {
nsqLog.LogErrorf("failed to parse metadata - %s", err)
return
}
if !protocol.IsValidTopicName(topicName) {
nsqLog.LogWarningf("skipping creation of invalid topic %s", topicName)
continue
}
part, err := topicJs.Get("partition").Int()
if err != nil {
nsqLog.LogErrorf("failed to parse metadata - %s", err)
return
}
topic := n.internalGetTopic(topicName, part, disabled)
channels, err := topicJs.Get("channels").Array()
if err != nil {
nsqLog.LogErrorf("failed to parse metadata - %s", err)
return
}
for ci := range channels {
channelJs := topicJs.Get("channels").GetIndex(ci)
channelName, err := channelJs.Get("name").String()
if err != nil {
nsqLog.LogErrorf("failed to parse metadata - %s", err)
return
}
if !protocol.IsValidChannelName(channelName) {
nsqLog.LogWarningf("skipping creation of invalid channel %s", channelName)
continue
}
channel := topic.GetChannel(channelName)
paused, _ := channelJs.Get("paused").Bool()
if paused {
channel.Pause()
}
}
}
}
func (n *NSQD) PersistMetadata(currentTopicMap map[string]map[int]*Topic) error {
if !atomic.CompareAndSwapInt32(&n.persisting, 0, 1) {
nsqLog.Logf("NSQ: persisting is already running")
return nil
}
defer atomic.StoreInt32(&n.persisting, 0)
// persist metadata about what topics/channels we have
// so that upon restart we can get back to the same state
fileName := fmt.Sprintf(path.Join(n.GetOpts().DataPath, "nsqd.%d.dat"), n.GetOpts().ID)
nsqLog.Logf("NSQ: persisting topic/channel metadata to %s", fileName)
js := make(map[string]interface{})
topics := []interface{}{}
for _, topicParts := range currentTopicMap {
for _, topic := range topicParts {
if topic.ephemeral {
continue
}
topicData := make(map[string]interface{})
topicData["name"] = topic.GetTopicName()
topicData["partition"] = topic.GetTopicPart()
channels := []interface{}{}
topic.channelLock.RLock()
for _, channel := range topic.channelMap {
channel.RLock()
if !channel.ephemeral {
channelData := make(map[string]interface{})
channelData["name"] = channel.name
channelData["paused"] = channel.IsPaused()
channels = append(channels, channelData)
}
channel.RUnlock()
}
topic.channelLock.RUnlock()
topicData["channels"] = channels
topics = append(topics, topicData)
}
}
js["version"] = version.Binary
js["topics"] = topics
data, err := json.Marshal(&js)
if err != nil {
return err
}
tmpFileName := fmt.Sprintf("%s.%d.tmp", fileName, rand.Int())
f, err := os.OpenFile(tmpFileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return err
}
_, err = f.Write(data)
if err != nil {
f.Close()
return err
}
f.Sync()
f.Close()
err = util.AtomicRename(tmpFileName, fileName)
if err != nil {
return err
}
return nil
}
func (n *NSQD) Exit() {
n.Lock()
if n.exiting {
n.Unlock()
return
}
n.exiting = true
n.Unlock()
tmpMap := n.GetTopicMapCopy()
err := n.PersistMetadata(tmpMap)
if err != nil {
nsqLog.LogErrorf(" failed to persist metadata - %s", err)
}
nsqLog.Logf("NSQ: closing topics")
for _, topics := range tmpMap {
for _, topic := range topics {
topic.Close()
}
}
// we want to do this last as it closes the idPump (if closed first it
// could potentially starve items in process and deadlock)
close(n.exitChan)
n.waitGroup.Wait()
n.dl.Unlock()
nsqLog.Logf("NSQ: exited")
}
func (n *NSQD) GetTopicDefaultPart(topicName string) int {
n.RLock()
topics, ok := n.topicMap[topicName]
if ok {
if len(topics) > 0 {
for _, t := range topics {
n.RUnlock()
return t.GetTopicPart()
}
}
}
n.RUnlock()
return -1
}
func (n *NSQD) GetTopicIgnPart(topicName string) *Topic {
n.RLock()
topics, ok := n.topicMap[topicName]
if ok {
if len(topics) > 0 {
for _, t := range topics {
n.RUnlock()
return t
}
}
}
n.RUnlock()
return n.GetTopic(topicName, 0)
}
func (n *NSQD) GetTopicWithDisabled(topicName string, part int) *Topic {
return n.internalGetTopic(topicName, part, 1)
}
// GetTopic performs a thread safe operation
// to return a pointer to a Topic object (potentially new)
func (n *NSQD) GetTopic(topicName string, part int) *Topic {
return n.internalGetTopic(topicName, part, 0)
}
func (n *NSQD) internalGetTopic(topicName string, part int, disabled int32) *Topic {
if part > MAX_TOPIC_PARTITION || part < 0 {
return nil
}
if topicName == "" {
nsqLog.Logf("TOPIC name is empty")
return nil
}
// most likely, we already have this topic, so try read lock first.
n.RLock()
topics, ok := n.topicMap[topicName]
if ok {
t, ok2 := topics[part]
if ok2 {
n.RUnlock()
return t
}
}
n.RUnlock()
n.Lock()
topics, ok = n.topicMap[topicName]
if ok {
t, ok := topics[part]
if ok {
n.Unlock()
return t
}
} else {
topics = make(map[int]*Topic)
n.topicMap[topicName] = topics
}
if part < 0 {
part = 0
}
deleteCallback := func(t *Topic) {
n.DeleteExistingTopic(t.GetTopicName(), t.GetTopicPart())
}
t := NewTopic(topicName, part, n.GetOpts(), deleteCallback, disabled, n.Notify)
topics[part] = t
nsqLog.Logf("TOPIC(%s): created", t.GetFullName())
n.Unlock()
// if using lookupd, make a blocking call to get the topics, and immediately create them.
// this makes sure that any message received is buffered to the right channels
//lookupdHTTPAddrs := n.lookupdHTTPAddrs()
//if len(lookupdHTTPAddrs) > 0 {
// channelNames, _ := n.ci.GetLookupdTopicChannels(t.GetTopicName(),
// t.GetTopicPart(), lookupdHTTPAddrs)
// for _, channelName := range channelNames {
// if strings.HasSuffix(channelName, "#ephemeral") {
// // we don't want to pre-create ephemeral channels
// // because there isn't a client connected
// continue
// }
// t.getOrCreateChannel(channelName)
// }
//}
// update messagePump state
t.NotifyReloadChannels()
return t
}
// GetExistingTopic gets a topic only if it exists
func (n *NSQD) GetExistingTopic(topicName string, part int) (*Topic, error) {
n.RLock()
defer n.RUnlock()
topics, ok := n.topicMap[topicName]
if !ok {
return nil, ErrTopicNotExist
}
topic, ok := topics[part]
if !ok {
return nil, ErrTopicNotExist
}
return topic, nil
}
func (n *NSQD) deleteTopic(topicName string, part int) {
n.Lock()
defer n.Unlock()
topics, ok := n.topicMap[topicName]
if !ok {
return
}
delete(topics, part)
if len(topics) == 0 {
delete(n.topicMap, topicName)
}
}
// this just close the topic and remove from map, but keep the data for later.
func (n *NSQD) CloseExistingTopic(topicName string, partition int) error {
topic, err := n.GetExistingTopic(topicName, partition)
if err != nil {
return err
}
// delete empties all channels and the topic itself before closing
// (so that we dont leave any messages around)
//
// we do this before removing the topic from map below (with no lock)
// so that any incoming writes will error and not create a new topic
// to enforce ordering
topic.Close()
n.deleteTopic(topicName, partition)
return nil
}
func (n *NSQD) CheckMagicCode(name string, partition int, code int64, tryFix bool) (string, error) {
localTopic, err := n.GetExistingTopic(name, partition)
if err != nil {
// not exist, create temp for check
deleteCallback := func(t *Topic) {
n.DeleteExistingTopic(t.GetTopicName(), t.GetTopicPart())
}
localTopic = NewTopic(name, partition, n.GetOpts(), deleteCallback, 1, n.Notify)
defer localTopic.Close()
}
magicCodeWrong := false
localMagicCode := localTopic.GetMagicCode()
if localMagicCode != 0 && localMagicCode != code {
nsqLog.Infof("local topic %v magic code is not matching with the current:%v-%v", localTopic.GetFullName(), localTopic.GetMagicCode(), code)
magicCodeWrong = true
}
if magicCodeWrong {
if !tryFix {
return "", errors.New("magic code is wrong")
} else {
nsqLog.Warningf("local topic %v removed for wrong magic code: %v vs %v", localTopic.GetFullName(), localTopic.GetMagicCode(), code)
n.deleteTopic(localTopic.GetTopicName(), localTopic.GetTopicPart())
localTopic.Close()
removedPath, err := localTopic.MarkAsRemoved()
return removedPath, err
}
}
return "", nil
}
func (n *NSQD) SetTopicMagicCode(t *Topic, code int64) error {
n.magicCodeMutex.Lock()
err := t.SetMagicCode(code)
n.magicCodeMutex.Unlock()
return err
}
// DeleteExistingTopic removes a topic only if it exists
func (n *NSQD) DeleteExistingTopic(topicName string, part int) error {
topic, err := n.GetExistingTopic(topicName, part)
if err != nil {
return err
}
// delete empties all channels and the topic itself before closing
// (so that we dont leave any messages around)
//
// we do this before removing the topic from map below (with no lock)
// so that any incoming writes will error and not create a new topic
// to enforce ordering
topic.Delete()
n.deleteTopic(topicName, part)
return nil
}
func (n *NSQD) CleanClientPubStats(remote string, protocol string) {
tmpMap := n.GetTopicMapCopy()
for _, topics := range tmpMap {
for _, t := range topics {
t.RemovePubStats(remote, protocol)
}
}
}
func (n *NSQD) flushAll(all bool) {
tmpMap := n.GetTopicMapCopy()
for _, topics := range tmpMap {
for _, t := range topics {
if !all && t.IsWriteDisabled() {
continue
}
t.ForceFlush()
}
}
}
func (n *NSQD) Notify(v interface{}) {
// since the in-memory metadata is incomplete,
// should not persist metadata while loading it.
// nsqd will call `PersistMetadata` it after loading
persist := atomic.LoadInt32(&n.isLoading) == 0
n.waitGroup.Wrap(func() {
// by selecting on exitChan we guarantee that
// we do not block exit, see issue #123
select {
case <-n.exitChan:
case n.MetaNotifyChan <- v:
if !persist {
return
}
tmpMap := n.GetTopicMapCopy()
err := n.PersistMetadata(tmpMap)
if err != nil {
nsqLog.LogErrorf("failed to persist metadata - %s", err)
}
}
})
}
// channels returns a flat slice of all channels in all topics
func (n *NSQD) channels() []*Channel {
var channels []*Channel
tmpMap := n.GetTopicMapCopy()
for _, topics := range tmpMap {
for _, t := range topics {
t.channelLock.RLock()
for _, c := range t.channelMap {
channels = append(channels, c)
}
t.channelLock.RUnlock()
}
}
return channels
}
// resizePool adjusts the size of the pool of queueScanWorker goroutines
//
// 1 <= pool <= min(num * 0.25, QueueScanWorkerPoolMax)
//
func (n *NSQD) resizePool(num int, workCh chan *Channel, responseCh chan bool, closeCh chan int) {
idealPoolSize := int(float64(num) * 0.25)
if idealPoolSize < 1 {
idealPoolSize = 1
} else if idealPoolSize > n.GetOpts().QueueScanWorkerPoolMax {
idealPoolSize = n.GetOpts().QueueScanWorkerPoolMax
}
for {
if idealPoolSize == n.poolSize {
break
} else if idealPoolSize < n.poolSize {
// contract
closeCh <- 1
n.poolSize--
} else {
// expand
n.waitGroup.Wrap(func() {
n.queueScanWorker(workCh, responseCh, closeCh)
})
n.poolSize++
}
}
}
// queueScanWorker receives work (in the form of a channel) from queueScanLoop
// and processes the in-flight queues
func (n *NSQD) queueScanWorker(workCh chan *Channel, responseCh chan bool, closeCh chan int) {
for {
select {
case c := <-workCh:
now := time.Now().UnixNano()
dirty := false
if c.processInFlightQueue(now) {
dirty = true
}
responseCh <- dirty
case <-closeCh:
return
}
}
}
// queueScanLoop runs in a single goroutine to process in-flight
// . It manages a pool of queueScanWorker (configurable max of
// QueueScanWorkerPoolMax (default: 4)) that process channels concurrently.
//
// It copies Redis's probabilistic expiration algorithm: it wakes up every
// QueueScanInterval (default: 100ms) to select a random QueueScanSelectionCount
// (default: 20) channels from a locally cached list (refreshed every
// QueueScanRefreshInterval (default: 5s)).
//
// If either of the queues had work to do the channel is considered "dirty".
//
// If QueueScanDirtyPercent (default: 25%) of the selected channels were dirty,
// the loop continues without sleep.
func (n *NSQD) queueScanLoop() {
workCh := make(chan *Channel, n.GetOpts().QueueScanSelectionCount)
responseCh := make(chan bool, n.GetOpts().QueueScanSelectionCount)
closeCh := make(chan int)
workTicker := time.NewTicker(n.GetOpts().QueueScanInterval)
refreshTicker := time.NewTicker(n.GetOpts().QueueScanRefreshInterval)
flushTicker := time.NewTicker(n.GetOpts().SyncTimeout)
channels := n.channels()
n.resizePool(len(channels), workCh, responseCh, closeCh)
flushCnt := 0
for {
select {
case <-workTicker.C:
if len(channels) == 0 {
continue
}
case <-refreshTicker.C:
channels = n.channels()
n.resizePool(len(channels), workCh, responseCh, closeCh)
continue
case <-flushTicker.C:
n.flushAll(flushCnt%100 == 0)
continue
case <-n.exitChan:
goto exit
}
num := n.GetOpts().QueueScanSelectionCount
if num > len(channels) {
num = len(channels)
}
loop:
for _, i := range util.UniqRands(num, len(channels)) {
workCh <- channels[i]
}
numDirty := 0
for i := 0; i < num; i++ {
if <-responseCh {
numDirty++
}
}
if float64(numDirty)/float64(num) > n.GetOpts().QueueScanDirtyPercent {
goto loop
}
}
exit:
nsqLog.Logf("QUEUESCAN: closing")
close(closeCh)
workTicker.Stop()
refreshTicker.Stop()
}
func (n *NSQD) IsAuthEnabled() bool {
return len(n.GetOpts().AuthHTTPAddresses) != 0
}