当前位置: 首页>>代码示例>>Java>>正文


Java S3Object.getDataInputStream方法代码示例

本文整理汇总了Java中org.jets3t.service.model.S3Object.getDataInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java S3Object.getDataInputStream方法的具体用法?Java S3Object.getDataInputStream怎么用?Java S3Object.getDataInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jets3t.service.model.S3Object的用法示例。


在下文中一共展示了S3Object.getDataInputStream方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: read

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public InputStream read(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    try {
        final HttpRange range = HttpRange.withStatus(status);
        final RequestEntityRestStorageService client = session.getClient();
        final S3Object object = client.getVersionedObject(
                file.attributes().getVersionId(),
                containerService.getContainer(file).getName(),
                containerService.getKey(file),
                null, // ifModifiedSince
                null, // ifUnmodifiedSince
                null, // ifMatch
                null, // ifNoneMatch
                status.isAppend() ? range.getStart() : null,
                status.isAppend() ? (range.getEnd() == -1 ? null : range.getEnd()) : null);
        if(log.isDebugEnabled()) {
            log.debug(String.format("Reading stream with content length %d", object.getContentLength()));
        }
        return object.getDataInputStream();
    }
    catch(ServiceException e) {
        throw new S3ExceptionMappingService().map("Download {0} failed", e, file);
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:25,代码来源:S3ReadFeature.java

示例2: retrieve

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
/**
 *
 * @param key
 * The key is the object name that is being retrieved from the S3 bucket
 * @return
 * This method returns null if the key is not found
 * @throws IOException
 */

@Override
public InputStream retrieve(String key, long byteRangeStart)
        throws IOException {
  try {
    LOG.debug("Getting key: {} from bucket: {} with byteRangeStart: {}",
        key, bucket.getName(), byteRangeStart);
    S3Object object = s3Service.getObject(bucket, key, null, null, null,
                                          null, byteRangeStart, null);
    return object.getDataInputStream();
  } catch (ServiceException e) {
    handleException(e, key);
    return null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:Jets3tNativeFileSystemStore.java

示例3: createDownloader

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private Callable<Path> createDownloader(final int retryNum) {
  return new Callable<Path>() {
    public Path call() throws Exception {
      final Path chunkPath = (chunk == 0) ? downloadTo : Paths.get(downloadTo + "_" + chunk + "_" + retryNum);
      chunkPath.toFile().deleteOnExit();

      final long startTime = System.currentTimeMillis();

      final long byteRangeStart = chunk * chunkSize;
      final long byteRangeEnd = Math.min((chunk + 1) * chunkSize - 1, length);

      log.info("Downloading {} - chunk {} (retry {}) ({}-{}) to {}", s3Artifact.getFilename(), chunk, retryNum, byteRangeStart, byteRangeEnd, chunkPath);

      S3Object fetchedObject = s3.getObject(s3Artifact.getS3Bucket(), s3Artifact.getS3ObjectKey(), null, null, null, null, byteRangeStart, byteRangeEnd);

      try (InputStream is = fetchedObject.getDataInputStream()) {
        Files.copy(is, chunkPath, StandardCopyOption.REPLACE_EXISTING);
      }

      log.info("Finished downloading chunk {} (retry {}) of {} ({} bytes) in {}", chunk, retryNum, s3Artifact.getFilename(), byteRangeEnd - byteRangeStart, JavaUtils.duration(startTime));

      return chunkPath;
    };
  };
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:26,代码来源:S3ArtifactChunkDownloader.java

示例4: retrieve

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public InputStream retrieve(String key, long byteRangeStart)
  throws IOException {
  try {
    S3Object object = s3Service.getObject(bucket, key, null, null, null,
                                          null, byteRangeStart, null);
    return object.getDataInputStream();
  } catch (S3ServiceException e) {
    if ("NoSuchKey".equals(e.getS3ErrorCode())) {
      return null;
    }
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:17,代码来源:Jets3tNativeFileSystemStore.java

示例5: get

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private InputStream get(String key, boolean checkMetadata)
    throws IOException {
  
  try {
    S3Object object = s3Service.getObject(bucket, key);
    if (checkMetadata) {
      checkMetadata(object);
    }
    return object.getDataInputStream();
  } catch (S3ServiceException e) {
    if ("NoSuchKey".equals(e.getS3ErrorCode())) {
      return null;
    }
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:20,代码来源:Jets3tFileSystemStore.java

示例6: retrieve

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
/**
 *
 * @param key
 * The key is the object name that is being retrieved from the S3 bucket
 * @return
 * This method returns null if the key is not found
 * @throws IOException
 */

@Override
public InputStream retrieve(String key, long byteRangeStart)
        throws IOException {
  try {
    if(LOG.isDebugEnabled()) {
      LOG.debug("Getting key: " + key + " from bucket:" + bucket.getName() + " with byteRangeStart: " + byteRangeStart);
    }
    S3Object object = s3Service.getObject(bucket, key, null, null, null,
                                          null, byteRangeStart, null);
    return object.getDataInputStream();
  } catch (ServiceException e) {
    handleServiceException(key, e);
    return null; //return null if key not found
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre2,代码行数:25,代码来源:Jets3tNativeFileSystemStore.java

示例7: getDirectReadableChannel

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
protected ReadableByteChannel getDirectReadableChannel() throws ContentIOException {
	try {
		// Confirm the requested object exists
		if (!exists()) {
			throw new ContentIOException("Content object does not exist");
		}
		if(LOG.isDebugEnabled()){
			LOG.debug("S3ContentReader Obtaining Input Stream: nodeUrl="+nodeUrl);
		}
		// Get the object and retrieve the input stream
		final S3Object object = s3Service.getObject(bucket, nodeUrl);
		ReadableByteChannel channel = null;
		final InputStream is = object.getDataInputStream();
		channel = Channels.newChannel(is);
		if(LOG.isDebugEnabled()){
			LOG.debug("S3ContentReader Success Obtaining Input Stream: nodeUrl="+nodeUrl);
		}
		return channel;
	} catch (Exception excp) {
		throw new ContentIOException("Failed to open channel: " + this, excp);
	}
}
 
开发者ID:abhinavmishra14,项目名称:alfresco-amazon-s3-content-store-integration,代码行数:24,代码来源:S3ContentReader.java

示例8: get

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private InputStream get(String key) throws IOException {
  try {
    S3Object object = s3Service.getObject(bucket, key);
    return object.getDataInputStream();
  } catch (S3ServiceException e) {
    if ("NoSuchKey".equals(e.getS3ErrorCode())) {
      return null;
    }
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:15,代码来源:MigrationTool.java

示例9: retrieve

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public InputStream retrieve(String key) throws IOException {
  try {
    S3Object object = s3Service.getObject(bucket, key);
    return object.getDataInputStream();
  } catch (S3ServiceException e) {
    handleServiceException(key, e);
    return null; //never returned - keep compiler happy
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:11,代码来源:Jets3tNativeFileSystemStore.java

示例10: getFile

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public InputStream getFile(String path) throws IOException {
    try {
        path = stripLeadingSlash(path);
        S3Object object = service.getObject(bucketName, path);
        return object.getDataInputStream();
    } catch (ServiceException e) {
        throw new IOException(e);
    }
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:11,代码来源:AmazonFileStorageService.java

示例11: get

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
private InputStream get(String key, long byteRangeStart) throws IOException {
  try {
    S3Object object = s3Service.getObject(bucket, key, null, null, null,
                                          null, byteRangeStart, null);
    return object.getDataInputStream();
  } catch (S3ServiceException e) {
    if ("NoSuchKey".equals(e.getS3ErrorCode())) {
      return null;
    }
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:16,代码来源:Jets3tFileSystemStore.java

示例12: makeObjects

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
void makeObjects()
    throws IOException, URISyntaxException, ServiceException, NoSuchAlgorithmException {
  // Configure the service
  S3Service s3Service = testUtil.configureS3Service(hostName, PROXY_PORT);

  // Prepare objects inside MasterBucket; PUT and READ
  int randInt = Math.abs(new Random().nextInt() % 10) + 2;
  for (int i = 0; i < randInt; i++) {
    String oid = (useMasterObject) ? masterObjectName :
        "object_" + id + "_" + i;
    byte[] data = new byte[SMALL_SIZE];
    for (int d = 0; d < SMALL_SIZE; d++) {
      data[i] = (byte) (d % 256);
    }
    S3Object s3Object = new S3Object(oid, data);
    s3Service.putObject(masterBucket, s3Object);
    S3Object object =
        s3Service.getObject(masterBucket, s3Object.getKey());
    InputStream dataInputStream = object.getDataInputStream();
    for (int j = 0; j < SMALL_SIZE; j++) {
      int read = dataInputStream.read();
      if (read == -1) fail();
    }
    assertEquals(-1, dataInputStream.read());
    dataInputStream.close();
  }

  // Shutdown the service
  s3Service.shutdown();
  passed = true;
}
 
开发者ID:WANdisco,项目名称:s3hdfs,代码行数:32,代码来源:TestConcurrency.java

示例13: retrieve

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
public InputStream retrieve(String key) throws IOException {
  try {
    S3Object object = s3Service.getObject(bucket, key);
    return object.getDataInputStream();
  } catch (S3ServiceException e) {
    if ("NoSuchKey".equals(e.getS3ErrorCode())) {
      return null;
    }
    if (e.getCause() instanceof IOException) {
      throw (IOException) e.getCause();
    }
    throw new S3Exception(e);
  }
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:15,代码来源:Jets3tNativeFileSystemStore.java

示例14: run

import org.jets3t.service.model.S3Object; //导入方法依赖的package包/类
@Override
public void run() {
	try {
		log.info("Retrieving "
				+ object.getKey()
				+ ", ("
				+ i
				+ "/"
				+ length
				+ ") "
				+ CSVExport.humanReadableByteCount(
						object.getContentLength(), false));

		// now really download the file
		S3Object dataObject = getStorage().getObject(resultBucket,
				object.getKey());

		// data file
		if (object.getKey().endsWith(".nq.gz")) {

			BufferedReader retrievedDataReader = new BufferedReader(
					new InputStreamReader(new GZIPInputStream(
							dataObject.getDataInputStream())));

			String line;
			while ((line = retrievedDataReader.readLine()) != null) {
				Line l = parseLine(line);
				if (l == null) {
					continue;
				}
				OutputStream out = getOutput(l.extractor, dataDir,
						sizeLimitMb);
				out.write(new String(l.quad + "\n").getBytes());
			}
			retrievedDataReader.close();
		}
	} catch (Exception e) {
		log.warn("Error in " + object.getKey(), e);
	} finally {
		setChanged();
		notifyObservers();
	}
}
 
开发者ID:JulianEberius,项目名称:dwtc-extractor,代码行数:44,代码来源:Master.java


注:本文中的org.jets3t.service.model.S3Object.getDataInputStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。