/// <summary> /// Broadcasts given job to all nodes in grid projection. Every participating node will return a job result. /// </summary> /// <param name="clo">Job to broadcast to all projection nodes.</param> /// <returns>Collection of results for this execution.</returns> public IFuture <ICollection <TR> > Broadcast <TR>(IComputeFunc <TR> clo) { IgniteArgumentCheck.NotNull(clo, "clo"); return(ExecuteClosures0(new ComputeMultiClosureTask <object, TR, ICollection <TR> >(1), new ComputeOutFuncJob(clo.ToNonGeneric()), null, true)); }
/// <summary> /// Broadcasts given closure job with passed in argument to all nodes in grid projection. /// Every participating node will return a job result. /// </summary> /// <param name="clo">Job to broadcast to all projection nodes.</param> /// <param name="arg">Job closure argument.</param> /// <returns>Collection of results for this execution.</returns> public Future <ICollection <TJobRes> > Broadcast <TArg, TJobRes>(IComputeFunc <TArg, TJobRes> clo, TArg arg) { IgniteArgumentCheck.NotNull(clo, "clo"); return(ExecuteClosures0(new ComputeMultiClosureTask <object, TJobRes, ICollection <TJobRes> >(1), new ComputeFuncJob(clo.ToNonGeneric(), arg), null, true)); }
/// <summary> /// Executes provided closure job on a node in this grid projection. /// </summary> /// <param name="clo">Job to run.</param> /// <param name="arg">Job argument.</param> /// <returns>Job result for this execution.</returns> public Future <TJobRes> Apply <TArg, TJobRes>(IComputeFunc <TArg, TJobRes> clo, TArg arg) { IgniteArgumentCheck.NotNull(clo, "clo"); return(ExecuteClosures0(new ComputeSingleClosureTask <TArg, TJobRes, TJobRes>(), new ComputeFuncJob(clo.ToNonGeneric(), arg), null, false)); }
public ConfigSection(string key, string value, bool isStringHeader, IComputeFunc computeFuncs, IEnumerationFunc enumerationFuncs) { ComputeFuncs = computeFuncs; EnumerationFuncs = enumerationFuncs; Key = key; Value = value; RawValue = value; if (isStringHeader) { ReplaceVariables = new List <ConfigReplaceSet>(); ComputeVariables = new List <ConfigComputeSet>(); EnumerationVariables = new List <ConfigEnumerationSet>(); foreach (var item in RetrieveAllVariables('@')) { ReplaceVariables.Add(new ConfigReplaceSet(item.key, item.token)); } foreach (var item in RetrieveAllVariables('$')) { ComputeVariables.Add(new ConfigComputeSet(item.key, item.token, RetrieveFunc(item.key.TrimStart('$')))); } foreach (var item in RetrieveAllVariables('&')) { EnumerationVariables.Add(new ConfigEnumerationSet(item.key, item.token, GetEnumeration(item.key.TrimStart('&')))); } ReplaceAllVariables(); IsString = isStringHeader; } else { bool.Parse(value); IsString = isStringHeader; } }
/// <summary> /// Executes provided job on a node in this grid projection. The result of the /// job execution is returned from the result closure. /// </summary> /// <param name="clo">Job to execute.</param> /// <returns>Job result for this execution.</returns> public Future <TJobRes> Execute <TJobRes>(IComputeFunc <TJobRes> clo) { IgniteArgumentCheck.NotNull(clo, "clo"); return(ExecuteClosures0(new ComputeSingleClosureTask <object, TJobRes, TJobRes>(), new ComputeOutFuncJob(clo.ToNonGeneric()), null, false)); }
/// <summary> /// Initializes a new instance of the <see cref="ComputeFuncJob"/> class. /// </summary> /// <param name="reader">The reader.</param> public ComputeFuncJob(IPortableReader reader) { var reader0 = (PortableReaderImpl) reader.RawReader(); _clo = PortableUtils.ReadPortableOrSerializable<IComputeFunc>(reader0); _arg = PortableUtils.ReadPortableOrSerializable<object>(reader0); }
/// <summary> /// Initializes a new instance of the <see cref="ComputeFuncJob"/> class. /// </summary> /// <param name="reader">The reader.</param> public ComputeFuncJob(IPortableReader reader) { var reader0 = (PortableReaderImpl)reader.RawReader(); _clo = PortableUtils.ReadPortableOrSerializable <IComputeFunc>(reader0); _arg = PortableUtils.ReadPortableOrSerializable <object>(reader0); }
/// <summary> /// Initializes a new instance of the <see cref="ComputeFuncJob"/> class. /// </summary> /// <param name="reader">The reader.</param> public ComputeFuncJob(IBinaryReader reader) { var reader0 = (BinaryReader) reader.GetRawReader(); _clo = reader0.ReadObject<IComputeFunc>(); _arg = reader0.ReadObject<object>(); }
public ConfigFileHandler(IComputeFunc computeFuncs, IEnumerationFunc enumerationFuncs, IFileSystem fileSystem, string fileName = "ConfigFile.ocff") { FileSystem = fileSystem; ComputeFuncs = computeFuncs; EnumerationFuncs = enumerationFuncs; ConfigData = new ConfigData(); FileName = fileName; }
/// <summary> /// Executes given job on the node where data for provided affinity key is located /// (a.k.a. affinity co-location). /// </summary> /// <param name="cacheName">Name of the cache to use for affinity co-location.</param> /// <param name="affinityKey">Affinity key.</param> /// <param name="clo">Job to execute.</param> /// <returns>Job result for this execution.</returns> /// <typeparam name="TR">Type of job result.</typeparam> public IFuture <TR> AffinityCall <TR>(string cacheName, object affinityKey, IComputeFunc <TR> clo) { IgniteArgumentCheck.NotNull(clo, "clo"); return(ExecuteClosures0(new ComputeSingleClosureTask <object, TR, TR>(), new ComputeOutFuncJob(clo.ToNonGeneric()), opId: OpAffinity, writeAction: w => WriteAffinity(w, cacheName, affinityKey))); }
public ConfigParsedData ComputeAndReplace(IArguments arguments, IComputeFunc computeFuncs, IEnumerationFunc enumerationFuncs) { var newConfigData = new ConfigParsedData(); var dictionary = new Dictionary <string, List <string> >(); List <(string header, string value, List <IConfigSet> variables)> list = new List <(string, string, List <IConfigSet>)>(); var allKeys = TurnListConfigSectionIntoDict(); DataStore.Where(y => y.IsString).ToList().ForEach(x => { var keyValue = allKeys[x.Key]; list.Add((x.Key, keyValue, x.ReturnAllVariables())); }); foreach (var item in list) { StringBuilder stringBuilder = new StringBuilder(item.value); List <StringBuilder> stringBuilderList = new List <StringBuilder>() { stringBuilder }; foreach (var innerItem in item.variables) { if (innerItem is ConfigComputeSet) { var innerComputeItem = innerItem as ConfigComputeSet; stringBuilderList = stringBuilderList.SelectMany(y => GetParameter(innerComputeItem.Name, arguments, dictionary).Select(x => new StringBuilder(y.ToString().Replace(innerComputeItem.Token, innerComputeItem.Compute(x))))).ToList(); } else if (innerItem is ConfigEnumerationSet) { var innerEnumerationItem = innerItem as ConfigEnumerationSet; var enumeration = GetParameter(innerEnumerationItem.Name, arguments, dictionary).SelectMany(y => innerEnumerationItem.GetEnumerable(y)); stringBuilderList = stringBuilderList.SelectMany(y => enumeration.Select(x => new StringBuilder(y.ToString().Replace(innerEnumerationItem.Token, x)))).ToList(); } else { stringBuilderList = stringBuilderList.SelectMany(y => GetParameter(innerItem.Name, arguments, dictionary).Select(x => new StringBuilder(y.ToString().Replace(innerItem.Token, x)))).ToList(); } } AddConfigSections(item, stringBuilderList); dictionary.Add(item.header, stringBuilderList.Select(x => x.ToString()).ToList()); } newConfigData.AddRange(DataStore.Where(x => !x.IsString)); return(newConfigData); void AddConfigSections((string header, string value, List <IConfigSet> variables) item, List <StringBuilder> listOfStringBuilders) { foreach (var itemForEach in listOfStringBuilders) { var stringBuilderValue = itemForEach.ToString(); newConfigData.Add(new ConfigSection(item.header, stringBuilderValue, isStringHeader: true, computeFuncs: computeFuncs, enumerationFuncs: enumerationFuncs)); } } }
/// <summary> /// Executes provided closure job on nodes within this grid projection. A new job is executed for /// every argument in the passed in collection. The number of actual job executions will be /// equal to size of the job arguments collection. /// </summary> /// <param name="clo">Job to run.</param> /// <param name="args">Job arguments.</param> /// <returns>Collection of job results.</returns> public IFuture <ICollection <TR> > Apply <T, TR>(IComputeFunc <T, TR> clo, IEnumerable <T> args) { IgniteArgumentCheck.NotNull(clo, "clo"); IgniteArgumentCheck.NotNull(clo, "clo"); var jobs = new List <IComputeJob>(GetCountOrZero(args)); var func = clo.ToNonGeneric(); foreach (T arg in args) { jobs.Add(new ComputeFuncJob(func, arg)); } return(ExecuteClosures0(new ComputeMultiClosureTask <T, TR, ICollection <TR> >(jobs.Count), null, jobs, false)); }
/// <summary> /// Executes provided closure job on nodes within this grid projection. A new job is executed for /// every argument in the passed in collection. The number of actual job executions will be /// equal to size of the job arguments collection. The returned job results will be reduced /// into an individual result by provided reducer. /// </summary> /// <param name="clo">Job to run.</param> /// <param name="args">Job arguments.</param> /// <param name="rdc">Reducer to reduce all job results into one individual return value.</param> /// <returns>Reduced job result for this execution.</returns> public Future <TReduceRes> Apply <TArg, TJobRes, TReduceRes>(IComputeFunc <TArg, TJobRes> clo, IEnumerable <TArg> args, IComputeReducer <TJobRes, TReduceRes> rdc) { IgniteArgumentCheck.NotNull(clo, "clo"); IgniteArgumentCheck.NotNull(clo, "clo"); IgniteArgumentCheck.NotNull(clo, "clo"); ICollection <IComputeJob> jobs = new List <IComputeJob>(GetCountOrZero(args)); var func = clo.ToNonGeneric(); foreach (TArg arg in args) { jobs.Add(new ComputeFuncJob(func, arg)); } return(ExecuteClosures0(new ComputeReducingClosureTask <TArg, TJobRes, TReduceRes>(rdc), null, jobs, false)); }
/** <inheritDoc /> */ public ICollection <TJobRes> Apply <TArg, TJobRes>(IComputeFunc <TArg, TJobRes> clo, IEnumerable <TArg> args) { return(_compute.Apply(clo, args).Get()); }
/** <inheritDoc /> */ public Task <TRes> ApplyAsync <TArg, TRes>(IComputeFunc <TArg, TRes> clo, TArg arg) { return(_compute.Apply(clo, arg).Task); }
/** <inheritDoc /> */ public Task <TRes> ApplyAsync <TArg, TRes>(IComputeFunc <TArg, TRes> clo, TArg arg, CancellationToken cancellationToken) { return(GetTaskIfAlreadyCancelled <TRes>(cancellationToken) ?? _compute.Apply(clo, arg).GetTask(cancellationToken)); }
/** <inheritDoc /> */ public Task <ICollection <TRes> > BroadcastAsync <TArg, TRes>(IComputeFunc <TArg, TRes> clo, TArg arg, CancellationToken cancellationToken) { return(GetTaskIfAlreadyCancelled <ICollection <TRes> >(cancellationToken) ?? _compute.Broadcast(clo, arg).GetTask(cancellationToken)); }
/** <inheritDoc /> */ public TJobRes Apply <TArg, TJobRes>(IComputeFunc <TArg, TJobRes> clo, TArg arg) { return(_compute.Apply(clo, arg).Get()); }
/** <inheritDoc /> */ public ICollection <TJobRes> Broadcast <T, TJobRes>(IComputeFunc <T, TJobRes> clo, T arg) { return(_compute.Broadcast(clo, arg).Get()); }
/** <inheritDoc /> */ public Task <ICollection <TRes> > BroadcastAsync <TArg, TRes>(IComputeFunc <TArg, TRes> clo, TArg arg) { return(_compute.Broadcast(clo, arg).Task); }
/** <inheritDoc /> */ public Task <TRes> AffinityCallAsync <TRes>(string cacheName, object affinityKey, IComputeFunc <TRes> clo) { IgniteArgumentCheck.NotNull(cacheName, "cacheName"); return(_compute.AffinityCall(cacheName, affinityKey, clo).Task); }
/** <inheritDoc /> */ public Task <TRes> AffinityCallAsync <TRes>(string cacheName, object affinityKey, IComputeFunc <TRes> clo, CancellationToken cancellationToken) { IgniteArgumentCheck.NotNull(cacheName, "cacheName"); return(GetTaskIfAlreadyCancelled <TRes>(cancellationToken) ?? _compute.AffinityCall(cacheName, affinityKey, clo).GetTask(cancellationToken)); }
/** <inheritDoc /> */ public TJobRes AffinityCall <TJobRes>(string cacheName, object affinityKey, IComputeFunc <TJobRes> clo) { IgniteArgumentCheck.NotNull(cacheName, "cacheName"); return(_compute.AffinityCall(cacheName, affinityKey, clo).Get()); }
/// <summary> /// Constructor. /// </summary> /// <param name="clo">Closure.</param> /// <param name="arg">Argument.</param> public ComputeFuncJob(IComputeFunc clo, object arg) { _clo = clo; _arg = arg; }
/** <inheritDoc /> */ public Task <TRes> ApplyAsync <TArg, TFuncRes, TRes>(IComputeFunc <TArg, TFuncRes> clo, IEnumerable <TArg> args, IComputeReducer <TFuncRes, TRes> rdc, CancellationToken cancellationToken) { return(GetTaskIfAlreadyCancelled <TRes>(cancellationToken) ?? _compute.Apply(clo, args, rdc).GetTask(cancellationToken)); }
/** <inheritDoc /> */ public TReduceRes Apply <TArg, TJobRes, TReduceRes>(IComputeFunc <TArg, TJobRes> clo, IEnumerable <TArg> args, IComputeReducer <TJobRes, TReduceRes> rdc) { return(_compute.Apply(clo, args, rdc).Get()); }
/** <inheritDoc /> */ public Task <ICollection <TRes> > ApplyAsync <TArg, TRes>(IComputeFunc <TArg, TRes> clo, IEnumerable <TArg> args) { return(_compute.Apply(clo, args).Task); }
/** <inheritDoc /> */ public Task <ICollection <TRes> > ApplyAsync <TArg, TRes>(IComputeFunc <TArg, TRes> clo, IEnumerable <TArg> args, CancellationToken cancellationToken) { return(GetTaskIfAlreadyCancelled <ICollection <TRes> >(cancellationToken) ?? _compute.Apply(clo, args).GetTask(cancellationToken)); }
/** <inheritDoc /> */ public TJobRes Call <TJobRes>(IComputeFunc <TJobRes> clo) { return(_compute.Execute(clo).Get()); }
/** <inheritDoc /> */ public Task <TRes> ApplyAsync <TArg, TFuncRes, TRes>(IComputeFunc <TArg, TFuncRes> clo, IEnumerable <TArg> args, IComputeReducer <TFuncRes, TRes> rdc) { return(_compute.Apply(clo, args, rdc).Task); }
/** <inheritDoc /> */ public Task <TRes> CallAsync <TRes>(IComputeFunc <TRes> clo) { return(_compute.Execute(clo).Task); }
/// <summary> /// Convert to non-generic wrapper. /// </summary> public static IComputeFunc ToNonGeneric <T, TR>(this IComputeFunc <T, TR> func) { return(new ComputeFuncWrapper(func, x => func.Invoke((T)x))); }
/** <inheritDoc /> */ public Task <TRes> CallAsync <TRes>(IComputeFunc <TRes> clo, CancellationToken cancellationToken) { return(GetTaskIfAlreadyCancelled <TRes>(cancellationToken) ?? _compute.Execute(clo).GetTask(cancellationToken)); }