-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace logger `logrus` with `zap` Signed-off-by: Arrobo, Gabriel <[email protected]> --------- Signed-off-by: Arrobo, Gabriel <[email protected]>
- Loading branch information
1 parent
f4d2641
commit 66520bc
Showing
9 changed files
with
117 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.4.4-dev | ||
1.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// SPDX-FileCopyrightText: 2022 Open Networking Foundation <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package backend | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
"time" | ||
|
||
|
@@ -26,7 +26,7 @@ func RoundRobin() Backend { | |
length := ctx.NFLength() | ||
|
||
if length <= 0 { | ||
logger.DispatchLog.Errorln("There are no backend NFs running") | ||
logger.DispatchLog.Errorln("there are no backend NFs running") | ||
return nil | ||
} | ||
if next >= length { | ||
|
@@ -49,15 +49,15 @@ func (b BackendSvc) DispatchAddServer() { | |
svcList := b.Cfg.Configuration.Services | ||
for _, svc := range svcList { | ||
for { | ||
logger.DiscoveryLog.Traceln("Discover Service ", svc.Uri) | ||
logger.DiscoveryLog.Debugln("discover Service", svc.Uri) | ||
ips, err := net.LookupIP(svc.Uri) | ||
if err != nil { | ||
logger.DiscoveryLog.Errorln("Discover Service ", svc.Uri, " Error ", err) | ||
logger.DiscoveryLog.Warnf("discover Service %s error %+v", svc.Uri, err) | ||
time.Sleep(2 * time.Second) | ||
continue | ||
} | ||
for _, ip := range ips { | ||
logger.DiscoveryLog.Traceln("Discover Service ", svc.Uri, ", ip ", ip) | ||
logger.DiscoveryLog.Debugln("discover Service %s, ip %s", svc.Uri, ", ip", ip.String()) | ||
found := false | ||
if ipv4 := ip.To4(); ipv4 != nil { | ||
for _, instance := range ctx.Backends { | ||
|
@@ -70,16 +70,15 @@ func (b BackendSvc) DispatchAddServer() { | |
if found { | ||
continue | ||
} | ||
logger.DiscoveryLog.Infoln("New Server found IPv4: ", ipv4.String()) | ||
logger.DiscoveryLog.Infoln("new server found IPv4:", ipv4.String()) | ||
var backend context.NF | ||
switch b.Cfg.Configuration.Type { | ||
case "grpc": | ||
backend = &GrpcServer{ | ||
address: ipv4.String(), | ||
} | ||
default: | ||
logger.DiscoveryLog.Warnln("unsupported backend type: " + | ||
b.Cfg.Configuration.Type) | ||
logger.DiscoveryLog.Warnln("unsupported backend type:", b.Cfg.Configuration.Type) | ||
} | ||
ctx.Lock() | ||
ctx.AddNF(backend) | ||
|
@@ -99,7 +98,7 @@ func deleteBackendNF(b context.NF) { | |
defer ctx.Unlock() | ||
ctx.DeleteNF(b) | ||
for _, b1 := range ctx.Backends { | ||
fmt.Printf("Available backend %v \n", b1) | ||
logger.AppLog.Infof("available backend %v", b1) | ||
} | ||
} | ||
|
||
|
@@ -114,40 +113,40 @@ func dispatchMessage(conn net.Conn, msg []byte) { //*gClient.Message) { | |
var peer *SctpConnections | ||
p, ok := connections.Load(conn) | ||
if !ok { | ||
logger.SctpLog.Infof("Notification for unknown connection") | ||
logger.SctpLog.Infoln("notification for unknown connection") | ||
return | ||
} else { | ||
peer = p.(*SctpConnections) | ||
logger.SctpLog.Warnf("Handle SCTP Notification[addr: %+v], peer %v ", conn.RemoteAddr(), peer) | ||
logger.SctpLog.Infoln("handle SCTP Notification from peer", peer.address) | ||
} | ||
ctx := context.Sctplb_Self() | ||
ctx.Lock() | ||
defer ctx.Unlock() | ||
ran, _ := ctx.RanFindByConn(conn) | ||
if len(msg) == 0 { | ||
logger.SctpLog.Infof("send Gnb connection [%v] close message to all AMF Instances", peer) | ||
logger.SctpLog.Infof("send Gnb connection [%v] close message to all AMF Instances", peer.address) | ||
if ctx.Backends != nil && ctx.NFLength() > 0 { | ||
var i int | ||
for ; i < ctx.NFLength(); i++ { | ||
backend := ctx.Backends[i] | ||
if backend.State() { | ||
if err := backend.Send(msg, true, ran); err != nil { | ||
logger.SctpLog.Errorln("can not send ", err) | ||
logger.SctpLog.Errorln("can not send", err) | ||
} | ||
} | ||
} | ||
} else { | ||
logger.SctpLog.Errorln("No AMF Connections") | ||
logger.SctpLog.Errorln("no AMF Connections") | ||
} | ||
context.Sctplb_Self().DeleteRan(conn) | ||
return | ||
} | ||
if ran == nil { | ||
ran = context.Sctplb_Self().NewRan(conn) | ||
} | ||
logger.SctpLog.Println("Message received from remoteAddr ", conn.RemoteAddr().String()) | ||
logger.SctpLog.Infoln("message received from remoteAddr", conn.RemoteAddr().String()) | ||
if ctx.NFLength() == 0 { | ||
fmt.Println("NO backend available") | ||
logger.AppLog.Errorln("no backend available") | ||
return | ||
} | ||
var i int | ||
|
@@ -156,7 +155,7 @@ func dispatchMessage(conn net.Conn, msg []byte) { //*gClient.Message) { | |
backend := RoundRobin() | ||
if backend.State() { | ||
if err := backend.Send(msg, false, ran); err != nil { | ||
logger.SctpLog.Errorln("can not send: ", err) | ||
logger.SctpLog.Errorln("can not send:", err) | ||
} | ||
break | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
// SPDX-FileCopyrightText: 2022 Open Networking Foundation <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package backend | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
"io" | ||
"net" | ||
"sync" | ||
|
@@ -39,7 +39,7 @@ var sctpConfig sctp.SocketConfig = sctp.SocketConfig{ | |
} | ||
|
||
func ServiceRun(addresses []string, port int) { | ||
fmt.Println("service Run is called") | ||
logger.AppLog.Infoln("service Run is called") | ||
handler := SCTPHandler{ | ||
HandleMessage: dispatchMessage, | ||
} | ||
|
@@ -48,9 +48,9 @@ func ServiceRun(addresses []string, port int) { | |
|
||
for _, addr := range addresses { | ||
if netAddr, err := net.ResolveIPAddr("ip", addr); err != nil { | ||
logger.SctpLog.Errorf("error resolving address '%s': %v\n", addr, err) | ||
logger.SctpLog.Errorf("error resolving address '%s': %v", addr, err) | ||
} else { | ||
logger.SctpLog.Debugf("resolved address '%s' to %s\n", addr, netAddr) | ||
logger.SctpLog.Debugf("resolved address '%s' to %s", addr, netAddr) | ||
ips = append(ips, *netAddr) | ||
} | ||
} | ||
|
@@ -71,7 +71,7 @@ func listenAndServe(addr *sctp.SCTPAddr, handler SCTPHandler) { | |
sctpListener = listener | ||
} | ||
|
||
logger.SctpLog.Infof("listen on %s", sctpListener.Addr()) | ||
logger.SctpLog.Infoln("listen on", sctpListener.Addr()) | ||
|
||
for { | ||
newConn, err := sctpListener.AcceptSCTP() | ||
|
@@ -116,7 +116,7 @@ func listenAndServe(addr *sctp.SCTPAddr, handler SCTPHandler) { | |
} | ||
continue | ||
} else { | ||
logger.SctpLog.Debugln("Subscribe SCTP event[DATA_IO, SHUTDOWN_EVENT, ASSOCIATION_CHANGE]") | ||
logger.SctpLog.Debugln("subscribe SCTP event[DATA_IO, SHUTDOWN_EVENT, ASSOCIATION_CHANGE]") | ||
} | ||
|
||
if err := newConn.SetReadBuffer(int(readBufSize)); err != nil { | ||
|
@@ -178,7 +178,7 @@ func handleConnection(conn *sctp.SCTPConn, bufsize uint32, handler SCTPHandler) | |
logger.SctpLog.Debugf("SCTPRead: %+v", err) | ||
continue | ||
default: | ||
logger.SctpLog.Errorf("handle connection[addr: %+v] error: %+v", conn.RemoteAddr(), err) | ||
logger.SctpLog.Errorf("handle connection [addr: %+v] error: %+v", conn.RemoteAddr(), err) | ||
GnbConnChan <- false | ||
return | ||
} | ||
|
@@ -187,10 +187,10 @@ func handleConnection(conn *sctp.SCTPConn, bufsize uint32, handler SCTPHandler) | |
if notification != nil { | ||
p, ok := connections.Load(conn) | ||
if !ok { | ||
logger.SctpLog.Infof("notification for unknown connection") | ||
logger.SctpLog.Warnln("notification for unknown connection") | ||
} else { | ||
peer := p.(*SctpConnections) | ||
logger.SctpLog.Warnf("handle SCTP Notification[addr: %+v], peer %v ", conn.RemoteAddr(), peer) | ||
logger.SctpLog.Infof("handle SCTP Notification peer %v ", peer.address) | ||
GnbConnChan <- false | ||
} | ||
} else { | ||
|
@@ -199,16 +199,16 @@ func handleConnection(conn *sctp.SCTPConn, bufsize uint32, handler SCTPHandler) | |
continue | ||
} | ||
|
||
logger.SctpLog.Tracef("read %d bytes", n) | ||
logger.SctpLog.Tracef("packet content:\n%+v", hex.Dump(buf[:n])) | ||
logger.SctpLog.Debugf("read %d bytes", n) | ||
logger.SctpLog.Debugf("packet content: %+v", hex.Dump(buf[:n])) | ||
|
||
handler.HandleMessage(conn, buf[:n]) | ||
} | ||
} | ||
}() | ||
|
||
for x := range GnbConnChan { | ||
logger.SctpLog.Errorln("closing gnb Connection ", x) | ||
logger.SctpLog.Infoln("closing gnb Connection:", x) | ||
buf := make([]byte, bufsize) | ||
handler.HandleMessage(conn, buf[:0]) | ||
return | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.