예제 #1
0
        /// <exception cref="Org.Apache.Hadoop.Security.Token.SecretManager.InvalidToken"/>
        private BlockReader GetBlockReaderLocal()
        {
            if (Log.IsTraceEnabled())
            {
                Log.Trace(this + ": trying to construct a BlockReaderLocal " + "for short-circuit reads."
                          );
            }
            if (pathInfo == null)
            {
                pathInfo = clientContext.GetDomainSocketFactory().GetPathInfo(inetSocketAddress,
                                                                              conf);
            }
            if (!pathInfo.GetPathState().GetUsableForShortCircuit())
            {
                PerformanceAdvisory.Log.Debug(this + ": " + pathInfo + " is not " + "usable for short circuit; giving up on BlockReaderLocal."
                                              );
                return(null);
            }
            ShortCircuitCache cache = clientContext.GetShortCircuitCache();
            ExtendedBlockId   key   = new ExtendedBlockId(block.GetBlockId(), block.GetBlockPoolId
                                                              ());
            ShortCircuitReplicaInfo info = cache.FetchOrCreate(key, this);

            SecretManager.InvalidToken exc = info.GetInvalidTokenException();
            if (exc != null)
            {
                if (Log.IsTraceEnabled())
                {
                    Log.Trace(this + ": got InvalidToken exception while trying to " + "construct BlockReaderLocal via "
                              + pathInfo.GetPath());
                }
                throw exc;
            }
            if (info.GetReplica() == null)
            {
                if (Log.IsTraceEnabled())
                {
                    PerformanceAdvisory.Log.Debug(this + ": failed to get " + "ShortCircuitReplica. Cannot construct "
                                                  + "BlockReaderLocal via " + pathInfo.GetPath());
                }
                return(null);
            }
            return(new BlockReaderLocal.Builder(conf).SetFilename(fileName).SetBlock(block).SetStartOffset
                       (startOffset).SetShortCircuitReplica(info.GetReplica()).SetVerifyChecksum(verifyChecksum
                                                                                                 ).SetCachingStrategy(cachingStrategy).SetStorageType(storageType).Build());
        }
 /// <exception cref="Org.Apache.Hadoop.Security.Token.SecretManager.InvalidToken"/>
 public override byte[] RetrievePassword(DelegationTokenIdentifier identifier)
 {
     try
     {
         // this check introduces inconsistency in the authentication to a
         // HA standby NN.  non-token auths are allowed into the namespace which
         // decides whether to throw a StandbyException.  tokens are a bit
         // different in that a standby may be behind and thus not yet know
         // of all tokens issued by the active NN.  the following check does
         // not allow ANY token auth, however it should allow known tokens in
         namesystem.CheckOperation(NameNode.OperationCategory.Read);
     }
     catch (StandbyException se)
     {
         // FIXME: this is a hack to get around changing method signatures by
         // tunneling a non-InvalidToken exception as the cause which the
         // RPC server will unwrap before returning to the client
         SecretManager.InvalidToken wrappedStandby = new SecretManager.InvalidToken("StandbyException"
                                                                                    );
         Sharpen.Extensions.InitCause(wrappedStandby, se);
         throw wrappedStandby;
     }
     return(base.RetrievePassword(identifier));
 }
 public ShortCircuitReplicaInfo(SecretManager.InvalidToken exc)
 {
     this.replica = null;
     this.exc     = exc;
 }
 public ShortCircuitReplicaInfo(ShortCircuitReplica replica)
 {
     this.replica = replica;
     this.exc     = null;
 }
 public ShortCircuitReplicaInfo()
 {
     this.replica = null;
     this.exc     = null;
 }