All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.fs.CosNCopyFileTask Maven / Gradle / Ivy

Go to download

This module contains code to support integration with Tencent Cloud COS. It also declares the dependencies needed to work with COS.

There is a newer version: 8.2.7
Show newest version
package org.apache.hadoop.fs;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

public class CosNCopyFileTask implements Runnable {
    private static final Logger LOG = LoggerFactory.getLogger(CosNCopyFileTask.class);

    private final NativeFileSystemStore store;

    private final String srcKey;
    private final String dstKey;
    private final CosNCopyFileContext cosCopyFileContext;

    public CosNCopyFileTask(NativeFileSystemStore store, String srcKey,
                            String dstKey,
                            CosNCopyFileContext cosCopyFileContext) {
        this.store = store;
        this.srcKey = srcKey;
        this.dstKey = dstKey;
        this.cosCopyFileContext = cosCopyFileContext;
    }

    @Override
    public void run() {
        boolean fail = false;
        try {
            this.store.copy(srcKey, dstKey);
        } catch (IOException e) {
            LOG.warn("Exception thrown when copy from {} to {}, exception:{}",
                    this.srcKey, this.dstKey, e);
            fail = true;
        } finally {
            this.cosCopyFileContext.lock();
            if (fail) {
                cosCopyFileContext.setCopySuccess(false);
            }
            cosCopyFileContext.incCopiesFinish();
            cosCopyFileContext.signalAll();
            cosCopyFileContext.unlock();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy