All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.flink.runtime.state.gemini.engine.snapshot.DBSnapshotMeta Maven / Gradle / Ivy

There is a newer version: 1.5.1
Show newest version
/*
 * 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.state.gemini.engine.snapshot;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

/**
 * Encapsulates meta data for a completed DB snapshot used by backend.
 * This is created by DB and returned to backend.
 */
public class DBSnapshotMeta implements Serializable{

	private static final long serialVersionUID = 6595214484441644131L;

	/**
	 * Path for DB snapshot meta.
	 */
	private final String snapshotMetaPath;

	/**
	 * NameSpace for this snapshot, refer to {@link SnapshotManager#getNameSpace()}.
	 */
	private final String nameSpace;

	/**
	 * ID for start region.
	 */
	private final int startRegionId;

	/**
	 * ID for end region.
	 */
	private final int endRegionId;

	/**
	 * The ID of the checkpoint.
	 */
	private final long checkpointId;

	/**
	 * The offsets of regions.
	 */
	private final long[] regionOffsets;

	/**
	 * The offset of the dfs file mapping.
	 */
	private final long dfsFileMappingOffset;

	/**
	 * The offset of the local file mapping.
	 */
	private final long localFileMappingOffset;

	/**
	 * Size of snapshot meta.
	 */
	private final long snapshotMetaSize;

	/**
	 * Incremental size of this snapshot.
	 */
	private final long incrementalSize;

	/**
	 * Full size of this snapshot.
	 */
	private final long fullSize;

	public DBSnapshotMeta(
				long checkpointId,
				int startRegionId,
				int endRegionId,
				long[] regionOffsets,
				long dfsFileMappingOffset,
				long localFileMappingOffset,
				long snapshotMetaSize,
				long fullSize,
				long incrementalSize,
				String snapshotMetaPath,
				String nameSpace) {

		this.checkpointId = checkpointId;
		this.startRegionId = startRegionId;
		this.endRegionId = endRegionId;
		this.regionOffsets = regionOffsets;
		this.dfsFileMappingOffset = dfsFileMappingOffset;
		this.localFileMappingOffset = localFileMappingOffset;
		this.snapshotMetaSize = snapshotMetaSize;
		this.fullSize = fullSize;
		this.incrementalSize = incrementalSize;
		this.snapshotMetaPath = snapshotMetaPath;
		this.nameSpace = nameSpace;
	}

	public String getSnapshotMetaPath() {
		return snapshotMetaPath;
	}

	public String getNameSpace() {
		return nameSpace;
	}

	public int getStartRegionId() {
		return startRegionId;
	}

	public int getEndRegionId() {
		return endRegionId;
	}

	public long getCheckPointId() {
		return checkpointId;
	}

	public long getSnapshotMetaSize() {
		return snapshotMetaSize;
	}

	public long getFullSize() {
		return fullSize;
	}

	public long getIncrementalSize() {
		return incrementalSize;
	}

	public long[] getRegionOffsets() {
		return regionOffsets;
	}

	public long getDfsFileMappingOffset() {
		return dfsFileMappingOffset;
	}

	public long getLocalFileMappingOffset() {
		return localFileMappingOffset;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}

		if (o == null || getClass() != o.getClass()) {
			return false;
		}

		DBSnapshotMeta that = (DBSnapshotMeta) o;

		return checkpointId == that.checkpointId &&
			startRegionId == that.startRegionId &&
			endRegionId == that.endRegionId &&
			Arrays.equals(regionOffsets, that.regionOffsets) &&
			dfsFileMappingOffset == that.dfsFileMappingOffset &&
			localFileMappingOffset == that.localFileMappingOffset &&
			snapshotMetaSize == that.snapshotMetaSize &&
			fullSize == that.fullSize &&
			incrementalSize == that.incrementalSize &&
			Objects.equals(snapshotMetaPath, that.snapshotMetaPath) &&
			Objects.equals(nameSpace, that.nameSpace);
	}

	@Override
	public int hashCode() {
		int result = startRegionId;
		result = 31 * result + endRegionId;
		result = 31 * result + Arrays.hashCode(regionOffsets);
		result = 31 * result + (int) (dfsFileMappingOffset ^ (dfsFileMappingOffset >>> 32));
		result = 31 * result + (int) (localFileMappingOffset ^ (localFileMappingOffset >>> 32));
		result = 31 * result + (int) (checkpointId ^ (checkpointId >>> 32));
		result = 31 * result + (int) (snapshotMetaSize ^ (snapshotMetaSize >>> 32));
		result = 31 * result + (int) (fullSize ^ (fullSize >>> 32));
		result = 31 * result + (int) (incrementalSize ^ (incrementalSize >>> 32));
		result = 31 * result + snapshotMetaPath.hashCode();
		result = 31 * result + nameSpace.hashCode();
		return result;
	}

	@Override
	public String toString() {
		return "DBSnapshotMeta{" +
			"checkpointId=" + checkpointId +
			", startRegionId=" + startRegionId +
			", endRegionId=" + endRegionId +
			", nameSpace=" + nameSpace +
			", dfsFileMappingOffset=" + dfsFileMappingOffset +
			", localFileMappingOffset=" + localFileMappingOffset +
			", snapshotMetaSize=" + snapshotMetaSize +
			", fullSize=" + fullSize +
			", incrementalSize=" + incrementalSize +
			", snapshotMetaPath=" + snapshotMetaPath +
			'}';
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy