Skip to content

Commit

Permalink
Merge pull request #2 from xiongrenyi/dev2
Browse files Browse the repository at this point in the history
improve DStreamSample's synchronization of C# and Java to let StreamingContext stop gracefully
  • Loading branch information
xiongrenyi committed Nov 12, 2015
2 parents a44536e + 617a0fc commit 80f5ea0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions csharp/Samples/Microsoft.Spark.CSharp/DStreamSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ private static void StartFileServer(string directory, string pattern, int loop)
}
System.Threading.Thread.Sleep(200);
}
foreach (var file in Directory.GetFiles(testDir, "*"))
File.Delete(file);
});
Expand All @@ -62,6 +63,10 @@ internal static void DStreamTextFileSamples()

state.ForeachRDD((time, rdd) =>
{
// there's chance rdd.Take conflicts with ssc.Stop
if (stopFileServer)
return;
object[] taken = rdd.Take(10);
Console.WriteLine("-------------------------------------------");
Console.WriteLine("Time: {0}", time);
Expand All @@ -83,6 +88,9 @@ internal static void DStreamTextFileSamples()
System.Threading.Thread.Sleep(1000);
}

// wait ForeachRDD to complete to let ssc.Stop() gracefully
System.Threading.Thread.Sleep(2000);

ssc.Stop();
}
}
Expand Down

0 comments on commit 80f5ea0

Please sign in to comment.