| #!/usr/bin/env python |
| # ----------------------------------------------------------------------- |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| # ----------------------------------------------------------------------- |
| |
| |
| import os |
| import sys |
| import subprocess |
| |
| from ducc_util import DuccUtil |
| |
| class DuccRmQOccupancy(DuccUtil): |
| |
| def format_shares(self, sh): |
| for s in sh: |
| if ( s['blacklisted'] ): |
| pass |
| else: |
| print '%19s J[%8d] S[%8d] O[%d] II[%8d] IR[%8d] E[%5s] P[%5s] F[%5s] I[%5s]' % ('', s['jobid'], s['shareid'], s['order'], s['investment-init'], s['investment-run'], |
| s['evicted'], s['purged'], s['fixed'], s['initialized']) |
| |
| |
| def format_machines(self, lines): |
| |
| print("%20s %11s %6s %6s %15s %10s %5s %6s" % ("Node", "Blacklisted", "Online", "Status", "Nodepool", "Memory", "Order", "Free")) |
| |
| for m in lines: |
| print "%20s %11s %6s %6s %15s %10s %5s %6s" % (m['name'], m['blacklisted'], m['online'], m['status'], m['nodepool'], m['memory'], m['order'], m['shares-free']) |
| if ( len(m['shares']) != 0 ) : |
| self.format_shares(m['shares']) |
| print '' |
| |
| |
| def format(self, lines): |
| qoccupancy = eval(lines) |
| self.format_machines(qoccupancy) |
| |
| |
| def main(self, argv): |
| |
| if ( argv == '-h' or argv == '-?' or argv == '--help' ): |
| print 'rm_qload queries and formats the current state of the RM scheduling tables. It takes no parameters.' |
| sys.exit(1); |
| |
| DUCC_JVM_OPTS = ' -Dducc.deploy.configuration=' + self.DUCC_HOME + "/resources/ducc.properties " |
| DUCC_JVM_OPTS = DUCC_JVM_OPTS + ' -DDUCC_HOME=' + self.DUCC_HOME |
| DUCC_JVM_OPTS = DUCC_JVM_OPTS + ' -Dducc.head=' + self.ducc_properties.get('ducc.head') |
| |
| CMD = [self.java(), DUCC_JVM_OPTS, 'org.apache.uima.ducc.common.main.DuccRmAdmin', '--qoccupancy'] |
| CMD = ' '.join(CMD) |
| lines = '' |
| proc = subprocess.Popen(CMD, bufsize=0, stdout=subprocess.PIPE, shell=True) |
| for line in proc.stdout: |
| lines = lines + line |
| |
| if 'not yet initialized' in lines: |
| print lines |
| return |
| |
| self.format(lines) |
| |
| return |
| |
| if __name__ == "__main__": |
| stopper = DuccRmQOccupancy() |
| stopper.main(sys.argv[1:]) |
| |
| |