Example usage for org.apache.hadoop.io EnumSetWritable EnumSetWritable

List of usage examples for org.apache.hadoop.io EnumSetWritable EnumSetWritable

Introduction

In this page you can find the example usage for org.apache.hadoop.io EnumSetWritable EnumSetWritable.

Prototype

public EnumSetWritable(EnumSet<E> value) 

Source Link

Document

Construct a new EnumSetWritable.

Usage

From source file:com.mellanox.r4h.DFSOutputStream.java

License:Apache License

static DFSOutputStream newStreamForCreate(DFSClient dfsClient, String src, FsPermission masked,
        EnumSet<CreateFlag> flag, boolean createParent, short replication, long blockSize,
        Progressable progress, int buffersize, DataChecksum checksum, String[] favoredNodes)
        throws IOException {
    TraceScope scope = dfsClient.getPathTraceScope("newStreamForCreate", src);
    try {//w w  w. ja va 2  s.  com
        HdfsFileStatus stat = null;

        // Retry the create if we get a RetryStartFileException up to a maximum
        // number of times
        boolean shouldRetry = true;
        int retryCount = CREATE_RETRY_COUNT;
        while (shouldRetry) {
            shouldRetry = false;
            try {
                stat = dfsClient.namenode.create(src, masked, dfsClient.clientName,
                        new EnumSetWritable<CreateFlag>(flag), createParent, replication, blockSize,
                        SUPPORTED_CRYPTO_VERSIONS);
                break;
            } catch (RemoteException re) {
                IOException e = re.unwrapRemoteException(AccessControlException.class,
                        DSQuotaExceededException.class, FileAlreadyExistsException.class,
                        FileNotFoundException.class, ParentNotDirectoryException.class,
                        NSQuotaExceededException.class, RetryStartFileException.class, SafeModeException.class,
                        UnresolvedPathException.class, SnapshotAccessControlException.class,
                        UnknownCryptoProtocolVersionException.class);
                if (e instanceof RetryStartFileException) {
                    if (retryCount > 0) {
                        shouldRetry = true;
                        retryCount--;
                    } else {
                        throw new IOException("Too many retries because of encryption" + " zone operations", e);
                    }
                } else {
                    throw e;
                }
            }
        }
        Preconditions.checkNotNull(stat, "HdfsFileStatus should not be null!");
        final DFSOutputStream out = new DFSOutputStream(dfsClient, src, stat, flag, progress, checksum,
                favoredNodes);
        out.start();
        return out;
    } finally {
        scope.close();
    }
}