@@ -139,20 +139,20 @@ func (t *Tracker) internalServerError(message string, err error, r *http.Request
139139func (t * Tracker ) getPath (w http.ResponseWriter , r * http.Request ) {
140140 var response GetPath
141141 key := r .FormValue ("key" )
142- row := t .db .QueryRow ("select h.hostip , d.read_port, d.devid, f.fid, f.created_at " +
142+ row := t .db .QueryRow ("select h.hostname , d.read_port, d.devid, f.fid, f.created_at " +
143143 "from file f " +
144144 "join file_on fo on f.fid=fo.fid " +
145145 "join device d on d.devid=fo.devid " +
146146 "join host h on h.hostid=d.hostid " +
147147 "where h.status='alive' " +
148148 "and d.status in ('alive', 'drain') " +
149149 "and f.dkey=?" , key )
150- var hostip string
150+ var hostname string
151151 var httpPort int64
152152 var devid int64
153153 var fid int64
154154 var createdAt mysql.NullTime
155- err := row .Scan (& hostip , & httpPort , & devid , & fid , & createdAt )
155+ err := row .Scan (& hostname , & httpPort , & devid , & fid , & createdAt )
156156 if err == sql .ErrNoRows {
157157 http .Error (w , "file not found" , http .StatusNotFound )
158158 return
@@ -161,7 +161,7 @@ func (t *Tracker) getPath(w http.ResponseWriter, r *http.Request) {
161161 t .internalServerError ("cannot scan rows" , err , r , w )
162162 return
163163 }
164- response .Path = fmt .Sprintf ("http://%s:%d/dev%d/%s" , hostip , httpPort , devid , vivify (fid ))
164+ response .Path = fmt .Sprintf ("http://%s:%d/dev%d/%s" , hostname , httpPort , devid , vivify (fid ))
165165 response .CreatedAt = createdAt .Time .Format (time .RFC3339 )
166166 encoder := json .NewEncoder (w )
167167 encoder .Encode (response ) // nolint: errcheck
@@ -172,7 +172,7 @@ func (t *Tracker) getPaths(w http.ResponseWriter, r *http.Request) {
172172 Paths : make ([]GetPath , 0 ),
173173 }
174174 key := r .FormValue ("key" )
175- rows , err := t .db .Query ("select h.hostip , d.read_port, d.devid, f.fid, f.created_at " +
175+ rows , err := t .db .Query ("select h.hostname , d.read_port, d.devid, f.fid, f.created_at " +
176176 "from file f " +
177177 "join file_on fo on f.fid=fo.fid " +
178178 "join device d on d.devid=fo.devid " +
@@ -186,12 +186,12 @@ func (t *Tracker) getPaths(w http.ResponseWriter, r *http.Request) {
186186 }
187187 defer rows .Close () // nolint: errcheck
188188 for rows .Next () {
189- var hostip string
189+ var hostname string
190190 var httpPort int64
191191 var devid int64
192192 var fid int64
193193 var createdAt mysql.NullTime
194- err = rows .Scan (& hostip , & httpPort , & devid , & fid , & createdAt )
194+ err = rows .Scan (& hostname , & httpPort , & devid , & fid , & createdAt )
195195 if err == sql .ErrNoRows {
196196 http .Error (w , "file not found" , http .StatusNotFound )
197197 return
@@ -201,7 +201,7 @@ func (t *Tracker) getPaths(w http.ResponseWriter, r *http.Request) {
201201 return
202202 }
203203 path := GetPath {
204- Path : fmt .Sprintf ("http://%s:%d/dev%d/%s" , hostip , httpPort , devid , vivify (fid )),
204+ Path : fmt .Sprintf ("http://%s:%d/dev%d/%s" , hostname , httpPort , devid , vivify (fid )),
205205 CreatedAt : createdAt .Time .Format (time .RFC3339 ),
206206 }
207207 response .Paths = append (response .Paths , path )
@@ -262,13 +262,13 @@ func (t *Tracker) createOpen(w http.ResponseWriter, r *http.Request) {
262262var errNoDeviceAvailable = errors .New ("no device available" )
263263
264264type aliveDevice struct {
265- hostip string
265+ hostname string
266266 httpPort int64
267267 devid int64
268268}
269269
270270func (d * aliveDevice ) PatchURL (fid int64 ) string {
271- return fmt .Sprintf ("http://%s:%d/dev%d/%s" , d .hostip , d .httpPort , d .devid , vivify (fid ))
271+ return fmt .Sprintf ("http://%s:%d/dev%d/%s" , d .hostname , d .httpPort , d .devid , vivify (fid ))
272272}
273273
274274func findAliveDevice (db * sql.DB , size int64 , devids []int64 ) (* aliveDevice , error ) {
@@ -282,7 +282,7 @@ func findAliveDevice(db *sql.DB, size int64, devids []int64) (*aliveDevice, erro
282282 } else {
283283 devidsSQL = "and d.status='alive' "
284284 }
285- rows , err := db .Query ("select h.hostip , d.write_port, d.devid " +
285+ rows , err := db .Query ("select h.hostname , d.write_port, d.devid " +
286286 "from device d " +
287287 "join host h on d.hostid=h.hostid " +
288288 "where h.status='alive' " +
@@ -297,7 +297,7 @@ func findAliveDevice(db *sql.DB, size int64, devids []int64) (*aliveDevice, erro
297297 defer rows .Close () // nolint: errcheck
298298 for rows .Next () {
299299 var d aliveDevice
300- err = rows .Scan (& d .hostip , & d .httpPort , & d .devid )
300+ err = rows .Scan (& d .hostname , & d .httpPort , & d .devid )
301301 if err != nil {
302302 return nil , err
303303 }
@@ -385,12 +385,12 @@ func (t *Tracker) createClose(w http.ResponseWriter, r *http.Request) {
385385 t .internalServerError ("cannot insert file_on record" , err , r , w )
386386 return
387387 }
388- row = tx .QueryRow ("select h.hostip , d.read_port " +
388+ row = tx .QueryRow ("select h.hostname , d.read_port " +
389389 "from device d join host h on h.hostid=d.hostid " +
390390 "where d.devid=?" , devid )
391- var hostip string
391+ var hostname string
392392 var httpPort int64
393- err = row .Scan (& hostip , & httpPort )
393+ err = row .Scan (& hostname , & httpPort )
394394 if err != nil {
395395 t .internalServerError ("cannot select host ip" , err , r , w )
396396 return
@@ -404,7 +404,7 @@ func (t *Tracker) createClose(w http.ResponseWriter, r *http.Request) {
404404 go t .publishDeleteTask (olddevids , oldfid )
405405 }
406406 var response CreateClose
407- response .Path = fmt .Sprintf ("http://%s:%d/dev%d/%s" , hostip , httpPort , devid , vivify (fid ))
407+ response .Path = fmt .Sprintf ("http://%s:%d/dev%d/%s" , hostname , httpPort , devid , vivify (fid ))
408408 encoder := json .NewEncoder (w )
409409 encoder .Encode (response ) // nolint: errcheck
410410}
0 commit comments