• Facebook
  • Twitter
  • Youtube
  • LinedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Download
  • Contact Us
Download
Show / Hide Table of Contents

Interface IExecutionService

This interface contains properties and methods required for a Execution Service.

Assembly: Alachisoft.NCache.Client.dll
Syntax
public interface IExecutionService

Methods

Aggregate(IValueExtractor, IAggregator, IKeyFilter, QueryCommand, Int32)

Built upon MapReduce framework, processes distributed data records to return compiled and statistical results for analytical purposes.

Declaration
[Obsolete("This feature is not in active development and may be removed in a future update.")]
object Aggregate(IValueExtractor extractor, IAggregator aggregator, IKeyFilter keyFilter = null, QueryCommand queryCommand = null, int timeout = 2147483647)
Parameters
Type Name Description
IValueExtractor extractor

Implementation of IValueExtractor to extract the meaningful attributes from given objects.

IAggregator aggregator

IAggregator For actual grouping and analytical operations on given data using Map Reduce Combiner and Reducer.

IKeyFilter keyFilter

Instance of IKeyFilter implementation.

QueryCommand queryCommand

Instance of QueryCommand containing query and values.

System.Int32 timeout

Time in millisecond in which if result is not returned, thread will be terminated and exception or null will be given.

Returns
Type Description
System.Object

Returns a single result depending upon given extractor.

Remarks

Aggregator can perform following operations Average, Sum, Min, Max, Count, Distinct. If the result after aggregation execution is null than default value of built in Aggregator for that specific type is returned. User can also implement custom aggregator, as well as, aggregator for custom data types and also for custom functions like Mean, Median, Mode.

Examples
ICache cache = CacheManager.GetCache("demoClusteredCache");

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);

string query = "SELECT Alachisoft.NCache.Sample.Data.Product WHERE this.Category=?";
QueryCommand queryCommand = new QueryCommand(query);
queryCommand.Parameters.Add("Category", "Clothes");

object result = cache.ExecutionService.Aggregate(new BasicTypeExtractor(), BuiltInAggregator.Count(), null, queryCommand, 50000);

ExecuteTask(MapReduceTask, IKeyFilter, QueryCommand)

Executes the specified MapReduce task on the cache, with Key Filter specified and QueryCommand which produce the resultset upon which the task is performed. This task contains implementations of the Mapper and Combiner/Reducer(optional), which will aid in the distributed processing of the cache data filtered out on Keyfilter implementation.

Declaration
[Obsolete("This feature is not in active development and may be removed in a future update.")]
ITrackableTask ExecuteTask(MapReduceTask task, IKeyFilter keyFilter = null, QueryCommand queryCommand = null)
Parameters
Type Name Description
MapReduceTask task

Instance of MapReduceTask, which initializes the Mapper, Combiner and Reducer.

IKeyFilter keyFilter

Filters cache data based on its keys before being provided to the Mapper. The KeyFilter is called during Mapper’s execution. If it returns true, the Map will be executed on the key. If it returns false, Mapper will skip the key and move to next one from the Cache.

QueryCommand queryCommand

Instance of QueryCommand containing query and values.

Returns
Type Description
ITrackableTask

Tracks the submitted task for result and status.

Examples

Note: Implemeting IReducerFactory,ICombinerFactory and ICombiner is optional.

ICache cache = CacheManager.GetCache("demoClusteredCache");

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);

GetRunningTasksIds()

Get all the running tasks.

Declaration
[Obsolete("This feature is not in active development and may be removed in a future update.")]
ICollection<string> GetRunningTasksIds()
Returns
Type Description
System.Collections.Generic.ICollection<System.String>

Collection of taskIds of running Map Reduce tasks.

Examples
ICache cache = CacheManager.GetCache("demoClusteredCache");

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);

//Implement Map Reduce Interferaces

MapReduceTask mapReduceTask = new MapReduceTask();
ICollection<string> runningTasks = cache.ExecutionService.GetRunningTasksIds();

GetTaskResult(String)

Get a trackable instance of the Task with specified taskId.

