apply new params to replica set member
        Args:
            repl_id - replica set identity
            member_id - member index
            params - new member's params

        return True if operation success otherwise False
166115
def member_update(self, repl_id, member_id, params):
        
        repl = self[repl_id]
        result = repl.member_update(member_id, params)
        self[repl_id] = repl
        return result
932698
def router_add(self, params):
        """"""
        if self.uses_rs_configdb:
            # Replica set configdb.
            rs_id = self._configsvrs[0]
            config_members = ReplicaSets().members(rs_id)
            configdb = '%s/%s' % (
                rs_id, ','.join(m['host'] for m in config_members))
        else:
            configdb = ','.join(Servers().hostname(item)
                                for item in self._configsvrs)
        server_id = params.pop('server_id', None)
        version = params.pop('version', self._version)
        params.update({'configdb': configdb})

        if self.enable_ipv6:
            common.enable_ipv6_single(params)
        # Remove flags that turn auth on.
        params = self._strip_auth(params)

        self._routers.append(Servers().create(
            'mongos', params, sslParams=self.sslParams, autostart=True,
            version=version, server_id=server_id))
        return {'id': self._routers[-1], 'hostname': Servers().hostname(self._routers[-1])}
602480
public boolean repl(boolean local) {
		try {
			String className = local ? "Local" : "Remote";
			String serviceName = local ? "$repl" : "$repl-remote";
			try {
				serviceRegistry.getService(serviceName);
				return false;
			} catch (Exception ignored) {
			}
			createService(serviceName,
					(Service) Class.forName("services.moleculer.repl." + className + "Repl").newInstance());
			return true;
		} catch (ClassNotFoundException notFound) {
			logger.error("Unable to start REPL console!");
			suggestDependency("com.github.berkesa", "moleculer-java-repl", "1.0.5");
		} catch (Exception cause) {
			logger.error("Unable to start REPL console!", cause);
		}
		return false;
	}
1296108
def needs_repl_key(self):
        
        cluster = self.get_cluster()
        return (self.supports_repl_key() and
                cluster is not None and cluster.get_repl_key() is not None)
727498
function replSetGetStatus(admin, options, callback) {
  executeDbAdminCommand(admin.s.db, { replSetGetStatus: 1 }, options, callback);
}
169707
def usable_id(cls, id):
        
        try:
            # id is maybe a sshkey name
            qry_id = cls.from_name(id)
            if not qry_id:
                qry_id = int(id)
        except DuplicateResults as exc:
            cls.error(exc.errors)
        except Exception:
            qry_id = None

        if not qry_id:
            msg = 'unknown identifier %s' % id
            cls.error(msg)

        return qry_id
512937
function queryReplication (id, opts0, callback0) {
    const { opts, callback } = getCallback(opts0, callback0)
    return relax({ db: '_replicator', method: 'GET', path: id, qs: opts }, callback)
  }
16469
def update_replication_schedule(self, schedule_id, schedule):
    
    return self._put("replications/%s" % schedule_id, ApiReplicationSchedule,
        data=schedule, api_version=3)
1361559
def create_replica(self, clone_member):
        

        self.set_state('creating replica')
        self._sysid = None

        is_remote_master = isinstance(clone_member, RemoteMember)
        create_replica_methods = is_remote_master and clone_member.create_replica_methods

        # get list of replica methods either from clone member or from
        # the config. If there is no configuration key, or no value is
        # specified, use basebackup
        replica_methods = (
            create_replica_methods
            or self._create_replica_methods
            or ['basebackup']
        )

        if clone_member and clone_member.conn_url:
            r = clone_member.conn_kwargs(self._replication)
            connstring = 'postgres://{user}@{host}:{port}/{database}'.format(**r)
            # add the credentials to connect to the replica origin to pgpass.
            env = self.write_pgpass(r)
        else:
            connstring = ''
            env = os.environ.copy()
            # if we don't have any source, leave only replica methods that work without it
            replica_methods = \
                [r for r in replica_methods if self.replica_method_can_work_without_replication_connection(r)]

        # go through them in priority order
        ret = 1
        for replica_method in replica_methods:
            with self._cancellable_lock:
                if self._is_cancelled:
                    break
            # if the method is basebackup, then use the built-in
            if replica_method == "basebackup":
                ret = self.basebackup(connstring, env, self.config.get(replica_method, {}))
                if ret == 0:
                    logger.info("replica has been created using basebackup")
                    # if basebackup succeeds, exit with success
                    break
            else:
                if not self.data_directory_empty():
                    if self.config.get(replica_method, {}).get('keep_data', False):
                        logger.info('Leaving data directory uncleaned')
                    else:
                        self.remove_data_directory()

                cmd = replica_method
                method_config = {}
                # user-defined method; check for configuration
                # not required, actually
                if self.config.get(replica_method, {}):
                    method_config = self.config[replica_method].copy()
                    # look to see if the user has supplied a full command path
                    # if not, use the method name as the command
                    cmd = method_config.pop('command', cmd)

                # add the default parameters
                if not method_config.get('no_params', False):
                    method_config.update({"scope": self.scope,
                                          "role": "replica",
                                          "datadir": self._data_dir,
                                          "connstring": connstring})
                else:
                    for param in ('no_params', 'no_master', 'keep_data'):
                        method_config.pop(param, None)
                params = ["--{0}={1}".format(arg, val) for arg, val in method_config.items()]
                try:
                    # call script with the full set of parameters
                    ret = self.cancellable_subprocess_call(shlex.split(cmd) + params, env=env)
                    # if we succeeded, stop
                    if ret == 0:
                        logger.info('replica has been created using %s', replica_method)
                        break
                    else:
                        logger.error('Error creating replica using method %s: %s exited with code=%s',
                                     replica_method, cmd, ret)
                except Exception:
                    logger.exception('Error creating replica using method %s', replica_method)
                    ret = 1

        self.set_state('stopped')
        return ret
