@@ -86,6 +86,12 @@ func (d *MasterDaemon) Init() {
86
86
if err != nil {
87
87
log .Fatalf ("Failed to init resource manager. Error: %s" , err )
88
88
}
89
+
90
+ // Create an objdb client
91
+ d .objdbClient , err = objdb .NewClient (d .ClusterStore )
92
+ if err != nil {
93
+ log .Fatalf ("Error connecting to state store: %v. Err: %v" , d .ClusterStore , err )
94
+ }
89
95
}
90
96
91
97
func (d * MasterDaemon ) registerService () {
@@ -105,7 +111,7 @@ func (d *MasterDaemon) registerService() {
105
111
}
106
112
107
113
// Register the node with service registry
108
- err = master . ObjdbClient .RegisterService (srvInfo )
114
+ err = d . objdbClient .RegisterService (srvInfo )
109
115
if err != nil {
110
116
log .Fatalf ("Error registering service. Err: %v" , err )
111
117
}
@@ -120,7 +126,7 @@ func (d *MasterDaemon) registerService() {
120
126
}
121
127
122
128
// Register the node with service registry
123
- err = master . ObjdbClient .RegisterService (srvInfo )
129
+ err = d . objdbClient .RegisterService (srvInfo )
124
130
if err != nil {
125
131
log .Fatalf ("Error registering service. Err: %v" , err )
126
132
}
@@ -136,7 +142,7 @@ func (d *MasterDaemon) agentDiscoveryLoop() {
136
142
watchStopCh := make (chan bool , 1 )
137
143
138
144
// Start a watch on netplugin service
139
- err := master . ObjdbClient .WatchService ("netplugin" , agentEventCh , watchStopCh )
145
+ err := d . objdbClient .WatchService ("netplugin" , agentEventCh , watchStopCh )
140
146
if err != nil {
141
147
log .Fatalf ("Could not start a watch on netplugin service. Err: %v" , err )
142
148
}
@@ -230,7 +236,7 @@ func (d *MasterDaemon) runLeader() {
230
236
defer d .listenerMutex .Unlock ()
231
237
232
238
// Create a new api controller
233
- d .apiController = objApi .NewAPIController (router , d .ClusterStore )
239
+ d .apiController = objApi .NewAPIController (router , d .objdbClient , d . ClusterStore )
234
240
235
241
//Restore state from clusterStore
236
242
d .restoreCache ()
@@ -342,17 +348,11 @@ func (d *MasterDaemon) RunMasterFsm() {
342
348
log .Fatalf ("Error creating ofnet master" )
343
349
}
344
350
345
- // Create an objdb client
346
- master .ObjdbClient , err = objdb .NewClient (d .ClusterStore )
347
- if err != nil {
348
- log .Fatalf ("Error connecting to state store: %v. Err: %v" , d .ClusterStore , err )
349
- }
350
-
351
351
// Register all existing netplugins in the background
352
352
go d .agentDiscoveryLoop ()
353
353
354
354
// Create the lock
355
- leaderLock , err = master . ObjdbClient .NewLock ("netmaster/leader" , localIP , leaderLockTTL )
355
+ leaderLock , err = d . objdbClient .NewLock ("netmaster/leader" , localIP , leaderLockTTL )
356
356
if err != nil {
357
357
log .Fatalf ("Could not create leader lock. Err: %v" , err )
358
358
}
0 commit comments