Skip to content

Commit

Permalink
refactor: increase verbosity level of some log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
buraksezer committed Oct 14, 2022
1 parent fb44ec8 commit 6a9245f
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 35 deletions.
10 changes: 2 additions & 8 deletions cluster_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ func (dm *ClusterDMap) Incr(ctx context.Context, key string, delta int) (int, er
if err != nil {
return 0, processProtocolError(err)
}
// TODO: Consider returning uint64 as response
res, err := cmd.Uint64()
if err != nil {
return 0, processProtocolError(cmd.Err())
Expand All @@ -245,7 +244,6 @@ func (dm *ClusterDMap) Decr(ctx context.Context, key string, delta int) (int, er
if err != nil {
return 0, processProtocolError(err)
}
// TODO: Consider returning uint64 as response
res, err := cmd.Uint64()
if err != nil {
return 0, processProtocolError(cmd.Err())
Expand Down Expand Up @@ -343,7 +341,6 @@ func (dm *ClusterDMap) Lock(ctx context.Context, key string, deadline time.Durat
return nil, err
}

// TODO: Inconsistency: TIMEOUT, duration or second?
cmd := protocol.NewLock(dm.name, key, deadline.Seconds()).Command(ctx)
err = rc.Process(ctx, cmd)
if err != nil {
Expand All @@ -362,9 +359,8 @@ func (dm *ClusterDMap) Lock(ctx context.Context, key string, deadline time.Durat
}

// LockWithTimeout sets a lock for the given key. If the lock is still unreleased
// the end of given period of time,
// it automatically releases the lock. Acquired lock is only for the key in
// this dmap.
// the end of given period of time, it automatically releases the lock.
// Acquired lock is only for the key in this DMap.
//
// It returns immediately if it acquires the lock for the given key. Otherwise,
// it waits until deadline.
Expand All @@ -377,7 +373,6 @@ func (dm *ClusterDMap) LockWithTimeout(ctx context.Context, key string, timeout,
return nil, err
}

// TODO: Inconsistency: TIMEOUT, duration or second?
cmd := protocol.NewLock(dm.name, key, deadline.Seconds()).SetPX(timeout.Milliseconds()).Command(ctx)
err = rc.Process(ctx, cmd)
if err != nil {
Expand Down Expand Up @@ -414,7 +409,6 @@ func (c *ClusterLockContext) Lease(ctx context.Context, duration time.Duration)
if err != nil {
return err
}
// TODO: Inconsistency!
cmd := protocol.NewLockLease(c.dm.name, c.key, c.token, duration.Seconds()).Command(ctx)
err = rc.Process(ctx, cmd)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/olricd/olricd-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ logging:
# * 6 - Trace level verbosity
# * Context to understand the steps leading up to neterrors and warnings
# * More information for troubleshooting reported issues
verbosity: 6
verbosity: 3

# Default LogLevel is DEBUG. Available levels: "DEBUG", "WARN", "ERROR", "INFO"
level: DEBUG
level: INFO
output: stderr

memberlist:
Expand Down
4 changes: 2 additions & 2 deletions docker/olricd-consul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ logging:
# * 6 - Trace level verbosity
# * Context to understand the steps leading up to neterrors and warnings
# * More information for troubleshooting reported issues
verbosity: 6
verbosity: 3

# Default LogLevel is DEBUG. Available levels: "DEBUG", "WARN", "ERROR", "INFO"
level: DEBUG
level: INFO
output: stderr

memberlist:
Expand Down
14 changes: 6 additions & 8 deletions internal/cluster/routingtable/distribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ func (r *RoutingTable) distributePrimaryCopies(partID uint64) []discovery.Member
r.log.V(6).Printf("[DEBUG] Failed to find %s in the cluster: %v", owner, err)
owners = append(owners[:i], owners[i+1:]...)
i--
r.log.V(6).Printf("[INFO] Member: %s has been deleted from the primary owners list of PartID: %v", owner.String(), partID)
r.log.V(3).Printf("[INFO] Member: %s has been deleted from the primary owners list of PartID: %v", owner.String(), partID)
continue
}
if !owner.CompareByID(current) {
r.log.V(4).Printf("[WARN] One of the partitions owners is probably re-joined: %s", current)
r.log.V(3).Printf("[WARN] One of the partitions owners is probably re-joined: %s", current)
owners = append(owners[:i], owners[i+1:]...)
i--
continue
Expand All @@ -61,17 +61,16 @@ func (r *RoutingTable) distributePrimaryCopies(partID uint64) []discovery.Member
cmd := protocol.NewLengthOfPart(partID).Command(r.ctx)
rc := r.client.Get(owner.String())
err := rc.Process(r.ctx, cmd)
// TODO: improve logging
if err != nil {
r.log.V(3).Printf("[ERROR] Failed to check key count on backup "+
r.log.V(6).Printf("[DEBUG] Failed to check key count on backup "+
"partition: %d: %v", partID, err)
// Pass it. If the node is down, memberlist package will send a leave event.
continue
}

count, err := cmd.Result()
if err != nil {
r.log.V(3).Printf("[ERROR] Failed to check key count on backup "+
r.log.V(6).Printf("[DEBUG] Failed to check key count on backup "+
"partition: %d: %v", partID, err)
// Pass it. If the node is down, memberlist package will send a leave event.
continue
Expand Down Expand Up @@ -170,16 +169,15 @@ func (r *RoutingTable) distributeBackups(partID uint64) []discovery.Member {
cmd := protocol.NewLengthOfPart(partID).SetReplica().Command(r.ctx)
rc := r.client.Get(backup.String())
err := rc.Process(r.ctx, cmd)
// TODO: improve logging
if err != nil {
r.log.V(3).Printf("[ERROR] Failed to check key count on backup "+
r.log.V(6).Printf("[DEBUG] Failed to check key count on backup "+
"partition: %d: %v", partID, err)
// Pass it. If the node is down, memberlist package will send a leave event.
continue
}
count, err := cmd.Result()
if err != nil {
r.log.V(3).Printf("[ERROR] Failed to check key count on backup "+
r.log.V(6).Printf("[DEBUG] Failed to check key count on backup "+
"partition: %d: %v", partID, err)
// Pass it. If the node is down, memberlist package will send a leave event.
continue
Expand Down
2 changes: 1 addition & 1 deletion internal/dmap/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (c *dmapConfig) load(dc *config.DMaps, name string) error {
}
}

// TODO: Create a new function to verify config config.
//TODO: Create a new function to verify config.
if c.evictionPolicy == config.LRUEviction {
if c.maxInuse <= 0 && c.maxKeys <= 0 {
return fmt.Errorf("maxInuse or maxKeys have to be greater than zero")
Expand Down
1 change: 0 additions & 1 deletion internal/dmap/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func (dm *DMap) deleteBackupOnCluster(hkey uint64, key string) error {
dm.s.log.V(3).Printf("[ERROR] Failed to delete replica key/value on %s: %s", dm.name, err)
return protocol.ConvertError(err)
}
// TODO: Improve logging
return protocol.ConvertError(cmd.Err())
})
}
Expand Down
4 changes: 2 additions & 2 deletions internal/dmap/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func (dm *DMap) destroyOnCluster(ctx context.Context) error {
}
defer sem.Release(1)

// TODO: Improve logging
dm.s.log.V(6).Printf("[DEBUG] Calling Destroy command on %s for %s", addr, dm.name)
dm.s.log.V(6).Printf("[DEBUG] Calling DM.DESTROY command on %s for %s", addr, dm.name)
cmd := protocol.NewDestroy(dm.name).SetLocal().Command(dm.s.ctx)
rc := dm.s.client.Get(addr)
err := rc.Process(ctx, cmd)
if err != nil {
dm.s.log.V(3).Printf("[ERROR] DM.DESTROY returned an error: %v", err)
return err
}
return cmd.Err()
Expand Down
2 changes: 1 addition & 1 deletion internal/dmap/eviction.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (dm *DMap) isKeyIdleOnFragment(hkey uint64, f *fragment) bool {
if errors.Is(err, storage.ErrKeyNotFound) {
return false
}
// TODO: Handle other errors.
//TODO: Handle other errors.
ttl := (dm.config.maxIdleDuration.Nanoseconds() + lastAccess) / 1000000
return isKeyExpired(ttl)
}
Expand Down
5 changes: 2 additions & 3 deletions internal/dmap/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (dm *DMap) lookupOnReplicas(hkey uint64, key string) []*version {
err = protocol.ConvertError(err)
if err != nil {
if dm.s.log.V(6).Ok() {
dm.s.log.V(6).Printf("[ERROR] Failed to call get on"+
dm.s.log.V(6).Printf("[DEBUG] Failed to call get on"+
" a replica owner: %s: %v", host, err)
}
continue
Expand All @@ -214,9 +214,8 @@ func (dm *DMap) lookupOnReplicas(hkey uint64, key string) []*version {
value, err := cmd.Bytes()
err = protocol.ConvertError(err)
if err != nil {
// TODO: Improve logging
if dm.s.log.V(6).Ok() {
dm.s.log.V(6).Printf("[ERROR] Failed to call get on"+
dm.s.log.V(6).Printf("[DEBUG] Failed to call get on"+
" a replica owner: %s: %v", host, err)
}
}
Expand Down
1 change: 0 additions & 1 deletion internal/dmap/get_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (s *Service) getEntryCommandHandler(conn redcon.Conn, cmd redcon.Command) {
e.hkey = partitions.HKey(getEntryCmd.DMap, getEntryCmd.Key)
e.kind = kind
nt, err := dm.getOnFragment(e)
// TODO: errFragmentNotFound??
if err == errFragmentNotFound {
err = ErrKeyNotFound
}
Expand Down
1 change: 0 additions & 1 deletion internal/dmap/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ func (dm *DMap) putOnCluster(e *env) error {
e.timeout = dm.config.ttlDuration
}
if dm.config.evictionPolicy == config.LRUEviction {
// TODO: What about lock?
if err = dm.setLRUEvictionStats(e); err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions internal/protocol/dmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,6 @@ func ParseIncrByFloatCommand(cmd redcon.Command) (*IncrByFloat, error) {
), nil
}

// TODO: Add PLock

type Lock struct {
DMap string
Key string
Expand Down
2 changes: 1 addition & 1 deletion internal/pubsub/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func TestPubSub_Handler_Close(t *testing.T) {

err = ps.Ping(ctx)
require.Error(t, err, "redis: client is closed")
// TODO: Control active subscriber count
//TODO: Control active subscriber count
}

func TestPubSub_Handler_PubSubChannels_Without_Patterns(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions olricd-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ logging:
# * 6 - Trace level verbosity
# * Context to understand the steps leading up to neterrors and warnings
# * More information for troubleshooting reported issues
verbosity: 6
verbosity: 3

# Default LogLevel is DEBUG. Available levels: "DEBUG", "WARN", "ERROR", "INFO"
level: DEBUG
level: INFO
output: stderr

memberlist:
Expand Down

0 comments on commit 6a9245f

Please sign in to comment.