public class Concentrator extends BaseAgentEndpoint implements MatcherEndpoint
This class represents a Concentrator component where several instances can be created.
The Concentrator receives Bid from the agents and forwards this in an aggregate Bid up in the
hierarchy to a Concentrator or to the Auctioneer. It will receive price updates from the
Auctioneer and forward them to its connected agents.
| Modifier and Type | Class and Description |
|---|---|
static interface |
Concentrator.Config |
BaseAgentEndpoint.ConnectedAgent.StatusAgentEndpoint.Status| Modifier and Type | Field and Description |
|---|---|
protected Concentrator.Config |
config |
NOT_CONNECTED| Constructor and Description |
|---|
Concentrator() |
| Modifier and Type | Method and Description |
|---|---|
void |
activate(Concentrator.Config config)
Convenient activate method that takes a
Concentrator.Config object. |
void |
activate(java.util.Map<java.lang.String,?> properties)
OSGi calls this method to activate a managed service.
|
void |
addObserver(AgentObserver observer)
Used to add an
AgentObserver to the list of observers of this instance. |
void |
agentEndpointDisconnected(Session session)
|
void |
connectToAgent(Session session)
Connects this
MatcherEndpoint instance to an AgentEndpoint. |
void |
connectToMatcher(Session session)
Connects this
AgentEndpoint instance to a MatcherEndpoint. |
void |
deactivate()
OSGi calls this method to deactivate a managed service.
|
void |
handleBidUpdate(Session session,
BidUpdate bidUpdate)
|
void |
handlePriceUpdate(PriceUpdate priceUpdate)
|
void |
matcherEndpointDisconnected(Session session)
|
void |
removeObserver(AgentObserver observer)
Used to remove an
AgentObserver from the list of observers of this instance. |
void |
setContext(org.flexiblepower.context.FlexiblePowerContext context)
Give the agent a reference to a
FlexiblePowerContext. |
protected Bid |
transformBid(Bid aggregatedBid)
This method should be overridden when the bid that will be sent has to be changed.
|
protected Price |
transformPrice(Price price,
SentBidInformation info)
This method should be overridden when the price that will be sent down has to be changed.
|
getAgentId, getDesiredParentId, getLastBidUpdate, getStatus, init, publishBidnow, publishEventclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAgentId, getStatusprotected Concentrator.Config config
public void activate(java.util.Map<java.lang.String,?> properties)
properties - the configuration propertiespublic void activate(Concentrator.Config config)
Concentrator.Config object. This also makes subclassing easier.config - The Concentrator.Config object that configures this concentratorpublic void setContext(org.flexiblepower.context.FlexiblePowerContext context)
AgentFlexiblePowerContext. This should be done by the runtime bundle after the
component is activated.setContext in interface AgentsetContext in class BaseAgentcontext - reference to the FlexiblePowerContextAgent.setContext(org.flexiblepower.context.FlexiblePowerContext)public void deactivate()
deactivate in class BaseAgentEndpointpublic void connectToMatcher(Session session)
BaseAgentEndpointAgentEndpoint instance to a MatcherEndpoint.connectToMatcher in interface AgentEndpointconnectToMatcher in class BaseAgentEndpointsession - the Session that will link this AgentEndpoint with a MatcherEndpoint.public void matcherEndpointDisconnected(Session session)
BaseAgentEndpointmatcherEndpointDisconnected in interface AgentEndpointmatcherEndpointDisconnected in class BaseAgentEndpointsession - the Session that used to link the MatcherEndpoint with this AgentEndpoint.public void handlePriceUpdate(PriceUpdate priceUpdate)
MatcherEndpoint via the Session to update the Price used by this
AgentEndpoint instance.
This base implementation checks if the PriceUpdate is valid and publishes the
IncomingPriceUpdateEvent.handlePriceUpdate in interface AgentEndpointhandlePriceUpdate in class BaseAgentEndpointpriceUpdate - The new Price, wrapped in a PriceUpdate, along with the id of the Bid it was
based on.protected Bid transformBid(Bid aggregatedBid)
aggregatedBid - The (input) aggregated bid as calculated normally (the sum of all the bids of the agents).Concentrator.protected Price transformPrice(Price price, SentBidInformation info)
price - The input price update as received from the connected matcher.info - The information about the bid that has been sendPrice as it has to be sent to the connected agents.public void agentEndpointDisconnected(Session session)
MatcherEndpointagentEndpointDisconnected in interface MatcherEndpointsession - the Session that used to link this MatcherEndpoint with an AgentEndpoint.public void connectToAgent(Session session)
MatcherEndpointMatcherEndpoint instance to an AgentEndpoint.connectToAgent in interface MatcherEndpointsession - the Session that will link this AgentEndpoint with a MatcherEndpoint.public void handleBidUpdate(Session session, BidUpdate bidUpdate)
MatcherEndpointhandleBidUpdate in interface MatcherEndpointsession - The session linking this MatcherEndpoint with a specific AgentEndpoint instance.bidUpdate - The new BidUpdate.public void addObserver(AgentObserver observer)
BaseAgentAgentObserver to the list of observers of this instance.addObserver in interface ObservableAgentaddObserver in class BaseAgentobserver - the new AgentObserver.public void removeObserver(AgentObserver observer)
BaseAgentAgentObserver from the list of observers of this instance.removeObserver in interface ObservableAgentremoveObserver in class BaseAgentobserver - the AgentObserver that will be removed.