Writing a custom supervisor class

We can write our CustomScheduler class by implementing the org.apache.storm.scheduler.IScheduler interface. The interface contains two important methods:

  • prepare(Map conf): This method only initializes the scheduler
  • schedule(Topologies topologies, Cluster cluster): This method contains logic that is responsible for topology workers in the cluster supervisor slots

CustomScheduler contains the following private method, which is responsible for assigning workers to the cluster supervisor slots.

The getSupervisorsByType() method returns the map. The key of the map represents the node type (for example, CPU or GPU) and the value contains the list of supervisor nodes of that type:

 private Map<String, ArrayList<SupervisorDetails>> ...

Get Mastering Apache Storm now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.