Search in sources :

Example 1 with ExportStats

use of com.amazonaws.services.neptune.propertygraph.ExportStats in project amazon-neptune-tools by awslabs.

the class ExportToS3NeptuneExportEventHandler method onExportComplete.

@Override
public void onExportComplete(Directories directories, ExportStats stats, Cluster cluster, GraphSchema graphSchema) throws Exception {
    try {
        long size = Files.walk(directories.rootDirectory()).mapToLong(p -> p.toFile().length()).sum();
        logger.info("Total size of exported files: {}", FileUtils.byteCountToDisplaySize(size));
    } catch (Exception e) {
    // Ignore
    }
    if (StringUtils.isEmpty(outputS3Path)) {
        return;
    }
    logger.info("S3 upload params: {}", s3UploadParams);
    try (TransferManagerWrapper transferManager = new TransferManagerWrapper(s3Region)) {
        File outputDirectory = directories.rootDirectory().toFile();
        S3ObjectInfo outputS3ObjectInfo = calculateOutputS3Path(outputDirectory);
        Timer.timedActivity("uploading files to S3", (CheckedActivity.Runnable) () -> {
            deleteS3Directories(directories, outputS3ObjectInfo);
            uploadExportFilesToS3(transferManager.get(), outputDirectory, outputS3ObjectInfo);
            uploadCompletionFileToS3(transferManager.get(), outputDirectory, outputS3ObjectInfo, stats, graphSchema);
        });
        result.set(outputS3ObjectInfo);
    }
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Cluster(com.amazonaws.services.neptune.cluster.Cluster) S3ObjectInfo(com.amazonaws.services.neptune.util.S3ObjectInfo) LoggerFactory(org.slf4j.LoggerFactory) Directories(com.amazonaws.services.neptune.io.Directories) Timer(com.amazonaws.services.neptune.util.Timer) AtomicReference(java.util.concurrent.atomic.AtomicReference) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProgressEvent(com.amazonaws.event.ProgressEvent) ArrayList(java.util.ArrayList) ProgressListener(com.amazonaws.event.ProgressListener) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) TransferManagerWrapper(com.amazonaws.services.neptune.util.TransferManagerWrapper) com.amazonaws.services.s3.transfer(com.amazonaws.services.s3.transfer) ObjectTagging(com.amazonaws.services.s3.model.ObjectTagging) Path(java.nio.file.Path) ExportStats(com.amazonaws.services.neptune.propertygraph.ExportStats) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Collection(java.util.Collection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) FileUtils(org.apache.commons.io.FileUtils) Tag(com.amazonaws.services.s3.model.Tag) UUID(java.util.UUID) PutObjectRequest(com.amazonaws.services.s3.model.PutObjectRequest) GraphSchema(com.amazonaws.services.neptune.propertygraph.schema.GraphSchema) List(java.util.List) java.io(java.io) NEPTUNE_EXPORT_TAGS(com.amazonaws.services.neptune.export.NeptuneExportService.NEPTUNE_EXPORT_TAGS) Paths(java.nio.file.Paths) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory) AmazonClientException(com.amazonaws.AmazonClientException) FilenameUtils(org.apache.commons.io.FilenameUtils) CheckedActivity(com.amazonaws.services.neptune.util.CheckedActivity) S3ObjectInfo(com.amazonaws.services.neptune.util.S3ObjectInfo) TransferManagerWrapper(com.amazonaws.services.neptune.util.TransferManagerWrapper) CheckedActivity(com.amazonaws.services.neptune.util.CheckedActivity) AmazonClientException(com.amazonaws.AmazonClientException)

Aggregations

AmazonClientException (com.amazonaws.AmazonClientException)1 ProgressEvent (com.amazonaws.event.ProgressEvent)1 ProgressListener (com.amazonaws.event.ProgressListener)1 Cluster (com.amazonaws.services.neptune.cluster.Cluster)1 NEPTUNE_EXPORT_TAGS (com.amazonaws.services.neptune.export.NeptuneExportService.NEPTUNE_EXPORT_TAGS)1 Directories (com.amazonaws.services.neptune.io.Directories)1 ExportStats (com.amazonaws.services.neptune.propertygraph.ExportStats)1 GraphSchema (com.amazonaws.services.neptune.propertygraph.schema.GraphSchema)1 CheckedActivity (com.amazonaws.services.neptune.util.CheckedActivity)1 S3ObjectInfo (com.amazonaws.services.neptune.util.S3ObjectInfo)1 Timer (com.amazonaws.services.neptune.util.Timer)1 TransferManagerWrapper (com.amazonaws.services.neptune.util.TransferManagerWrapper)1 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)1 ObjectTagging (com.amazonaws.services.s3.model.ObjectTagging)1 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)1 Tag (com.amazonaws.services.s3.model.Tag)1 com.amazonaws.services.s3.transfer (com.amazonaws.services.s3.transfer)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)1