Java Code Examples for org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator#writeNumberField()
The following examples show how to use
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator#writeNumberField() .
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 |
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: MutableIOMetrics.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * 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 3
Source File: HistoryServer.java From flink with Apache License 2.0 | 6 votes |
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 4
Source File: JobDetails.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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 5
Source File: JobDetails.java From flink with Apache License 2.0 | 5 votes |
@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 6
Source File: JobDetails.java From flink with Apache License 2.0 | 5 votes |
@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(); }