ReplicasManagerImpl implements ReplicasManager { @Override public void updateNumberOfReplicas( int numberOfReplicas, String... indices) { UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest( indices); Settings.Builder builder = Settings.builder(); builder.put("number_of_replicas", numberOfReplicas); updateSettingsRequest.settings(builder); try { ActionResponse actionResponse = _indicesClient.putSettings( updateSettingsRequest, RequestOptions.DEFAULT); SearchLogHelperUtil.logActionResponse(_log, actionResponse); } catch (Exception exception) { if (_log.isWarnEnabled()) { _log.warn("Unable to update number of replicas", exception); } } } ReplicasManagerImpl(IndicesClient indicesClient); @Override void updateNumberOfReplicas(
		int numberOfReplicas, String... indices);  }
@Test public void testSystemCompanyIndexIsReplicatedAndMigrated() throws Exception { long companyId = RandomTestUtil.randomLong(); setUpCompanyLocalService(companyId); ElasticsearchClientResolver elasticsearchClientResolver1 = createNode( 1); IndexCreator indexCreator1 = new IndexCreator() { { setElasticsearchClientResolver(elasticsearchClientResolver1); } }; indexCreator1.createIndex(getTestIndexName(CompanyConstants.SYSTEM)); ElasticsearchClientResolver elasticsearchClientResolver2 = createNode( 2); assert1PrimaryShardAnd2Nodes(elasticsearchClientResolver1); IndexCreator indexCreator2 = new IndexCreator() { { setElasticsearchClientResolver(elasticsearchClientResolver2); } }; indexCreator2.createIndex(getTestIndexName(companyId)); assert2PrimaryShardsAnd2Nodes(elasticsearchClientResolver2); RestHighLevelClient restHighLevelClient = elasticsearchClientResolver1.getRestHighLevelClient(); ReplicasManager replicasManager = new ReplicasManagerImpl( restHighLevelClient.indices()); replicasManager.updateNumberOfReplicas( 1, _replicasClusterContext.getTargetIndexNames()); assert2PrimaryShards1ReplicaAnd2Nodes(elasticsearchClientResolver1); createNode(3); createNode(4); _testCluster.destroyNode(1); waitForShardReroute(); assert2PrimaryShards1ReplicaAnd3Nodes(elasticsearchClientResolver2); }