from interface PeerService
19590
public void generateReport (String arg1, InvocationService.ResultListener arg2)
    {
        InvocationMarshaller.ResultMarshaller listener2 = new InvocationMarshaller.ResultMarshaller();
        listener2.listener = arg2;
        sendRequest(GENERATE_REPORT, new Object[] {
            arg1, listener2
        });
    }
642753
@Override
  public Transport newInstance(final String hostAddress,
                               final int port,
                               final EStage<TransportEvent> clientStage,
                               final EStage<TransportEvent> serverStage,
                               final int numberOfTries,
                               final int retryTimeout) {
    try {
      TcpPortProvider tcpPortProvider = Tang.Factory.getTang().newInjector().getInstance(TcpPortProvider.class);
      return newInstance(hostAddress, port, clientStage,
              serverStage, numberOfTries, retryTimeout, tcpPortProvider);
    } catch (final InjectionException e) {
      throw new RuntimeException(e);
    }
  }
158382
function TChannelPeer(channel, hostPort, options) {
    assert(hostPort !== '0.0.0.0:0', 'Cannot create ephemeral peer');

    options = options || {};
    EventEmitter.call(this);

    this.stateChangedEvent = this.defineEvent('stateChanged');
    this.allocConnectionEvent = this.defineEvent('allocConnection');
    this.removeConnectionEvent = this.defineEvent('removeConnection');
    this.deltaOutConnectionEvent = this.defineEvent('deltaOutConnection');

    this.channel = channel;
    this.socketInitTimeout = channel.initTimeout;
    this.logger = this.channel.logger;
    this.timers = this.channel.timers;
    this.random = this.channel.random;
    this.hostPort = hostPort;
    this.connections = [];
    this.pendingIdentified = 0;
    this.heapElements = [];
    this.scoreStrategy = null;
    this.draining = null;
    this.boundOnIdentified = onIdentified;
    this.boundOnConnectionError = onConnectionError;
    this.boundOnConnectionClose = onConnectionClose;
    this.boundOnPendingChange = onPendingChange;
    this.scoreRange = null;

    // Timestamp when next conn attempt is allowed
    this.nextConnAttemptTime = 0;
    // How long to delay conn attempt by on failure (ms)
    this.nextConnAttemptDelay = 0;
    // Whether we are doing a connection attempt
    this.hasConnectionAttempt = false;

    this.waitForIdentifiedListeners = [];

    this.reportInterval = options.reportInterval || DEFAULT_REPORT_INTERVAL;
    if (this.reportInterval > 0 && this.channel.emitConnectionMetrics) {
        this.reportTimer = this.timers.setTimeout(
            onReport, this.reportInterval
        );
    }

    this.connectionAttemptDelay = this.channel.connectionAttemptDelay ||
        INITIAL_CONN_ATTEMPT_DELAY;
    this.maxConnectionAttemptDelay = this.channel.maxConnectionAttemptDelay ||
        MAX_CONN_ATTEMPT_DELAY;

    this.setPreferConnectionDirection(options.preferConnectionDirection || 'any');

    var self = this;

    function onIdentified(_, conn) {
        self.onIdentified(conn);
    }

    function onConnectionError(err, conn) {
        self.onConnectionError(err, conn);
    }

    function onConnectionClose(_, conn) {
        self.onConnectionClose(conn);
    }

    function onPendingChange(pending, conn) {
        self.onPendingChange(conn, pending);
    }

    function onReport() {
        if (!self.hostPort) {
            return;
        }

        var count = self.countConnections('out');
        if (self.channel.emitConnectionMetrics) {
            self.channel.emitFastStat(
                'tchannel.connections.active',
                'gauge',
                count,
                new stat.ConnectionsActiveTags(
                    self.channel.hostPort,
                    self.hostPort
                )
            );
        }

        self.reportTimer = self.timers.setTimeout(
            onReport, self.reportInterval
        );
    }
}
1203412
def peers(cls):
        """"""
        contentType = ContentType.objects.get_for_model(cls)
        return cls.objects.filter(content_type=contentType)
