# Prime resource Vs Non-Prime resource

**URL:** https://community.openpbs.org/t/prime-resource-vs-non-prime-resource/917
**Category:** Users/Site Administrators
**Created:** [March 25, 2018, 8:31am UTC](https://community.openpbs.org/t/prime-resource-vs-non-prime-resource/917 "2018-03-25T08:31:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Source](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/source/32/756_2.png) [@Source](https://community.openpbs.org/u/Source)
#### Post date: [March 25, 2018, 8:31am UTC](https://community.openpbs.org/t/prime-resource-vs-non-prime-resource/917/1 "2018-03-25T08:31:33Z")

</div>

First of all , in order to avoid X-Y problem, I’d like to describe the original purpose  
Say we have node1-node16, and we want to run application (say App-A) on node1-node10, and reserve node11-node16 for App-B for prime time use，yet keep non-prime time for App-A available on node10-node16

For App-B it’s straight forward, just create a p\_ suffixed queue is enough  
but it’s somehow difficulty if we work on App-A  
if we have a boolean resource which can indicate that if we are in prime-time (sure we can use hooks to set this resources, but it’s out of the sched\_config, as we need to manage holiday file and hook configure file)

Any suggestions?

---

<div class="post-metadata">

### Author: ![adarsh](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@adarsh](https://community.openpbs.org/u/adarsh)
#### Post date: [March 26, 2018, 10:20am UTC](https://community.openpbs.org/t/prime-resource-vs-non-prime-resource/917/2 "2018-03-26T10:20:13Z")

</div>

You can use qlist concept to achieve this along with Server Periodic hook

1. qmgr -c “create queue p\_queue queue\_type=e,started=t,enabled=t”
2. qmgr -c “create queue np\_queue queue\_type=e,started=t,enabled=t”

Create custom resource:  
a. qmgr -c “create resource qlist type=string\_array,flag=h”  
b. add qlist to the resources: line of the sched\_config and kill -HUP

for i in {1…10}; do qmgr -c “set node node${1} resources\_available.qlist=applicationA” ; done  
for i in {11…16}; do qmgr -c “set node node${1} resources\_available.qlist=applicationB” ; done

Now set the default chunk of the queues as below:

1. qmgr -c “set queue p\_queue default\_chunk.qlist=applicationA”
2. qmgr -c “set queue np\_queue default\_chunk.qlist=applicationB”

Note the prime time and non-prime time is controlled by the holidays file, any changes to the holiday file requires kill -HUP of the PID of the pbs\_sched process.

Now create a server periodic hook, that will run the below command at non-primetime and prime time **( make sure the below command in the if loops runs once per prime time and non-primetime respectively)**

if time = prime:  
count = 0  
if count == 0:  
for i in {11…16}; do qmgr -c “set node node${1} resources\_available.qlist+=applicationA” ; done  
count=count+1  
else  
count = 0  
if count == 0:  
for i in {11…16}; do qmgr -c “set node node${1} resources\_available.qlist-=applicationA” ; done  
count=count+1

Thank you

---

<div class="post-metadata">

### Author: ![Source](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/source/32/756_2.png) [@Source](https://community.openpbs.org/u/Source)
#### Post date: [March 28, 2018, 8:16pm UTC](https://community.openpbs.org/t/prime-resource-vs-non-prime-resource/917/3 "2018-03-28T20:16:19Z")

</div>

is there any way that a hook can determine itself runs at prime-time or not ?

---

<div class="post-metadata">

### Author: ![adarsh](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@adarsh](https://community.openpbs.org/u/adarsh)
#### Post date: [March 28, 2018, 8:36pm UTC](https://community.openpbs.org/t/prime-resource-vs-non-prime-resource/917/4 "2018-03-28T20:36:59Z")

</div>

Hooks are job event based and the below are the non-job hooks (that are not directly related to a specific job )

1. server periodic hook
2. exechost\_periodic hook.
3. exechost\_startup hook
4. reservsub hook
5. provision hook

We can decide to run a job in prime time or not.

Within a hook , we can program it to void if the current time is non-prime or prime base on that reject and accept the job (at every job event). This would not be an ideal solution, I think.

In the above explanation, server periodic hook (non-job event hook) is used to check the time at regular intervals ( frequency) , based on whether it is prime or non-prime, it will update the node attributes. The above mentioned configuration would 100% work.

Thank you
