提交 f04b32b0 编写于 作者: S Stephan Ewen

[hotfix] [core] Fix lots of checkstyle errors in core.fs

上级 1854a3de
......@@ -32,13 +32,13 @@ import java.io.IOException;
@Internal
public abstract class AbstractMultiFSDataInputStream extends FSDataInputStream {
/** Inner stream for the currently accessed segment of the virtual global stream */
/** Inner stream for the currently accessed segment of the virtual global stream. */
protected FSDataInputStream delegate;
/** Position in the virtual global stream */
/** Position in the virtual global stream. */
protected long totalPos;
/** Total available bytes in the virtual global stream */
/** Total available bytes in the virtual global stream. */
protected long totalAvailable;
public AbstractMultiFSDataInputStream() {
......@@ -48,7 +48,7 @@ public abstract class AbstractMultiFSDataInputStream extends FSDataInputStream {
@Override
public void seek(long desired) throws IOException {
if(desired == totalPos) {
if (desired == totalPos) {
return;
}
......
......@@ -30,7 +30,7 @@ public interface BlockLocation extends Comparable<BlockLocation> {
/**
* Get the list of hosts (hostname) hosting this block.
*
*
* @return A list of hosts (hostname) hosting this block.
* @throws IOException
* thrown if the list of hosts could not be retrieved
......@@ -39,14 +39,14 @@ public interface BlockLocation extends Comparable<BlockLocation> {
/**
* Get the start offset of the file associated with this block.
*
*
* @return The start offset of the file associated with this block.
*/
long getOffset();
/**
* Get the length of the block.
*
*
* @return the length of the block
*/
long getLength();
......
......@@ -29,10 +29,10 @@ import java.util.Map;
/**
* This class allows to register instances of {@link Closeable}, which are all closed if this registry is closed.
* <p>
* Registering to an already closed registry will throw an exception and close the provided {@link Closeable}
* <p>
* All methods in this class are thread-safe.
*
* <p>Registering to an already closed registry will throw an exception and close the provided {@link Closeable}
*
* <p>All methods in this class are thread-safe.
*/
@Internal
public class CloseableRegistry extends AbstractCloseableRegistry<Closeable, Object> {
......
......@@ -26,8 +26,8 @@ import java.io.IOException;
/**
* This class is a {@link org.apache.flink.util.WrappingProxy} for {@link FSDataInputStream} that is used to
* implement a safety net against unclosed streams.
* <p>
* See {@link SafetyNetCloseableRegistry} for more details on how this is utilized.
*
* <p>See {@link SafetyNetCloseableRegistry} for more details on how this is utilized.
*/
@Internal
public class ClosingFSDataInputStream
......
......@@ -26,8 +26,8 @@ import java.io.IOException;
/**
* This class is a {@link org.apache.flink.util.WrappingProxy} for {@link FSDataOutputStream} that is used to
* implement a safety net against unclosed streams.
* <p>
* See {@link SafetyNetCloseableRegistry} for more details on how this is utilized.
*
* <p>See {@link SafetyNetCloseableRegistry} for more details on how this is utilized.
*/
@Internal
public class ClosingFSDataOutputStream
......
......@@ -25,7 +25,7 @@ import java.io.InputStream;
/**
* Interface for a data input stream to a file on a {@link FileSystem}.
*
*
* <p>This extends the {@link java.io.InputStream} with methods for accessing
* the stream's {@link #getPos() current position} and
* {@link #seek(long) seeking} to a desired position.
......@@ -36,7 +36,7 @@ public abstract class FSDataInputStream extends InputStream {
/**
* Seek to the given offset from the start of the file. The next read() will be from that location.
* Can't seek past the end of the file.
*
*
* @param desired
* the desired offset
* @throws IOException Thrown if an error occurred while seeking inside the input stream.
......@@ -47,7 +47,7 @@ public abstract class FSDataInputStream extends InputStream {
* Gets the current position in the input stream.
*
* @return current position in the input stream
* @throws IOException Thrown if an I/O error occurred in the underlying stream
* @throws IOException Thrown if an I/O error occurred in the underlying stream
* implementation while accessing the stream's position.
*/
public abstract long getPos() throws IOException;
......
......@@ -25,7 +25,7 @@ import org.apache.flink.util.WrappingProxy;
import java.io.IOException;
/**
* Simple forwarding wrapper around {@link FSDataInputStream}
* Simple forwarding wrapper around {@link FSDataInputStream}.
*/
@Internal
public class FSDataInputStreamWrapper extends FSDataInputStream implements WrappingProxy<FSDataInputStream> {
......
......@@ -26,22 +26,22 @@ import java.io.OutputStream;
/**
* An output stream to a file that is created via a {@link FileSystem}.
* This class extends the base {@link java.io.OutputStream} with some additional important methods.
*
*
* <h2>Data Persistence Guarantees</h2>
*
* These streams are used to persistently store data, both for results of streaming applications
*
* <p>These streams are used to persistently store data, both for results of streaming applications
* and for fault tolerance and recovery. It is therefore crucial that the persistence semantics
* of these streams are well defined.
*
*
* <p>Please refer to the class-level docs of {@link FileSystem} for the definition of data persistence
* via Flink's FileSystem abstraction and the {@code FSDataOutputStream}.
*
*
* <h2>Thread Safety</h2>
*
* Implementations of the {@code FSDataOutputStream} are generally not assumed to be thread safe.
*
* <p>Implementations of the {@code FSDataOutputStream} are generally not assumed to be thread safe.
* Instances of {@code FSDataOutputStream} should not be passed between threads, because there
* are no guarantees about the order of visibility of operations across threads.
*
*
* @see FileSystem
* @see FSDataInputStream
*/
......@@ -52,13 +52,13 @@ public abstract class FSDataOutputStream extends OutputStream {
* Gets the position of the stream (non-negative), defined as the number of bytes
* from the beginning of the file to the current writing position. The position
* corresponds to the zero-based index of the next byte that will be written.
*
*
* <p>This method must report accurately report the current position of the stream.
* Various components of the high-availability and recovery logic rely on the accurate
*
*
* @return The current position in the stream, defined as the number of bytes
* from the beginning of the file to the current writing position.
*
*
* @throws IOException Thrown if an I/O error occurs while obtaining the position from
* the stream implementation.
*/
......@@ -68,14 +68,14 @@ public abstract class FSDataOutputStream extends OutputStream {
* Flushes the stream, writing any data currently buffered in stream implementation
* to the proper output stream. After this method has been called, the stream implementation
* must not hold onto any buffered data any more.
*
*
* <p>A completed flush does not mean that the data is necessarily persistent. Data
* persistence can is only assumed after calls to {@link #close()} or {@link #sync()}.
*
*
* <p>Implementation note: This overrides the method defined in {@link OutputStream}
* as abstract to force implementations of the {@code FSDataOutputStream} to implement
* this method directly.
*
*
* @throws IOException Thrown if an I/O error occurs while flushing the stream.
*/
public abstract void flush() throws IOException;
......@@ -84,9 +84,7 @@ public abstract class FSDataOutputStream extends OutputStream {
* Flushes the data all the way to the persistent non-volatile storage (for example disks).
* The method behaves similar to the <i>fsync</i> function, forcing all data to
* be persistent on the devices.
*
* <p>
*
*
* @throws IOException Thrown if an I/O error occurs
*/
public abstract void sync() throws IOException;
......@@ -95,20 +93,20 @@ public abstract class FSDataOutputStream extends OutputStream {
* Closes the output stream. After this method returns, the implementation must guarantee
* that all data written to the stream is persistent/visible, as defined in the
* {@link FileSystem class-level docs}.
*
*
* <p>The above implies that the method must block until persistence can be guaranteed.
* For example for distributed replicated file systems, the method must block until the
* replication quorum has been reached. If the calling thread is interrupted in the
* process, it must fail with an {@code IOException} to indicate that persistence cannot
* be guaranteed.
*
*
* <p>If this method throws an exception, the data in the stream cannot be assumed to be
* persistent.
*
*
* <p>Implementation note: This overrides the method defined in {@link OutputStream}
* as abstract to force implementations of the {@code FSDataOutputStream} to implement
* this method directly.
*
*
* @throws IOException Thrown, if an error occurred while closing the stream or guaranteeing
* that the data is persistent.
*/
......
......@@ -25,7 +25,7 @@ import org.apache.flink.util.WrappingProxy;
import java.io.IOException;
/**
* Simple forwarding wrapper around {@link FSDataInputStream}
* Simple forwarding wrapper around {@link FSDataInputStream}.
*/
@Internal
public class FSDataOutputStreamWrapper extends FSDataOutputStream implements WrappingProxy<FSDataOutputStream> {
......
......@@ -23,7 +23,7 @@ import org.apache.flink.core.io.LocatableInputSplit;
/**
* A file input split provides information on a particular part of a file, possibly
* hosted on a distributed file system and replicated among several hosts.
* hosted on a distributed file system and replicated among several hosts.
*/
@Public
public class FileInputSplit extends LocatableInputSplit {
......@@ -34,16 +34,16 @@ public class FileInputSplit extends LocatableInputSplit {
private final Path file;
/** The position of the first byte in the file to process. */
private long start;
private final long start;
/** The number of bytes in the file to process. */
private long length;
private final long length;
// --------------------------------------------------------------------------------------------
/**
* Constructs a split with host information.
*
*
* @param num
* the number of this input split
* @param file
......@@ -57,17 +57,17 @@ public class FileInputSplit extends LocatableInputSplit {
*/
public FileInputSplit(int num, Path file, long start, long length, String[] hosts) {
super(num, hosts);
this.file = file;
this.start = start;
this.length = length;
}
// --------------------------------------------------------------------------------------------
/**
* Returns the path of the file containing this split's data.
*
*
* @return the path of the file containing this split's data.
*/
public Path getPath() {
......@@ -76,7 +76,7 @@ public class FileInputSplit extends LocatableInputSplit {
/**
* Returns the position of the first byte in the file to process.
*
*
* @return the position of the first byte in the file to process
*/
public long getStart() {
......@@ -85,20 +85,20 @@ public class FileInputSplit extends LocatableInputSplit {
/**
* Returns the number of bytes in the file to process.
*
*
* @return the number of bytes in the file to process
*/
public long getLength() {
return length;
}
// --------------------------------------------------------------------------------------------
@Override
public int hashCode() {
return getSplitNumber() ^ (file == null ? 0 : file.hashCode());
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
......@@ -106,7 +106,7 @@ public class FileInputSplit extends LocatableInputSplit {
}
else if (obj != null && obj instanceof FileInputSplit && super.equals(obj)) {
FileInputSplit other = (FileInputSplit) obj;
return this.start == other.start &&
this.length == other.length &&
(this.file == null ? other.file == null : (other.file != null && this.file.equals(other.file)));
......@@ -115,7 +115,7 @@ public class FileInputSplit extends LocatableInputSplit {
return false;
}
}
@Override
public String toString() {
return "[" + getSplitNumber() + "] " + file + ":" + start + "+" + length;
......
......@@ -20,7 +20,7 @@
/**
* This file is based on source code from the Hadoop Project (http://hadoop.apache.org/), licensed by the Apache
* Software Foundation (ASF) under the Apache License, Version 2.0. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
* additional information regarding copyright ownership.
*/
package org.apache.flink.core.fs;
......@@ -30,56 +30,55 @@ import org.apache.flink.annotation.Public;
/**
* Interface that represents the client side information for a file
* independent of the file system.
*
*/
@Public
public interface FileStatus {
/**
* Return the length of this file
*
* Return the length of this file.
*
* @return the length of this file
*/
long getLen();
/**
*Get the block size of the file.
*
*
* @return the number of bytes
*/
long getBlockSize();
/**
* Get the replication factor of a file.
*
*
* @return the replication factor of a file.
*/
short getReplication();
/**
* Get the modification time of the file.
*
*
* @return the modification time of file in milliseconds since January 1, 1970 UTC.
*/
long getModificationTime();
/**
* Get the access time of the file.
*
*
* @return the access time of file in milliseconds since January 1, 1970 UTC.
*/
long getAccessTime();
/**
* Checks if this object represents a directory.
*
*
* @return <code>true</code> if this is a directory, <code>false</code> otherwise
*/
boolean isDir();
/**
* Returns the corresponding Path to the FileStatus.
*
*
* @return the corresponding Path to the FileStatus
*/
Path getPath();
......
......@@ -58,4 +58,4 @@ public interface FileSystemFactory {
* @throws IOException Thrown if the file system could not be instantiated.
*/
FileSystem create(URI fsUri) throws IOException;
}
\ No newline at end of file
}
......@@ -22,26 +22,26 @@
package org.apache.flink.core.fs;
import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.flink.annotation.Public;
import org.apache.flink.core.io.IOReadableWritable;
import org.apache.flink.core.memory.DataInputView;
import org.apache.flink.core.memory.DataOutputView;
import org.apache.flink.util.StringUtils;
import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
/**
* Names a file or directory in a {@link FileSystem}. Path strings use slash as
* the directory separator. A path string is absolute if it begins with a slash.
*
* Tailing slashes are removed from the path.
* <p>Tailing slashes are removed from the path.
*/
@Public
public class Path implements IOReadableWritable, Serializable {
private static final long serialVersionUID = 1L;
/**
......@@ -71,7 +71,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Constructs a path object from a given URI.
*
*
* @param uri
* the URI to construct the path object from
*/
......@@ -81,7 +81,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Resolve a child path against a parent path.
*
*
* @param parent
* the parent path
* @param child
......@@ -93,7 +93,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Resolve a child path against a parent path.
*
*
* @param parent
* the parent path
* @param child
......@@ -105,7 +105,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Resolve a child path against a parent path.
*
*
* @param parent
* the parent path
* @param child
......@@ -117,7 +117,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Resolve a child path against a parent path.
*
*
* @param parent
* the parent path
* @param child
......@@ -168,7 +168,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Construct a path from a String. Path strings are URIs, but with unescaped
* elements and some additional normalization.
*
*
* @param pathString
* the string to construct a path from
*/
......@@ -214,7 +214,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Construct a Path from a scheme, an authority and a path string.
*
*
* @param scheme
* the scheme string
* @param authority
......@@ -229,7 +229,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Initializes a path object given the scheme, authority and path string.
*
*
* @param scheme
* the scheme string.
* @param authority
......@@ -247,7 +247,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Normalizes a path string.
*
*
* @param path
* the path string to normalize
* @return the normalized path string
......@@ -262,10 +262,10 @@ public class Path implements IOReadableWritable, Serializable {
path = path.replaceAll("/+", "/");
// remove tailing separator
if(!path.equals(SEPARATOR) && // UNIX root path
if (!path.equals(SEPARATOR) && // UNIX root path
!path.matches("/\\p{Alpha}+:/") && // Windows root path
path.endsWith(SEPARATOR))
{
path.endsWith(SEPARATOR)) {
// remove tailing slash
path = path.substring(0, path.length() - SEPARATOR.length());
}
......@@ -275,7 +275,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Converts the path object to a {@link URI}.
*
*
* @return the {@link URI} object converted from the path object
*/
public URI toUri() {
......@@ -284,7 +284,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Returns the FileSystem that owns this Path.
*
*
* @return the FileSystem that owns this Path
* @throws IOException
* thrown if the file system could not be retrieved
......@@ -295,7 +295,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Checks if the directory of this path is absolute.
*
*
* @return <code>true</code> if the directory of this path is absolute, <code>false</code> otherwise
*/
public boolean isAbsolute() {
......@@ -305,7 +305,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Returns the final component of this path, i.e., everything that follows the last separator.
*
*
* @return the final component of the path
*/
public String getName() {
......@@ -325,7 +325,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Returns the parent of a path, i.e., everything that precedes the last separator
* or <code>null</code> if at root.
*
*
* @return the parent of a path or <code>null</code> if at root.
*/
public Path getParent() {
......@@ -348,7 +348,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Adds a suffix to the final name in the path.
*
*
* @param suffix The suffix to be added
* @return the new path including the suffix
*/
......@@ -381,7 +381,6 @@ public class Path implements IOReadableWritable, Serializable {
return buffer.toString();
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Path)) {
......@@ -391,7 +390,6 @@ public class Path implements IOReadableWritable, Serializable {
return this.uri.equals(that.uri);
}
@Override
public int hashCode() {
return uri.hashCode();
......@@ -404,7 +402,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Returns the number of elements in this path.
*
*
* @return the number of elements in this path
*/
public int depth() {
......@@ -420,7 +418,7 @@ public class Path implements IOReadableWritable, Serializable {
/**
* Returns a qualified path object.
*
*
* @param fs
* the FileSystem that should be used to obtain the current working directory
* @return the qualified path object
......@@ -479,7 +477,6 @@ public class Path implements IOReadableWritable, Serializable {
}
}
@Override
public void write(DataOutputView out) throws IOException {
if (uri == null) {
......@@ -516,7 +513,7 @@ public class Path implements IOReadableWritable, Serializable {
* the path to check
* @param slashed
* true to indicate the first character of the string is a slash, false otherwise
*
*
* @return <code>true</code> if the path string contains a windows drive letter, false otherwise
*/
private boolean hasWindowsDrive(String path, boolean slashed) {
......
......@@ -20,11 +20,9 @@ package org.apache.flink.core.fs;
import org.apache.flink.annotation.Internal;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.core.fs.FileSystem;
import org.apache.flink.core.fs.FileSystemFactory;
import org.apache.flink.core.fs.UnsupportedFileSystemSchemeException;
import javax.annotation.Nullable;
import java.io.IOException;
import java.net.URI;
......
......@@ -27,6 +27,4 @@ import java.io.Closeable;
* {@link WrappingProxy} for {@link Closeable} that is also closeable.
*/
@Internal
public interface WrappingProxyCloseable<T extends Closeable> extends Closeable, WrappingProxy<T> {
}
public interface WrappingProxyCloseable<T extends Closeable> extends Closeable, WrappingProxy<T> {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册