@@ -177,11 +177,16 @@ public class AutoRepairUtils
177177 "SELECT %s FROM %s.%s WHERE %s = ? AND %s = ?" , COL_REPAIR_FINISH_TS , SchemaConstants .DISTRIBUTED_KEYSPACE_NAME ,
178178 SystemDistributedKeyspace .AUTO_REPAIR_HISTORY , COL_REPAIR_TYPE , COL_HOST_ID );
179179
180+ final static String SELECT_LAST_REPAIR_START_TIME_FOR_NODE = String .format (
181+ "SELECT %s FROM %s.%s WHERE %s = ? AND %s = ?" , COL_REPAIR_START_TS , SchemaConstants .DISTRIBUTED_KEYSPACE_NAME ,
182+ SystemDistributedKeyspace .AUTO_REPAIR_HISTORY , COL_REPAIR_TYPE , COL_HOST_ID );
183+
180184 static ModificationStatement delStatementRepairHistory ;
181185 static SelectStatement selectStatementRepairHistory ;
182186 static ModificationStatement delStatementPriorityStatus ;
183187 static SelectStatement selectStatementRepairPriority ;
184188 static SelectStatement selectLastRepairTimeForNode ;
189+ static SelectStatement selectLastRepairStartTimeForNode ;
185190 static ModificationStatement addPriorityHost ;
186191 static ModificationStatement insertNewRepairHistoryStatement ;
187192 static ModificationStatement recordStartRepairHistoryStatement ;
@@ -207,6 +212,8 @@ public static void setup()
207212 .forInternalCalls ());
208213 selectLastRepairTimeForNode = (SelectStatement ) QueryProcessor .getStatement (SELECT_LAST_REPAIR_TIME_FOR_NODE , ClientState
209214 .forInternalCalls ());
215+ selectLastRepairStartTimeForNode = (SelectStatement ) QueryProcessor .getStatement (SELECT_LAST_REPAIR_START_TIME_FOR_NODE , ClientState
216+ .forInternalCalls ());
210217 delStatementPriorityStatus = (ModificationStatement ) QueryProcessor .getStatement (DEL_REPAIR_PRIORITY , ClientState
211218 .forInternalCalls ());
212219 addPriorityHost = (ModificationStatement ) QueryProcessor .getStatement (ADD_PRIORITY_HOST , ClientState
@@ -382,7 +389,8 @@ public static void setForceRepairNewNode(RepairType repairType)
382389 // this function will be called when a node bootstrap finished
383390 UUID hostId = StorageService .instance .getHostIdForEndpoint (FBUtilities .getBroadcastAddressAndPort ());
384391 // insert the data first
385- insertNewRepairHistory (repairType , currentTimeMillis (), currentTimeMillis ());
392+ long timestamp = currentTimeMillis ();
393+ insertNewRepairHistory (repairType , timestamp , timestamp );
386394 setForceRepair (repairType , hostId );
387395 }
388396
@@ -407,7 +415,7 @@ public static void setForceRepair(RepairType repairType, UUID hostId)
407415 logger .info ("Set force repair repair type: {}, node: {}" , repairType , hostId );
408416 }
409417
410- public static long getLastRepairTimeForNode (RepairType repairType , UUID hostId )
418+ public static long getLastRepairFinishTimeForNode (RepairType repairType , UUID hostId )
411419 {
412420 ResultMessage .Rows rows = selectLastRepairTimeForNode .execute (QueryState .forInternalCalls (),
413421 QueryOptions .forInternalCalls (internalQueryCL ,
@@ -423,6 +431,22 @@ public static long getLastRepairTimeForNode(RepairType repairType, UUID hostId)
423431 return repairTime .one ().getLong (COL_REPAIR_FINISH_TS );
424432 }
425433
434+ public static long getLastRepairStartTimeForNode (RepairType repairType , UUID hostId )
435+ {
436+ ResultMessage .Rows rows = selectLastRepairStartTimeForNode .execute (QueryState .forInternalCalls (),
437+ QueryOptions .forInternalCalls (internalQueryCL ,
438+ Lists .newArrayList (
439+ ByteBufferUtil .bytes (repairType .toString ()),
440+ ByteBufferUtil .bytes (hostId ))),
441+ Dispatcher .RequestTime .forImmediateExecution ());
442+ UntypedResultSet repairTime = UntypedResultSet .create (rows .result );
443+ if (repairTime .isEmpty ())
444+ {
445+ return 0 ;
446+ }
447+ return repairTime .one ().getLong (COL_REPAIR_START_TS );
448+ }
449+
426450 @ VisibleForTesting
427451 public static CurrentRepairStatus getCurrentRepairStatus (RepairType repairType , List <AutoRepairHistory > autoRepairHistories , UUID myId )
428452 {
@@ -840,7 +864,8 @@ else if (!hostIdsInCurrentRing.contains(nodeHistory.hostId))
840864 if (!autoRepairHistoryIds .contains (hostId ))
841865 {
842866 logger .info ("{} for repair type {} doesn't exist in the auto repair history table, insert a new record." , repairType , hostId );
843- insertNewRepairHistory (repairType , hostId , currentTimeMillis (), currentTimeMillis ());
867+ long timestamp = currentTimeMillis ();
868+ insertNewRepairHistory (repairType , hostId , timestamp , timestamp );
844869 }
845870 }
846871
0 commit comments