Search in sources :

Example 1 with RetryStartFileException

use of org.apache.hadoop.hdfs.server.namenode.RetryStartFileException in project hadoop by apache.

the class DFSOutputStream method newStreamForCreate.

static DFSOutputStream newStreamForCreate(DFSClient dfsClient, String src, FsPermission masked, EnumSet<CreateFlag> flag, boolean createParent, short replication, long blockSize, Progressable progress, DataChecksum checksum, String[] favoredNodes) throws IOException {
    try (TraceScope ignored = dfsClient.newPathTraceScope("newStreamForCreate", src)) {
        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<>(flag), createParent, replication, blockSize, SUPPORTED_CRYPTO_VERSIONS);
                break;
            } catch (RemoteException re) {
                IOException e = re.unwrapRemoteException(AccessControlException.class, DSQuotaExceededException.class, QuotaByStorageTypeExceededException.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;
        if (stat.getErasureCodingPolicy() != null) {
            out = new DFSStripedOutputStream(dfsClient, src, stat, flag, progress, checksum, favoredNodes);
        } else {
            out = new DFSOutputStream(dfsClient, src, stat, flag, progress, checksum, favoredNodes, true);
        }
        out.start();
        return out;
    }
}
Also used : EnumSetWritable(org.apache.hadoop.io.EnumSetWritable) QuotaByStorageTypeExceededException(org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException) FileAlreadyExistsException(org.apache.hadoop.fs.FileAlreadyExistsException) TraceScope(org.apache.htrace.core.TraceScope) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(org.apache.hadoop.security.AccessControlException) SnapshotAccessControlException(org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) MultipleIOException(org.apache.hadoop.io.MultipleIOException) RetryStartFileException(org.apache.hadoop.hdfs.server.namenode.RetryStartFileException) ParentNotDirectoryException(org.apache.hadoop.fs.ParentNotDirectoryException) HdfsFileStatus(org.apache.hadoop.hdfs.protocol.HdfsFileStatus) DSQuotaExceededException(org.apache.hadoop.hdfs.protocol.DSQuotaExceededException) NSQuotaExceededException(org.apache.hadoop.hdfs.protocol.NSQuotaExceededException) SafeModeException(org.apache.hadoop.hdfs.server.namenode.SafeModeException) SnapshotAccessControlException(org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException) RemoteException(org.apache.hadoop.ipc.RemoteException) UnresolvedPathException(org.apache.hadoop.hdfs.protocol.UnresolvedPathException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)1 ParentNotDirectoryException (org.apache.hadoop.fs.ParentNotDirectoryException)1 DSQuotaExceededException (org.apache.hadoop.hdfs.protocol.DSQuotaExceededException)1 HdfsFileStatus (org.apache.hadoop.hdfs.protocol.HdfsFileStatus)1 NSQuotaExceededException (org.apache.hadoop.hdfs.protocol.NSQuotaExceededException)1 QuotaByStorageTypeExceededException (org.apache.hadoop.hdfs.protocol.QuotaByStorageTypeExceededException)1 SnapshotAccessControlException (org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException)1 UnresolvedPathException (org.apache.hadoop.hdfs.protocol.UnresolvedPathException)1 RetryStartFileException (org.apache.hadoop.hdfs.server.namenode.RetryStartFileException)1 SafeModeException (org.apache.hadoop.hdfs.server.namenode.SafeModeException)1 EnumSetWritable (org.apache.hadoop.io.EnumSetWritable)1 MultipleIOException (org.apache.hadoop.io.MultipleIOException)1 RemoteException (org.apache.hadoop.ipc.RemoteException)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 TraceScope (org.apache.htrace.core.TraceScope)1