Search in sources :

Example 11 with StandbyException

use of org.apache.hadoop.ipc.StandbyException in project hadoop by apache.

the class FSNamesystem method appendFile.

/**
   * Append to an existing file in the namespace.
   */
LastBlockWithStatus appendFile(String srcArg, String holder, String clientMachine, EnumSet<CreateFlag> flag, boolean logRetryCache) throws IOException {
    final String operationName = "append";
    boolean newBlock = flag.contains(CreateFlag.NEW_BLOCK);
    if (newBlock) {
        requireEffectiveLayoutVersionForFeature(Feature.APPEND_NEW_BLOCK);
    }
    NameNode.stateChangeLog.debug("DIR* NameSystem.appendFile: src={}, holder={}, clientMachine={}", srcArg, holder, clientMachine);
    try {
        boolean skipSync = false;
        LastBlockWithStatus lbs = null;
        final FSPermissionChecker pc = getPermissionChecker();
        checkOperation(OperationCategory.WRITE);
        writeLock();
        try {
            checkOperation(OperationCategory.WRITE);
            checkNameNodeSafeMode("Cannot append to file" + srcArg);
            lbs = FSDirAppendOp.appendFile(this, srcArg, pc, holder, clientMachine, newBlock, logRetryCache);
        } catch (StandbyException se) {
            skipSync = true;
            throw se;
        } finally {
            writeUnlock(operationName);
            // They need to be sync'ed even when an exception was thrown.
            if (!skipSync) {
                getEditLog().logSync();
            }
        }
        logAuditEvent(true, operationName, srcArg);
        return lbs;
    } catch (AccessControlException e) {
        logAuditEvent(false, operationName, srcArg);
        throw e;
    }
}
Also used : StandbyException(org.apache.hadoop.ipc.StandbyException) LastBlockWithStatus(org.apache.hadoop.hdfs.protocol.LastBlockWithStatus) AccessControlException(org.apache.hadoop.security.AccessControlException) SnapshotAccessControlException(org.apache.hadoop.hdfs.protocol.SnapshotAccessControlException)

Aggregations

StandbyException (org.apache.hadoop.ipc.StandbyException)11 IOException (java.io.IOException)8 Test (org.junit.Test)8 RemoteException (org.apache.hadoop.ipc.RemoteException)6 EOFException (java.io.EOFException)3 FileNotFoundException (java.io.FileNotFoundException)3 Configuration (org.apache.hadoop.conf.Configuration)3 NamenodeProtocols (org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 DataInputStream (java.io.DataInputStream)2 ConnectException (java.net.ConnectException)2 URISyntaxException (java.net.URISyntaxException)2 DelegationTokenIdentifier (org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier)2 MultiException (org.apache.hadoop.io.retry.MultiException)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetSocketAddress (java.net.InetSocketAddress)1 MalformedURLException (java.net.MalformedURLException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1