本文整理匯總了Java中org.apache.hadoop.fs.FSDataInputStream.available方法的典型用法代碼示例。如果您正苦於以下問題:Java FSDataInputStream.available方法的具體用法?Java FSDataInputStream.available怎麽用?Java FSDataInputStream.available使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.fs.FSDataInputStream
的用法示例。
在下文中一共展示了FSDataInputStream.available方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: download
import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
/**
* 從hadoop中下載文件
*
* @param taskName
* @param filePath
*/
public static void download(String taskName, String filePath, boolean existDelete) {
File file = new File(filePath);
if (file.exists()) {
if (existDelete) {
file.deleteOnExit();
} else {
return;
}
}
String hadoopAddress = propertyConfig.getProperty("sqoop.task." + taskName + ".tolink.linkConfig.uri");
String itemmodels = propertyConfig.getProperty("sqoop.task." + taskName + ".recommend.itemmodels");
try {
DistributedFileSystem distributedFileSystem = distributedFileSystem(hadoopAddress);
FSDataInputStream fsDataInputStream = distributedFileSystem.open(new Path(itemmodels));
byte[] bs = new byte[fsDataInputStream.available()];
fsDataInputStream.read(bs);
log.info(new String(bs));
FileOutputStream fileOutputStream = new FileOutputStream(new File(filePath));
IOUtils.write(bs, fileOutputStream);
IOUtils.closeQuietly(fileOutputStream);
} catch (IOException e) {
log.error(e);
}
}
示例2: print
import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
/**
* 查看輸出結果
*
* @param path
*/
public void print(String path) {
log.info("mapreduce輸出結果:...................................................");
DistributedFileSystem distributedFileSystem = distributedFileSystem();
try {
FileStatus[] fileStatuses = distributedFileSystem.listStatus(new Path(path));
for (FileStatus fs : fileStatuses) {
log.info(fs);
FSDataInputStream fsDataInputStream = distributedFileSystem.open(fs.getPath());
byte[] bs = new byte[fsDataInputStream.available()];
fsDataInputStream.read(bs);
log.info("\n" + new String(bs) + "\n");
}
} catch (IOException e) {
log.error(e);
} finally {
close(distributedFileSystem);
}
}
示例3: printMessage
import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
public void printMessage(String path) {
System.out.println("\nprint result:");
DistributedFileSystem distributedFileSystem = distributedFileSystem();
try {
FileStatus[] fileStatuses = distributedFileSystem.listStatus(new Path(path));
for (FileStatus fileStatus : fileStatuses) {
System.out.println(fileStatus);
if (fileStatus.isFile()) {
FSDataInputStream fsDataInputStream = distributedFileSystem.open(fileStatus.getPath());
byte[] bs = new byte[fsDataInputStream.available()];
fsDataInputStream.read(bs);
fsDataInputStream.close();
System.out.println(new String(bs));
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
close(distributedFileSystem);
}
}
示例4: deserialize
import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
/**
* read matrix meta protos from input stream
* @param input input stream
* @throws IOException, InvalidParameterException
*/
public void deserialize(FSDataInputStream input)
throws IOException, InvalidParameterException, ClassNotFoundException {
while(input.available() > 0) {
MatrixMeta meta = ProtobufUtil.convertToMatrixMeta(ProtobufUtil.loadMatrixMetaProto(input));
matrixMetaManager.addMatrix(meta);
try {
writeLock.lock();
buildPSMatrixMeta(meta);
} finally {
writeLock.unlock();
}
}
}
示例5: readFile
import org.apache.hadoop.fs.FSDataInputStream; //導入方法依賴的package包/類
private static byte [] readFile(final FileSystem fs, final Path path) throws IOException {
FSDataInputStream tmpIn = fs.open(path);
try {
byte [] rawData = new byte[tmpIn.available()];
tmpIn.readFully(rawData);
return rawData;
} finally {
tmpIn.close();
}
}