Skip to content

Commit 862af7b

Browse files
committed
address comments
Signed-off-by: Kaushal Kumar <[email protected]>
1 parent 040ed4c commit 862af7b

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

server/src/main/java/org/opensearch/wlm/QueryGroupTask.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import org.opensearch.tasks.CancellableTask;
1818

1919
import java.util.Map;
20-
import java.util.Optional;
2120
import java.util.function.LongSupplier;
2221
import java.util.function.Supplier;
2322

@@ -82,12 +81,11 @@ public final String getQueryGroupId() {
8281
* @param threadContext current threadContext
8382
*/
8483
public final void setQueryGroupId(final ThreadContext threadContext) {
85-
this.queryGroupId = Optional.ofNullable(threadContext)
86-
.map(
87-
threadContext1 -> Optional.ofNullable(threadContext1.getHeader(QUERY_GROUP_ID_HEADER))
88-
.orElse(DEFAULT_QUERY_GROUP_ID_SUPPLIER.get())
89-
)
90-
.orElse(DEFAULT_QUERY_GROUP_ID_SUPPLIER.get());
84+
if (threadContext != null && threadContext.getHeader(QUERY_GROUP_ID_HEADER) != null) {
85+
this.queryGroupId = threadContext.getHeader(QUERY_GROUP_ID_HEADER);
86+
} else {
87+
this.queryGroupId = DEFAULT_QUERY_GROUP_ID_SUPPLIER.get();
88+
}
9189
}
9290

9391
public long getElapsedTime() {

server/src/main/java/org/opensearch/wlm/stats/QueryGroupStats.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package org.opensearch.wlm.stats;
1010

11-
import org.opensearch.Version;
1211
import org.opensearch.core.common.io.stream.StreamInput;
1312
import org.opensearch.core.common.io.stream.StreamOutput;
1413
import org.opensearch.core.common.io.stream.Writeable;
@@ -124,9 +123,7 @@ public QueryGroupStatsHolder(StreamInput in) throws IOException {
124123
this.rejections = in.readVLong();
125124
this.failures = in.readVLong();
126125
this.totalCancellations = in.readVLong();
127-
if (in.getVersion().onOrAfter(Version.V_2_18_0)) {
128-
this.shardCompletions = in.readVLong();
129-
}
126+
this.shardCompletions = in.readVLong();
130127
this.resourceStats = in.readMap((i) -> ResourceType.fromName(i.readString()), ResourceStats::new);
131128
}
132129

@@ -164,9 +161,7 @@ public static void writeTo(StreamOutput out, QueryGroupStatsHolder statsHolder)
164161
out.writeVLong(statsHolder.rejections);
165162
out.writeVLong(statsHolder.failures);
166163
out.writeVLong(statsHolder.totalCancellations);
167-
if (out.getVersion().onOrAfter(Version.V_2_18_0)) {
168-
out.writeVLong(statsHolder.shardCompletions);
169-
}
164+
out.writeVLong(statsHolder.shardCompletions);
170165
out.writeMap(statsHolder.resourceStats, (o, val) -> o.writeString(val.getName()), ResourceStats::writeTo);
171166
}
172167

0 commit comments

Comments
 (0)