Java Code Examples for org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator#writeEndObject()

The following examples show how to use org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator#writeEndObject() . 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: HistoryServer.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static String createConfigJson(DashboardConfiguration dashboardConfiguration) throws IOException {
	StringWriter writer = new StringWriter();
	JsonGenerator gen = JsonFactory.JACKSON_FACTORY.createGenerator(writer);

	gen.writeStartObject();
	gen.writeNumberField(DashboardConfiguration.FIELD_NAME_REFRESH_INTERVAL, dashboardConfiguration.getRefreshInterval());
	gen.writeNumberField(DashboardConfiguration.FIELD_NAME_TIMEZONE_OFFSET, dashboardConfiguration.getTimeZoneOffset());
	gen.writeStringField(DashboardConfiguration.FIELD_NAME_TIMEZONE_NAME, dashboardConfiguration.getTimeZoneName());
	gen.writeStringField(DashboardConfiguration.FIELD_NAME_FLINK_VERSION, dashboardConfiguration.getFlinkVersion());
	gen.writeStringField(DashboardConfiguration.FIELD_NAME_FLINK_REVISION, dashboardConfiguration.getFlinkRevision());

	gen.writeEndObject();

	gen.close();

	return writer.toString();
}
 
Example 2
Source File: JobConfigInfo.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(
		JobConfigInfo jobConfigInfo,
		JsonGenerator jsonGenerator,
		SerializerProvider serializerProvider) throws IOException {
	jsonGenerator.writeStartObject();

	jsonGenerator.writeStringField(FIELD_NAME_JOB_ID, jobConfigInfo.getJobId().toString());
	jsonGenerator.writeStringField(FIELD_NAME_JOB_NAME, jobConfigInfo.getJobName());

	if (jobConfigInfo.getExecutionConfigInfo() != null) {
		jsonGenerator.writeObjectField(FIELD_NAME_EXECUTION_CONFIG, jobConfigInfo.getExecutionConfigInfo());
	}

	jsonGenerator.writeEndObject();
}
 
Example 3
Source File: MutableIOMetrics.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Writes the IO metrics contained in this object to the given {@link JsonGenerator}.
 *
 * <p>The JSON structure written is as follows:
 * "metrics": {
 *     "read-bytes": 1,
 *     "read-bytes-complete": true,
 *     "write-bytes": 2,
 *     "write-bytes-complete": true,
 *     "read-records": 3,
 *     "read-records-complete": true,
 *     "write-records": 4,
 *     "write-records-complete": true
 * }
 *
 * @param gen JsonGenerator to which the metrics should be written
 * @throws IOException
 */
public void writeIOMetricsAsJson(JsonGenerator gen) throws IOException {
	/**
	 * As described in {@link addIOMetrics}, we want to distinguish incomplete values from 0.
	 * However, for API backward compatibility, incomplete metrics will still be represented by the 0 value and
	 * a boolean will indicate the completeness.
	 */

	gen.writeObjectFieldStart("metrics");

	Long numBytesIn = this.numBytesInLocal + this.numBytesInRemote;
	gen.writeNumberField("read-bytes", numBytesIn);
	gen.writeBooleanField("read-bytes-complete", (this.numBytesInLocalComplete && this.numBytesInRemoteComplete));
	gen.writeNumberField("write-bytes", this.numBytesOut);
	gen.writeBooleanField("write-bytes-complete", this.numBytesOutComplete);
	gen.writeNumberField("read-records", this.numRecordsIn);
	gen.writeBooleanField("read-records-complete", this.numRecordsInComplete);
	gen.writeNumberField("write-records", this.numRecordsOut);
	gen.writeBooleanField("write-records-complete", this.numRecordsOutComplete);

	gen.writeEndObject();
}
 
Example 4
Source File: HistoryServer.java    From flink with Apache License 2.0 6 votes vote down vote up
private static String createConfigJson(DashboardConfiguration dashboardConfiguration) throws IOException {
	StringWriter writer = new StringWriter();
	JsonGenerator gen = JsonFactory.JACKSON_FACTORY.createGenerator(writer);

	gen.writeStartObject();
	gen.writeNumberField(DashboardConfiguration.FIELD_NAME_REFRESH_INTERVAL, dashboardConfiguration.getRefreshInterval());
	gen.writeNumberField(DashboardConfiguration.FIELD_NAME_TIMEZONE_OFFSET, dashboardConfiguration.getTimeZoneOffset());
	gen.writeStringField(DashboardConfiguration.FIELD_NAME_TIMEZONE_NAME, dashboardConfiguration.getTimeZoneName());
	gen.writeStringField(DashboardConfiguration.FIELD_NAME_FLINK_VERSION, dashboardConfiguration.getFlinkVersion());
	gen.writeStringField(DashboardConfiguration.FIELD_NAME_FLINK_REVISION, dashboardConfiguration.getFlinkRevision());

	gen.writeEndObject();

	gen.close();

	return writer.toString();
}
 
