[Rename] XContentElasticsearchExtension class in server module (#178)
This commit refactors XContentElasticsearchExtension class in the server module to XContentOpenSearchExtension. References and usages throughout the rest of the codebase are fully refactored. Signed-off-by: Nicholas Knize <nknize@amazon.com>
This commit is contained in:
parent
84d953b1c6
commit
a08a0edaa3
|
@ -57,11 +57,11 @@ import java.util.Objects;
|
|||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* SPI extensions for Elasticsearch-specific classes (like the Lucene or Joda
|
||||
* SPI extensions for OpenSearch-specific classes (like the Lucene or Joda
|
||||
* dependency classes) that need to be encoded by {@link XContentBuilder} in a
|
||||
* specific way.
|
||||
*/
|
||||
public class XContentElasticsearchExtension implements XContentBuilderExtension {
|
||||
public class XContentOpenSearchExtension implements XContentBuilderExtension {
|
||||
|
||||
public static final DateTimeFormatter DEFAULT_DATE_PRINTER = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
|
||||
public static final DateFormatter DEFAULT_FORMATTER = DateFormatter.forPattern("strict_date_optional_time_nanos");
|
|
@ -29,7 +29,7 @@ import org.elasticsearch.cluster.routing.RecoverySource.SnapshotRecoverySource;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.Table;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentElasticsearchExtension;
|
||||
import org.elasticsearch.common.xcontent.XContentOpenSearchExtension;
|
||||
import org.elasticsearch.indices.recovery.RecoveryState;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestResponse;
|
||||
|
@ -156,9 +156,9 @@ public class RestCatRecoveryAction extends AbstractCatAction {
|
|||
t.startRow();
|
||||
t.addCell(index);
|
||||
t.addCell(state.getShardId().id());
|
||||
t.addCell(XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().startTime()));
|
||||
t.addCell(XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().startTime()));
|
||||
t.addCell(state.getTimer().startTime());
|
||||
t.addCell(XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().stopTime()));
|
||||
t.addCell(XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().stopTime()));
|
||||
t.addCell(state.getTimer().stopTime());
|
||||
t.addCell(new TimeValue(state.getTimer().time()));
|
||||
t.addCell(state.getRecoverySource().getType().toString().toLowerCase(Locale.ROOT));
|
||||
|
|
|
@ -1 +1 @@
|
|||
org.elasticsearch.common.xcontent.XContentElasticsearchExtension
|
||||
org.elasticsearch.common.xcontent.XContentOpenSearchExtension
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentElasticsearchExtension;
|
||||
import org.elasticsearch.common.xcontent.XContentOpenSearchExtension;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.index.Index;
|
||||
|
@ -73,7 +73,7 @@ public class IndexGraveyardTests extends ESTestCase {
|
|||
if (graveyard.getTombstones().size() > 0) {
|
||||
// check that date properly printed
|
||||
assertThat(Strings.toString(graveyard, false, true),
|
||||
containsString(XContentElasticsearchExtension.DEFAULT_DATE_PRINTER
|
||||
containsString(XContentOpenSearchExtension.DEFAULT_DATE_PRINTER
|
||||
.print(graveyard.getTombstones().get(0).getDeleteDateInMillis())));
|
||||
}
|
||||
XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(builder));
|
||||
|
|
|
@ -444,7 +444,7 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
long date = Math.abs(randomLong() % (2 * (long) 10e11)); // 1970-01-01T00:00:00Z - 2033-05-18T05:33:20.000+02:00
|
||||
final DateTime t5 = new DateTime(date, randomDateTimeZone());
|
||||
|
||||
expected = "{'t5':'" + XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(t5) + "'}";
|
||||
expected = "{'t5':'" + XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(t5) + "'}";
|
||||
assertResult(expected, () -> builder().startObject().timeField("t5", t5).endObject());
|
||||
assertResult(expected, () -> builder().startObject().field("t5").timeValue(t5).endObject());
|
||||
|
||||
|
@ -663,7 +663,7 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
final String paths = Constants.WINDOWS ? "{'objects':['a\\\\b\\\\c','d\\\\e']}" : "{'objects':['a/b/c','d/e']}";
|
||||
objects.put(paths, new Object[]{PathUtils.get("a", "b", "c"), PathUtils.get("d", "e")});
|
||||
|
||||
final DateTimeFormatter formatter = XContentElasticsearchExtension.DEFAULT_DATE_PRINTER;
|
||||
final DateTimeFormatter formatter = XContentOpenSearchExtension.DEFAULT_DATE_PRINTER;
|
||||
final Date d1 = new DateTime(2016, 1, 1, 0, 0, DateTimeZone.UTC).toDate();
|
||||
final Date d2 = new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC).toDate();
|
||||
objects.put("{'objects':['" + formatter.print(d1.getTime()) + "','" + formatter.print(d2.getTime()) + "']}", new Object[]{d1, d2});
|
||||
|
@ -711,7 +711,7 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
|||
final String path = Constants.WINDOWS ? "{'object':'a\\\\b\\\\c'}" : "{'object':'a/b/c'}";
|
||||
object.put(path, PathUtils.get("a", "b", "c"));
|
||||
|
||||
final DateTimeFormatter formatter = XContentElasticsearchExtension.DEFAULT_DATE_PRINTER;
|
||||
final DateTimeFormatter formatter = XContentOpenSearchExtension.DEFAULT_DATE_PRINTER;
|
||||
final Date d1 = new DateTime(2016, 1, 1, 0, 0, DateTimeZone.UTC).toDate();
|
||||
object.put("{'object':'" + formatter.print(d1.getTime()) + "'}", d1);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.geo.GeoPoint;
|
|||
import org.elasticsearch.common.io.PathUtils;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentElasticsearchExtension;
|
||||
import org.elasticsearch.common.xcontent.XContentOpenSearchExtension;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -179,9 +179,9 @@ public class XContentBuilderTests extends ESTestCase {
|
|||
|
||||
public void testDateTypesConversion() throws Exception {
|
||||
Date date = new Date();
|
||||
String expectedDate = XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(date.getTime());
|
||||
String expectedDate = XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(date.getTime());
|
||||
Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"), Locale.ROOT);
|
||||
String expectedCalendar = XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(calendar.getTimeInMillis());
|
||||
String expectedCalendar = XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(calendar.getTimeInMillis());
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.startObject().timeField("date", date).endObject();
|
||||
assertThat(Strings.toString(builder), equalTo("{\"date\":\"" + expectedDate + "\"}"));
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.elasticsearch.cluster.routing.TestShardRouting;
|
|||
import org.elasticsearch.common.Randomness;
|
||||
import org.elasticsearch.common.Table;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentElasticsearchExtension;
|
||||
import org.elasticsearch.common.xcontent.XContentOpenSearchExtension;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.recovery.RecoveryState;
|
||||
|
@ -161,9 +161,9 @@ public class RestRecoveryActionTests extends ESTestCase {
|
|||
final List<Object> expectedValues = Arrays.asList(
|
||||
"index",
|
||||
i,
|
||||
XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().startTime()),
|
||||
XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().startTime()),
|
||||
state.getTimer().startTime(),
|
||||
XContentElasticsearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().stopTime()),
|
||||
XContentOpenSearchExtension.DEFAULT_DATE_PRINTER.print(state.getTimer().stopTime()),
|
||||
state.getTimer().stopTime(),
|
||||
new TimeValue(state.getTimer().time()),
|
||||
state.getRecoverySource().getType().name().toLowerCase(Locale.ROOT),
|
||||
|
|
Loading…
Reference in New Issue