Method GetTaskResult
GetTaskResult(String)
Get a Trackable instance of the task with specified taskId.
Declaration
ITrackableTask GetTaskResult(string taskId)
Parameters
Type | Name | Description |
---|---|---|
System.String | taskId | Task Id of the Map reduce task. |
Returns
Type | Description |
---|---|
ITrackableTask | Returns an instance to track the task for result and status. |
Examples
ICache cache = CacheManager.GetCache("myCache");
string key1 = "2202";
Product product1 = new Product()
{
Id = 4,
Category = "Clothes",
UnitPrice = 4,
UnitsAvailable = 2
};
string key2 = "2203";
Product product2 = new Product()
{
Id = 4,
Category = "Shoes",
UnitPrice = 5,
UnitsAvailable = 9
};
cache.Add(key1, product1);
cache.Add(key2, product2);
MapReduceTask mapReduceTask = new MapReduceTask();
mapReduceTask.Mapper = new ProductCountMapper();
mapReduceTask.Combiner = new ProductCountCombinerFactory();
mapReduceTask.Reducer = new ProductCountReducerFactory();
string query = "SELECT Alachisoft.NCache.Sample.Data.Product WHERE this.Category IN (?)";
QueryCommand queryCommand = new QueryCommand(query);
queryCommand.Parameters.Add("Category", "Clothes");
ITrackableTask trackableInstance = cache.ExecutionService.ExecuteTask(mapReduceTask, null, queryCommand);
string taskID1 = trackableInstance.TaskId;
Random randomNumber = new Random();
string taskID2 = randomNumber.Next(2).ToString();
ITrackableTask testResult = cache.ExecutionService.GetTaskResult(taskID1); //returns the traceable instance
testResult = cache.ExecutionService.GetTaskResult(taskID2); //returns nothing as no task with such id is being running