Example 5
Source File: JobConfigInfo.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(
		JobConfigInfo jobConfigInfo,
		JsonGenerator jsonGenerator,
		SerializerProvider serializerProvider) throws IOException {
	jsonGenerator.writeStartObject();

	jsonGenerator.writeStringField(FIELD_NAME_JOB_ID, jobConfigInfo.getJobId().toString());
	jsonGenerator.writeStringField(FIELD_NAME_JOB_NAME, jobConfigInfo.getJobName());

	if (jobConfigInfo.getExecutionConfigInfo() != null) {
		jsonGenerator.writeObjectField(FIELD_NAME_EXECUTION_CONFIG, jobConfigInfo.getExecutionConfigInfo());
	}

	jsonGenerator.writeEndObject();
}
 
Example 6
Source File: JobConfigInfo.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(
		JobConfigInfo jobConfigInfo,
		JsonGenerator jsonGenerator,
		SerializerProvider serializerProvider) throws IOException {
	jsonGenerator.writeStartObject();

	jsonGenerator.writeStringField(FIELD_NAME_JOB_ID, jobConfigInfo.getJobId().toString());
	jsonGenerator.writeStringField(FIELD_NAME_JOB_NAME, jobConfigInfo.getJobName());

	if (jobConfigInfo.getExecutionConfigInfo() != null) {
		jsonGenerator.writeObjectField(FIELD_NAME_EXECUTION_CONFIG, jobConfigInfo.getExecutionConfigInfo());
	}

	jsonGenerator.writeEndObject();
}
 
Example 7
Source File: JobDetails.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(
		JobDetails jobDetails,
		JsonGenerator jsonGenerator,
		SerializerProvider serializerProvider) throws IOException {
	jsonGenerator.writeStartObject();

	jsonGenerator.writeStringField(FIELD_NAME_JOB_ID, jobDetails.getJobId().toString());
	jsonGenerator.writeStringField(FIELD_NAME_JOB_NAME, jobDetails.getJobName());
	jsonGenerator.writeStringField(FIELD_NAME_STATUS, jobDetails.getStatus().name());

	jsonGenerator.writeNumberField(FIELD_NAME_START_TIME, jobDetails.getStartTime());
	jsonGenerator.writeNumberField(FIELD_NAME_END_TIME, jobDetails.getEndTime());
	jsonGenerator.writeNumberField(FIELD_NAME_DURATION, jobDetails.getDuration());
	jsonGenerator.writeNumberField(FIELD_NAME_LAST_MODIFICATION, jobDetails.getLastUpdateTime());

	jsonGenerator.writeObjectFieldStart("tasks");
	jsonGenerator.writeNumberField(FIELD_NAME_TOTAL_NUMBER_TASKS, jobDetails.getNumTasks());

	final int[] perState = jobDetails.getTasksPerState();

	for (ExecutionState executionState : ExecutionState.values()) {
		jsonGenerator.writeNumberField(executionState.name().toLowerCase(), perState[executionState.ordinal()]);
	}

	jsonGenerator.writeEndObject();

	jsonGenerator.writeEndObject();
}
 
Example 8
Source File: SerializedThrowableSerializer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final SerializedThrowable value, final JsonGenerator gen, final SerializerProvider provider) throws IOException {
	gen.writeStartObject();
	gen.writeStringField(FIELD_NAME_CLASS, value.getOriginalErrorClassName());
	gen.writeStringField(FIELD_NAME_STACK_TRACE, value.getFullStringifiedStackTrace());
	gen.writeBinaryField(FIELD_NAME_SERIALIZED_THROWABLE, InstantiationUtil.serializeObject(value));
	gen.writeEndObject();
}
 
