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.Connected
Agent.Status
AgentEndpoint.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, publishBid
now, publishEvent
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAgentId, getStatus
protected 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)
Agent
FlexiblePowerContext
. This should be done by the runtime bundle after the
component is activated.setContext
in interface Agent
setContext
in class BaseAgent
context
- reference to the FlexiblePowerContext
Agent.setContext(org.flexiblepower.context.FlexiblePowerContext)
public void deactivate()
deactivate
in class BaseAgentEndpoint
public void connectToMatcher(Session session)
BaseAgentEndpoint
AgentEndpoint
instance to a MatcherEndpoint
.connectToMatcher
in interface AgentEndpoint
connectToMatcher
in class BaseAgentEndpoint
session
- the Session
that will link this AgentEndpoint
with a MatcherEndpoint
.public void matcherEndpointDisconnected(Session session)
BaseAgentEndpoint
matcherEndpointDisconnected
in interface AgentEndpoint
matcherEndpointDisconnected
in class BaseAgentEndpoint
session
- 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 AgentEndpoint
handlePriceUpdate
in class BaseAgentEndpoint
priceUpdate
- 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)
MatcherEndpoint
agentEndpointDisconnected
in interface MatcherEndpoint
session
- the Session
that used to link this MatcherEndpoint
with an AgentEndpoint
.public void connectToAgent(Session session)
MatcherEndpoint
MatcherEndpoint
instance to an AgentEndpoint
.connectToAgent
in interface MatcherEndpoint
session
- the Session
that will link this AgentEndpoint
with a MatcherEndpoint
.public void handleBidUpdate(Session session, BidUpdate bidUpdate)
MatcherEndpoint
handleBidUpdate
in interface MatcherEndpoint
session
- The session linking this MatcherEndpoint
with a specific AgentEndpoint
instance.bidUpdate
- The new BidUpdate
.public void addObserver(AgentObserver observer)
BaseAgent
AgentObserver
to the list of observers of this instance.addObserver
in interface ObservableAgent
addObserver
in class BaseAgent
observer
- the new AgentObserver
.public void removeObserver(AgentObserver observer)
BaseAgent
AgentObserver
from the list of observers of this instance.removeObserver
in interface ObservableAgent
removeObserver
in class BaseAgent
observer
- the AgentObserver
that will be removed.