144552
def replica_set_link(rel, repl_id=None, member_id=None, self_rel=False):
    """"""
    repls_href = '/v1/replica_sets'
    link = _REPLICA_SET_LINKS[rel].copy()
    link['href'] = link['href'].format(**locals())
    link['rel'] = 'self' if self_rel else rel
    return link
1261162
def deploy(self, ids):
        
        url = build_uri_with_ids('api/v3/vip-request/deploy/%s/', ids)

        return super(ApiVipRequest, self).post(url)
1070826
def build_params(self, params, i):
        
        prefix = 'Tags.member.%d.' % i
        params[prefix+'ResourceId'] = self.resource_id
        params[prefix+'ResourceType'] = self.resource_type
        params[prefix+'Key'] = self.key
        params[prefix+'Value'] = self.value
        if self.propagate_at_launch:
            params[prefix+'PropagateAtLaunch'] = 'true'
        else:
            params[prefix+'PropagateAtLaunch'] = 'false'
240440
def get_actual_replica(self, service_id: str) -> str:
        
        # Raise an exception if we are not a manager
        if not self._manager:
            raise RuntimeError('Only the Swarm manager node can retrieve '
                               'replication level of the service')

        service_details = self.get_service_details(service_id)
        actual_replica = service_details["Spec"]["Mode"][
            "Replicated"]["Replicas"]
        return actual_replica
623751
def repl_db_sub(master_dsn, slave_dsn, tables):
    
    logger = logging.getLogger("meepo.sub.replicate_sub")

    # sqlalchemy reflection
    logger.info("reflecting master database: {}".format(master_dsn))
    master_engine = sa.create_engine(master_dsn)
    master_base = automap_base()
    master_base.prepare(engine=master_engine, reflect=True)
    MasterSession = scoped_session(sessionmaker(bind=master_engine))

    logger.info("reflecting slave database: {}".format(slave_dsn))
    slave_engine = sa.create_engine(slave_dsn)
    slave_base = automap_base()
    slave_base.prepare(engine=slave_engine, reflect=True)
    SlaveSession = scoped_session(sessionmaker(bind=slave_engine))

    def _write_by_pk(name, pk):
        """Copy row from master to slave based on pk
        """
        MasterModel = master_base.classes[name]
        obj = MasterSession.query(MasterModel).get(pk)
        if not obj:
            logger.error("pk for {} not found in master: {}".format(name, pk))
            return

        SlaveModel = slave_base.classes[name]
        columns = [c.name for c in SlaveModel.__table__.columns]
        s_obj = SlaveModel(**{k: v
                              for k, v in obj.__dict__.items()
                              if k in columns})
        SlaveSession.add(s_obj)

        try:
            SlaveSession.commit()
        except SQLAlchemyError as e:
            SlaveSession.rollback()
            logger.exception(e)

        # cleanup
        MasterSession.close()
        SlaveSession.close()

    def _update_by_pk(name, pk):
        """Update row from master to slave based on pk
        """
        MasterModel = master_base.classes[name]
        obj = MasterSession.query(MasterModel).get(pk)

        SlaveModel = slave_base.classes[name]
        s_obj = SlaveSession.query(SlaveModel).get(pk)
        if not s_obj:
            return _write_by_pk(name, pk)

        columns = [c.name for c in SlaveModel.__table__.columns]
        for col in columns:
            try:
                val = getattr(obj, col)
            except AttributeError as e:
                continue
            setattr(s_obj, col, val)

        try:
            SlaveSession.commit()
        except SQLAlchemyError as e:
            SlaveSession.rollback()
            logger.exception(e)

        # cleanup
        MasterSession.close()
        SlaveSession.close()

    def _delete_by_pk(name, pk):
        """Copy row from slave based on pk
        """
        Model = slave_base.classes[name]
        obj = SlaveSession.query(Model).get(pk)
        if obj:
            SlaveSession.delete(obj)
        SlaveSession.commit()

        # cleanup
        SlaveSession.close()

    def _sub(table):

        def _sub_write(pk):
            logger.info("repl_db {}_write: {}".format(table, pk))
            _write_by_pk(table, pk)
        signal("%s_write" % table).connect(_sub_write, weak=False)

        def _sub_update(pk):
            logger.info("repl_db {}_update: {}".format(table, pk))
            _update_by_pk(table, pk)
        signal("%s_update" % table).connect(_sub_update, weak=False)

        def _sub_delete(pk):
            logger.info("repl_db {}_delete: {}".format(table, pk))
            _delete_by_pk(table, pk)
        signal("%s_delete" % table).connect(_sub_delete, weak=False)

    tables = (t for t in tables if t in slave_base.classes.keys())
    for table in tables:
        _sub(table)
864607
def member_del(self, member_id, reconfig=True):
        
        server_id = self._servers.host_to_server_id(
            self.member_id_to_host(member_id))
        if reconfig and member_id in [member['_id'] for member in self.members()]:
            config = self.config
            config['members'].pop(member_id)
            self.repl_update(config)
        self._servers.remove(server_id)
        return True
1189052
def create(self, id):
        
        resp = self.client.accounts.create(id=id)
        self.display(resp)
192696
def _append_request_ids(self, resp):
        
        if isinstance(resp, list):
            # Add list of request_ids if response is of type list.
            for resp_obj in resp:
                self._append_request_id(resp_obj)
        elif resp is not None:
            # Add request_ids if response contains single object.
            self._append_request_id(resp)