This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.io.checkpoint.fs;
020
021import org.apache.hadoop.fs.Path;
022import org.apache.hadoop.io.Text;
023import org.apache.reef.io.checkpoint.CheckpointID;
024
025import java.io.DataInput;
026import java.io.DataOutput;
027import java.io.IOException;
028
029/**
030 * A FileSystem based checkpoint ID contains reference to the Path
031 * where the checkpoint has been saved.
032 */
033public class FSCheckpointID implements CheckpointID {
034
035  private Path path;
036
037  public FSCheckpointID() {
038  }
039
040  public FSCheckpointID(final Path path) {
041    this.path = path;
042  }
043
044  public Path getPath() {
045    return path;
046  }
047
048  @Override
049  public String toString() {
050    return path.toString();
051  }
052
053  @Override
054  public void write(final DataOutput out) throws IOException {
055    Text.writeString(out, path.toString());
056  }
057
058  @Override
059  public void readFields(final DataInput in) throws IOException {
060    this.path = new Path(Text.readString(in));
061  }
062
063  @Override
064  public boolean equals(final Object other) {
065    return other instanceof FSCheckpointID
066        && path.equals(((FSCheckpointID) other).path);
067  }
068
069  @Override
070  public int hashCode() {
071    return path.hashCode();
072  }
073
074}