Package org.powertac.common
Class Broker
- java.lang.Object
- 
- org.powertac.common.Broker
 
- 
 @Domain public class Broker extends Object A broker instance represents a competition participant. Broker instances are not communicated to other brokers; only usernames are considered public information and get communicated. Every entity that needs to trade in the wholesale market or post TariffSpecifications must be a broker.Brokers may be local or non-local (remote), and they may be wholesale or non-wholesale (retail) brokers. Remote brokers receive messages through JMS, while local brokers are assumed to reside in the server's process space where they receive messages by calls to their receiveMessage() methods. Local brokers must override receiveMessage() to see these messages, otherwise they will be dropped on the floor. Local brokers can send messages by calling BrokerProxy.routeMessage(); Wholesale brokers are not permitted to offer tariffs, but may trade in the wholesale market, and they are not included in the balancing process. - Author:
- Carsten Block, David Dauer, John Collins
 
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BrokeraddMarketPosition(MarketPosition posn, int slot)Associates a MarketPosition with a given Timeslot.BrokeraddMarketPosition(MarketPosition posn, Timeslot slot)Deprecated.MarketPositionfindMarketPositionByTimeslot(int slot)Returns the MarketPosition associated with the given Timeslot.MarketPositionfindMarketPositionByTimeslot(Timeslot slot)Deprecated.doublegetCashBalance()Returns broker's cash balance.longgetId()Returns the unique ID for this brokerintgetIdPrefix()Returns the ID prefix for this broker.StringgetKey()Returns the jms ID for this broker.StringgetPassword()StringgetUsername()Returns the username for this Broker.booleanisEnabled()True just in case either the broker is logged in, or is a local wholesale broker.booleanisLocal()True for a Broker that is local to the server.booleanisWholesale()True for a broker that operates on the wholeside of the wholesale market.voidreceiveMessage(Object object)Default implementation does nothing.voidsetEnabled(boolean enabled)Enables this Broker.voidsetIdPrefix(int prefix)Sets the ID prefix for this broker.voidsetKey(String key)Sets the jms key for a remote broker.voidsetLocal(boolean value)Allows subclasses to set themselves as local brokers.voidsetPassword(String newPassword)voidsetQueueName(String queueName)Sets the broker's queue name.voidsetWholesale(boolean value)Allows subclasses to make themselves wholesale brokersStringtoQueueName()Returns the broker's queue name if it's been set, otherwise the default queue name.StringtoString()voidupdateCash(double depositAmount)Updates broker's cash position.
 
- 
- 
- 
Method Detail- 
getIdpublic long getId() Returns the unique ID for this broker
 - 
setKeypublic void setKey(String key) Sets the jms key for a remote broker.
 - 
getKeypublic String getKey() Returns the jms ID for this broker.
 - 
setIdPrefixpublic void setIdPrefix(int prefix) Sets the ID prefix for this broker. Intended to be called by competition control when a remote broker logs in.
 - 
getIdPrefixpublic int getIdPrefix() Returns the ID prefix for this broker. Used in the server to validate incoming messages. Should be non-zero only for remote brokers.
 - 
updateCashpublic void updateCash(double depositAmount) Updates broker's cash position. Note that this operation does not generate a state log entry. To see the broker's cash balance in the state log, you have to create a new CashPosition.
 - 
getCashBalancepublic double getCashBalance() Returns broker's cash balance.
 - 
addMarketPosition@StateChange public Broker addMarketPosition(MarketPosition posn, int slot) Associates a MarketPosition with a given Timeslot.
 - 
addMarketPosition@Deprecated public Broker addMarketPosition(MarketPosition posn, Timeslot slot) Deprecated.
 - 
findMarketPositionByTimeslotpublic MarketPosition findMarketPositionByTimeslot(int slot) Returns the MarketPosition associated with the given Timeslot. Result is guaranteed to be non-null.
 - 
findMarketPositionByTimeslot@Deprecated public MarketPosition findMarketPositionByTimeslot(Timeslot slot) Deprecated.
 - 
getUsernamepublic String getUsername() Returns the username for this Broker.
 - 
getPasswordpublic String getPassword() 
 - 
setPasswordpublic void setPassword(String newPassword) 
 - 
isEnabledpublic boolean isEnabled() True just in case either the broker is logged in, or is a local wholesale broker.
 - 
setEnabledpublic void setEnabled(boolean enabled) Enables this Broker. Of course, calling this method on a remote broker will have no effect; it must be called on the Broker instance in the server.
 - 
isLocalpublic boolean isLocal() True for a Broker that is local to the server. Affects message routing.
 - 
setLocal@StateChange public void setLocal(boolean value) Allows subclasses to set themselves as local brokers. Local brokers must subclass this class, and implement receiveMessage() to receive messages from the server. They send messages by calling BrokerProxy.routeMessage().
 - 
isWholesalepublic boolean isWholesale() True for a broker that operates on the wholeside of the wholesale market.
 - 
setWholesale@StateChange public void setWholesale(boolean value) Allows subclasses to make themselves wholesale brokers
 - 
setQueueNamepublic void setQueueName(String queueName) Sets the broker's queue name.
 - 
toQueueNamepublic String toQueueName() Returns the broker's queue name if it's been set, otherwise the default queue name.
 - 
receiveMessagepublic void receiveMessage(Object object) Default implementation does nothing. Broker subclasses implemented within the server can override this method to receive messages from BrokerProxy
 
- 
 
-