2020package com .secdec .codepulse .tracer
2121
2222import java .util .concurrent .TimeoutException
23+
2324import scala .concurrent .Await
2425import scala .concurrent .ExecutionContext
2526import scala .concurrent .Future
26- import scala .concurrent .duration .DurationInt
27+ import scala .concurrent .duration .{ DurationInt , FiniteDuration }
2728import scala .util .Failure
2829import scala .util .Success
2930import com .codedx .codepulse .hq .trace .Trace
@@ -169,7 +170,13 @@ object AkkaTracingTarget {
169170 deletionKey -> deletionFuture
170171 }
171172
172- def connectTrace (trace : Trace )(implicit exc : ExecutionContext ) = getAckFuture(TraceConnected (trace))
173+ def connectTrace (trace : Trace )(implicit exc : ExecutionContext ) = {
174+ // TraceSettingsCreator.generateTraceSettings may take awhile to complete if
175+ // there are many records in the tree_node_data table. Use a timeout duration of
176+ // 10 minutes to effectively make a synchronous transition between the Initializing
177+ // and Tracing states
178+ getAckFuture(TraceConnected (trace))(exc = exc, timeout = new Timeout (10 .minutes))
179+ }
173180
174181 def cancelPendingDeletion ()(implicit exc : ExecutionContext ) = getAckFuture(CancelPendingDeletion )
175182 def finalizeDeletion (key : DeletionKey )(implicit exc : ExecutionContext ) = getAckFuture(FinalizeDeletion (key))
@@ -181,8 +188,7 @@ object AkkaTracingTarget {
181188 * containing that message. If any other message is sent, the future fails
182189 * with no exception message.
183190 */
184- private def getAckFuture (msg : TargetRequest )(implicit exc : ExecutionContext ) = {
185- implicit val timeout = new Timeout (5 .seconds)
191+ private def getAckFuture (msg : TargetRequest )(implicit exc : ExecutionContext , timeout : Timeout = new Timeout (5 .seconds)) = {
186192 val future = actor ? msg
187193 future flatMap {
188194 case Ack => Future successful ()
0 commit comments