Skip to content

Commit 30f241f

Browse files
committed
rename field
1 parent 9025dd8 commit 30f241f

File tree

5 files changed

+31
-31
lines changed

5 files changed

+31
-31
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/action/GetInferenceModelAction.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,38 @@ public GetInferenceModelAction() {
3434

3535
public static class Request extends AcknowledgedRequest<GetInferenceModelAction.Request> {
3636

37-
private static boolean DEFAULT_DO_NOT_PERSIST_DEFAULT_CONFIGS = false;
37+
private static boolean PERSIST_DEFAULT_CONFIGS = true;
3838

3939
private final String inferenceEntityId;
4040
private final TaskType taskType;
4141
// Default endpoint configurations are persisted on first read.
42-
// Set to true to avoid persisting on read.
43-
// This setting only applies to GET * requests it has
42+
// Set to false to avoid persisting on read.
43+
// This setting only applies to GET * requests. It has
4444
// no effect when getting a single model
45-
private final boolean doNotPersistDefaultConfigs;
45+
private final boolean persistDefaultConfig;
4646

4747
public Request(String inferenceEntityId, TaskType taskType) {
4848
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT, DEFAULT_ACK_TIMEOUT);
4949
this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId);
5050
this.taskType = Objects.requireNonNull(taskType);
51-
this.doNotPersistDefaultConfigs = DEFAULT_DO_NOT_PERSIST_DEFAULT_CONFIGS;
51+
this.persistDefaultConfig = PERSIST_DEFAULT_CONFIGS;
5252
}
5353

54-
public Request(String inferenceEntityId, TaskType taskType, boolean doNotPersistDefaultConfigs) {
54+
public Request(String inferenceEntityId, TaskType taskType, boolean persistDefaultConfig) {
5555
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT, DEFAULT_ACK_TIMEOUT);
5656
this.inferenceEntityId = Objects.requireNonNull(inferenceEntityId);
5757
this.taskType = Objects.requireNonNull(taskType);
58-
this.doNotPersistDefaultConfigs = doNotPersistDefaultConfigs;
58+
this.persistDefaultConfig = persistDefaultConfig;
5959
}
6060

6161
public Request(StreamInput in) throws IOException {
6262
super(in);
6363
this.inferenceEntityId = in.readString();
6464
this.taskType = TaskType.fromStream(in);
6565
if (in.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_DONT_PERSIST_ON_READ)) {
66-
this.doNotPersistDefaultConfigs = in.readBoolean();
66+
this.persistDefaultConfig = in.readBoolean();
6767
} else {
68-
this.doNotPersistDefaultConfigs = DEFAULT_DO_NOT_PERSIST_DEFAULT_CONFIGS;
68+
this.persistDefaultConfig = PERSIST_DEFAULT_CONFIGS;
6969
}
7070

7171
}
@@ -78,8 +78,8 @@ public TaskType getTaskType() {
7878
return taskType;
7979
}
8080

81-
public boolean isDoNotPersistDefaultConfigs() {
82-
return doNotPersistDefaultConfigs;
81+
public boolean isPersistDefaultConfig() {
82+
return persistDefaultConfig;
8383
}
8484

8585
@Override
@@ -88,7 +88,7 @@ public void writeTo(StreamOutput out) throws IOException {
8888
out.writeString(inferenceEntityId);
8989
taskType.writeTo(out);
9090
if (out.getTransportVersion().onOrAfter(TransportVersions.INFERENCE_DONT_PERSIST_ON_READ)) {
91-
out.writeBoolean(this.doNotPersistDefaultConfigs);
91+
out.writeBoolean(this.persistDefaultConfig);
9292
}
9393
}
9494

@@ -99,12 +99,12 @@ public boolean equals(Object o) {
9999
Request request = (Request) o;
100100
return Objects.equals(inferenceEntityId, request.inferenceEntityId)
101101
&& taskType == request.taskType
102-
&& doNotPersistDefaultConfigs == request.doNotPersistDefaultConfigs;
102+
&& persistDefaultConfig == request.persistDefaultConfig;
103103
}
104104

105105
@Override
106106
public int hashCode() {
107-
return Objects.hash(inferenceEntityId, taskType, doNotPersistDefaultConfigs);
107+
return Objects.hash(inferenceEntityId, taskType, persistDefaultConfig);
108108
}
109109
}
110110

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportGetInferenceModelAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected void doExecute(
6969
boolean inferenceEntityIdIsWildCard = Strings.isAllOrWildcard(request.getInferenceEntityId());
7070

7171
if (request.getTaskType() == TaskType.ANY && inferenceEntityIdIsWildCard) {
72-
getAllModels(request.isDoNotPersistDefaultConfigs(), listener);
72+
getAllModels(request.isPersistDefaultConfig(), listener);
7373
} else if (inferenceEntityIdIsWildCard) {
7474
getModelsByTaskType(request.getTaskType(), listener);
7575
} else {
@@ -100,9 +100,9 @@ private void getSingleModel(
100100
}));
101101
}
102102

