Skip to content

Commit

Permalink
Addressing comment
Browse files Browse the repository at this point in the history
Signed-off-by: Bharathwaj G <bharath78910@gmail.com>
  • Loading branch information
bharath-techie committed Aug 4, 2022
1 parent 1c702de commit babab92
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
* Transport request for retrieving PITs segment information
*/
public class PitSegmentsRequest extends BroadcastRequest<PitSegmentsRequest> {

boolean verbose = false;
private List<String> pitIds;

Expand Down Expand Up @@ -54,7 +53,7 @@ public boolean isVerbose() {
* Sets the <code>verbose</code> option.
* @see #isVerbose()
*/
public void isVerbose(boolean v) {
public void setVerbose(boolean v) {
verbose = v;
}

Expand All @@ -67,7 +66,6 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeStringArray(pitIds.toArray(new String[pitIds.size()]));
}
out.writeBoolean(verbose);

}

public Collection<String> getPitIds() {
Expand Down
65 changes: 0 additions & 65 deletions server/src/test/java/org/opensearch/search/PitMultiNodeTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
import org.opensearch.action.LatchedActionListener;
import org.opensearch.action.admin.cluster.state.ClusterStateRequest;
import org.opensearch.action.admin.cluster.state.ClusterStateResponse;
import org.opensearch.action.admin.indices.segments.IndicesSegmentResponse;
import org.opensearch.action.admin.indices.segments.PitSegmentsAction;
import org.opensearch.action.admin.indices.segments.PitSegmentsRequest;
import org.opensearch.action.search.CreatePitAction;
import org.opensearch.action.search.CreatePitRequest;
import org.opensearch.action.search.CreatePitResponse;
Expand Down Expand Up @@ -98,7 +95,6 @@ public Settings onNodeStopped(String nodeName) throws Exception {
ActionFuture<CreatePitResponse> execute = client().execute(CreatePitAction.INSTANCE, request);
ExecutionException ex = expectThrows(ExecutionException.class, execute::get);
assertTrue(ex.getMessage().contains("Failed to execute phase [create_pit]"));
assertTrue(ex.getMessage().contains("Partial shards failure"));
return super.onNodeStopped(nodeName);
}
});
Expand Down Expand Up @@ -144,7 +140,6 @@ public Settings onNodeStopped(String nodeName) throws Exception {
assertEquals(0, searchResponse.getSkippedShards());
assertEquals(2, searchResponse.getTotalShards());
PitTestsUtil.assertUsingGetAllPits(client(), pitResponse.getId(), pitResponse.getCreationTime());
assertSegments(false, client());
return super.onNodeStopped(nodeName);
}
});
Expand Down Expand Up @@ -461,64 +456,4 @@ public void onFailure(Exception e) {}
}
}

public void testConcurrentGetSegmentsWithDeletes() throws InterruptedException, ExecutionException {
CreatePitRequest createPitRequest = new CreatePitRequest(TimeValue.timeValueDays(1), true);
createPitRequest.setIndices(new String[] { "index" });
List<String> pitIds = new ArrayList<>();
String id = client().execute(CreatePitAction.INSTANCE, createPitRequest).get().getId();
pitIds.add(id);
DeletePitRequest deletePITRequest = new DeletePitRequest(pitIds);
AtomicInteger numSuccess = new AtomicInteger();
TestThreadPool testThreadPool = null;
try {
testThreadPool = new TestThreadPool(PitMultiNodeTests.class.getName());
int concurrentRuns = randomIntBetween(20, 50);

List<Runnable> operationThreads = new ArrayList<>();
CountDownLatch countDownLatch = new CountDownLatch(concurrentRuns);
long randomDeleteThread = randomLongBetween(0, concurrentRuns - 1);
for (int i = 0; i < concurrentRuns; i++) {
int currentThreadIteration = i;
Runnable thread = () -> {
if (currentThreadIteration == randomDeleteThread) {
LatchedActionListener listener = new LatchedActionListener<>(new ActionListener<IndicesSegmentResponse>() {
@Override
public void onResponse(IndicesSegmentResponse indicesSegmentResponse) {
if (indicesSegmentResponse.getShardFailures() == null
|| indicesSegmentResponse.getShardFailures().length == 0) {
numSuccess.incrementAndGet();
}
}

@Override
public void onFailure(Exception e) {}
}, countDownLatch);
client().execute(PitSegmentsAction.INSTANCE, new PitSegmentsRequest(), listener);
} else {
LatchedActionListener listener = new LatchedActionListener<>(new ActionListener<DeletePitResponse>() {
@Override
public void onResponse(DeletePitResponse deletePitResponse) {
if (deletePitResponse.getDeletePitResults().get(0).isSuccessful()) {
numSuccess.incrementAndGet();
}
}

@Override
public void onFailure(Exception e) {}
}, countDownLatch);
client().execute(DeletePitAction.INSTANCE, deletePITRequest, listener);
}
};
operationThreads.add(thread);
}
TestThreadPool finalTestThreadPool = testThreadPool;
operationThreads.forEach(runnable -> finalTestThreadPool.executor("generic").execute(runnable));
countDownLatch.await();
assertEquals(concurrentRuns, numSuccess.get());

} finally {
ThreadPool.terminate(testThreadPool, 500, TimeUnit.MILLISECONDS);
}
}

}

0 comments on commit babab92

Please sign in to comment.