Class EventsGenerator
java.lang.Object
org.apache.flink.streaming.examples.statemachine.generator.EventsGenerator
A generator for events. The generator internally maintains a series of state machines (addresses
and current associated state) and returns transition events from those state machines. Each time
the next event is generators, this generator picks a random state machine and creates a random
transition on that state machine.
The generator randomly adds new state machines, and removes state machines as soon as they reach the terminal state. This implementation maintains up to 1000 state machines concurrently.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnext(int minIp, int maxIp) Creates a new random event.Creates an event for an illegal state transition of one of the internal state machines.int
-
Constructor Details
-
EventsGenerator
public EventsGenerator() -
EventsGenerator
public EventsGenerator(double errorProb)
-
-
Method Details
-
next
Creates a new random event. This method randomly pick either one of its currently running state machines, or start a new state machine for a random IP address.With
errorProbprobability, the generated event will be from an illegal state transition of one of the currently running state machines.- Parameters:
minIp- The lower bound for the range from which a new IP address may be picked.maxIp- The upper bound for the range from which a new IP address may be picked.- Returns:
- A next random event.
-
nextInvalid
Creates an event for an illegal state transition of one of the internal state machines. If the generator has not yet started any state machines (for example, because no call tonext(int, int)was made, yet), this will return null.- Returns:
- An event for a illegal state transition, or null, if not possible.
-
numActiveEntries
public int numActiveEntries()
-