Starts a session with a NATS Streaming cluster.

        :param cluster: Name of the cluster to which we will connect.
        :param nats: NATS connection to be borrowed for NATS Streaming.
546226
async def connect(self, cluster_id, client_id,
                      nats=None,
                      connect_timeout=DEFAULT_CONNECT_TIMEOUT,
                      max_pub_acks_inflight=DEFAULT_MAX_PUB_ACKS_INFLIGHT,
                      loop=None,
                      ):
        
        self._cluster_id = cluster_id
        self._client_id = client_id
        self._loop = loop
        self._connect_timeout = connect_timeout

        if nats is not None:
            self._nc = nats
            # NATS Streaming client should use same event loop
            # as the borrowed NATS connection.
            self._loop = self._nc._loop

        # Subjects
        self._discover_subject = DEFAULT_DISCOVER_SUBJECT % self._cluster_id
        self._hb_inbox = new_guid()
        self._ack_subject = DEFAULT_ACKS_SUBJECT % new_guid()

        # Pending pub acks inflight
        self._pending_pub_acks_queue = asyncio.Queue(
            maxsize=max_pub_acks_inflight, loop=self._loop)

        # Heartbeats subscription
        self._hb_inbox_sid = await self._nc.subscribe(
            self._hb_inbox,
            cb=self._process_heartbeats,
            )

        # Acks processing subscription
        self._ack_subject_sid = await self._nc.subscribe(
            self._ack_subject,
            cb=self._process_ack,
            )
        await self._nc.flush()

        # Start NATS Streaming session by sending ConnectRequest
        creq = protocol.ConnectRequest()
        creq.clientID = self._client_id
        creq.heartbeatInbox = self._hb_inbox
        payload = creq.SerializeToString()

        msg = None
        try:
            msg = await self._nc.request(
                self._discover_subject,
                payload,
                timeout=self._connect_timeout,
                )
        except:
            await self._close()
            raise ErrConnectReqTimeout("stan: failed connecting to '{}'".format(cluster_id))

        # We should get the NATS Streaming subject from the
        # response from the ConnectRequest.
        resp = protocol.ConnectResponse()
        resp.ParseFromString(msg.data)
        if resp.error != "":
            try:
                await self._close()
            except:
                pass
            raise StanError(resp.error)

        self._pub_prefix = resp.pubPrefix
        self._sub_req_subject = resp.subRequests
        self._unsub_req_subject = resp.unsubRequests
        self._close_req_subject = resp.closeRequests
        self._sub_close_req_subject = resp.subCloseRequests
28602
def _start_rpc_session(self, sock):
        
        session_name = RpcSession.NAME_FMT % str(sock.getpeername())
        self._stop_child_activities(session_name)

        rpc_session = RpcSession(sock, self)
        self._spawn_activity(rpc_session)
224037
public void setClusters(java.util.Collection<Cluster> clusters) {
        if (clusters == null) {
            this.clusters = null;
            return;
        }

        this.clusters = new java.util.ArrayList<Cluster>(clusters);
    }
775513
public void setClusters(java.util.Collection<ClusterSummary> clusters) {
        if (clusters == null) {
            this.clusters = null;
            return;
        }

        this.clusters = new com.amazonaws.internal.SdkInternalList<ClusterSummary>(clusters);
    }
713800
public void reconnect() {
        metadata = cluster.getMetadata();
        LOGGER.debug("Connected to cluster (" + host + "): "
                + metadata.getClusterName() + "\n");
        this.session = this.cluster.connect();
    }
535985
def start(host, port=5959, tag='salt/engine/logstash', proto='udp'):
    '''
    
    '''

    if proto == 'tcp':
        logstashHandler = logstash.TCPLogstashHandler
    elif proto == 'udp':
        logstashHandler = logstash.UDPLogstashHandler

    logstash_logger = logging.getLogger('python-logstash-logger')
    logstash_logger.setLevel(logging.INFO)
    logstash_logger.addHandler(logstashHandler(host, port, version=1))

    if __opts__.get('id').endswith('_master'):
        event_bus = salt.utils.event.get_master_event(
                __opts__,
                __opts__['sock_dir'],
                listen=True)
    else:
        event_bus = salt.utils.event.get_event(
            'minion',
            transport=__opts__['transport'],
            opts=__opts__,
            sock_dir=__opts__['sock_dir'],
            listen=True)
        log.debug('Logstash engine started')

    while True:
        event = event_bus.get_event()
        if event:
            logstash_logger.info(tag, extra=event)
933526
void setClusterId(String newClusterId) {
        assert lock.isHeldByCurrentThread() : "Called without holding cluster service lock!";
        assert clusterId == null : "Cluster ID should be null: " + clusterId;
        clusterId = newClusterId;
    }
939754
def _on_cluster_discovery(self, future):
        
        LOGGER.debug('_on_cluster_discovery(%r)', future)
        common.maybe_raise_exception(future)
        nodes = future.result()
        for node in nodes:
            name = '{}:{}'.format(node.ip, node.port)
            if name in self._cluster:
                LOGGER.debug('Updating cluster connection info for %s:%s',
                             node.ip, node.port)
                self._cluster[name].set_slots(node.slots)
                self._cluster[name].set_read_only('slave' in node.flags)
            else:
                self._create_cluster_connection(node)
        self._discovery = True
