Skip to content

Commit

Permalink
Rename method refreshCacheVersion to updateCacheVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret committed Apr 22, 2024
1 parent 492b2a5 commit f05700a
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void createComponents() throws Exception {
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, ActionListener.class).onResponse(AcknowledgedResponse.TRUE);
return Void.TYPE;
}).when(modelCacheMetadataService).refreshCacheVersion(any(ActionListener.class));
}).when(modelCacheMetadataService).updateCacheVersion(any(ActionListener.class));
trainedModelProvider = new TrainedModelProvider(client(), modelCacheMetadataService, xContentRegistry());
waitForMlTemplates();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void createComponents() throws Exception {
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, ActionListener.class).onResponse(AcknowledgedResponse.TRUE);
return Void.TYPE;
}).when(modelCacheMetadataService).refreshCacheVersion(any(ActionListener.class));
}).when(modelCacheMetadataService).updateCacheVersion(any(ActionListener.class));
trainedModelProvider = new TrainedModelProvider(client(), modelCacheMetadataService, xContentRegistry());
waitForMlTemplates();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void createComponents() throws Exception {
doAnswer(invocationOnMock -> {
invocationOnMock.getArgument(0, ActionListener.class).onResponse(AcknowledgedResponse.TRUE);
return Void.TYPE;
}).when(modelCacheMetadataService).refreshCacheVersion(any(ActionListener.class));
}).when(modelCacheMetadataService).updateCacheVersion(any(ActionListener.class));
trainedModelProvider = new TrainedModelProvider(client(), modelCacheMetadataService, xContentRegistry());
waitForMlTemplates();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void masterOperation(
ClusterState state,
ActionListener<AcknowledgedResponse> listener
) {
modelCacheMetadataService.refreshCacheVersion(listener);
modelCacheMetadataService.updateCacheVersion(listener);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public TrainedModelCacheMetadataService(ClusterService clusterService, Client cl
clusterService.addListener(this);
}

public void refreshCacheVersion(ActionListener<AcknowledgedResponse> listener) {
public void updateCacheVersion(ActionListener<AcknowledgedResponse> listener) {
if (this.isMasterNode == false) {
client.execute(FlushTrainedModelCacheAction.INSTANCE, new FlushTrainedModelCacheAction.Request(), listener);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
import static org.elasticsearch.xpack.core.ml.job.messages.Messages.INFERENCE_FAILED_TO_DESERIALIZE;
Expand Down Expand Up @@ -1387,7 +1386,7 @@ private static IndexRequest createRequest(IndexRequest request, String docId, To
}

private void refreshCacheVersion(ActionListener<Boolean> listener) {
modelCacheMetadataService.refreshCacheVersion(ActionListener.wrap(resp -> {
modelCacheMetadataService.updateCacheVersion(ActionListener.wrap(resp -> {
// Checking the response is always AcknowledgedResponse.TRUE because AcknowledgedResponse.FALSE does not make sense.
// Errors should be reported through the onFailure method of the listener.
assert resp.equals(AcknowledgedResponse.TRUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private void setupMocks() {
ActionListener listener = invocationOnMock.getArgument(0, ActionListener.class);
listener.onResponse(AcknowledgedResponse.TRUE);
return null;
}).when(modelCacheMetadataService).refreshCacheVersion(any(ActionListener.class));
}).when(modelCacheMetadataService).updateCacheVersion(any(ActionListener.class));
}

@After
Expand All @@ -69,7 +69,7 @@ public void testOperation() {
action.masterOperation(null, request, clusterState, listener);

assertTrue(ack.get().isAcknowledged());
verify(modelCacheMetadataService).refreshCacheVersion(listener);
verify(modelCacheMetadataService).updateCacheVersion(listener);
}

private TransportFlushTrainedModelCacheAction createAction(ClusterService clusterService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void testRefreshCacheVersionOnMasterNode() {

@SuppressWarnings("unchecked")
final ActionListener<AcknowledgedResponse> listener = mock(ActionListener.class);
modelCacheMetadataService.refreshCacheVersion(listener);
modelCacheMetadataService.updateCacheVersion(listener);

// Verify a cluster state update task were submitted.
ArgumentCaptor<CacheMetadataUpdateTask> updateTaskCaptor = ArgumentCaptor.forClass(RefreshCacheMetadataVersionTask.class);
Expand All @@ -103,7 +103,7 @@ public void testRefreshCacheVersionOnNonMasterNode() {

@SuppressWarnings("unchecked")
final ActionListener<AcknowledgedResponse> listener = mock(ActionListener.class);
modelCacheMetadataService.refreshCacheVersion(listener);
modelCacheMetadataService.updateCacheVersion(listener);

// Check a FlushTrainedModelCacheAction request is emitted to the master node, that will flush the cache.
verify(client).execute(
Expand Down

0 comments on commit f05700a

Please sign in to comment.