Declaration
[Obsolete("This feature is not in active development and may be removed in a future update.")]
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("demoClusteredCache");

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

Invoke(IEnumerable<String>, IEntryProcessor, ReadThruOptions, WriteThruOptions, Object[])

Execution of entry processor on a set of keys (regardless of caching topology used), allows to execute code against a set of cache entries on server-side, without fetching any data on client-side.

Declaration
[Obsolete("This feature is not in active development and may be removed in a future update.")]
ICollection Invoke(IEnumerable<string> keys, IEntryProcessor entryProcessor, ReadThruOptions readThruOption = null, WriteThruOptions writeThruOption = null, params object[] arguments)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<System.String> keys

Set of keys of Cache entries on which EntryProcessor will be executed.

Alachisoft.NCache.Runtime.Processor.IEntryProcessor entryProcessor

IEntryProcessor instance.

ReadThruOptions readThruOption

ReadThruOptions to read from data source. These can be either ReadThru, ReadThruForced or none.

WriteThruOptions writeThruOption

WriteThruOptions regarding updating the data source. This can be either WriteThru, WriteBehind or none.

System.Object[] arguments

Arguments list for the process.

Returns
Type Description
System.Collections.ICollection

Returns a collection of instances of IEntryProcessorResult.

Examples
ICache cache = CacheManager.GetCache("demoClusteredCache");

//Get a new instance of sample Class implementing EntryProcessor interface.
CustomEntryProcessor myProcessor = new CustomEntryProcessor();
string[] keys = new string[] { "1", "5", "12", "15" };

cache.Insert(keys[0], "Value1");
cache.Insert(keys[1], "Value1");
cache.Insert(keys[2], "Value1");
cache.Insert(keys[3], "Value1");
//Invoking the Entry processor against a set of items.

ReadThruOptions readThruOptions = new ReadThruOptions(ReadMode.ReadThru, "ProdDataSource");
WriteThruOptions writeThruOptions = new WriteThruOptions(WriteMode.WriteThru, "ProdDataSource");

ICollection retEntries = cache.ExecutionService.Invoke(keys, myProcessor,readThruOptions,writeThruOptions);

Invoke(String, IEntryProcessor, ReadThruOptions, WriteThruOptions, Object[])

Execution of entry processor (regardless of caching topology used), allows to execute code against a cache entry on server-side, without fetching any data on client-side.

Declaration
[Obsolete("This feature is not in active development and may be removed in a future update.")]
object Invoke(string key, IEntryProcessor entryProcessor, ReadThruOptions readThruOption = null, WriteThruOptions writeThruOption = null, params object[] arguments)
Parameters
Type Name Description
System.String key

Key of Cache entry on which the EntryProcessor is executed.

Alachisoft.NCache.Runtime.Processor.IEntryProcessor entryProcessor

IEntryProcessor instance

ReadThruOptions readThruOption

ReadThruOptions to read from data source. These can be either ReadThru, ReadThruForced or none.

WriteThruOptions writeThruOption

WriteThruOptions regarding updating the data source. This can be either WriteThru, WriteBehind or none.

System.Object[] arguments

Arguments list for the process.

Returns
Type Description
System.Object

Returns an instance of IEntryProcessorResult.

Examples
ICache cache = CacheManager.GetCache("demoClusteredCache");

//Get a new instance of sample Class implementing EntryProcessor interface.
CustomEntryProcessor myProcessor = new CustomEntryProcessor();
string[] keys = new string[] { "1", "5", "12", "15" };

cache.Insert(keys[0], "Value1");
cache.Insert(keys[1], "Value1");
cache.Insert(keys[2], "Value1");
cache.Insert(keys[3], "Value1");
//Invoking the Entry processor against a set of items.

ReadThruOptions readThruOptions = new ReadThruOptions(ReadMode.ReadThru, "ProdDataSource");
WriteThruOptions writeThruOptions = new WriteThruOptions(WriteMode.WriteThru, "ProdDataSource");
Object invokerVal = cache.ExecutionService.Invoke(keys[2], myProcessor,readThruOptions,writeThruOptions);

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Community
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top