Helper method for nodes that have at most one default incoming connection
353251
public Connection getFrom() {
        final List<Connection> list =
            getIncomingConnections(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
        if (list.size() == 0) {
            return null;
        }
        if (list.size() == 1) {
        	return list.get(0);
        }
        if ("true".equals(System.getProperty("jbpm.enable.multi.con"))) { 
        	return list.get(0);
        } else {
        	throw new IllegalArgumentException(
    		"Trying to retrieve the from connection but multiple connections are present");
        }
    }
536865
function setup(connection) {

                node.connection = connection;

                // node connected
                node.status({ fill: 'green', shape: 'dot', text: 'connected' });

                // build sender options based on node configuration
                var options = {
                    target: {
                        address: node.address,
                        dynamic: node.dynamic,
                        durable: node.durable,
                        expiry_policy: node.expirypolicy
                    },
                    autosettle: node.autosettle,
                    snd_settle_mode: node.sndsettlemode,
                    rcv_settle_mode: node.rcvsettlemode
                };
                node.sender = node.connection.open_sender(options);

                node.sender.on('accepted', function(context) {
                    var msg = outDelivery(node, context.delivery);
                    node.send(msg);
                });

                node.sender.on('released', function(context) {
                    var msg = outDelivery(node, context.delivery);
                    node.send(msg);
                });

                node.sender.on('rejected', function(context) {
                    var msg = outDelivery(node, context.delivery);
                    node.send(msg);
                });

                node.connection.on('disconnected', function(context) {
                    // node disconnected
                    node.status({fill: 'red', shape: 'dot', text: 'disconnected' });
                });

                node.on('input', function(msg) {
                    // enough credits to send
                    if (node.sender.sendable()) {
                        node.sender.send(msg.payload);
                    }
                });

                node.on('close', function() {
                    if (node.sender != null)
                        node.sender.detach();
                    node.connection.close();
                });
            }
1046121
def outgoing(self, node):
        """"""
        nodes = node if isinstance(node, list) else [node]
        node_ids = [self.id(n) for n in nodes]
        # Find edges outgoing from this group but not incoming to it
        outgoing = [self[e[1]] for e in self.edges
                    if e[0] in node_ids and e[1] not in node_ids]
        return outgoing
312622
def connections( self, cls = None ):
        
        scene = self.scene()
        if ( not scene ):
            return []
        
        if ( not cls ):
            cls = XNodeConnection
        
        output = []
        for item in scene.items():
            if ( not isinstance(item, cls) ):
                continue
            
            if ( item.inputNode() == self or item.outputNode() == self ):
                output.append(item)
        
        return output
1285673
def incoming_connections(self):
        """"""

        # Incoming connections are on the left.
        return list(
            takewhile(lambda c: c.direction == INCOMING, self.connections)
        )
121252
private boolean getGoodNode(Set<Node> candidateNodes,
                              boolean considerLoad,
                              long blockSize,
                              List<DatanodeDescriptor> results) {
    List<DatanodeDescriptor> sorted = new ArrayList<DatanodeDescriptor>();
    for (Node n : candidateNodes) {
      sorted.add((DatanodeDescriptor)n);
    }
    final long blocksize = blockSize;
    Collections.sort(sorted, new Comparator<DatanodeDescriptor>() {
      public int compare(DatanodeDescriptor n1, DatanodeDescriptor n2) {
        long ret = (n2.getRemaining() - (n2.getBlocksScheduled() * blocksize)) -
                   (n1.getRemaining() - (n1.getBlocksScheduled() * blocksize));
        return ret == 0 ? 0 : (ret > 0) ? 1 : -1;
      }
    });
    // Also, add some randomness. We are doing so because it seems
    // that if there are many copies scheduled at the same time, namenode
    // does not have the uptodate information. So, we need to add some
    // randomness so that there is not a lot of copies targeted to
    // the same node, which will overload the hosts and may lead to
    // timeouts.
    int count = sorted.size() / 2;
    Collections.shuffle(sorted.subList(0, count));
    for (DatanodeDescriptor n : sorted) {
      if (this.isGoodTarget((DatanodeDescriptor)n,
                            blocksize,
                            1, // MaxTargerPerLoc (per rack)
                            considerLoad,
                            results)) {
        results.add((DatanodeDescriptor)n);
        return true;
      }
    }
    return false;
  }
964851
def get_node(conn, name):
    '''
    
    '''
    nodes = conn.list_nodes()
    for node in nodes:
        if node.name == name:
            __utils__['cloud.cache_node'](salt.utils.data.simple_types_filter(node.__dict__), __active_provider_name__, __opts__)
            return node
828368
def steady_connection(self):
        """"""
        return SteadyPgConnection(self._maxusage, self._setsession, True,
                                  *self._args, **self._kwargs)
1042858
def make_connection(self):
        """"""
        if self._created_connections[self._pattern_idx] >= self.max_connections_per_pattern:
            raise ConnectionError("Too many connections")
        self._created_connections[self._pattern_idx] += 1
        conn = self.connection_class(**self.patterns[self._pattern_idx])
        conn._pattern_idx = self._pattern_idx
        return conn
833175
static RedisNodeDescription findNodeByHostAndPort(Collection<RedisNodeDescription> nodes, String host, int port) {
        for (RedisNodeDescription node : nodes) {
            RedisURI nodeUri = node.getUri();
            if (nodeUri.getHost().equals(host) && nodeUri.getPort() == port) {
                return node;
            }
        }
        return null;
    }
749036
def __get_known_node(self, ip, host):
        '''
        
        '''
        # already known by IP ?
        for ex in self.nodes:
            for exip in ex.ip:
                if (exip == '0.0.0.0'):
                    continue
                if (exip == ip):
                    return (ex, 0)

        # already known by HOST ?
        node = self.__get_known_node_by_host(host)
        if (node != None):
            # node already known
            if (ip not in node.ip):
                node.ip.append(ip)
                return (node, 1)
            return (node, 0)

        return (None, 0)
1069610
def _choose_capture_side(self):
        

        ALWAYS_RUNNING_NODES_TYPE = ("cloud", "nat", "ethernet_switch", "ethernet_hub")

        for node in self._nodes:
            if node["node"].compute.id == "local" and node["node"].node_type in ALWAYS_RUNNING_NODES_TYPE and node["node"].status == "started":
                return node

        for node in self._nodes:
            if node["node"].node_type in ALWAYS_RUNNING_NODES_TYPE and node["node"].status == "started":
                return node

        for node in self._nodes:
            if node["node"].compute.id == "local" and node["node"].status == "started":
                return node

        for node in self._nodes:
            if node["node"].node_type and node["node"].status == "started":
                return node

        raise aiohttp.web.HTTPConflict(text="Cannot capture because there is no running device on this link")
1062458
function NodeClient(node) {
  if (!(this instanceof NodeClient))
    return new NodeClient(node);

  AsyncObject.call(this);

  this.node = node;
  this.network = node.network;
  this.filter = null;
  this.listen = false;

  this._init();
}
866592
def default(self, node):
        """"""
        if hasattr(node, 'linestart'):
            if node.linestart:
                self.source_linemap[self.current_line_number] = node.linestart
        return super(LineMapWalker, self).default(node)
122301
def get(self, key, default=None):
		
		if key in self._nodes: return self._nodes[key]
		else: return default
9627
function(hostname, callback) {
  get_nodes(function(err,nodes) {
    if (err) return callback(err);

    var n = nodes.filter(function(node) {
      return node.name === hostname;
    });

    callback(null,(n.length === 1) ? n[0].ip_address : null);
  });
}
1356206
private AsyncConnections getConnections(Iterable<RedisNodeDescription> nodes) {

        List<RedisNodeDescription> nodeList = LettuceLists.newList(nodes);
        AsyncConnections connections = new AsyncConnections(nodeList);

        for (RedisNodeDescription node : nodeList) {

            RedisURI redisURI = node.getUri();
            String message = String.format("Unable to connect to %s", redisURI);
            try {
                CompletableFuture<StatefulRedisConnection<String, String>> connectionFuture = nodeConnectionFactory
                        .connectToNodeAsync(CODEC, redisURI);

                CompletableFuture<StatefulRedisConnection<String, String>> sync = new CompletableFuture<>();

                connectionFuture.whenComplete((connection, throwable) -> {

                    if (throwable != null) {

                        if (throwable instanceof RedisConnectionException) {
                            if (logger.isDebugEnabled()) {
                                logger.debug(throwable.getMessage(), throwable);
                            } else {
                                logger.warn(throwable.getMessage());
                            }
                        } else {
                            logger.warn(message, throwable);
                        }

                        sync.completeExceptionally(new RedisConnectionException(message, throwable));
                    } else {
                        connection.async().clientSetname("lettuce#MasterSlaveTopologyRefresh");
                        sync.complete(connection);
                    }
                });

                connections.addConnection(redisURI, sync);
            } catch (RuntimeException e) {
                logger.warn(String.format(message, redisURI), e);
            }
        }

        return connections;
    }