org.apache.flink.streaming.examples.statemachine.event.EventType Java Examples

The following examples show how to use org.apache.flink.streaming.examples.statemachine.event.EventType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventsGenerator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * 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 to {@link #next(int, int)} was made, yet), this
 * will return null.
 *
 * @return An event for a illegal state transition, or null, if not possible.
 */
@Nullable
public Event nextInvalid() {
	final Iterator<Entry<Integer, State>> iter = states.entrySet().iterator();
	if (iter.hasNext()) {
		final Entry<Integer, State> entry = iter.next();

		State currentState = entry.getValue();
		int address = entry.getKey();
		iter.remove();

		EventType event = currentState.randomInvalidTransition(rnd);
		return new Event(event, address);
	}
	else {
		return null;
	}
}
 
Example #2
Source File: EventsGenerator.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * 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 to {@link #next(int, int)} was made, yet), this
 * will return null.
 *
 * @return An event for a illegal state transition, or null, if not possible.
 */
@Nullable
public Event nextInvalid() {
	final Iterator<Entry<Integer, State>> iter = states.entrySet().iterator();
	if (iter.hasNext()) {
		final Entry<Integer, State> entry = iter.next();

		State currentState = entry.getValue();
		int address = entry.getKey();
		iter.remove();

		EventType event = currentState.randomInvalidTransition(rnd);
		return new Event(event, address);
	}
	else {
		return null;
	}
}
 
Example #3
Source File: EventsGenerator.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * 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 to {@link #next(int, int)} was made, yet), this
 * will return null.
 *
 * @return An event for a illegal state transition, or null, if not possible.
 */
@Nullable
public Event nextInvalid() {
	final Iterator<Entry<Integer, State>> iter = states.entrySet().iterator();
	if (iter.hasNext()) {
		final Entry<Integer, State> entry = iter.next();

		State currentState = entry.getValue();
		int address = entry.getKey();
		iter.remove();

		EventType event = currentState.randomInvalidTransition(rnd);
		return new Event(event, address);
	}
	else {
		return null;
	}
}
 
Example #4
Source File: EventDeSerializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public Event deserialize(byte[] message) throws IOException {
	ByteBuffer buffer = ByteBuffer.wrap(message).order(ByteOrder.LITTLE_ENDIAN);
	int address = buffer.getInt(0);
	int typeOrdinal = buffer.getInt(4);
	return new Event(EventType.values()[typeOrdinal], address);
}
 
Example #5
Source File: EventDeSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Event deserialize(byte[] message) throws IOException {
	ByteBuffer buffer = ByteBuffer.wrap(message).order(ByteOrder.LITTLE_ENDIAN);
	int address = buffer.getInt(0);
	int typeOrdinal = buffer.getInt(4);
	return new Event(EventType.values()[typeOrdinal], address);
}
 
Example #6
Source File: EventDeSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Event deserialize(byte[] message) throws IOException {
	ByteBuffer buffer = ByteBuffer.wrap(message).order(ByteOrder.LITTLE_ENDIAN);
	int address = buffer.getInt(0);
	int typeOrdinal = buffer.getInt(4);
	return new Event(EventType.values()[typeOrdinal], address);
}
 
Example #7
Source File: Transition.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public EventType eventType() {
	return eventType;
}
 
Example #8
Source File: EventTypeAndState.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public EventTypeAndState(EventType eventType, State state) {
	this.eventType = eventType;
	this.state = state;
}
 
Example #9
Source File: Transition.java    From flink with Apache License 2.0 4 votes vote down vote up
public EventType eventType() {
	return eventType;
}
 
Example #10
Source File: EventTypeAndState.java    From flink with Apache License 2.0 4 votes vote down vote up
public EventTypeAndState(EventType eventType, State state) {
	this.eventType = eventType;
	this.state = state;
}
 
Example #11
Source File: Transition.java    From flink with Apache License 2.0 4 votes vote down vote up
public EventType eventType() {
	return eventType;
}
 
Example #12
Source File: EventTypeAndState.java    From flink with Apache License 2.0 4 votes vote down vote up
public EventTypeAndState(EventType eventType, State state) {
	this.eventType = eventType;
	this.state = state;
}
 
Example #13
Source File: Transition.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new transition.
 *
 * @param eventType The event that triggers the transition.
 * @param targetState The target state after the transition.
 * @param prob The probability of the transition.
 */
public Transition(EventType eventType, State targetState, float prob) {
	this.eventType = checkNotNull(eventType);
	this.targetState = checkNotNull(targetState);
	this.prob = prob;
}
 
Example #14
Source File: Transition.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new transition.
 *
 * @param eventType The event that triggers the transition.
 * @param targetState The target state after the transition.
 * @param prob The probability of the transition.
 */
public Transition(EventType eventType, State targetState, float prob) {
	this.eventType = checkNotNull(eventType);
	this.targetState = checkNotNull(targetState);
	this.prob = prob;
}
 
Example #15
Source File: Transition.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new transition.
 *
 * @param eventType The event that triggers the transition.
 * @param targetState The target state after the transition.
 * @param prob The probability of the transition.
 */
public Transition(EventType eventType, State targetState, float prob) {
	this.eventType = checkNotNull(eventType);
	this.targetState = checkNotNull(targetState);
	this.prob = prob;
}