Example #1
0
def update_restrictions():
    # Create an internal handler function, takes a resource line and returns the new number of threads
    def _internal_func(lineContents):
        try:
            threads = float(lineContents[2])
            threads = threads * EVENT_SCALAR
            threads = int(threads)
            threads = max(threads, HARD_MIN)  # Set a hard minimum
            return threads
        except:
            # On failure, return the minimum
            return HARD_MIN

    # Create a task that uses our internal function
    task = ("resource", "events", _internal_func, True)
    taskList = [task]

    # Process all the resource files
    errors = nmrestrictionsprocessor.process_all_files(taskList)

    # Log any errors we encounter
    if errors != []:
        for e in errors:
            print e
            servicelogger.log(
                "[ERROR]:Unable to patch events limit in resource file " + e[0] + ", exception " + str(e[1])
            )
Example #2
0
def update_restrictions():
    # Create an internal handler function, takes a resource line and returns the new number of threads
    def _internal_func(lineContents):
        try:
            threads = float(lineContents[2])
            threads = threads * EVENT_SCALAR
            threads = int(threads)
            threads = max(threads, HARD_MIN)  # Set a hard minimum
            return threads
        except:
            # On failure, return the minimum
            return HARD_MIN

    # Create a task that uses our internal function
    task = ("resource", "events", _internal_func, True)
    taskList = [task]

    # Process all the resource files
    errors = nmrestrictionsprocessor.process_all_files(taskList)

    # Log any errors we encounter
    if errors != []:
        for e in errors:
            print e
            servicelogger.log(
                "[ERROR]:Unable to patch events limit in resource file " +
                e[0] + ", exception " + str(e[1]))
Example #3
0
            threads = int(float(lineContents[2]))
            _allocatedThreads += threads
            return lineContents[2]
        except Exception, e:
            # On failure, return the initial value
            return lineContents[2]

    # Reset the thread count
    _allocatedThreads = 0

    # Create a task that uses our internal function, which will tally up the allocated threads
    task = ("resource", "events", _internal_func, True)
    taskList = [task]

    # Process all the resource files
    errors = nmrestrictionsprocessor.process_all_files(taskList)

    return _allocatedThreads


def handle_threading_error(nmAPI):
    """
  <Purpose>
    Handles a repy node failing with ThreadErr. Reduces global thread count by 50%.
    Restarts all existing vesselts

  <Arguments>
    nmAPI: the nmAPI module -- passed to the function to avoid import loops;
           see ticket #590 for more information about this.
  """
    # Make a log of this
Example #4
0
            threads = int(float(lineContents[2]))
            _allocatedThreads += threads
            return lineContents[2]
        except Exception, e:
            # On failure, return the initial value
            return lineContents[2]

    # Reset the thread count
    _allocatedThreads = 0

    # Create a task that uses our internal function, which will tally up the allocated threads
    task = ("resource", "events", _internal_func, True)
    taskList = [task]

    # Process all the resource files
    errors = nmrestrictionsprocessor.process_all_files(taskList)

    return _allocatedThreads


def handle_threading_error(nmAPI):
    """
  <Purpose>
    Handles a repy node failing with ThreadErr. Reduces global thread count by 50%.
    Restarts all existing vesselts

  <Arguments>
    nmAPI: the nmAPI module -- passed to the function to avoid import loops;
           see ticket #590 for more information about this.
  """
    # Make a log of this