Skip to content

Commit

Permalink
Remove unused loggers from history (uber#4822)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-sidlauskas authored May 20, 2022
1 parent 915a777 commit 535cda8
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 31 deletions.
5 changes: 2 additions & 3 deletions service/history/execution/history_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package execution

import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
)
Expand All @@ -37,7 +36,7 @@ type (
)

// NewHistoryBuilder creates a new history builder
func NewHistoryBuilder(msBuilder MutableState, logger log.Logger) *HistoryBuilder {
func NewHistoryBuilder(msBuilder MutableState) *HistoryBuilder {
return &HistoryBuilder{
transientHistory: []*types.HistoryEvent{},
history: []*types.HistoryEvent{},
Expand All @@ -46,7 +45,7 @@ func NewHistoryBuilder(msBuilder MutableState, logger log.Logger) *HistoryBuilde
}

// NewHistoryBuilderFromEvents creates a new history builder based on the given workflow history events
func NewHistoryBuilderFromEvents(history []*types.HistoryEvent, logger log.Logger) *HistoryBuilder {
func NewHistoryBuilderFromEvents(history []*types.HistoryEvent) *HistoryBuilder {
return &HistoryBuilder{
history: history,
}
Expand Down
2 changes: 1 addition & 1 deletion service/history/execution/history_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *historyBuilderSuite) SetupTest() {
s.mockShard.Resource.ClusterMetadata.EXPECT().GetCurrentClusterName().Return(cluster.TestCurrentClusterName).AnyTimes()

s.msBuilder = NewMutableStateBuilder(s.mockShard, s.logger, s.domainEntry)
s.builder = NewHistoryBuilder(s.msBuilder, s.logger)
s.builder = NewHistoryBuilder(s.msBuilder)
}

func (s *historyBuilderSuite) TearDownTest() {
Expand Down
6 changes: 3 additions & 3 deletions service/history/execution/mutable_state_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ func newMutableStateBuilder(
CloseStatus: persistence.WorkflowCloseStatusNone,
LastProcessedEvent: common.EmptyEventID,
}
s.hBuilder = NewHistoryBuilder(s, logger)
s.hBuilder = NewHistoryBuilder(s)

s.taskGenerator = NewMutableStateTaskGenerator(shard.GetClusterMetadata(), shard.GetDomainCache(), s.logger, s)
s.taskGenerator = NewMutableStateTaskGenerator(shard.GetClusterMetadata(), shard.GetDomainCache(), s)
s.decisionTaskManager = newMutableStateDecisionTaskManager(s)

return s
Expand Down Expand Up @@ -4226,7 +4226,7 @@ func (e *mutableStateBuilder) prepareCloseTransaction(
func (e *mutableStateBuilder) cleanupTransaction() error {

// Clear all updates to prepare for the next session
e.hBuilder = NewHistoryBuilder(e, e.logger)
e.hBuilder = NewHistoryBuilder(e)

e.updateActivityInfos = make(map[int64]*persistence.ActivityInfo)
e.deleteActivityInfos = make(map[int64]struct{})
Expand Down
4 changes: 0 additions & 4 deletions service/history/execution/mutable_state_task_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/cache"
"github.com/uber/cadence/common/cluster"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
)
Expand Down Expand Up @@ -109,7 +108,6 @@ type (
mutableStateTaskGeneratorImpl struct {
clusterMetadata cluster.Metadata
domainCache cache.DomainCache
logger log.Logger

mutableState MutableState
}
Expand All @@ -128,14 +126,12 @@ var _ MutableStateTaskGenerator = (*mutableStateTaskGeneratorImpl)(nil)
func NewMutableStateTaskGenerator(
clusterMetadata cluster.Metadata,
domainCache cache.DomainCache,
logger log.Logger,
mutableState MutableState,
) MutableStateTaskGenerator {

return &mutableStateTaskGeneratorImpl{
clusterMetadata: clusterMetadata,
domainCache: domainCache,
logger: logger,

mutableState: mutableState,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/cache"
"github.com/uber/cadence/common/cluster"
"github.com/uber/cadence/common/log/loggerimpl"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
"github.com/uber/cadence/service/history/constants"
Expand Down Expand Up @@ -74,7 +73,6 @@ func (s *mutableStateTaskGeneratorSuite) SetupTest() {
s.taskGenerator = NewMutableStateTaskGenerator(
constants.TestClusterMetadata,
s.mockDomainCache,
loggerimpl.NewLoggerForTest(s.Suite),
s.mockMutableState,
).(*mutableStateTaskGeneratorImpl)
}
Expand Down Expand Up @@ -148,7 +146,6 @@ func (s *mutableStateTaskGeneratorSuite) TestGenerateWorkflowCloseTasks_Jittered
taskGenerator := NewMutableStateTaskGenerator(
constants.TestClusterMetadata,
s.mockDomainCache,
loggerimpl.NewLoggerForTest(s.Suite),
mockMutableState,
)

Expand Down Expand Up @@ -208,7 +205,6 @@ func (s *mutableStateTaskGeneratorSuite) TestGenerateWorkflowCloseTasks() {
taskGenerator := NewMutableStateTaskGenerator(
constants.TestClusterMetadata,
s.mockDomainCache,
loggerimpl.NewLoggerForTest(s.Suite),
mockMutableState,
)

Expand Down Expand Up @@ -618,7 +614,6 @@ func (s *mutableStateTaskGeneratorSuite) TestGenerateFromCrossClusterTask() {
taskGenerator := NewMutableStateTaskGenerator(
constants.TestClusterMetadata,
s.mockDomainCache,
loggerimpl.NewLoggerForTest(s.Suite),
mockMutableState,
)

Expand Down
5 changes: 0 additions & 5 deletions service/history/execution/mutable_state_task_refresher.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/cache"
"github.com/uber/cadence/common/cluster"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
"github.com/uber/cadence/service/history/config"
Expand All @@ -49,7 +48,6 @@ type (
clusterMetadata cluster.Metadata
domainCache cache.DomainCache
eventsCache events.Cache
logger log.Logger
shardID int
}
)
Expand All @@ -60,7 +58,6 @@ func NewMutableStateTaskRefresher(
clusterMetadata cluster.Metadata,
domainCache cache.DomainCache,
eventsCache events.Cache,
logger log.Logger,
shardID int,
) MutableStateTaskRefresher {

Expand All @@ -69,7 +66,6 @@ func NewMutableStateTaskRefresher(
clusterMetadata: clusterMetadata,
domainCache: domainCache,
eventsCache: eventsCache,
logger: logger,
shardID: shardID,
}
}
Expand All @@ -83,7 +79,6 @@ func (r *mutableStateTaskRefresherImpl) RefreshTasks(
taskGenerator := NewMutableStateTaskGenerator(
r.clusterMetadata,
r.domainCache,
r.logger,
mutableState,
)

Expand Down
2 changes: 1 addition & 1 deletion service/history/execution/state_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func (b *stateBuilderImpl) ApplyEvents(
b.mutableState.GetExecutionInfo().SetLastFirstEventID(firstEvent.ID)
b.mutableState.GetExecutionInfo().SetNextEventID(lastEvent.ID + 1)

b.mutableState.SetHistoryBuilder(NewHistoryBuilderFromEvents(history, b.logger))
b.mutableState.SetHistoryBuilder(NewHistoryBuilderFromEvents(history))

return newRunMutableStateBuilder, nil
}
Expand Down
2 changes: 1 addition & 1 deletion service/history/execution/state_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (s *stateBuilderSuite) mockUpdateVersion(events ...*types.HistoryEvent) {
}
s.mockTaskGenerator.EXPECT().GenerateActivityTimerTasks().Return(nil).Times(1)
s.mockTaskGenerator.EXPECT().GenerateUserTimerTasks().Return(nil).Times(1)
s.mockMutableState.EXPECT().SetHistoryBuilder(NewHistoryBuilderFromEvents(events, s.logger)).Times(1)
s.mockMutableState.EXPECT().SetHistoryBuilder(NewHistoryBuilderFromEvents(events)).Times(1)
}

func (s *stateBuilderSuite) toHistory(events ...*types.HistoryEvent) []*types.HistoryEvent {
Expand Down
7 changes: 3 additions & 4 deletions service/history/execution/state_rebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func NewStateRebuilder(
shard.GetClusterMetadata(),
shard.GetDomainCache(),
shard.GetEventsCache(),
logger,
shard.GetShardID(),
),
rebuiltHistorySize: 0,
Expand Down Expand Up @@ -205,7 +204,7 @@ func (r *stateRebuilderImpl) initializeBuilders(
r.logger,
resetMutableStateBuilder,
func(mutableState MutableState) MutableStateTaskGenerator {
return NewMutableStateTaskGenerator(r.shard.GetClusterMetadata(), r.shard.GetDomainCache(), r.logger, mutableState)
return NewMutableStateTaskGenerator(r.shard.GetClusterMetadata(), r.shard.GetDomainCache(), mutableState)
},
)
return resetMutableStateBuilder, stateBuilder
Expand All @@ -230,9 +229,9 @@ func (r *stateRebuilderImpl) applyEvents(
)
if err != nil {
r.logger.Error("nDCStateRebuilder unable to rebuild mutable state.", tag.Error(err))
return err
}
return nil

return err
}

func (r *stateRebuilderImpl) getPaginationFn(
Expand Down
1 change: 0 additions & 1 deletion service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -3425,7 +3425,6 @@ func (e *historyEngineImpl) RefreshWorkflowTasks(
e.shard.GetClusterMetadata(),
e.shard.GetDomainCache(),
e.shard.GetEventsCache(),
e.shard.GetLogger(),
e.shard.GetShardID(),
)

Expand Down
2 changes: 1 addition & 1 deletion service/history/ndc/history_replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func NewHistoryReplicator(
logger,
state,
func(mutableState execution.MutableState) execution.MutableStateTaskGenerator {
return execution.NewMutableStateTaskGenerator(shard.GetClusterMetadata(), shard.GetDomainCache(), logger, mutableState)
return execution.NewMutableStateTaskGenerator(shard.GetClusterMetadata(), shard.GetDomainCache(), mutableState)
},
)
},
Expand Down
1 change: 0 additions & 1 deletion service/history/task/cross_cluster_source_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ func (t *crossClusterSourceTaskExecutor) generateNewTask(
taskGenerator := execution.NewMutableStateTaskGenerator(
clusterMetadata,
t.shard.GetDomainCache(),
t.logger,
mutableState,
)
taskInfo := task.GetInfo().(*persistence.CrossClusterTaskInfo)
Expand Down
1 change: 0 additions & 1 deletion service/history/task/transfer_active_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,6 @@ func (t *transferActiveTaskExecutor) generateCrossClusterTasks(
taskGenerator := execution.NewMutableStateTaskGenerator(
t.shard.GetClusterMetadata(),
t.shard.GetDomainCache(),
t.logger,
mutableState,
)
for _, generator := range generators {
Expand Down

0 comments on commit 535cda8

Please sign in to comment.