116946
def start_transmit(self, blocking=False):
        

        self.session.start_transmit(blocking, False, self)
106043
def start(self, streamer=False):
        
        if streamer and not general.socket_ready(self.task_in_url):  # started
            self.streamer = multiprocessing.Process(
                target=_streamer,
                args=(self.master_host, self.task_in_port, self.task_out_port))
            self.streamer.start()
        starting = []
        for host, cores in self.host_cores:
            if self.status(host)[0][1] == 'running':
                print('%s:%s already running' % (host, self.ctrl_port))
                continue
            ctrl_url = 'tcp://%s:%s' % (host, self.ctrl_port)
            if host == '127.0.0.1':  # localhost
                args = [sys.executable]
            else:
                args = ['ssh', host, self.remote_python]
            args += ['-m', 'openquake.baselib.workerpool',
                     ctrl_url, self.task_out_url, cores]
            starting.append(' '.join(args))
            po = subprocess.Popen(args)
            self.pids.append(po.pid)
        return 'starting %s' % starting
1235294
private void connect(CompletableFuture<Connection> future) {
    if (!selector.hasNext()) {
      LOGGER.debug("{} - Failed to connect to the cluster", id);
      future.complete(null);
    } else {
      Address address = selector.next();
      LOGGER.debug("{} - Connecting to {}", id, address);
      client.connect(address).whenComplete((c, e) -> handleConnection(address, c, e, future));
    }
  }
301837
def _start_nodes_sequentially(self, nodes):
        
        started_nodes = set()
        for node in copy(nodes):
            started = self._start_node(node)
            if started:
                started_nodes.add(node)
            # checkpoint cluster state
            self.repository.save_or_update(self)
        return started_nodes
691994
public static ns_cluster[] get(nitro_service client) throws Exception
	{
		ns_cluster resource = new ns_cluster();
		resource.validate("get");
		return (ns_cluster[]) resource.get_resources(client);
	}
125304
def do_start_service(self, service):
        
        if not self.has_cluster():
            return None

        if self.service_action(service=service, action="start"):
            print("%s is being started" % (service))
        else:
            print("Error starting service")
            return None
534973
def launchCluster(self, leaderNodeType, leaderStorage, owner, **kwargs):
        
        if 'keyName' not in kwargs:
            raise RuntimeError("A keyPairName is required for the AWS provisioner.")
        self._keyName = kwargs['keyName']
        self._vpcSubnet = kwargs['vpcSubnet'] if 'vpcSubnet' in kwargs else None

        profileARN = self._getProfileARN()
        # the security group name is used as the cluster identifier
        sgs = self._createSecurityGroup()
        bdm = self._getBlockDeviceMapping(E2Instances[leaderNodeType], rootVolSize=leaderStorage)

        self._masterPublicKey = 'AAAAB3NzaC1yc2Enoauthorizedkeyneeded' # dummy key
        userData =  self._getCloudConfigUserData('leader', self._masterPublicKey)
        specKwargs = {'key_name': self._keyName, 'security_group_ids': [sg.id for sg in sgs],
                  'instance_type': leaderNodeType,
                  'user_data': userData, 'block_device_map': bdm,
                  'instance_profile_arn': profileARN,
                  'placement': self._zone}
        if self._vpcSubnet:
            specKwargs["subnet_id"] = self._vpcSubnet
        instances = create_ondemand_instances(self._ctx.ec2, image_id=self._discoverAMI(),
                                                  spec=specKwargs, num_instances=1)

        # wait for the leader to finish setting up
        leader = instances[0]
        wait_instances_running(self._ctx.ec2, [leader])
        self._waitForIP(leader)
        leaderNode = Node(publicIP=leader.ip_address, privateIP=leader.private_ip_address,
                          name=leader.id, launchTime=leader.launch_time, nodeType=leaderNodeType,
                          preemptable=False, tags=leader.tags)
        leaderNode.waitForNode('toil_leader')

        defaultTags = {'Name': self.clusterName, 'Owner': owner}
        if kwargs['userTags']:
            defaultTags.update(kwargs['userTags'])

        # if we running launch cluster we need to save this data as it won't be generated
        # from the metadata. This data is needed to launch worker nodes.
        self._leaderPrivateIP = leader.private_ip_address
        self._addTags([leader], defaultTags)
        self._tags = leader.tags
        self._subnetID = leader.subnet_id
59637
async def on_connect(self):
        
        if self.db:
            warnings.warn('SELECT DB is not allowed in cluster mode')
            self.db = ''
        await super(ClusterConnection, self).on_connect()
        if self.readonly:
            await self.send_command('READONLY')
            if nativestr(await self.read_response()) != 'OK':
                raise ConnectionError('READONLY command failed')
195865
def __StartMaster(self):
        
    num_masters = len(self.cluster.get_instances_in_role("master", "running"))
    assert(num_masters < 1)
    logging.info( "waiting for masters to start")
    if self.config.master_on_spot_instances:          
      self.__LaunchSpotMasterInstances()
    else:
      self.__LaunchOnDemandMasterInstances()
    time.sleep(1)
    self.__ConfigureMaster()
    return True