public abstract class SingleThreadedBusTopicSource extends BusTopicBase implements Runnable, BusTopicSource
Topic.CommInfrastructure
Modifier and Type | Field and Description |
---|---|
protected boolean |
alive
Am I running?
reflects invocation of start()/stop()
!locked & start() => alive
stop() => !alive
|
protected Thread |
busPollerThread
Independent thread reading message over my topic
|
protected BusConsumer |
consumer
Message Bus Consumer
|
protected String |
consumerGroup
Bus consumer group
|
protected String |
consumerInstance
Bus consumer instance
|
protected int |
fetchLimit
Bus fetch limit
|
protected int |
fetchTimeout
Bus fetch timeout
|
protected boolean |
locked
Am I locked?
reflects invocation of lock()/unlock() operations
locked => !alive (but not in the other direction necessarily)
locked => !offer, !run, !start, !stop (but this last one is obvious
since locked => !alive)
|
protected static org.apache.log4j.Logger |
networkLogger
Not to be converted to PolicyLogger.
|
protected ArrayList<TopicListener> |
topicListeners
All my subscribers for new message notifications
|
apiKey, apiSecret, recentEvents, servers, topic
DEFAULT_CONSUMER_INSTANCE, DEFAULT_LIMIT_FETCH, DEFAULT_TIMEOUT_MS_FETCH, NO_LIMIT_FETCH, NO_TIMEOUT_MS_FETCH
NETWORK_LOGGER
Constructor and Description |
---|
SingleThreadedBusTopicSource(List<String> servers,
String topic,
String apiKey,
String apiSecret,
String consumerGroup,
String consumerInstance,
int fetchTimeout,
int fetchLimit) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
broadcast(String message)
broadcast event to all listeners
|
String |
getConsumerGroup()
gets the consumer group
|
String |
getConsumerInstance()
gets the consumer instance
|
int |
getFetchLimit()
gets the fetch limit
|
int |
getFetchTimeout()
gets the fetch timeout
|
abstract void |
init()
Initialize the Bus client
|
boolean |
isAlive() |
boolean |
isLocked() |
boolean |
lock() |
boolean |
offer(String event)
pushes an event into the source programatically
|
void |
register(TopicListener topicListener)
Register for notification of events with this Topic Entity
|
void |
run()
Run thread method for the Bus Reader
|
void |
shutdown() |
protected List<TopicListener> |
snapshotTopicListeners()
take a snapshot of current topic listeners
|
boolean |
start() |
boolean |
stop() |
String |
toString() |
boolean |
unlock() |
void |
unregister(TopicListener topicListener)
Unregisters for notification of events with this Topic Entity
|
getApiKey, getApiSecret, getRecentEvents, getServers, getTopic
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getApiKey, getApiSecret
getRecentEvents, getServers, getTopic, getTopicCommInfrastructure
protected static final org.apache.log4j.Logger networkLogger
protected final String consumerGroup
protected final String consumerInstance
protected final int fetchTimeout
protected final int fetchLimit
protected BusConsumer consumer
protected volatile boolean alive
protected volatile boolean locked
protected Thread busPollerThread
protected final ArrayList<TopicListener> topicListeners
public SingleThreadedBusTopicSource(List<String> servers, String topic, String apiKey, String apiSecret, String consumerGroup, String consumerInstance, int fetchTimeout, int fetchLimit) throws IllegalArgumentException
servers
- Bus serverstopic
- Bus Topic to be monitoredapiKey
- Bus API Key (optional)apiSecret
- Bus API Secret (optional)consumerGroup
- Bus Reader Consumer GroupconsumerInstance
- Bus Reader InstancefetchTimeout
- Bus fetch timeoutfetchLimit
- Bus fetch limitIllegalArgumentException
- An invalid parameter passed inpublic void register(TopicListener topicListener) throws IllegalArgumentException
register
in interface TopicRegisterable
topicListener
- the listener of eventsIllegalArgumentException
public void unregister(TopicListener topicListener)
unregister
in interface TopicRegisterable
topicListener
- the listener of eventspublic boolean lock()
lock
in interface org.openecomp.policy.drools.properties.Lockable
public boolean unlock()
unlock
in interface org.openecomp.policy.drools.properties.Lockable
public boolean start() throws IllegalStateException
start
in interface org.openecomp.policy.drools.properties.Startable
IllegalStateException
public boolean stop()
stop
in interface org.openecomp.policy.drools.properties.Startable
public boolean isLocked()
isLocked
in interface org.openecomp.policy.drools.properties.Lockable
protected boolean broadcast(String message)
message
- the eventprotected List<TopicListener> snapshotTopicListeners()
public boolean offer(String event)
offer
in interface TopicSource
event
- the event in json formatpublic String toString()
toString
in class BusTopicBase
public boolean isAlive()
isAlive
in interface org.openecomp.policy.drools.properties.Startable
public String getConsumerGroup()
getConsumerGroup
in interface BusTopicSource
public String getConsumerInstance()
getConsumerInstance
in interface BusTopicSource
public void shutdown() throws IllegalStateException
shutdown
in interface org.openecomp.policy.drools.properties.Startable
IllegalStateException
public int getFetchTimeout()
getFetchTimeout
in interface BusTopicSource
public int getFetchLimit()
getFetchLimit
in interface BusTopicSource
Copyright © 2018. All rights reserved.