@@ -65,14 +65,11 @@ public final class Worker {
6565 final SyncNexusWorker nexusWorker ;
6666 private final AtomicBoolean started = new AtomicBoolean ();
6767 private volatile boolean shuttingDown = false ;
68- private boolean hasWorkflows = false ;
69- private boolean hasActivities = false ;
70- private boolean hasNexusServices = false ;
7168 private final String workerInstanceKey = UUID .randomUUID ().toString ();
7269 private volatile Instant startTime ;
7370 private final WorkflowClientOptions clientOptions ;
7471 private final @ Nonnull WorkflowExecutorCache cache ;
75- private final Map <String , TaskSnapshot > previousSnapshots = new ConcurrentHashMap <>();
72+ private final Map <String , TaskSnapshot > previousHeartbeatSnapshots = new ConcurrentHashMap <>();
7673
7774 private static final class TaskSnapshot {
7875 final int processed ;
@@ -227,7 +224,6 @@ public void registerWorkflowImplementationTypes(Class<?>... workflowImplementati
227224
228225 workflowWorker .registerWorkflowImplementationTypes (
229226 WorkflowImplementationOptions .newBuilder ().build (), workflowImplementationClasses );
230- hasWorkflows = true ;
231227 }
232228
233229 /**
@@ -252,7 +248,6 @@ public void registerWorkflowImplementationTypes(
252248 "registerWorkflowImplementationTypes is not allowed after worker has started" );
253249
254250 workflowWorker .registerWorkflowImplementationTypes (options , workflowImplementationClasses );
255- hasWorkflows = true ;
256251 }
257252
258253 /**
@@ -354,7 +349,6 @@ public <R> void addWorkflowImplementationFactory(Class<R> workflowInterface, Fun
354349 public <R > void registerWorkflowImplementationFactory (
355350 Class <R > workflowInterface , Func <R > factory , WorkflowImplementationOptions options ) {
356351 workflowWorker .registerWorkflowImplementationFactory (options , workflowInterface , factory );
357- hasWorkflows = true ;
358352 }
359353
360354 @ VisibleForTesting
@@ -363,7 +357,6 @@ public <R> void registerWorkflowImplementationFactory(
363357 Functions .Func1 <EncodedValues , R > factory ,
364358 WorkflowImplementationOptions options ) {
365359 workflowWorker .registerWorkflowImplementationFactory (options , workflowInterface , factory );
366- hasWorkflows = true ;
367360 }
368361
369362 /**
@@ -407,7 +400,6 @@ public <R> void registerWorkflowImplementationFactory(
407400 Class <R > workflowInterface , Func <R > factory ) {
408401 workflowWorker .registerWorkflowImplementationFactory (
409402 WorkflowImplementationOptions .getDefaultInstance (), workflowInterface , factory );
410- hasWorkflows = true ;
411403 }
412404
413405 /**
@@ -434,7 +426,6 @@ public void registerActivitiesImplementations(Object... activityImplementations)
434426
435427 if (activityWorker != null ) {
436428 activityWorker .registerActivityImplementations (activityImplementations );
437- hasActivities = true ;
438429 }
439430 workflowWorker .registerLocalActivityImplementations (activityImplementations );
440431 }
@@ -452,7 +443,6 @@ public void registerNexusServiceImplementation(Object... nexusServiceImplementat
452443 !started .get (),
453444 "registerNexusServiceImplementation is not allowed after worker has started" );
454445 nexusWorker .registerNexusServiceImplementation (nexusServiceImplementations );
455- hasNexusServices = true ;
456446 }
457447
458448 void start () {
@@ -507,13 +497,13 @@ String getWorkerInstanceKey() {
507497
508498 List <TaskQueueType > getActiveTaskQueueTypes () {
509499 List <TaskQueueType > types = new ArrayList <>();
510- if (hasWorkflows ) {
500+ if (workflowWorker . isAnyTypeSupported () ) {
511501 types .add (TaskQueueType .TASK_QUEUE_TYPE_WORKFLOW );
512502 }
513- if (hasActivities ) {
503+ if (activityWorker != null && activityWorker . isAnyTypeSupported () ) {
514504 types .add (TaskQueueType .TASK_QUEUE_TYPE_ACTIVITY );
515505 }
516- if (hasNexusServices ) {
506+ if (nexusWorker . isAnyTypeSupported () ) {
517507 types .add (TaskQueueType .TASK_QUEUE_TYPE_NEXUS );
518508 }
519509 return types ;
@@ -630,7 +620,7 @@ private WorkerSlotsInfo buildSlotsInfo(
630620 int currentProcessed = taskCounter .getTotalProcessed ();
631621 int currentFailed = taskCounter .getTotalFailed ();
632622 TaskSnapshot previous =
633- previousSnapshots .put (key , new TaskSnapshot (currentProcessed , currentFailed ));
623+ previousHeartbeatSnapshots .put (key , new TaskSnapshot (currentProcessed , currentFailed ));
634624 int intervalProcessed = previous != null ? currentProcessed - previous .processed : 0 ;
635625 int intervalFailed = previous != null ? currentFailed - previous .failed : 0 ;
636626 return WorkerSlotsInfo .newBuilder ()
0 commit comments