Associate Kademlia IDs with their endpoints. `localId` must be the ID of the local node, more close contacts are effectively stored than far contacts.
778456
function (localId, bucketSize) {
    if (!(localId instanceof Id))
        throw new Error('id must be a valid identifier');
    this._bucketSize = bucketSize;
    this._root = new Bucket(bucketSize);
    Object.defineProperty(this, 'id', {value: localId});
}
419885
def resolve_name_with_call_id(caller_id, ns, name, remappings)
      name = canonicalize_name(expand_local_name(caller_id, name))
      if remappings
        remappings.each_pair do |key, value|
          if name == canonicalize_name(key)
            name = value
          end
        end
      end
      if ns
        name = ns + SEP + name
      end
      return canonicalize_name(name)
    end
221068
def all_neighbour_nodes(chain_state: ChainState) -> Set[Address]:
    
    addresses = set()

    for payment_network in chain_state.identifiers_to_paymentnetworks.values():
        for token_network in payment_network.tokenidentifiers_to_tokennetworks.values():
            channel_states = token_network.channelidentifiers_to_channels.values()
            for channel_state in channel_states:
                addresses.add(channel_state.partner_state.address)

    return addresses
243620
private AttributesImpl validateId(final String localName, final Attributes atts, final AttributesImpl modified) throws SAXException {
        AttributesImpl res = modified;
        final String cls = atts.getValue(ATTRIBUTE_NAME_CLASS);
        if (MAP_MAP.matches(cls)) {
            topicIds.clear();
        } else if (TOPIC_TOPIC.matches(cls)) {
            final String id = atts.getValue(ATTRIBUTE_NAME_ID);
            if (id == null) {
                switch (processingMode) {
                case STRICT:
                    throw new SAXException(MessageUtils.getMessage("DOTJ067E", localName).setLocation(locator).toString());
                case LAX:
                    if (res == null) {
                        res = new AttributesImpl(atts);
                    }
                    final String gen = "gen_" + UUID.randomUUID().toString();
                    addOrSetAttribute(res, ATTRIBUTE_NAME_ID, gen);
                    logger.error(MessageUtils.getMessage("DOTJ066E", localName, gen).setLocation(locator).toString());
                    break;
                case SKIP:
                    logger.error(MessageUtils.getMessage("DOTJ067E", localName).setLocation(locator).toString());
                    break;
                }
            }
            topicIds.clear();
        } else if (TOPIC_RESOURCEID.matches(cls) || DELAY_D_ANCHORID.matches(cls)) {
            // not considered a normal element ID
        } else {
            final String id = atts.getValue(ATTRIBUTE_NAME_ID);
            if (id != null) {
                if (topicIds.contains(id)) {
                    if (processingMode == Mode.STRICT) {
                        throw new SAXException(MessageUtils.getMessage("DOTJ057E", id).setLocation(locator).toString());
                    } else {
                        logger.warn(MessageUtils.getMessage("DOTJ057E", id).setLocation(locator).toString());
                    }
                }
                topicIds.add(id);
            }
        }
        return res;
    }
673901
def getLocalID(self):
        """"""
        # I looked at this conditional and thought "ah-hah! there's the bug!"
        # but Python actually makes that one big expression somehow, i.e.
        # "x is x is x" is not the same thing as "(x is x) is x".
        # That's pretty weird, dude.  -- kmt, 1/07
        if (self.local_id is self.canonicalID is None):
            return self.claimed_id
        else:
            return self.local_id or self.canonicalID
