Skip to content

Commit 65a04a2

Browse files
committed
refactoring in remote routing table service
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
1 parent 6776c03 commit 65a04a2

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

server/src/main/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableService.java

+2-21
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private String getIndexRoutingFileName() {
237237
public CheckedRunnable<IOException> getAsyncIndexMetadataReadAction(
238238
String uploadedFilename,
239239
Index index,
240-
LatchedActionListener<RemoteIndexRoutingResult> latchedActionListener) {
240+
LatchedActionListener<IndexRoutingTable> latchedActionListener) {
241241
int idx = uploadedFilename.lastIndexOf("/");
242242
String blobFileName = uploadedFilename.substring(idx+1);
243243
BlobContainer blobContainer = blobStoreRepository.blobStore().blobContainer( BlobPath.cleanPath().add(uploadedFilename.substring(0,idx)));
@@ -246,7 +246,7 @@ public CheckedRunnable<IOException> getAsyncIndexMetadataReadAction(
246246
blobContainer,
247247
blobFileName,
248248
threadPool.executor(ThreadPool.Names.GENERIC),
249-
ActionListener.wrap(response -> latchedActionListener.onResponse(new RemoteIndexRoutingResult(index.getName(), response.readIndexRoutingTable(index))), latchedActionListener::onFailure)
249+
ActionListener.wrap(response -> latchedActionListener.onResponse(response.readIndexRoutingTable(index)), latchedActionListener::onFailure)
250250
);
251251
}
252252

@@ -255,7 +255,6 @@ public void readAsync(BlobContainer blobContainer, String name, ExecutorService
255255
try {
256256
listener.onResponse(read(blobContainer, name));
257257
} catch (Exception e) {
258-
logger.error("routing table download failed : ", e);
259258
listener.onFailure(e);
260259
}
261260
});
@@ -307,22 +306,4 @@ public void start() {
307306
blobStoreRepository = (BlobStoreRepository) repository;
308307
}
309308

310-
public static class RemoteIndexRoutingResult {
311-
String indexName;
312-
IndexRoutingTable indexRoutingTable;
313-
314-
public RemoteIndexRoutingResult(String indexName, IndexRoutingTable indexRoutingTable) {
315-
this.indexName = indexName;
316-
this.indexRoutingTable = indexRoutingTable;
317-
}
318-
319-
public String getIndexName() {
320-
return indexName;
321-
}
322-
323-
public IndexRoutingTable getIndexRoutingTable() {
324-
return indexRoutingTable;
325-
}
326-
}
327-
328309
}

server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateService.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ private ClusterState readClusterStateInParallel(
985985
CountDownLatch latch = new CountDownLatch(totalReadTasks);
986986
List<CheckedRunnable<IOException>> asyncMetadataReadActions = new ArrayList<>();
987987
List<RemoteReadResult> readResults = new ArrayList<>();
988-
List<RemoteRoutingTableService.RemoteIndexRoutingResult> readIndexRoutingTableResults = new ArrayList<>();
988+
List<IndexRoutingTable> readIndexRoutingTableResults = new ArrayList<>();
989989
List<Exception> exceptionList = Collections.synchronizedList(new ArrayList<>(totalReadTasks));
990990

991991
LatchedActionListener<RemoteReadResult> listener = new LatchedActionListener<>(
@@ -1012,7 +1012,7 @@ private ClusterState readClusterStateInParallel(
10121012
);
10131013
}
10141014

1015-
LatchedActionListener<RemoteRoutingTableService.RemoteIndexRoutingResult> routingTableLatchedActionListener = new LatchedActionListener<>(
1015+
LatchedActionListener<IndexRoutingTable> routingTableLatchedActionListener = new LatchedActionListener<>(
10161016
ActionListener.wrap(
10171017
response -> {
10181018
logger.debug("Successfully read cluster state component from remote");
@@ -1187,8 +1187,8 @@ private ClusterState readClusterStateInParallel(
11871187
}
11881188
});
11891189

1190-
readIndexRoutingTableResults.forEach(remoteIndexRoutingResult -> {
1191-
indicesRouting.put(remoteIndexRoutingResult.getIndexName(), remoteIndexRoutingResult.getIndexRoutingTable());
1190+
readIndexRoutingTableResults.forEach(indexRoutingTable -> {
1191+
indicesRouting.put(indexRoutingTable.getIndex().getName(), indexRoutingTable);
11921192
});
11931193

11941194
metadataBuilder.indices(indexMetadataMap);

0 commit comments

Comments
 (0)