Example 9
Source File: JobDetails.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(
		JobDetails jobDetails,
		JsonGenerator jsonGenerator,
		SerializerProvider serializerProvider) throws IOException {
	jsonGenerator.writeStartObject();

	jsonGenerator.writeStringField(FIELD_NAME_JOB_ID, jobDetails.getJobId().toString());
	jsonGenerator.writeStringField(FIELD_NAME_JOB_NAME, jobDetails.getJobName());
	jsonGenerator.writeStringField(FIELD_NAME_STATUS, jobDetails.getStatus().name());

	jsonGenerator.writeNumberField(FIELD_NAME_START_TIME, jobDetails.getStartTime());
	jsonGenerator.writeNumberField(FIELD_NAME_END_TIME, jobDetails.getEndTime());
	jsonGenerator.writeNumberField(FIELD_NAME_DURATION, jobDetails.getDuration());
	jsonGenerator.writeNumberField(FIELD_NAME_LAST_MODIFICATION, jobDetails.getLastUpdateTime());

	jsonGenerator.writeObjectFieldStart("tasks");
	jsonGenerator.writeNumberField(FIELD_NAME_TOTAL_NUMBER_TASKS, jobDetails.getNumTasks());

	final int[] perState = jobDetails.getTasksPerState();

	for (ExecutionState executionState : ExecutionState.values()) {
		jsonGenerator.writeNumberField(executionState.name().toLowerCase(), perState[executionState.ordinal()]);
	}

	jsonGenerator.writeEndObject();

	jsonGenerator.writeEndObject();
}
 
Example 10
Source File: SerializedThrowableSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final SerializedThrowable value, final JsonGenerator gen, final SerializerProvider provider) throws IOException {
	gen.writeStartObject();
	gen.writeStringField(FIELD_NAME_CLASS, value.getOriginalErrorClassName());
	gen.writeStringField(FIELD_NAME_STACK_TRACE, value.getFullStringifiedStackTrace());
	gen.writeBinaryField(FIELD_NAME_SERIALIZED_THROWABLE, InstantiationUtil.serializeObject(value));
	gen.writeEndObject();
}
 
Example 11
Source File: JobDetails.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(
		JobDetails jobDetails,
		JsonGenerator jsonGenerator,
		SerializerProvider serializerProvider) throws IOException {
	jsonGenerator.writeStartObject();

	jsonGenerator.writeStringField(FIELD_NAME_JOB_ID, jobDetails.getJobId().toString());
	jsonGenerator.writeStringField(FIELD_NAME_JOB_NAME, jobDetails.getJobName());
	jsonGenerator.writeStringField(FIELD_NAME_STATUS, jobDetails.getStatus().name());

	jsonGenerator.writeNumberField(FIELD_NAME_START_TIME, jobDetails.getStartTime());
	jsonGenerator.writeNumberField(FIELD_NAME_END_TIME, jobDetails.getEndTime());
	jsonGenerator.writeNumberField(FIELD_NAME_DURATION, jobDetails.getDuration());
	jsonGenerator.writeNumberField(FIELD_NAME_LAST_MODIFICATION, jobDetails.getLastUpdateTime());

	jsonGenerator.writeObjectFieldStart("tasks");
	jsonGenerator.writeNumberField(FIELD_NAME_TOTAL_NUMBER_TASKS, jobDetails.getNumTasks());

	final int[] perState = jobDetails.getTasksPerState();

	for (ExecutionState executionState : ExecutionState.values()) {
		jsonGenerator.writeNumberField(executionState.name().toLowerCase(), perState[executionState.ordinal()]);
	}

	jsonGenerator.writeEndObject();

	jsonGenerator.writeEndObject();
}
 
Example 12
Source File: SerializedThrowableSerializer.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final SerializedThrowable value, final JsonGenerator gen, final SerializerProvider provider) throws IOException {
	gen.writeStartObject();
	gen.writeStringField(FIELD_NAME_CLASS, value.getOriginalErrorClassName());
	gen.writeStringField(FIELD_NAME_STACK_TRACE, value.getFullStringifiedStackTrace());
	gen.writeBinaryField(FIELD_NAME_SERIALIZED_THROWABLE, InstantiationUtil.serializeObject(value));
	gen.writeEndObject();
}
 
Example 13
Source File: JsonMapper.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static void addProperty(JsonGenerator gen, String name, String value) throws IOException {
	gen.writeStartObject();
	gen.writeStringField("name", name);
	gen.writeStringField("value", value);
	gen.writeEndObject();
}
 
Example 14
Source File: JsonMapper.java    From flink with Apache License 2.0 4 votes vote down vote up
private static void addProperty(JsonGenerator gen, String name, String value) throws IOException {
	gen.writeStartObject();
	gen.writeStringField("name", name);
	gen.writeStringField("value", value);
	gen.writeEndObject();
}
 
Example 15
Source File: JsonMapper.java    From flink with Apache License 2.0 4 votes vote down vote up
private static void addProperty(JsonGenerator gen, String name, String value) throws IOException {
	gen.writeStartObject();
	gen.writeStringField("name", name);
	gen.writeStringField("value", value);
	gen.writeEndObject();
}