flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request #4734: [FLINK-7652] [flip6] Port CurrentJobIdsHandler to ...
Date Tue, 10 Oct 2017 13:02:47 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4734#discussion_r143718904
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/messages/webmonitor/JobStatusesWithIdsOverview.java
---
    @@ -0,0 +1,368 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.runtime.messages.webmonitor;
    +
    +import org.apache.flink.api.common.JobID;
    +import org.apache.flink.runtime.rest.messages.ResponseBody;
    +
    +import com.fasterxml.jackson.core.JsonGenerator;
    +import com.fasterxml.jackson.core.JsonParser;
    +import com.fasterxml.jackson.databind.DeserializationContext;
    +import com.fasterxml.jackson.databind.JsonNode;
    +import com.fasterxml.jackson.databind.SerializerProvider;
    +import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
    +import com.fasterxml.jackson.databind.annotation.JsonSerialize;
    +import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
    +import com.fasterxml.jackson.databind.ser.std.StdSerializer;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.LinkedList;
    +import java.util.List;
    +
    +import static org.apache.flink.util.Preconditions.checkNotNull;
    +
    +/**
    + * An overview of how many jobs are in which status.
    + */
    +@JsonSerialize(using = JobStatusesWithIdsOverview.JobStatusesWithIdsOverviewSerializer.class)
    +@JsonDeserialize(using = JobStatusesWithIdsOverview.JobStatusesWithIdsOverviewDeserializer.class)
    +public class JobStatusesWithIdsOverview implements ResponseBody, InfoMessage {
    +
    +	private static final long serialVersionUID = -3699051943490133183L;
    +
    +	public static final String FIELD_NAME_JOBS_CREATED_IDS = "jobs-created";
    +	public static final String FIELD_NAME_JOBS_RUNNING_IDS = "jobs-running";
    +	public static final String FIELD_NAME_JOBS_FINISHED_IDS = "jobs-finished";
    +	public static final String FIELD_NAME_JOBS_CANCELLING_IDS = "jobs-cancelling";
    +	public static final String FIELD_NAME_JOBS_CANCELLED_IDS = "jobs-cancelled";
    +	public static final String FIELD_NAME_JOBS_FAILING_IDS = "jobs-failing";
    +	public static final String FIELD_NAME_JOBS_FAILED_IDS = "jobs-failed";
    +	public static final String FIELD_NAME_JOBS_RESTARTING_IDS = "jobs-restarting";
    +	public static final String FIELD_NAME_JOBS_SUSPENDED_IDS = "jobs-suspended";
    +	public static final String FIELD_NAME_JOBS_RECONCILING_IDS = "jobs-reconciling";
    +
    +	private final List<JobID> jobsCreated;
    +	private final List<JobID> jobsRunningOrPending;
    +	private final List<JobID> jobsFinished;
    +	private final List<JobID> jobsCancelling;
    +	private final List<JobID> jobsCancelled;
    +	private final List<JobID> jobsFailing;
    +	private final List<JobID> jobsFailed;
    +	private final List<JobID> jobsRestarting;
    +	private final List<JobID> jobsSuspended;
    +	private final List<JobID> jobsReconciling;
    +
    +	public JobStatusesWithIdsOverview(
    +			List<JobID> jobsCreated,
    +			List<JobID> jobsRunningOrPending,
    +			List<JobID> jobsFinished,
    +			List<JobID> jobsCancelling,
    +			List<JobID> jobsCancelled,
    +			List<JobID> jobsFailing,
    +			List<JobID> jobsFailed,
    +			List<JobID> jobsRestarting,
    +			List<JobID> jobsSuspended,
    +			List<JobID> jobsReconciling) {
    +
    +		this.jobsCreated = checkNotNull(jobsCreated);
    +		this.jobsRunningOrPending = checkNotNull(jobsRunningOrPending);
    +		this.jobsFinished = checkNotNull(jobsFinished);
    +		this.jobsCancelling = checkNotNull(jobsCancelling);
    +		this.jobsCancelled = checkNotNull(jobsCancelled);
    +		this.jobsFailing = checkNotNull(jobsFailing);
    +		this.jobsFailed = checkNotNull(jobsFailed);
    +		this.jobsRestarting = checkNotNull(jobsRestarting);
    +		this.jobsSuspended = checkNotNull(jobsSuspended);
    +		this.jobsReconciling = checkNotNull(jobsReconciling);
    +	}
    +
    +	public JobStatusesWithIdsOverview(JobStatusesWithIdsOverview first, JobStatusesWithIdsOverview
second) {
    +		this.jobsCreated = combine(first.getJobsCreated(), second.getJobsCreated());
    +		this.jobsRunningOrPending = combine(first.getJobsRunningOrPending(), second.getJobsRunningOrPending());
    +		this.jobsFinished = combine(first.getJobsFinished(), second.getJobsFinished());
    +		this.jobsCancelling = combine(first.getJobsCancelling(), second.getJobsCancelling());
    +		this.jobsCancelled = combine(first.getJobsCancelled(), second.getJobsCancelled());
    +		this.jobsFailing = combine(first.getJobsFailing(), second.getJobsFailing());
    +		this.jobsFailed = combine(first.getJobsFailed(), second.getJobsFailed());
    +		this.jobsRestarting = combine(first.getJobsRestarting(), second.getJobsRestarting());
    +		this.jobsSuspended = combine(first.getJobsSuspended(), second.getJobsSuspended());
    +		this.jobsReconciling = combine(first.getJobsReconciling(), second.getJobsReconciling());
    +	}
    +
    +	public List<JobID> getJobsCreated() {
    +		return jobsCreated;
    +	}
    +
    +	public List<JobID> getJobsRunningOrPending() {
    +		return jobsRunningOrPending;
    +	}
    +
    +	public List<JobID> getJobsFinished() {
    +		return jobsFinished;
    +	}
    +
    +	public List<JobID> getJobsCancelling() {
    +		return jobsCancelling;
    +	}
    +
    +	public List<JobID> getJobsCancelled() {
    +		return jobsCancelled;
    +	}
    +
    +	public List<JobID> getJobsFailing() {
    +		return jobsFailing;
    +	}
    +
    +	public List<JobID> getJobsFailed() {
    +		return jobsFailed;
    +	}
    +
    +	public List<JobID> getJobsRestarting() {
    +		return jobsRestarting;
    +	}
    +
    +	public List<JobID> getJobsSuspended() {
    +		return jobsSuspended;
    +	}
    +
    +	public List<JobID> getJobsReconciling() {
    +		return jobsReconciling;
    +	}
    +
    +	// ------------------------------------------------------------------------
    +
    +
    +	@Override
    +	public int hashCode() {
    +		return jobsCreated.hashCode() ^
    +				jobsRunningOrPending.hashCode() ^
    +				jobsFinished.hashCode() ^
    +				jobsCancelling.hashCode() ^
    +				jobsCancelled.hashCode() ^
    +				jobsFailing.hashCode() ^
    +				jobsFailed.hashCode() ^
    +				jobsRestarting.hashCode() ^
    +				jobsSuspended.hashCode() ^
    +				jobsReconciling.hashCode();
    +	}
    +
    +	@Override
    +	public boolean equals(Object obj) {
    +		if (obj == this) {
    +			return true;
    +		}
    +		else if (obj instanceof JobStatusesWithIdsOverview) {
    +			JobStatusesWithIdsOverview that = (JobStatusesWithIdsOverview) obj;
    +			return this.jobsCreated.equals(that.jobsCreated) &&
    +					this.jobsRunningOrPending.equals(that.jobsRunningOrPending) &&
    +					this.jobsFinished.equals(that.jobsFinished) &&
    +					this.jobsCancelling.equals(that.jobsCancelling) &&
    +					this.jobsCancelled.equals(that.jobsCancelled) &&
    +					this.jobsFailing.equals(that.jobsFailing) &&
    +					this.jobsFailed.equals(that.jobsFailed) &&
    +					this.jobsRestarting.equals(that.jobsRestarting) &&
    +					this.jobsSuspended.equals(that.jobsSuspended) &&
    +					this.jobsReconciling.equals(that.jobsReconciling);
    +		}
    +		else {
    +			return false;
    +		}
    +	}
    +
    +	@Override
    +	public String toString() {
    +		return "JobStatusesWithIdsOverview {" +
    +				"createdJobs=" + jobsCreated +
    +				", runningOrPendingJobs=" + jobsRunningOrPending +
    +				", finishedJobs=" + jobsFinished +
    +				", cancellingJobs=" + jobsCancelling +
    +				", cancelledJobs=" + jobsCancelled +
    +				", failingJobs=" + jobsFailing +
    +				", failedJobs=" + jobsFailed +
    +				", restartingJobs=" + jobsRestarting +
    +				", suspendedJobs=" + jobsSuspended +
    +				", reconcilingJobs=" + jobsReconciling +
    +				'}';
    +	}
    +
    +	// ------------------------------------------------------------------------
    +	//  Message serializers
    +	// ------------------------------------------------------------------------
    +
    +	public static final class JobStatusesWithIdsOverviewSerializer extends StdSerializer<JobStatusesWithIdsOverview>
{
    --- End diff --
    
    Just out of curiosity, why did you define a (de)serializer for this class? The structure
looks as if this could have been done automatically by the `ObjectMapper`.


---

Mime
View raw message