dragon.globalservices.group

Global Services API for the Group of resources (processes, channels, pools, etc.) primary resource component. Only process groups are supported at this time.

Functions

add_to(identifier, items)

Add existing resources to an existing group.

create(items, policy[, user_name, soft])

Asks Global Services to create a new group of specified resources.

create_add_to(identifier, items, policy)

Create resources and then add them to an existing group.

destroy(identifier)

Asks Global Services to destroy a specified group of resources.

destroy_remove_from(identifier, items)

Remove resources from an existing group and call destroy on them.

get_list()

Asks Global Services for a list of the g_uids of all groups.

kill(identifier[, sig, hide_stderr])

Asks Global Services to send the processes belonging to a specified group a specified signal.

query(identifier)

Asks Global Services for the GroupDescriptor of a specified group of resources.

remove_from(identifier, items)

Remove resources from an existing group.

Exceptions

GroupError

exception GroupError

Bases: Exception

create(items, policy, user_name='', soft=False)

Asks Global Services to create a new group of specified resources.

Parameters:
  • items (list[tuple[int, dragon.infrastructure.messages.Message]]) – list of tuples where each tuple contains a replication factor n and the Dragon create message. Dragon create messages do not have to be of the same primary resources, i.e. ChannelCreate and ProcessCreate messages can be mixed to into groups to represent composite resources.

  • policy (dragon.infrastructure.policy.Policy) – determines the placement of the group resources

  • user_name (str, optional) – Requested user specified reference name, defaults to ‘’

  • soft (bool, optional) – If group already exists with given name, do not create and return descriptor instead, defaults to False

Raises:
Returns:

the descriptor of the group object

Return type:

dragon.infrastructure.group_desc.GroupDescriptor

kill(identifier, sig=Signals.SIGKILL, hide_stderr=False)

Asks Global Services to send the processes belonging to a specified group a specified signal.

Note that this is like the unix ‘kill’ command - the signal given to the process might not necessarily be intended to cause it to terminate. If the group contains members other than processes, such as channels, then this operation has no effect to these members.

Parameters:
  • identifier (str|int) – string indicating group name or integer indicating a g_uid

  • sig (int) – signal to use to kill the process, default=signal.SIGKILL

  • hide_stderr (bool) – whether or not to suppress stderr from the process with the delivery of this signal

Raises:
Returns:

GSGroupKillResponse.desc

destroy(identifier)

Asks Global Services to destroy a specified group of resources. It will destroy all the members of the group as well as the group itself.

Parameters:

identifier (str|int) – string indicating group name or integer indicating a g_uid

Raises:
Returns:

the group descriptor in case of a success

Return type:

dragon.infrastructure.group_desc.GroupDescriptor

add_to(identifier, items)

Add existing resources to an existing group.

Parameters:
  • identifier (str|int) – string indicating group name or integer indicating a g_uid

  • items (List[ids : int|str]) – list of int or str corresponding to resource id or name respectively

Raises:
  • GroupError – if the addition of resources failed

  • GroupError – if the identifier corresponds to an unknown group

create_add_to(identifier, items, policy)

Create resources and then add them to an existing group.

Parameters:
  • identifier (str|int) – string indicating group name or integer indicating a g_uid

  • items (list[tuple[int, dragon.infrastructure.messages.Message]]) – list of tuples where each tuple contains a replication factor n and the Dragon create message. Dragon create messages do not have to be of the same primary resources, i.e. ChannelCreate and ProcessCreate messages can be mixed to into groups to represent composite resources.

  • policy (dragon.infrastructure.policy.Policy) – determines the placement of the group resources

Raises:
  • GroupError – if the addition of resources failed

  • GroupError – if the identifier corresponds to an unknown group

remove_from(identifier, items)

Remove resources from an existing group.

Parameters:
  • identifier (str|int) – string indicating group name or integer indicating a g_uid

  • items (List[ids : int|str]) – list of int or str corresponding to resource id or name respectively

Raises:
  • GroupError – if the addition of resources failed

  • GroupError – if the identifier corresponds to an unknown group

destroy_remove_from(identifier, items)

Remove resources from an existing group and call destroy on them. For processes we call process.kill (sends a SIGKILL signal) and for other types of resources we call destroy.

Parameters:
  • identifier (str|int) – string indicating group name or integer indicating a g_uid

  • items (List[ids : int|str]) – list of int or str corresponding to resource id or name respectively

Raises:
  • GroupError – if the addition of resources failed

  • GroupError – if the identifier corresponds to an unknown group

get_list()

Asks Global Services for a list of the g_uids of all groups.

Returns:

list of the g_uids of all groups, alive and dead

Return type:

list[g_uids]

query(identifier)

Asks Global Services for the GroupDescriptor of a specified group of resources. The group can be alive or dead.

Parameters:

identifier (str|int) – string indicating group name or integer indicating a g_uid

Raises:

GroupError – if there is no such group

Returns:

GroupDescriptor object corresponding to specified group

Return type:

GroupDescriptor