972315
public static void main(String[] args) {
    // ScaleCube Node node with no members
    Microservices seed =
        Microservices.builder()
            .discovery(ScalecubeServiceDiscovery::new)
            .transport(ServiceTransports::rsocketServiceTransport)
            .startAwait();

    // Construct a ScaleCube node which joins the cluster hosting the Greeting Service
    Microservices microservices =
        Microservices.builder()
            .discovery(
                serviceEndpoint ->
                    new ScalecubeServiceDiscovery(serviceEndpoint)
                        .options(opts -> opts.seedMembers(toAddress(seed.discovery().address()))))
            .transport(ServiceTransports::rsocketServiceTransport)
            .services(new GreetingServiceImpl())
            .startAwait();

    // Create service proxy
    GreetingsService service = seed.call().api(GreetingsService.class);

    // Execute the services and subscribe to service events
    service
        .sayHello("joe")
        .subscribe(
            consumer -> {
              System.out.println(consumer.message());
            });

    // shut down the nodes
    seed.shutdown().block();
    microservices.shutdown().block();
  }
388971
def connectPeer(self, peer):
        
        return self.conns.connectCached(endpoint.Q2QEndpoint(self.svc,
                                                             self.addr,
                                                             peer,
                                                             PROTOCOL_NAME),
                                        self.clientFactory)
962261
private static Observable<PingServiceHealth> pingBinary(
        final NetworkAddress hostname, final String bucket,
        final ClusterFacade core, final long timeout, final TimeUnit timeUnit) {
        final AtomicReference<CouchbaseRequest> request = new AtomicReference<CouchbaseRequest>();
        Observable<NoopResponse> response = Observable.defer(new Func0<Observable<NoopResponse>>() {
            @Override
            public Observable<NoopResponse> call() {
                CouchbaseRequest r = new NoopRequest(bucket, hostname);
                request.set(r);
                return core.send(r);
            }
        }).timeout(timeout, timeUnit);
        return mapToServiceHealth(bucket, ServiceType.BINARY, response, request, timeout, timeUnit);
    }
1345282
def clientInit(peer)
      # We connected to a peer
      # Send handshake
      torrentData = @torrentData[peer.infoHash]
      if ! torrentData
        @logger.warn "No tracker client found for peer #{peer}. Closing connection."
        close
        return
      end
      trackerclient = torrentData.trackerClient

      @logger.info "Connected to peer #{peer}. Sending handshake."
      msg = PeerHandshake.new
      msg.peerId = trackerclient.peerId
      msg.infoHash = peer.infoHash
      msg.serializeTo currentIo
      peer.state = :handshaking
      @reactor.scheduleTimer(@handshakeTimeout, [:handshake_timeout, peer], false)
      @logger.debug "Done sending handshake."

      # Send bitfield
      sendBitfield(currentIo, torrentData.blockState.completePieceBitfield) if torrentData.blockState

      setReadRateLimit(torrentData.downRateLimit) if torrentData.downRateLimit
      setWriteRateLimit(torrentData.upRateLimit) if torrentData.upRateLimit
    end
1184592
@Override
    public PubSubOutputHandler getPubSubOutputHandler(SIBUuid8 neighbourUUID)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getPubSubOutputHandler", neighbourUUID);

        PubSubOutputHandler handler =
                        _pubSubRealization.getPubSubOutputHandler(neighbourUUID);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "getPubSubOutputHandler", handler);

        return handler;
    }
1224205
void broadcast(Iterator<String> peers, Message message) {
    transport.broadcast(peers, message);
  }
1019223
@Override
  public TsiPeer extractPeer() throws GeneralSecurityException {
    Preconditions.checkState(!isInProgress(), "Handshake is not complete.");
    List<TsiPeer.Property<?>> peerProperties = new ArrayList<>();
    peerProperties.add(
        new TsiPeer.StringProperty(
            TSI_SERVICE_ACCOUNT_PEER_PROPERTY,
            handshaker.getResult().getPeerIdentity().getServiceAccount()));
    return new TsiPeer(peerProperties);
  }
503886
function PeerList() {
  this.map = new Map();
  this.ids = new Map();
  this.list = new List();
  this.load = null;
  this.inbound = 0;
  this.outbound = 0;
}
251295
@Override
  public void _Network_Peers_addPeer(String name, boolean attemptConnect, int rating, String realm) throws MBeanException {
    try {
      NetworkImpl n = (NetworkImpl) stack.unwrap(Network.class);
      /*Peer p =*/ n.addPeer(name, realm, attemptConnect);
    }
    catch (IllegalArgumentException e) {
      logger.warn(e.getMessage());
    }
    catch (InternalException e) {
      throw new MBeanException(e, "Failed to add peer with name '" + name + "'");
    }
  }
