public CommonNodeLabelsManager()
            : base(typeof(CommonNodeLabelsManager).FullName)
        {
            ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

            readLock  = Lock.ReadLock();
            writeLock = Lock.WriteLock();
        }
Exemplo n.º 2
0
        public QueueCapacities(bool isRoot)
        {
            ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

            readLock      = Lock.ReadLock();
            writeLock     = Lock.WriteLock();
            capacitiesMap = new Dictionary <string, QueueCapacities.Capacities>();
            this.isRoot   = isRoot;
        }
Exemplo n.º 3
0
            public StatefulContainer(NMClientAsync client, ContainerId containerId)
            {
                this.nmClientAsync = client;
                this.containerId   = containerId;
                stateMachine       = stateMachineFactory.Make(this);
                ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

                readLock  = Lock.ReadLock();
                writeLock = Lock.WriteLock();
            }
Exemplo n.º 4
0
        public ResourceUsage()
        {
            // short for no-label :)
            ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

            readLock   = Lock.ReadLock();
            writeLock  = Lock.WriteLock();
            usages     = new Dictionary <string, ResourceUsage.UsageByLabel>();
            usages[Nl] = new ResourceUsage.UsageByLabel(Nl);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The constructor takes a
        /// <see cref="Org.Apache.Hadoop.Crypto.Key.KeyProviderCryptoExtension"/>
        /// and an
        /// implementation of <code>KeyACLs</code>. All calls are delegated to the
        /// provider keyProvider after authorization check (if required)
        /// </summary>
        /// <param name="keyProvider"></param>
        /// <param name="acls"/>
        public KeyAuthorizationKeyProvider(KeyProviderCryptoExtension keyProvider, KeyAuthorizationKeyProvider.KeyACLs
                                           acls)
            : base(keyProvider, null)
        {
            this.provider = keyProvider;
            this.acls     = acls;
            ReadWriteLock Lock = new ReentrantReadWriteLock(true);

            readLock  = Lock.ReadLock();
            writeLock = Lock.WriteLock();
        }
Exemplo n.º 6
0
        public RMAppAttemptMetrics(ApplicationAttemptId attemptId, RMContext rmContext)
        {
            // preemption info
            // application headroom
            //HM: Line below replaced by one above for issue wih array 2nd dim
            //new int[NodeType.values().length][NodeType.values().length];
            this.attemptId = attemptId;
            ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

            this.readLock  = Lock.ReadLock();
            this.writeLock = Lock.WriteLock();
            this.rmContext = rmContext;
        }
Exemplo n.º 7
0
        /// <summary>Construct the service.</summary>
        /// <param name="name">service name</param>
        public AbstractYarnScheduler(string name)
            : base(name)
        {
            // Nodes in the cluster, indexed by NodeId
            // Whole capacity of the cluster

            /*
             * All schedulers which are inheriting AbstractYarnScheduler should use
             * concurrent version of 'applications' map.
             */
            ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

            this.maxAllocReadLock  = Lock.ReadLock();
            this.maxAllocWriteLock = Lock.WriteLock();
        }
Exemplo n.º 8
0
        public ApplicationImpl(Dispatcher dispatcher, string user, ApplicationId appId, Credentials
                               credentials, Context context)
        {
            this.dispatcher  = dispatcher;
            this.user        = user;
            this.appId       = appId;
            this.credentials = credentials;
            this.aclsManager = context.GetApplicationACLsManager();
            this.context     = context;
            ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

            readLock     = Lock.ReadLock();
            writeLock    = Lock.WriteLock();
            stateMachine = stateMachineFactory.Make(this);
        }
Exemplo n.º 9
0
        public LocalizedResource(LocalResourceRequest rsrc, Dispatcher dispatcher)
        {
            timestamp = new AtomicLong(CurrentTime());
            // Queue of containers using this localized
            // resource
            // From INIT (ref == 0, awaiting req)
            // From DOWNLOADING (ref > 0, may be localizing)
            // TODO: Duplicate addition!!
            // From LOCALIZED (ref >= 0, on disk)
            this.rsrc       = rsrc;
            this.dispatcher = dispatcher;
            this.@ref       = new List <ContainerId>();
            ReadWriteLock readWriteLock = new ReentrantReadWriteLock();

            this.readLock     = readWriteLock.ReadLock();
            this.writeLock    = readWriteLock.WriteLock();
            this.stateMachine = stateMachineFactory.Make(this);
        }
Exemplo n.º 10
0
        public RMContainerImpl(Container container, ApplicationAttemptId appAttemptId, NodeId
                               nodeId, string user, RMContext rmContext, long creationTime)
        {
            // Transitions from NEW state
            // Transitions from RESERVED state
            // nothing to do
            // nothing to do
            // Transitions from ALLOCATED state
            // Transitions from ACQUIRED state
            // Transitions from RUNNING state
            // Transitions from COMPLETED state
            // Transitions from EXPIRED state
            // Transitions from RELEASED state
            // Transitions from KILLED state
            // create the topology tables
            this.stateMachine = stateMachineFactory.Make(this);
            this.containerId  = container.GetId();
            this.nodeId       = nodeId;
            this.container    = container;
            this.appAttemptId = appAttemptId;
            this.user         = user;
            this.creationTime = creationTime;
            this.rmContext    = rmContext;
            this.eventHandler = rmContext.GetDispatcher().GetEventHandler();
            this.containerAllocationExpirer = rmContext.GetContainerAllocationExpirer();
            this.isAMContainer    = false;
            this.resourceRequests = null;
            ReentrantReadWriteLock Lock = new ReentrantReadWriteLock();

            this.readLock              = Lock.ReadLock();
            this.writeLock             = Lock.WriteLock();
            saveNonAMContainerMetaInfo = rmContext.GetYarnConfiguration().GetBoolean(YarnConfiguration
                                                                                     .ApplicationHistorySaveNonAmContainerMetaInfo, YarnConfiguration.DefaultApplicationHistorySaveNonAmContainerMetaInfo
                                                                                     );
            rmContext.GetRMApplicationHistoryWriter().ContainerStarted(this);
            // If saveNonAMContainerMetaInfo is true, store system metrics for all
            // containers. If false, and if this container is marked as the AM, metrics
            // will still be published for this container, but that calculation happens
            // later.
            if (saveNonAMContainerMetaInfo)
            {
                rmContext.GetSystemMetricsPublisher().ContainerCreated(this, this.creationTime);
            }
        }
Exemplo n.º 11
0
        /// <exception cref="System.IO.IOException"/>
        private JavaKeyStoreProvider(URI uri, Configuration conf)
            : base(conf)
        {
            this.uri = uri;
            path     = ProviderUtils.UnnestUri(uri);
            fs       = path.GetFileSystem(conf);
            // Get the password file from the conf, if not present from the user's
            // environment var
            if (Runtime.GetEnv().Contains(KeystorePasswordEnvVar))
            {
                password = Runtime.Getenv(KeystorePasswordEnvVar).ToCharArray();
            }
            if (password == null)
            {
                string pwFile = conf.Get(KeystorePasswordFileKey);
                if (pwFile != null)
                {
                    ClassLoader cl      = Thread.CurrentThread().GetContextClassLoader();
                    Uri         pwdFile = cl.GetResource(pwFile);
                    if (pwdFile == null)
                    {
                        // Provided Password file does not exist
                        throw new IOException("Password file does not exists");
                    }
                    using (InputStream @is = pwdFile.OpenStream())
                    {
                        password = IOUtils.ToString(@is).Trim().ToCharArray();
                    }
                }
            }
            if (password == null)
            {
                password = KeystorePasswordDefault;
            }
            try
            {
                Path oldPath = ConstructOldPath(path);
                Path newPath = ConstructNewPath(path);
                keyStore = KeyStore.GetInstance(SchemeName);
                FsPermission perm = null;
                if (fs.Exists(path))
                {
                    // flush did not proceed to completion
                    // _NEW should not exist
                    if (fs.Exists(newPath))
                    {
                        throw new IOException(string.Format("Keystore not loaded due to some inconsistency "
                                                            + "('%s' and '%s' should not exist together)!!", path, newPath));
                    }
                    perm = TryLoadFromPath(path, oldPath);
                }
                else
                {
                    perm = TryLoadIncompleteFlush(oldPath, newPath);
                }
                // Need to save off permissions in case we need to
                // rewrite the keystore in flush()
                permissions = perm;
            }
            catch (KeyStoreException e)
            {
                throw new IOException("Can't create keystore", e);
            }
            catch (NoSuchAlgorithmException e)
            {
                throw new IOException("Can't load keystore " + path, e);
            }
            catch (CertificateException e)
            {
                throw new IOException("Can't load keystore " + path, e);
            }
            ReadWriteLock Lock = new ReentrantReadWriteLock(true);

            readLock  = Lock.ReadLock();
            writeLock = Lock.WriteLock();
        }
        /// <exception cref="System.IO.IOException"/>
        protected internal AbstractJavaKeyStoreProvider(URI uri, Configuration conf)
        {
            this.uri = uri;
            InitFileSystem(uri, conf);
            // Get the password from the user's environment
            if (Runtime.GetEnv().Contains(CredentialPasswordName))
            {
                password = Runtime.Getenv(CredentialPasswordName).ToCharArray();
            }
            // if not in ENV get check for file
            if (password == null)
            {
                string pwFile = conf.Get(KeystorePasswordFileKey);
                if (pwFile != null)
                {
                    ClassLoader cl      = Thread.CurrentThread().GetContextClassLoader();
                    Uri         pwdFile = cl.GetResource(pwFile);
                    if (pwdFile != null)
                    {
                        using (InputStream @is = pwdFile.OpenStream())
                        {
                            password = IOUtils.ToString(@is).Trim().ToCharArray();
                        }
                    }
                }
            }
            if (password == null)
            {
                password = KeystorePasswordDefault.ToCharArray();
            }
            try
            {
                keyStore = KeyStore.GetInstance("jceks");
                if (KeystoreExists())
                {
                    StashOriginalFilePermissions();
                    using (InputStream @in = GetInputStreamForFile())
                    {
                        keyStore.Load(@in, password);
                    }
                }
                else
                {
                    CreatePermissions("700");
                    // required to create an empty keystore. *sigh*
                    keyStore.Load(null, password);
                }
            }
            catch (KeyStoreException e)
            {
                throw new IOException("Can't create keystore", e);
            }
            catch (NoSuchAlgorithmException e)
            {
                throw new IOException("Can't load keystore " + GetPathAsString(), e);
            }
            catch (CertificateException e)
            {
                throw new IOException("Can't load keystore " + GetPathAsString(), e);
            }
            ReadWriteLock Lock = new ReentrantReadWriteLock(true);

            readLock  = Lock.ReadLock();
            writeLock = Lock.WriteLock();
        }
Exemplo n.º 13
0
 public virtual Lock ReadLock()
 {
     return(coarseLock.ReadLock());
 }