Class WorkerRegistryService
- java.lang.Object
-
- com.snowflake.connectors.taskreactor.worker.registry.WorkerRegistryService
-
public class WorkerRegistryService extends Object
Registry of task reactor workers.
-
-
Constructor Summary
Constructors Constructor Description WorkerRegistryService(WorkerStatusRepository statusRepository, WorkerRegistry workerRegistry)Creates a newWorkerRegistryService.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNewWorkers(int workersToAdd)Adds the specified numbers of workers to the instance.booleancanDeleteWorker(WorkerId workerId)Returns whether a worker with the specified id can be deleted.booleancanProvisionWorker(WorkerId workerId)Returns whether a worker with the specified id can be requested.voiddeleteWorkers(int workersToDelete)Removes specified numbers of workers to the instance.static WorkerRegistryServicefrom(Session session, Identifier instanceSchema)Creates a newWorkerRegistryService.intgetActiveOrRequestedWorkersCount()Returns the number of active and requested workers.List<WorkerId>getActiveOrUpForDeletionWorkers()Returns ids of active or up for deletion workers.List<WorkerId>getActiveProvisioningOrUpForDeletionWorkers()Returns ids of active, provisioning or up for deletion workers.List<WorkerId>getActiveWorkers()Returns ids of active workers.List<WorkerId>getAllWorkers()Returns ids of all workers in one of the following states:WorkerLifecycleStatus.ACTIVEWorkerLifecycleStatus.PROVISIONINGWorkerLifecycleStatus.UP_FOR_DELETIONWorkerLifecycleStatus.DELETINGList<WorkerId>getWorkersToDelete()Returns ids of workers waiting for deletion.List<WorkerId>getWorkersToProvision()Returns ids of requested workers.voidworkerDeleted(WorkerId workerId)Sets the status of the specified worker toDELETED.voidworkerProvisioned(WorkerId workerId)Sets the status of the specified worker toACTIVE.
-
-
-
Constructor Detail
-
WorkerRegistryService
public WorkerRegistryService(WorkerStatusRepository statusRepository, WorkerRegistry workerRegistry)
Creates a newWorkerRegistryService.- Parameters:
statusRepository- Snowpark session objectworkerRegistry- task reactor instance schema name
-
-
Method Detail
-
from
public static WorkerRegistryService from(Session session, Identifier instanceSchema)
Creates a newWorkerRegistryService.- Parameters:
session- Snowpark session objectinstanceSchema- task reactor instance schema name- Returns:
- a new service instance
-
getAllWorkers
public List<WorkerId> getAllWorkers()
Returns ids of all workers in one of the following states:- Returns:
- ids of all workers in the above specified states
-
getActiveWorkers
public List<WorkerId> getActiveWorkers()
Returns ids of active workers.- Returns:
- list of ids of active workers
-
getActiveOrRequestedWorkersCount
public int getActiveOrRequestedWorkersCount()
Returns the number of active and requested workers.- Returns:
- number of active and requested workers
-
getWorkersToProvision
public List<WorkerId> getWorkersToProvision()
Returns ids of requested workers.- Returns:
- list of ids of requested workers
-
getActiveProvisioningOrUpForDeletionWorkers
public List<WorkerId> getActiveProvisioningOrUpForDeletionWorkers()
Returns ids of active, provisioning or up for deletion workers.- Returns:
- list of ids of active, provisioning or up for deletion workers
-
getActiveOrUpForDeletionWorkers
public List<WorkerId> getActiveOrUpForDeletionWorkers()
Returns ids of active or up for deletion workers.- Returns:
- list of ids of active or up for deletion workers
-
canProvisionWorker
public boolean canProvisionWorker(WorkerId workerId)
Returns whether a worker with the specified id can be requested.- Parameters:
workerId- worker id- Returns:
- whether a worker with the specified id can be requested
-
workerProvisioned
public void workerProvisioned(WorkerId workerId)
Sets the status of the specified worker toACTIVE.- Parameters:
workerId- worker id
-
getWorkersToDelete
public List<WorkerId> getWorkersToDelete()
Returns ids of workers waiting for deletion.- Returns:
- list of ids of workers waiting for deletion
-
canDeleteWorker
public boolean canDeleteWorker(WorkerId workerId)
Returns whether a worker with the specified id can be deleted.- Parameters:
workerId- worker id- Returns:
- whether a worker with the specified id can be deleted
-
workerDeleted
public void workerDeleted(WorkerId workerId)
Sets the status of the specified worker toDELETED.- Parameters:
workerId- worker id
-
addNewWorkers
public void addNewWorkers(int workersToAdd)
Adds the specified numbers of workers to the instance.- Parameters:
workersToAdd- number of workers to add
-
deleteWorkers
public void deleteWorkers(int workersToDelete)
Removes specified numbers of workers to the instance.- Parameters:
workersToDelete- number of workers to delete
-
-