1349193
function syncPeer (node) {

    // Global sync vars
    const remotePeer = Peer.fromJSON({});
    let remoteJsonPeer = {};

    return co(function *() {
      const json = yield node.getPeer();
      remotePeer.version = json.version
      remotePeer.currency = json.currency
      remotePeer.pub = json.pub
      remotePeer.endpoints = json.endpoints
      remotePeer.blockstamp = json.block
      remotePeer.signature = json.signature
      const entry = remotePeer.getRawUnsigned();
      const signature = dos2unix(remotePeer.signature);
      // Parameters
      if(!(entry && signature)){
        throw 'Requires a peering entry + signature';
      }

      remoteJsonPeer = json;
      remoteJsonPeer.pubkey = json.pubkey;
      let signatureOK = PeeringService.checkPeerSignature(remoteJsonPeer);
      if (!signatureOK) {
        watcher.writeStatus('Wrong signature for peer #' + remoteJsonPeer.pubkey);
      }
      try {
        yield PeeringService.submitP(remoteJsonPeer);
      } catch (err) {
        if (err.indexOf !== undefined && err.indexOf(constants.ERRORS.NEWER_PEER_DOCUMENT_AVAILABLE.uerr.message) !== -1 && err != constants.ERROR.PEER.UNKNOWN_REFERENCE_BLOCK) {
          throw err;
        }
      }
    });
  }
641530
function onBytesMessage(peer,data)
    {
        var arr = bufferToArray(scope._servConn.byteType,data);

        if(arr)
        {
            if(scope._servConn.rtcFallback == true)
            {
                arr = arr.slice(0,arr.length-2);
            }
            scope.dispatchEvent("peerMessage",{message:arr,id:peer.id,rtc:peer.rtcId,array:true,fallback:false});
        }
    }
775444
public static void main(String[] args) throws Exception {
    System.out.println("Start gateway");
    Microservices gateway =
        Microservices.builder()
            .discovery(ScalecubeServiceDiscovery::new)
            .transport(ServiceTransports::rsocketServiceTransport)
            .gateway(opts -> new HttpGatewayExample(opts.id("http").port(8181)))
            .gateway(opts -> new WebsocketGatewayExample(opts.id("ws").port(9191)))
            .startAwait();

    System.out.println("Start HelloWorldService with BusinessLogicFacade");
    final Microservices node1 =
        Microservices.builder()
            .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway))
            .transport(ServiceTransports::rsocketServiceTransport)
            .services(
                call ->
                    Collections.singleton(
                        ServiceInfo.fromServiceInstance(
                                new HelloWorldServiceImpl(
                                    new BusinessLogicFacade(
                                        call.api(ServiceHello.class),
                                        call.api(ServiceWorld.class))))
                            .build()))
            .startAwait();

    System.out.println("Start ServiceHello");
    final Microservices node2 =
        Microservices.builder()
            .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway))
            .transport(ServiceTransports::rsocketServiceTransport)
            .services(new ServiceHelloImpl())
            .startAwait();

    System.out.println("Start ServiceWorld");
    final Microservices node3 =
        Microservices.builder()
            .discovery(serviceEndpoint -> serviceDiscovery(serviceEndpoint, gateway))
            .transport(ServiceTransports::rsocketServiceTransport)
            .services(new ServiceWorldImpl())
            .startAwait();

    System.out.println("Wait for some time so nodes could catch up with each other ...");
    TimeUnit.SECONDS.sleep(3);

    System.out.println("Making hello world business logic ...");
    HelloWorldService helloWorldService = node1.call().api(HelloWorldService.class);

    String helloWorld = helloWorldService.helloWorld().block(Duration.ofSeconds(6));
    System.out.println("Result of calling hello world business logic is ... => " + helloWorld);

    Mono.when(gateway.shutdown(), node1.shutdown(), node2.shutdown(), node3.shutdown())
        .block(Duration.ofSeconds(5));
  }
1172984
function createPeerInstance(id)
    {
        var peer              = new ConnectaPeer(id,stunUrls);
        peer.onIceCandidate   = gotIceCandidate;
        peer.onDescription    = createdDescription;
        peer.onRemoteStream   = gotRemoteStream;
        peer.onConnected      = onPeerConnected;
        peer.onMessage        = onPeerMessage;
        peer.onBytesMessage   = onBytesMessage;
        peer.onConnectionFail = onPeerFailed;
        peer.onClosed         = onPeerClose;
        peer.onError          = onPeerError;
        peer.onChannelState   = onPeerState;
        scope.peers[id]       = peer;
        
        peer.init();

        return peer;
    }