storm-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] srdo commented on a change in pull request #2957: STORM-3335 allow timing out when scheduling a topology
Date Sat, 09 Feb 2019 08:30:18 GMT
srdo commented on a change in pull request #2957: STORM-3335 allow timing out when scheduling
a topology
URL: https://github.com/apache/storm/pull/2957#discussion_r255291976
 
 

 ##########
 File path: storm-server/src/main/java/org/apache/storm/scheduler/resource/ResourceAwareScheduler.java
 ##########
 @@ -136,10 +146,24 @@ private void scheduleTopology(TopologyDetails td, Cluster cluster,
final User to
             return;
         }
 
+        final IStrategy finalRasStrategy = rasStrategy;
         for (int i = 0; i < maxSchedulingAttempts; i++) {
             SingleTopologyCluster toSchedule = new SingleTopologyCluster(workingState, td.getId());
             try {
-                SchedulingResult result = rasStrategy.schedule(toSchedule, td);
+                SchedulingResult result = null;
+                Future<SchedulingResult> schedulingFuture = backgroundScheduling.submit(
+                    () -> finalRasStrategy.schedule(toSchedule, td)
+                );
+                try {
+                    result = schedulingFuture.get(schedulingTimeoutSeconds, TimeUnit.SECONDS);
+                } catch (TimeoutException te) {
+                    markFailedTopology(topologySubmitter, cluster, td, "Scheduling took too
long for "
+                            + td.getId() + " using strategy " + rasStrategy.getClass().getName()
+ " timeout after "
+                            + schedulingTimeoutSeconds + " seconds.");
+                    schedulingFuture.cancel(true);
+                    rasStrategy.stop();
 
 Review comment:
   Consider dropping the `stop` method and make the scheduler check for interrupts instead.
You're already sending an interrupt to it via the `cancel` call above.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message