Java Code Examples for org.apache.flink.runtime.clusterframework.ApplicationStatus#valueOf()

The following examples show how to use org.apache.flink.runtime.clusterframework.ApplicationStatus#valueOf() . 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: JobResultDeserializer.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public JobResult deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
	JobID jobId = null;
	ApplicationStatus applicationStatus = ApplicationStatus.UNKNOWN;
	long netRuntime = -1;
	SerializedThrowable serializedThrowable = null;
	Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = null;

	while (true) {
		final JsonToken jsonToken = p.nextToken();
		assertNotEndOfInput(p, jsonToken);
		if (jsonToken == JsonToken.END_OBJECT) {
			break;
		}

		final String fieldName = p.getValueAsString();
		switch (fieldName) {
			case JobResultSerializer.FIELD_NAME_JOB_ID:
				assertNextToken(p, JsonToken.VALUE_STRING);
				jobId = jobIdDeserializer.deserialize(p, ctxt);
				break;
			case JobResultSerializer.FIELD_NAME_APPLICATION_STATUS:
				assertNextToken(p, JsonToken.VALUE_STRING);
				applicationStatus = ApplicationStatus.valueOf(p.getValueAsString().toUpperCase());
				break;
			case JobResultSerializer.FIELD_NAME_NET_RUNTIME:
				assertNextToken(p, JsonToken.VALUE_NUMBER_INT);
				netRuntime = p.getLongValue();
				break;
			case JobResultSerializer.FIELD_NAME_ACCUMULATOR_RESULTS:
				assertNextToken(p, JsonToken.START_OBJECT);
				accumulatorResults = parseAccumulatorResults(p, ctxt);
				break;
			case JobResultSerializer.FIELD_NAME_FAILURE_CAUSE:
				assertNextToken(p, JsonToken.START_OBJECT);
				serializedThrowable = serializedThrowableDeserializer.deserialize(p, ctxt);
				break;
			default:
				// ignore unknown fields
		}
	}

	try {
		return new JobResult.Builder()
			.jobId(jobId)
			.applicationStatus(applicationStatus)
			.netRuntime(netRuntime)
			.accumulatorResults(accumulatorResults)
			.serializedThrowable(serializedThrowable)
			.build();
	} catch (final RuntimeException e) {
		throw new JsonMappingException(
			null,
			"Could not deserialize " + JobResult.class.getSimpleName(),
			e);
	}
}
 
Example 2
Source File: JobResultDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public JobResult deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
	JobID jobId = null;
	ApplicationStatus applicationStatus = ApplicationStatus.UNKNOWN;
	long netRuntime = -1;
	SerializedThrowable serializedThrowable = null;
	Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = null;

	while (true) {
		final JsonToken jsonToken = p.nextToken();
		assertNotEndOfInput(p, jsonToken);
		if (jsonToken == JsonToken.END_OBJECT) {
			break;
		}

		final String fieldName = p.getValueAsString();
		switch (fieldName) {
			case JobResultSerializer.FIELD_NAME_JOB_ID:
				assertNextToken(p, JsonToken.VALUE_STRING);
				jobId = jobIdDeserializer.deserialize(p, ctxt);
				break;
			case JobResultSerializer.FIELD_NAME_APPLICATION_STATUS:
				assertNextToken(p, JsonToken.VALUE_STRING);
				applicationStatus = ApplicationStatus.valueOf(p.getValueAsString().toUpperCase());
				break;
			case JobResultSerializer.FIELD_NAME_NET_RUNTIME:
				assertNextToken(p, JsonToken.VALUE_NUMBER_INT);
				netRuntime = p.getLongValue();
				break;
			case JobResultSerializer.FIELD_NAME_ACCUMULATOR_RESULTS:
				assertNextToken(p, JsonToken.START_OBJECT);
				accumulatorResults = parseAccumulatorResults(p, ctxt);
				break;
			case JobResultSerializer.FIELD_NAME_FAILURE_CAUSE:
				assertNextToken(p, JsonToken.START_OBJECT);
				serializedThrowable = serializedThrowableDeserializer.deserialize(p, ctxt);
				break;
			default:
				// ignore unknown fields
		}
	}

	try {
		return new JobResult.Builder()
			.jobId(jobId)
			.applicationStatus(applicationStatus)
			.netRuntime(netRuntime)
			.accumulatorResults(accumulatorResults)
			.serializedThrowable(serializedThrowable)
			.build();
	} catch (final RuntimeException e) {
		throw new JsonMappingException(
			null,
			"Could not deserialize " + JobResult.class.getSimpleName(),
			e);
	}
}
 
Example 3
Source File: JobResultDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public JobResult deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
	JobID jobId = null;
	ApplicationStatus applicationStatus = ApplicationStatus.UNKNOWN;
	long netRuntime = -1;
	SerializedThrowable serializedThrowable = null;
	Map<String, SerializedValue<OptionalFailure<Object>>> accumulatorResults = null;

	while (true) {
		final JsonToken jsonToken = p.nextToken();
		assertNotEndOfInput(p, jsonToken);
		if (jsonToken == JsonToken.END_OBJECT) {
			break;
		}

		final String fieldName = p.getValueAsString();
		switch (fieldName) {
			case JobResultSerializer.FIELD_NAME_JOB_ID:
				assertNextToken(p, JsonToken.VALUE_STRING);
				jobId = jobIdDeserializer.deserialize(p, ctxt);
				break;
			case JobResultSerializer.FIELD_NAME_APPLICATION_STATUS:
				assertNextToken(p, JsonToken.VALUE_STRING);
				applicationStatus = ApplicationStatus.valueOf(p.getValueAsString().toUpperCase());
				break;
			case JobResultSerializer.FIELD_NAME_NET_RUNTIME:
				assertNextToken(p, JsonToken.VALUE_NUMBER_INT);
				netRuntime = p.getLongValue();
				break;
			case JobResultSerializer.FIELD_NAME_ACCUMULATOR_RESULTS:
				assertNextToken(p, JsonToken.START_OBJECT);
				accumulatorResults = parseAccumulatorResults(p, ctxt);
				break;
			case JobResultSerializer.FIELD_NAME_FAILURE_CAUSE:
				assertNextToken(p, JsonToken.START_OBJECT);
				serializedThrowable = serializedThrowableDeserializer.deserialize(p, ctxt);
				break;
			default:
				// ignore unknown fields
		}
	}

	try {
		return new JobResult.Builder()
			.jobId(jobId)
			.applicationStatus(applicationStatus)
			.netRuntime(netRuntime)
			.accumulatorResults(accumulatorResults)
			.serializedThrowable(serializedThrowable)
			.build();
	} catch (final RuntimeException e) {
		throw new JsonMappingException(
			null,
			"Could not deserialize " + JobResult.class.getSimpleName(),
			e);
	}
}