-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HADOOP-13327 Output Stream Specification. (#2587)
This defines what output streams and especially those which implement Syncable are meant to do, and documents where implementations (HDFS; S3) don't. With tests. The file:// FileSystem now supports Syncable if an application calls FileSystem.setWriteChecksum(false) before creating a file -checksumming and Syncable.hsync() are incompatible. Contributed by Steve Loughran.
- Loading branch information
1 parent
a8bd516
commit 798df6d
Showing
33 changed files
with
1,561 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...oject/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/StoreImplementationUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* 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.hadoop.fs.impl; | ||
|
||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
import org.apache.hadoop.classification.InterfaceAudience; | ||
import org.apache.hadoop.classification.InterfaceStability; | ||
import org.apache.hadoop.fs.StreamCapabilities; | ||
|
||
import static org.apache.hadoop.fs.StreamCapabilities.HFLUSH; | ||
import static org.apache.hadoop.fs.StreamCapabilities.HSYNC; | ||
|
||
/** | ||
* Utility classes to help implementing filesystems and streams. | ||
*/ | ||
@InterfaceAudience.Private | ||
@InterfaceStability.Unstable | ||
public final class StoreImplementationUtils { | ||
|
||
private StoreImplementationUtils() { | ||
} | ||
|
||
/** | ||
* Check the probe capability being for {@link StreamCapabilities#HSYNC} | ||
* or {@link StreamCapabilities#HFLUSH} | ||
* {@code Syncable.hsync()} and {@code Syncable.hflush()} functionality. | ||
* @param capability capability string. | ||
* @return true if either refers to one of the Syncable operations. | ||
*/ | ||
public static boolean isProbeForSyncable(String capability) { | ||
return capability.equalsIgnoreCase(HSYNC) || | ||
capability.equalsIgnoreCase(HFLUSH); | ||
} | ||
|
||
/** | ||
* Probe for an object having a capability; returns true | ||
* if the stream implements {@link StreamCapabilities} and its | ||
* {@code hasCapabilities()} method returns true for the capability. | ||
* This is a package private method intended to provided a common | ||
* implementation for input and output streams. | ||
* {@link StreamCapabilities#hasCapability(String)} call is for public use. | ||
* @param object object to probe. | ||
* @param capability capability to probe for | ||
* @return true if the object implements stream capabilities and | ||
* declares that it supports the capability. | ||
*/ | ||
static boolean objectHasCapability(Object object, String capability) { | ||
if (object instanceof StreamCapabilities) { | ||
return ((StreamCapabilities) object).hasCapability(capability); | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Probe for an output stream having a capability; returns true | ||
* if the stream implements {@link StreamCapabilities} and its | ||
* {@code hasCapabilities()} method returns true for the capability. | ||
* @param out output stream | ||
* @param capability capability to probe for | ||
* @return true if the stream declares that it supports the capability. | ||
*/ | ||
public static boolean hasCapability(OutputStream out, String capability) { | ||
return objectHasCapability(out, capability); | ||
} | ||
|
||
/** | ||
* Probe for an input stream having a capability; returns true | ||
* if the stream implements {@link StreamCapabilities} and its | ||
* {@code hasCapabilities()} method returns true for the capability. | ||
* @param in input stream | ||
* @param capability capability to probe for | ||
* @return true if the stream declares that it supports the capability. | ||
*/ | ||
public static boolean hasCapability(InputStream in, String capability) { | ||
return objectHasCapability(in, capability); | ||
} | ||
|
||
} |
Oops, something went wrong.