Пример #1
0
        protected internal virtual ContainerTokenIdentifier WaitForContainerTokenToExpire
            (ContainerTokenIdentifier identifier)
        {
            int attempts = 5;

            while (Runtime.CurrentTimeMillis() < identifier.GetExpiryTimeStamp() && attempts--
                   > 0)
            {
                try
                {
                    Sharpen.Thread.Sleep(1000);
                }
                catch (Exception)
                {
                }
            }
            return(identifier);
        }
Пример #2
0
 /// <summary>
 /// Container will be remembered based on expiration time of the container
 /// token used for starting the container.
 /// </summary>
 /// <remarks>
 /// Container will be remembered based on expiration time of the container
 /// token used for starting the container. It is safe to use expiration time
 /// as there is one to many mapping between expiration time and containerId.
 /// </remarks>
 /// <returns>true if the current token identifier is not present in cache.</returns>
 public virtual bool IsValidStartContainerRequest(ContainerTokenIdentifier containerTokenIdentifier
                                                  )
 {
     lock (this)
     {
         RemoveAnyContainerTokenIfExpired();
         long expTime = containerTokenIdentifier.GetExpiryTimeStamp();
         IList <ContainerId> containers = this.recentlyStartedContainerTracker[expTime];
         if (containers == null || !containers.Contains(containerTokenIdentifier.GetContainerID
                                                            ()))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
        public ContainerTokenIdentifierForTest(ContainerTokenIdentifier identifier, string
                                               message)
        {
            YarnSecurityTestTokenProtos.ContainerTokenIdentifierForTestProto.Builder builder =
                YarnSecurityTestTokenProtos.ContainerTokenIdentifierForTestProto.NewBuilder();
            ContainerIdPBImpl containerID = (ContainerIdPBImpl)identifier.GetContainerID();

            if (containerID != null)
            {
                builder.SetContainerId(containerID.GetProto());
            }
            builder.SetNmHostAddr(identifier.GetNmHostAddress());
            builder.SetAppSubmitter(identifier.GetApplicationSubmitter());
            ResourcePBImpl resource = (ResourcePBImpl)identifier.GetResource();

            if (resource != null)
            {
                builder.SetResource(resource.GetProto());
            }
            builder.SetExpiryTimeStamp(identifier.GetExpiryTimeStamp());
            builder.SetMasterKeyId(identifier.GetMasterKeyId());
            builder.SetRmIdentifier(identifier.GetRMIdentifier());
            PriorityPBImpl priority = (PriorityPBImpl)identifier.GetPriority();

            if (priority != null)
            {
                builder.SetPriority(priority.GetProto());
            }
            builder.SetCreationTime(identifier.GetCreationTime());
            builder.SetMessage(message);
            LogAggregationContextPBImpl logAggregationContext = (LogAggregationContextPBImpl)
                                                                identifier.GetLogAggregationContext();

            if (logAggregationContext != null)
            {
                builder.SetLogAggregationContext(logAggregationContext.GetProto());
            }
            proto = ((YarnSecurityTestTokenProtos.ContainerTokenIdentifierForTestProto)builder
                     .Build());
        }
Пример #4
0
 /// <summary>Container start has gone through.</summary>
 /// <remarks>
 /// Container start has gone through. We need to store the containerId in order
 /// to block future container start requests with same container token. This
 /// container token needs to be saved till its container token expires.
 /// </remarks>
 public virtual void StartContainerSuccessful(ContainerTokenIdentifier tokenId)
 {
     lock (this)
     {
         RemoveAnyContainerTokenIfExpired();
         ContainerId containerId = tokenId.GetContainerID();
         long        expTime     = tokenId.GetExpiryTimeStamp();
         // We might have multiple containers with same expiration time.
         if (!recentlyStartedContainerTracker.Contains(expTime))
         {
             recentlyStartedContainerTracker[expTime] = new AList <ContainerId>();
         }
         recentlyStartedContainerTracker[expTime].AddItem(containerId);
         try
         {
             stateStore.StoreContainerToken(containerId, expTime);
         }
         catch (IOException e)
         {
             Log.Error("Unable to store token for container " + containerId, e);
         }
     }
 }