3434import com .datastax .mgmtapi .resources .models .ScrubRequest ;
3535import com .datastax .mgmtapi .resources .models .Table ;
3636import com .datastax .mgmtapi .resources .models .TakeSnapshotRequest ;
37+ import com .datastax .mgmtapi .resources .v2 .models .RepairParallelism ;
38+ import com .datastax .mgmtapi .resources .v2 .models .RepairRequestResponse ;
3739import com .datastax .oss .driver .api .core .metadata .schema .ClusteringOrder ;
3840import com .fasterxml .jackson .core .JsonProcessingException ;
3941import com .fasterxml .jackson .core .type .TypeReference ;
4042import com .fasterxml .jackson .databind .ObjectMapper ;
4143import com .fasterxml .jackson .databind .json .JsonMapper ;
44+ import com .google .common .base .Function ;
4245import com .google .common .base .Splitter ;
4346import com .google .common .collect .ImmutableList ;
4447import com .google .common .collect .ImmutableMap ;
4548import com .google .common .util .concurrent .Uninterruptibles ;
49+ import io .netty .handler .codec .http .FullHttpResponse ;
4650import io .netty .util .IllegalReferenceCountException ;
4751import java .io .IOException ;
4852import java .net .URI ;
@@ -1040,34 +1044,58 @@ public void ensureStatusChanges() throws Exception {
10401044 assumeTrue (IntegrationTestUtils .shouldRun ());
10411045 ensureStarted ();
10421046 NettyHttpClient client = new NettyHttpClient (BASE_URL );
1043- DefaultApi apiClient = new DefaultApi (new ApiClient ().setBasePath (BASE_HOST ));
1044- com .datastax .mgmtapi .client .model .RepairRequest req =
1045- new com .datastax .mgmtapi .client .model .RepairRequest ()
1046- .keyspace ("system_distributed" )
1047- .fullRepair (true )
1048- .notifications (true )
1049- .repairParallelism (
1050- com .datastax .mgmtapi .client .model .RepairRequest .RepairParallelismEnum .SEQUENTIAL )
1051- .associatedTokens (
1052- Collections .singletonList (
1053- new com .datastax .mgmtapi .client .model .RingRange ()
1054- .start (Long .valueOf (-1 ))
1055- .end (Long .valueOf (100 ))));
1047+
1048+
1049+ com .datastax .mgmtapi .resources .v2 .models .RepairRequest req
1050+ = new com .datastax .mgmtapi .resources .v2 .models .RepairRequest (
1051+ "system_distributed" ,
1052+ null ,
1053+ true ,
1054+ true ,
1055+ Collections .singletonList (
1056+ new com .datastax .mgmtapi .resources .v2 .models .RingRange (-1L , 100L )
1057+ ),
1058+ RepairParallelism .SEQUENTIAL ,
1059+ null ,
1060+ null
1061+ );
1062+
10561063 logger .info ("Sending repair request: {}" , req );
1057- String jobID = apiClient .putRepairV2 (req ).getRepairId ();
1058- Integer repairID = Integer .parseInt (jobID .substring (7 )); // Trimming off "repair-" prefix.
1064+ URI repairUri =
1065+ new URIBuilder (BASE_PATH_V2 + "repairs" ).build ();
1066+ Pair <Integer , String > repairResp = client
1067+ .put (
1068+ repairUri .toURL (),
1069+ new ObjectMapper ().writeValueAsString (req ))
1070+ .thenApply (this ::responseAsCodeAndBody ).join ();
1071+ String jobID = new ObjectMapper ()
1072+ .readValue (repairResp .getRight (), RepairRequestResponse .class )
1073+ .repairID ;
1074+ Integer repairID = Integer .parseInt (
1075+ jobID .substring (7 ) // Trimming off "repair-" prefix.
1076+ );
10591077 logger .info ("Repair ID: {}" , repairID );
10601078 assertThat (repairID ).isNotNull ();
10611079 assertThat (repairID ).isGreaterThan (0 );
10621080
1063- com .datastax .mgmtapi .client .model .Job status = apiClient .getJobStatus (jobID );
1064- logger .info ("Repair job status: {}" , status );
1065- assertThat (status .getStatus ()).isNotNull ();
1066- assertThat (status .getStatusChanges ()).isNotNull ();
1067- await ().atMost (5 , SECONDS ).until (() -> status .getStatusChanges ().size () > 0 );
1068- await ()
1069- .atMost (5 , SECONDS )
1070- .until (
1071- () -> status .getStatus () == com .datastax .mgmtapi .client .model .Job .StatusEnum .COMPLETED );
1081+ URI statusUri =
1082+ new URIBuilder (BASE_PATH_V2 + "/ops/executor/job" ).addParameter ("job_id" , jobID ).build ();
1083+ Pair <Integer , String > statusResp = client
1084+ .get (statusUri .toURL ())
1085+ .thenApply (this ::responseAsCodeAndBody ).join ();
1086+ logger .info ("Repair job status: {}" , statusResp );
1087+ Job jobStatus = new ObjectMapper ().readValue (statusResp .getRight (), Job .class );
1088+
1089+ assertThat (jobStatus .getStatus ()).isNotNull ();
1090+ assertThat (jobStatus .getStatusChanges ()).isNotNull ();
1091+ await ().atMost (5 , SECONDS ).until (() -> {
1092+ Pair <Integer , String > statusResp2 = client
1093+ .get (statusUri .toURL ())
1094+ .thenApply (this ::responseAsCodeAndBody ).join ();
1095+ logger .info ("Repair job status: {}" , statusResp );
1096+ Job jobStatus2 = new ObjectMapper ().readValue (statusResp .getRight (), Job .class );
1097+ return jobStatus2 .getStatusChanges ().size () > 0 &&
1098+ jobStatus2 .getStatus () == com .datastax .mgmtapi .resources .models .Job .JobStatus .COMPLETED ;
1099+ });
10721100 }
1073- }
1101+ }
0 commit comments