Refactored sample broker

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Refactored sample broker


Dear colleagues -

Today I have committed a significant refactoring of the sample broker, in the 0.5.0-SNAPSHOT development branch (master). The purpose is to make it easier to use as a foundation for broker development, and make it possible to update the broker-server interface in the future with minimal impact on broker developers. I hope it will not be overly disruptive in the short term.

Here's what I did:

  1. Introduced two new packages:
    • org.powertac.samplebroker.core is for the core elements of the broker and its interface to the server. The only uncertainty here (that I can see right now) is whether the command-line processing should be here, since broker developers might want to extend that.
    • org.powertac.samplebroker.interfaces is for interface definitions that should help insulate the core from the customized elements of the broker.
  2. Introduced two simple interfaces, interfaces.Initializable for modules that are to be initialized, and interfaces.Activatable for modules that are to be activated once per timeslot.
  3. Split SampleBroker into two classes, core.PowerTacBroker and BrokerContext. PowerTacBroker is responsible for handling the clock, for initializing all the Initializable modules, and for activating all the Activatable modules when the TimeslotComplete message arrives. BrokerContext handles the bank messages and the initial configuration messages. It mostly ignores them, but illustrates how to receive them.
  4. Made core.PowerTacBroker implement the interfaces.BrokerContext interface, which provides access to the message router, the list of competing brokers, and other basic data.

We will try hard to keep further changes, at least for the next few months, inside the core package. There's probably more than can be done to make the sample broker easier to work with; feel free to add your thoughts.

Cheers -