@@ -408,6 +408,48 @@ func AdminDescribeTask(c *cli.Context) {
408408 }
409409}
410410
411+ // AdminListTasks outputs a list of a tasks for given Shard and Task Type
412+ func AdminListTasks (c * cli.Context ) {
413+ sid := getRequiredIntOption (c , FlagShardID )
414+ category := commongenpb .TaskCategory (c .Int (FlagTaskType ))
415+
416+ pFactory := CreatePersistenceFactory (c )
417+ executionManager , err := pFactory .NewExecutionManager (sid )
418+ if err != nil {
419+ ErrorAndExit ("Failed to initialize execution manager" , err )
420+ }
421+
422+ if category == commongenpb .TaskCategory_TaskCategory_Transfer {
423+ req := & persistence.GetTransferTasksRequest {}
424+ tasks , err := executionManager .GetTransferTasks (req )
425+ if err != nil {
426+ ErrorAndExit ("Failed to get Transfer Tasks" , err )
427+ }
428+ prettyPrintJSONObject (tasks )
429+ } else if category == commongenpb .TaskCategory_TaskCategory_Timer {
430+ minVisFlag := parseTime (c .String (FlagMinVisibilityTimestamp ), 0 , time .Now ())
431+ minVis := time .Unix (0 , minVisFlag )
432+ maxVisFlag := parseTime (c .String (FlagMaxVisibilityTimestamp ), 0 , time .Now ())
433+ maxVis := time .Unix (0 , maxVisFlag )
434+
435+ req := & persistence.GetTimerIndexTasksRequest {MinTimestamp : minVis , MaxTimestamp : maxVis }
436+ tasks , err := executionManager .GetTimerIndexTasks (req )
437+ if err != nil {
438+ ErrorAndExit ("Failed to get Timer Tasks" , err )
439+ }
440+ prettyPrintJSONObject (tasks )
441+ } else if category == commongenpb .TaskCategory_TaskCategory_Replication {
442+ req := & persistence.GetReplicationTasksRequest {}
443+ task , err := executionManager .GetReplicationTasks (req )
444+ if err != nil {
445+ ErrorAndExit ("Failed to get Replication Tasks" , err )
446+ }
447+ prettyPrintJSONObject (task )
448+ } else {
449+ ErrorAndExit ("Failed to describe task" , fmt .Errorf ("Unrecognized task type, task_type=%v" , category ))
450+ }
451+ }
452+
411453// AdminRemoveTask describes history host
412454func AdminRemoveTask (c * cli.Context ) {
413455 adminClient := cFactory .AdminClient (c )
0 commit comments