forked from named-data/YaNFD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
76 lines (61 loc) · 2.34 KB
/
init.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
/* YaNFD - Yet another NDN Forwarding Daemon
*
* Copyright (C) 2020-2021 Eric Newberry.
*
* This file is licensed under the terms of the MIT License, as found in LICENSE.md.
*/
package table
import (
"time"
"github.com/eric135/YaNFD/core"
"github.com/eric135/YaNFD/ndn"
)
// tableQueueSize is the maxmimum size of queues in the tables.
var tableQueueSize int
// deadNonceListLifetime is the lifetime of entries in the dead nonce list.
var deadNonceListLifetime time.Duration
// csCapacity contains the default capacity of each forwarding thread's Content Store.
var csCapacity int
// csAdmit determines whether contents will be admitted to the Content Store.
var csAdmit bool
// csServe determines whether contents will be served from the Content Store.
var csServe bool
// csReplacementPolicy contains the replacement policy used by Content Stores in the forwarder.
var csReplacementPolicy string
// producerRegions contains the prefixes produced in this forwarder's region.
var producerRegions []string
// Configure configures the forwarding system.
func Configure() {
tableQueueSize = core.GetConfigIntDefault("tables.queue_size", 1024)
// Content Store
csCapacity = int(core.GetConfigUint16Default("tables.content_store.capacity", 1024))
csAdmit = core.GetConfigBoolDefault("tables.content_store.admit", true)
csServe = core.GetConfigBoolDefault("tables.content_store.serve", true)
csReplacementPolicyName := core.GetConfigStringDefault("tables.content_store.replacement_policy", "lru")
switch csReplacementPolicyName {
case "lru":
csReplacementPolicy = "lru"
default:
// Default to LRU
csReplacementPolicy = "lru"
}
// Dead Nonce List
deadNonceListLifetime = time.Duration(core.GetConfigIntDefault("tables.dead_nonce_list.lifetime", 6000)) * time.Millisecond
// Network Region Table
producerRegions = core.GetConfigArrayString("tables.network_region.regions")
if producerRegions == nil {
producerRegions = make([]string, 0)
}
for _, region := range producerRegions {
name, err := ndn.NameFromString(region)
if err != nil {
core.LogFatal("NetworkRegionTable", "Could not add name=", region, " to table: ", err)
}
NetworkRegion.Add(name)
core.LogDebug("NetworkRegionTable", "Added name=", region, " to table")
}
}
// SetCsCapacity sets the CS capacity from management.
func SetCsCapacity(capacity int) {
csCapacity = capacity
}