485533
@Override public void setupLocal() {
    int idx = H2O.SELF.index();
    _result = new NodeProfile[H2O.CLOUD.size()];

    Map<String, Integer> countedStackTraces = new HashMap<>();

    final int repeats = 100;
    for (int i=0; i<repeats; ++i) {
      Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
      for (Map.Entry<Thread, StackTraceElement[]> el : allStackTraces.entrySet()) {
        StringBuilder sb = new StringBuilder();
        int j=0;
        for (StackTraceElement ste : el.getValue()) {
          String val = ste.toString();
          // filter out unimportant stuff
          if( j==0 && (   val.equals("sun.misc.Unsafe.park(Native Method)")
                  || val.equals("java.lang.Object.wait(Native Method)")
                  || val.equals("java.lang.Thread.sleep(Native Method)")
                  || val.equals("java.lang.Thread.yield(Native Method)")
                  || val.equals("java.net.PlainSocketImpl.socketAccept(Native Method)")
                  || val.equals("sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)")
                  || val.equals("sun.nio.ch.DatagramChannelImpl.receive0(Native Method)")
                  || val.equals("java.lang.Thread.dumpThreads(Native Method)")
          ) ) { break; }

          sb.append(ste.toString());
          sb.append("\n");
          j++;
          if (j==_stack_depth) break;
        }
        String st = sb.toString();
        boolean found = false;
        for (Map.Entry<String, Integer> entry : countedStackTraces.entrySet()) {
          if (entry.getKey().equals(st)) {
            entry.setValue(entry.getValue() + 1);
            found = true;
            break;
          }
        }
        if (!found) countedStackTraces.put(st, 1);
      }
      try {
        Thread.sleep(1);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }

    int i=0;
    _result[idx] = new NodeProfile(countedStackTraces.size());
    _result[idx].node_name = H2O.getIpPortString();
    _result[idx].timestamp = System.currentTimeMillis();
    for (Map.Entry<String, Integer> entry : countedStackTraces.entrySet()) {
      _result[idx].stacktraces[i] = entry.getKey();
      _result[idx].counts[i] = entry.getValue();
      i++;
    }

    // sort it
    Map<Integer, String> sorted = new TreeMap<>(Collections.reverseOrder());
    for (int j=0; j<_result[idx].counts.length; ++j) {
      if (_result[idx].stacktraces[j] != null && _result[idx].stacktraces[j].length() > 0)
        sorted.put(_result[idx].counts[j], _result[idx].stacktraces[j]);
    }

    // overwrite results
    String[] sorted_stacktraces = new String[sorted.entrySet().size()];
    int[] sorted_counts = new int[sorted.entrySet().size()];
    i=0;
    for (Map.Entry<Integer, String> e : sorted.entrySet()) {
      sorted_stacktraces[i] = e.getValue();
      sorted_counts[i] = e.getKey();
      i++;
    }
    _result[idx].stacktraces = sorted_stacktraces;
    _result[idx].counts = sorted_counts;
  }
536645
def peer_store(key, value, relation_name='cluster'):
    """"""
    cluster_rels = relation_ids(relation_name)
    if len(cluster_rels) > 0:
        cluster_rid = cluster_rels[0]
        relation_set(relation_id=cluster_rid,
                     relation_settings={key: value})
    else:
        raise ValueError('Unable to detect '
                         'peer relation {}'.format(relation_name))
1188056
private NodeInterface getRelatedNode(boolean add) {

		T relatedNode = null;

		if ((currentObject != null) && (currentObject instanceof NodeInterface)) {

			NodeInterface localNode = (NodeInterface) currentObject;
			relatedNode = localNode.getProperty(sourceKey);
			
			if (relatedNode == null && add && sourceKey instanceof RelationProperty) {

				final RelationProperty relationProperty = (RelationProperty)sourceKey;
				final App app                           = StructrApp.getInstance();
				final Class<T> relatedType              = relationProperty.getTargetType();

				if (relatedType != null) {
					
					try {
						relatedNode = app.create(relatedType);
						relationProperty.addSingleElement(securityContext, localNode, relatedNode);

					} catch (FrameworkException fex) {

						logger.warn("", fex);
					}
					
				} else {
					
					logger.error("Related type was null for {}", currentObject);
				}
			}
		}

		return relatedNode;
	}
972412
synchronized OtpErlangPid[] localPids() {
        OtpErlangPid[] ret = null;
        if (count != 0) {
            ret = new OtpErlangPid[count];
            for (int i = 0; i < count; i++) {
                ret[i] = links[i].local();
            }
        }
        return ret;
    }
1311831
def connect_endpoint(collection, edge)
      if collection.any? { |o| ! edge.equal?(o) && edge.similar?(o) }
        raise DuplicateEdgeError.new(self, edge)
      end

      collection.add(edge)
    end
1299540
static public String getLocalId(BioPAXElement bpe) {
		String id = bpe.getUri();
		return (id != null) ? id.replaceFirst("^.+[#/]", "") : null; //greedy pattern matches everything up to the last '/' or '#'
	}
1083239
def __make_xpointer_compatible(self):
        

        node_id_map = {node: ensure_xpointer_compatibility(node)
                       for node in self.dg.nodes_iter()}

        old_token_ids = self.dg.tokens
        # replace document graph with node relabeled version
        self.dg = relabel_nodes(self.dg, node_id_map, copy=True)
        self.dg.tokens = [node_id_map[tok] for tok in old_token_ids]
696926
function makeLocal(id) {
        if (hasLocal(id)) {
            return getLocal(id).promise;
        } else {
            var deferred = Q.defer();
            locals.set(id, deferred);
            return deferred.promise;
        }
    }
509694
def set_id(self, dxid):
        '''
        
        '''
        if dxid is not None:
            if not (isinstance(dxid, basestring) and dxid.startswith('localjob-')):
                # localjob IDs (which do not follow the usual ID
                # syntax) should be allowed; otherwise, follow the
                # usual syntax checking
                verify_string_dxid(dxid, self._class)
        self._dxid = dxid
874554
def set_id(self,my_id):
        
        if self.type == 'NAF':
            self.node.set('id',my_id)
        elif self.type == 'KAF':
            self.node.set('oid',my_id)
75483
@Override
    public Set<String> getPreferredIDs(
        Locale locale,
        boolean smart
    ) {

        String country = FormatUtils.getRegion(locale);

        if (smart) {
            if (country.equals("US")) {
                Set<String> tzids = new LinkedHashSet<>();
                tzids.add("America/New_York");
                tzids.add("America/Chicago");
                tzids.add("America/Denver");
                tzids.add("America/Los_Angeles");
                tzids.add("America/Anchorage");
                tzids.add("Pacific/Honolulu");
                tzids.add("America/Adak");
                return Collections.unmodifiableSet(tzids);
            } else {
                String primaryZone = PRIMARIES.get(country);

                if (primaryZone != null) {
                    return Collections.singleton(primaryZone);
                }
            }
        }

        Set<String> result = TERRITORIES.get(country);

        if (result == null) {
            result = Collections.emptySet();
        }

        return result;

    }
1293011
def get_local_ep(*args, **kwargs):
    
    if kwargs.get("warn", True):
        raise DeprecationWarning("'get_local_ep()' has been deprecated in favor of "
                                 "'globus_sdk.LocalGlobusConnectPersonal().endpoint_id'. "
                                 "To override, pass in 'warn=False'.")
    else:
        import warnings
        warnings.warn("'get_local_ep()' has been deprecated in favor of "
                      "'globus_sdk.LocalGlobusConnectPersonal().endpoint_id'.")
    return globus_sdk.LocalGlobusConnectPersonal().endpoint_id