Get the peers relation id if a peers relation has been joined, else None.
195523
def peer_relation_id():
    ''''''
    md = metadata()
    section = md.get('peers')
    if section:
        for key in section:
            relids = relation_ids(key)
            if relids:
                return relids[0]
    return None
469621
def id_getter(self, relation_name, strict=False):
    """"""
    def get_id(old_id):
      """Get the new ID for the enclosed relation, given an old ID."""
      return self.get_new_id(relation_name, old_id, strict)
    return get_id
65488
def selectPeerToIntroduce(self, otherPeers):
        
        for peer in otherPeers:
            if peer not in self.otherPeers:
                self.otherPeers.append(peer)
                return peer
628020
async def RelationById(self, relation_ids):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Uniter',
                   request='RelationById',
                   version=5,
                   params=_params)
        _params['relation-ids'] = relation_ids
        reply = await self.rpc(msg)
        return reply
229575
def get_relation_cnt(self):
        """"""
        ctr = cx.Counter()
        for ntgpad in self.associations:
            if ntgpad.Extension is not None:
                ctr += ntgpad.Extension.get_relations_cnt()
        return ctr
585453
def neighbors(self, node_id):
        """"""
        node = self.get_node(node_id)
        flattened_nodes_list = []
        for a, b in [self.get_edge(edge_id)['vertices'] for edge_id in node['edges']]:
            flattened_nodes_list.append(a)
            flattened_nodes_list.append(b)
        node_set = set(flattened_nodes_list)
        if node_id in node_set:
            node_set.remove(node_id)
        return [nid for nid in node_set]
487537
def next_id
      if @file_lock
        dbname = ODBA.storage.instance_variable_get('@dbi').dbi_args.first.split(/:/).last
        id = new_id(dbname, ODBA.storage)
      else
        id = ODBA.storage.next_id
      end
      @peers.each do |peer|
        peer.reserve_next_id id rescue DRb::DRbError
      end
      id
    rescue OdbaDuplicateIdError
      retry
    end
223278
def neighbors(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/server/neighbors', params, 'GET')
48369
protected CSRelatedNodeWrapper findExistingRelatedNode(final Relationship relationship,
            final List<CSRelatedNodeWrapper> topicRelatedNodes) {
        if (topicRelatedNodes != null) {
            // Loop over the current nodes and see if any match
            for (final CSRelatedNodeWrapper relatedNode : topicRelatedNodes) {
                if (relationship instanceof TargetRelationship) {
                    if (doesRelationshipMatch((TargetRelationship) relationship, relatedNode)) {
                        return relatedNode;
                    }
                } else {
                    if (doesRelationshipMatch((TopicRelationship) relationship, relatedNode)) {
                        return relatedNode;
                    }
                }
            }
        }

        return null;
    }
1039694
def get_sync_info(self, name, key=None):
        """"""
        peer_target = self.peer
        if self.is_local():
            info = self.cur_dir_meta.dir["peer_sync"].get(peer_target.get_id())
        else:
            info = peer_target.cur_dir_meta.dir["peer_sync"].get(self.get_id())
        if name is not None:
            info = info.get(name) if info else None
        if info and key:
            info = info.get(key)
        return info
631222
private RelationType getRelationType(int index)
   {
      if (index < 0 || index > RELATION_TYPES.length)
      {
         index = 0;
      }

      return RELATION_TYPES[index];
   }
1159685
def RemoveConnectedPeer(self, peer):
        
        if peer in self.Peers:
            self.Peers.remove(peer)
1356933
function notify () {
    const newId = options.peerId
    const peerIds = Object.keys(peerTable)
    // check for all the peers
    // if same id skip
    // if notify === false skip
    // check the first finger that matches the criteria for ideal or next to ideal
    peerIds.forEach((peerId) => {
      if (newId === peerId) {
        return // skip ourselves
      }
      if (!peerTable[peerId].notify) {
        return // skip if it doesn't want to be notified of available peers
      }

      // if it had none, notify to get a successor
      if (peerTable[peerId].fingers['0'].current === undefined) {
        peerTable[peerId].fingers['0'].current = newId
        peerTable[peerId].socket.emit('we-update-finger', {
          row: '0',
          id: newId
        })
        return
      }

      const rows = Object.keys(peerTable[peerId].fingers)
      // find the first row that could use this finger
      rows.some((row) => {
        const finger = peerTable[peerId].fingers[row]
        const bestCandidate = fingerBestFit(
            new Id(peerId),
            new Id(finger.ideal),
            new Id(finger.current),
            new Id(newId))
        if (bestCandidate) {
          peerTable[peerId].fingers[row].current = newId
          peerTable[peerId].socket.emit('we-update-finger', {
            row: row,
            id: newId
          })
          return true
        }
      })
    })
  }
690725
def relation_ids(self):
        
        if self.scope == scopes.GLOBAL:
            # the namespace is the relation name and this conv speaks for all
            # connected instances of that relation
            return hookenv.relation_ids(self.namespace)
        else:
            # the namespace is the relation ID
            return [self.namespace]
60903
def _get_next_id(self):
        """"""
        if self.sensors:
            next_id = max(self.sensors.keys()) + 1
        else:
            next_id = 1
        if next_id <= self.const.MAX_NODE_ID:
            return next_id
        return None
1022111
def relation_operation(self):
        
        if len(self.nodes) > 0:
            rel_op = self.nodes[-1].relation_operation
        else:
            rel_op = None
        return rel_op
1011803
public List<Relation> getRelations(Collection<Long> relationIds)
	{
		if(relationIds.isEmpty()) return Collections.emptyList();
		return getSomeElements(RELATION + "s?" + RELATION + "s=" + toCommaList(relationIds), Relation.class);
	}