Java Code Examples for org.apache.flink.runtime.checkpoint.OperatorState#getSubtaskStates()

The following examples show how to use org.apache.flink.runtime.checkpoint.OperatorState#getSubtaskStates() . 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: MetadataV2Serializer.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void serializeOperatorState(OperatorState operatorState, DataOutputStream dos) throws IOException {
	// Operator ID
	dos.writeLong(operatorState.getOperatorID().getLowerPart());
	dos.writeLong(operatorState.getOperatorID().getUpperPart());

	// Parallelism
	int parallelism = operatorState.getParallelism();
	dos.writeInt(parallelism);
	dos.writeInt(operatorState.getMaxParallelism());

	// this field was "chain length" before Flink 1.3, and it is still part
	// of the format, despite being unused
	dos.writeInt(1);

	// Sub task states
	Map<Integer, OperatorSubtaskState> subtaskStateMap = operatorState.getSubtaskStates();
	dos.writeInt(subtaskStateMap.size());
	for (Map.Entry<Integer, OperatorSubtaskState> entry : subtaskStateMap.entrySet()) {
		dos.writeInt(entry.getKey());
		serializeSubtaskState(entry.getValue(), dos);
	}
}
 
Example 2
Source File: MetadataV3Serializer.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void serializeOperatorState(OperatorState operatorState, DataOutputStream dos) throws IOException {
	// Operator ID
	dos.writeLong(operatorState.getOperatorID().getLowerPart());
	dos.writeLong(operatorState.getOperatorID().getUpperPart());

	// Parallelism
	dos.writeInt(operatorState.getParallelism());
	dos.writeInt(operatorState.getMaxParallelism());

	// Coordinator state
	serializeStreamStateHandle(operatorState.getCoordinatorState(), dos);

	// Sub task states
	final Map<Integer, OperatorSubtaskState> subtaskStateMap = operatorState.getSubtaskStates();
	dos.writeInt(subtaskStateMap.size());
	for (Map.Entry<Integer, OperatorSubtaskState> entry : subtaskStateMap.entrySet()) {
		dos.writeInt(entry.getKey());
		serializeSubtaskState(entry.getValue(), dos);
	}
}
 
Example 3
Source File: SavepointV2Serializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(SavepointV2 checkpointMetadata, DataOutputStream dos) throws IOException {
	// first: checkpoint ID
	dos.writeLong(checkpointMetadata.getCheckpointId());

	// second: master state
	final Collection<MasterState> masterStates = checkpointMetadata.getMasterStates();
	dos.writeInt(masterStates.size());
	for (MasterState ms : masterStates) {
		serializeMasterState(ms, dos);
	}

	// third: operator states
	Collection<OperatorState> operatorStates = checkpointMetadata.getOperatorStates();
	dos.writeInt(operatorStates.size());

	for (OperatorState operatorState : operatorStates) {
		// Operator ID
		dos.writeLong(operatorState.getOperatorID().getLowerPart());
		dos.writeLong(operatorState.getOperatorID().getUpperPart());

		// Parallelism
		int parallelism = operatorState.getParallelism();
		dos.writeInt(parallelism);
		dos.writeInt(operatorState.getMaxParallelism());
		dos.writeInt(1);

		// Sub task states
		Map<Integer, OperatorSubtaskState> subtaskStateMap = operatorState.getSubtaskStates();
		dos.writeInt(subtaskStateMap.size());
		for (Map.Entry<Integer, OperatorSubtaskState> entry : subtaskStateMap.entrySet()) {
			dos.writeInt(entry.getKey());
			serializeSubtaskState(entry.getValue(), dos);
		}
	}
}
 
Example 4
Source File: SavepointV2Serializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(SavepointV2 checkpointMetadata, DataOutputStream dos) throws IOException {
	// first: checkpoint ID
	dos.writeLong(checkpointMetadata.getCheckpointId());

	// second: master state
	final Collection<MasterState> masterStates = checkpointMetadata.getMasterStates();
	dos.writeInt(masterStates.size());
	for (MasterState ms : masterStates) {
		serializeMasterState(ms, dos);
	}

	// third: operator states
	Collection<OperatorState> operatorStates = checkpointMetadata.getOperatorStates();
	dos.writeInt(operatorStates.size());

	for (OperatorState operatorState : operatorStates) {
		// Operator ID
		dos.writeLong(operatorState.getOperatorID().getLowerPart());
		dos.writeLong(operatorState.getOperatorID().getUpperPart());

		// Parallelism
		int parallelism = operatorState.getParallelism();
		dos.writeInt(parallelism);
		dos.writeInt(operatorState.getMaxParallelism());
		dos.writeInt(1);

		// Sub task states
		Map<Integer, OperatorSubtaskState> subtaskStateMap = operatorState.getSubtaskStates();
		dos.writeInt(subtaskStateMap.size());
		for (Map.Entry<Integer, OperatorSubtaskState> entry : subtaskStateMap.entrySet()) {
			dos.writeInt(entry.getKey());
			serializeSubtaskState(entry.getValue(), dos);
		}
	}
}