# simple_cluster module

Copyright (c) 2017 beyond-blockchain.org.

Licensed 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.

`NetworkDomain`([network, config, domain_id, …]) | Compose a simple core node cluster

class `simple_cluster.``NetworkDomain`(network=None, config=None, domain_id=None, node_id=None, loglevel='all', logname=None)

  Bases: `bbc1.core.bbc_network.DomainBase`

  Compose a simple core node cluster

  `add_peer_node`(node_id, ip4, addr_info)

    (internal use) add node as a peer node

    Parameters: | node_id – ip4 – addr_info –
    Returns: |

  `advertise_domain_info`()
  `alive_check`()
  `domain_manager_loop`()

    maintain domain (e.g., updating peer list and topology)

    Returns: |

  `get_neighbor_nodes`()

    Return neighbor nodes (for broadcasting message)

    Returns: |

  `get_resource`(query_entry)
  `print_peerlist`()

    Print peer list

    Returns: |

  `process_REQUEST_FIND_VALUE`(msg)
  `process_REQUEST_STORE`(msg)
  `process_RESPONSE_FIND_VALUE`(msg)
  `process_message`(ip4, from_addr, msg)

    process received message

    Parameters: | ip4 – True (from IPv4) / False (from IPv6) from_addr – sender address and port (None if TCP) msg – the message body (already deserialized)
    Returns: |

  `purge_by_LRU`()

    (internal use) purge cache entry by Least Recently Used algorithm

    Returns: |

  `put_resource`(resource_id, resource_type, resource, asset_group_id)
  `random_send`(msg, count)

    (internal use) send data to randomly selected nodes

    Parameters: | msg – count – number of nodes to send
    Returns: |

  `resend_resource`(query_entry)
  `resolve_accommodating_core_node`(query_entry)

    Resolve which node the user connects to

    Parameters: | query_entry –
    Returns: |

  `respond_find_node`(target_id, nonce, resource_id=None)
  `respond_find_value`(target_id, nonce, asset_group_id=None, resource_id=None, resource=None, resource_type=None)
  `send_find_value`(target_id, nonce, resource_id, resource_type, extra_info={})
  `send_p2p_message`(query_entry)

    Send a message to another node

    Parameters: | query_entry –
    Returns: |

  `send_peerlist`(query_entry)