103-
private void getAllModels(boolean doNotPersistEndpoints, ActionListener<GetInferenceModelAction.Response> listener) {
103+
private void getAllModels(boolean persistDefaultEndpoints, ActionListener<GetInferenceModelAction.Response> listener) {
104104
modelRegistry.getAllModels(
105-
doNotPersistEndpoints,
105+
persistDefaultEndpoints,
106106
listener.delegateFailureAndWrap((l, models) -> executor.execute(ActionRunnable.supply(l, () -> parseModels(models))))
107107
);
108108
}

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/action/TransportInferenceUsageAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected void masterOperation(
6363
ClusterState state,
6464
ActionListener<XPackUsageFeatureResponse> listener
6565
) {
66-
GetInferenceModelAction.Request getInferenceModelAction = new GetInferenceModelAction.Request("_all", TaskType.ANY, true);
66+
GetInferenceModelAction.Request getInferenceModelAction = new GetInferenceModelAction.Request("_all", TaskType.ANY, false);
6767
client.execute(GetInferenceModelAction.INSTANCE, getInferenceModelAction, listener.delegateFailureAndWrap((delegate, response) -> {
6868
Map<String, InferenceFeatureSetUsage.ModelStats> stats = new TreeMap<>();
6969
for (ModelConfigurations model : response.getEndpoints()) {

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/registry/ModelRegistry.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,19 @@ public void getModelsByTaskType(TaskType taskType, ActionListener<List<UnparsedM
228228
/**
229229
* Get all models.
230230
* If the defaults endpoint configurations have not been persisted then only
231-
* persist them if {@code doNotPersistDefaultEndpoints == true}. Persisting the
231+
* persist them if {@code persistDefaultEndpoints == true}. Persisting the
232232
* configs has the side effect of creating the index.
233233
*
234234
* Secret settings are not included
235-
* @param doNotPersistDefaultEndpoints Don't persist the defaults endpoint configurations if
236-
* not already persisted. When true this avoids the creation
237-
* of the backing index.
235+
* @param persistDefaultEndpoints Persist the defaults endpoint configurations if
236+
* not already persisted. When false this avoids the creation
237+
* of the backing index.
238238
* @param listener Models listener
239239
*/
240-
public void getAllModels(boolean doNotPersistDefaultEndpoints, ActionListener<List<UnparsedModel>> listener) {
240+
public void getAllModels(boolean persistDefaultEndpoints, ActionListener<List<UnparsedModel>> listener) {
241241
ActionListener<SearchResponse> searchListener = listener.delegateFailureAndWrap((delegate, searchResponse) -> {
242242
var foundConfigs = parseHitsAsModels(searchResponse.getHits()).stream().map(ModelRegistry::unparsedModelFromMap).toList();
243-
addAllDefaultConfigsIfMissing(doNotPersistDefaultEndpoints, foundConfigs, defaultConfigIds, delegate);
243+
addAllDefaultConfigsIfMissing(persistDefaultEndpoints, foundConfigs, defaultConfigIds, delegate);
244244
});
245245

246246
// In theory the index should only contain model config documents
@@ -259,7 +259,7 @@ public void getAllModels(boolean doNotPersistDefaultEndpoints, ActionListener<Li
259259
}
260260

261261
private void addAllDefaultConfigsIfMissing(
262-
boolean doNotPersistDefaultEndpoints,
262+
boolean persistDefaultEndpoints,
263263
List<UnparsedModel> foundConfigs,
264264
List<InferenceService.DefaultConfigId> matchedDefaults,
265265
ActionListener<List<UnparsedModel>> listener
@@ -282,13 +282,13 @@ private void addAllDefaultConfigsIfMissing(
282282
);
283283

284284
for (var required : missing) {
285-
getDefaultConfig(doNotPersistDefaultEndpoints, required, groupedListener);
285+
getDefaultConfig(persistDefaultEndpoints, required, groupedListener);
286286
}
287287
}
288288
}
289289

290290
private void getDefaultConfig(
291-
boolean doNotPersistDefaultEndpoints,
291+
boolean persistDefaultEndpoints,
292292
InferenceService.DefaultConfigId defaultConfig,
293293
ActionListener<UnparsedModel> listener
294294
) {
@@ -297,10 +297,10 @@ private void getDefaultConfig(
297297
for (var m : models) {
298298
if (m.getInferenceEntityId().equals(defaultConfig.inferenceId())) {
299299
foundModel = true;
300-
if (doNotPersistDefaultEndpoints) {
301-
listener.onResponse(modelToUnparsedModel(m));
302-
} else {
300+
if (persistDefaultEndpoints) {
303301
storeDefaultEndpoint(m, () -> listener.onResponse(modelToUnparsedModel(m)));
302+
} else {
303+
listener.onResponse(modelToUnparsedModel(m));
304304
}
305305
break;
306306
}

x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/action/GetInferenceModelRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected GetInferenceModelAction.Request mutateInstance(GetInferenceModelAction
3939
case 2 -> new GetInferenceModelAction.Request(
4040
instance.getInferenceEntityId(),
4141
instance.getTaskType(),
42-
instance.isDoNotPersistDefaultConfigs() == false
42+
instance.isPersistDefaultConfig() == false
4343
);
4444
default -> throw new UnsupportedOperationException();
4545
};

0 commit comments

Comments
 (0)