public static final String CUSTOM = "custom";
public static final String KEYWORD = "keyword";
public static final String CLASSIC = "classic";
+ public static final boolean REFRESH_IMMEDIATE = true; // ES 5: replace with org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE
+ public static final boolean REFRESH_NONE = false; // ES 5: replace with org.elasticsearch.action.support.WriteRequest.RefreshPolicy.NONE
public static final String TRUNCATE = "truncate";
import org.sonar.server.es.EsClient;
import org.sonar.server.es.IndexType;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
+
public class MetadataIndex {
private final EsClient esClient;
esClient.prepareIndex(MetadataIndexDefinition.INDEX_TYPE_METADATA)
.setId(id)
.setSource(MetadataIndexDefinition.FIELD_VALUE, hash)
- .setRefresh(true)
+ .setRefresh(REFRESH_IMMEDIATE) // ES 5: change to setRefreshPolicy
.get();
}
}
import static java.util.Collections.emptyList;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_NONE;
import static org.sonar.server.issue.index.IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID;
import static org.sonar.server.issue.index.IssueIndexDefinition.INDEX_TYPE_ISSUE;
import org.sonar.server.permission.index.AuthorizationScope;
import org.sonar.server.permission.index.NeedAuthorizationIndexer;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.INDEX_TYPE_PROJECT_MEASURES;
public class ProjectMeasuresIndexer implements ProjectIndexer, NeedAuthorizationIndexer {
import static java.util.Collections.emptyList;
import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
import static org.sonar.core.util.stream.MoreCollectors.toSet;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
/**
* Populates the types "authorization" of each index requiring project
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.asList;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
public class EsTester extends ExternalResource {
public void putDocuments(IndexType indexType, BaseDoc... docs) {
try {
- BulkRequestBuilder bulk = client.prepareBulk().setRefresh(true);
+ BulkRequestBuilder bulk = client.prepareBulk()
+ .setRefresh(REFRESH_IMMEDIATE); // ES 5: change to setRefreshPolicy
for (BaseDoc doc : docs) {
bulk.add(new IndexRequest(indexType.getIndex(), indexType.getType(), doc.getId())
.parent(doc.getParent())
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
+import static org.sonar.server.es.DefaultIndexSettings.REFRESH_IMMEDIATE;
import static org.sonar.server.test.index.TestIndexDefinition.FIELD_DURATION_IN_MS;
import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID;
import static org.sonar.server.test.index.TestIndexDefinition.FIELD_MESSAGE;
.setId(uuid)
.setRouting(projectUuid)
.setSource(IOUtils.toString(getClass().getResource(format("%s/%s_%s_%s.json", getClass().getSimpleName(), projectUuid, fileUuid, testName))))
- .setRefresh(true)
+ .setRefresh(REFRESH_IMMEDIATE) // ES 5: change to setRefreshPolicy
.get();
}