Merge branch 'stable-2.15'

* stable-2.15:
  ElasticIndexVersionDiscovery: Convert to Java stream API
  ElasticVersionManager: Use correct configuration value for prefix
  Elasticsearch: Refactor generation of bulk requests
  Rename AbstractReindexIT to AbstractReindexTests
  ElasticReindexIT: Use @ConfigSuite.Default instead of @ConfigSuite.Config

Change-Id: Iacd3f2db3728a9c1936170b575016973bf0336d9
This commit is contained in:
David Pursehouse
2018-05-31 21:27:46 +09:00
12 changed files with 258 additions and 78 deletions

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.elasticsearch.bulk;
import java.util.ArrayList;
import java.util.List;
public abstract class BulkRequest {
private final List<BulkRequest> requests = new ArrayList<>();
protected BulkRequest() {
add(this);
}
public BulkRequest add(BulkRequest request) {
requests.add(request);
return this;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
for (BulkRequest request : requests) {
builder.append(request.getRequest());
}
return builder.toString();
}
protected abstract String getRequest();
}