public Task <TJob> CreateAsync(string search, int count = 100, ExecutionMode mode = ExecutionMode.Normal, JobArgs args = null, CustomJobArgs customArgs = null, DispatchState requiredState = DispatchState.Running) { Contract.Requires <ArgumentNullException>(search != null); return(default(Task <TJob>)); }
public async Task UpdateJobArgs(JobArgs args) { using (var response = await this.Context.PostAsync(this.Namespace, this.ResourceName, args)) { await response.EnsureStatusCodeAsync(HttpStatusCode.OK); } }
void CanConstruct() { var expectedArguments = new Argument[] { new Argument("search", "some unchecked search string") }; string[] expectedString = new string[] { "auto_cancel=0; auto_finalize_ec=0; auto_pause=0; earliest_time=null; enable_lookups=t; exec_mode=normal; force_bundle_replication=f; id=null; index_earliest=null; index_latest=null; latest_time=null; max_count=10000; max_time=0; namespace=null; now=null; reduce_freq=0; reload_macros=t; remote_server_list=null; reuse_max_seconds_ago=0; rf=null; rt_blocking=f; rt_indexfilter=f; rt_maxblocksecs=60; rt_queue_size=10000; search=null; search_listener=null; search_mode=normal; spawn_process=t; status_buckets=0; sync_bundle_replication=f; time_format=null; timeout=86400", "auto_cancel=0; auto_finalize_ec=0; auto_pause=0; earliest_time=null; enable_lookups=t; exec_mode=normal; force_bundle_replication=f; id=null; index_earliest=null; index_latest=null; latest_time=null; max_count=10000; max_time=0; namespace=null; now=null; reduce_freq=0; reload_macros=t; remote_server_list=null; reuse_max_seconds_ago=0; rf=null; rt_blocking=f; rt_indexfilter=f; rt_maxblocksecs=60; rt_queue_size=10000; search=some unchecked search string; search_listener=null; search_mode=normal; spawn_process=t; status_buckets=0; sync_bundle_replication=f; time_format=null; timeout=86400" }; string search = "some unchecked search string"; var args = new JobArgs(search); Assert.Equal(expectedString[1], args.ToString()); Assert.Equal(expectedArguments, args); }
/// <inheritdoc/> public virtual async Task <SearchResultStream> SearchOneShotAsync(string search, int count = 0, JobArgs args = null, CustomJobArgs customArgs = null) { var resourceName = JobCollection.ClassResourceName; var arguments = new SearchArgs { Search = search, Count = count, ExecutionMode = ExecutionMode.OneShot } .AsEnumerable(); if (args != null) { arguments = arguments.Concat(args.Where(arg => arg.Name != "exec_mode")); } if (customArgs != null) { arguments = arguments.Concat(customArgs); } Response response = await this.Context.PostAsync(this.Namespace, resourceName, arguments).ConfigureAwait(false); try { await response.EnsureStatusCodeAsync(HttpStatusCode.OK).ConfigureAwait(false); var stream = await SearchResultStream.CreateAsync(response).ConfigureAwait(false); // Transfers response ownership return(stream); } catch { response.Dispose(); throw; } }
public Task <SearchResultStream> SearchOneShotAsync(string search, int count = 0, JobArgs args = null, CustomJobArgs customArgs = null) { Contract.Requires <ArgumentNullException>(search != null); return(default(Task <SearchResultStream>)); }
public Task <Job> SearchAsync(string search, int count = 0, ExecutionMode mode = ExecutionMode.Normal, JobArgs args = null, CustomJobArgs customArgs = null) { Contract.Requires <ArgumentNullException>(search != null); return(default(Task <Job>)); }
/// <inheritdoc/> public virtual async Task <Job> SearchAsync(string search, int count = 0, ExecutionMode mode = ExecutionMode.Normal, JobArgs args = null, CustomJobArgs customArgs = null) { var job = await this.Jobs.CreateAsync(search, count, mode, args, customArgs).ConfigureAwait(false); return(job); }
/// <summary> /// Asynchronously creates a new search <see cref="Job"/>. /// </summary> /// <remarks> /// This method uses the <a href="http://goo.gl/JZcPEb">POST search/jobs</a> /// endpoint to start a new search <see cref="Job"/> as specified by /// <paramref name="args"/>. /// </remarks> /// <param name="search"> /// Search string. /// </param> /// <param name="count"> /// /// </param> /// <param name="mode"> /// /// </param> /// <param name="args"> /// Optional search arguments. /// </param> /// <param name="customArgs"> /// /// </param> /// <param name="requiredState"> /// /// </param> /// <returns> /// An object representing the search job that was created. /// </returns> public virtual async Task <Job> CreateAsync(string search, int count = 100, ExecutionMode mode = ExecutionMode.Normal, JobArgs args = null, CustomJobArgs customArgs = null, DispatchState requiredState = DispatchState.Running) { var arguments = new Argument[] { new Argument("search", search), new Argument("count", count) } .AsEnumerable(); if (args != null) { arguments = arguments.Concat(args); } if (customArgs != null) { arguments = arguments.Concat(customArgs); } var job = await this.CreateAsync(arguments, requiredState).ConfigureAwait(false); return(job); }
void CanSetEveryValue() { var args = new JobArgs("some_unchecked_string") { AutoCancel = 1, AutoFinalizeEventCount = 2, AutoPause = 3, EarliestTime = "some_unchecked_string", EnableLookups = false, ExecutionMode = ExecutionMode.Blocking, ForceBundleReplication = true, Id = "some_unchecked_string", IndexEarliest = "some_unchecked_string", IndexLatest = "some_unchecked_string", LatestTime = "some_unchecked_string", MaxCount = 4, MaxTime = 5, Namespace = "some_unchecked_string", Now = "some_unchecked_string", RealTimeBlocking = true, RealTimeIndexFilter = true, RealTimeMaxBlockSeconds = 6, RealTimeQueueSize = 7, ReduceFrequency = 8, ReloadMacros = false, RemoteServerList = "some_unchecked_string", RequiredFieldList = new List <string>() { "some_unchecked_string", "some_other_uncheck_string" }, ReuseMaxSecondsAgo = 9, SearchListener = "some_unchecked_string", SearchMode = SearchMode.Realtime, SpawnProcess = false, StatusBuckets = 10, SyncBundleReplication = true, TimeFormat = "some_unchecked_string", Timeout = 11 }; Assert.Equal( "auto_cancel=1; " + "auto_finalize_ec=2; " + "auto_pause=3; " + "earliest_time=some_unchecked_string; " + "enable_lookups=f; " + "exec_mode=blocking; " + "force_bundle_replication=t; " + "id=some_unchecked_string; " + "index_earliest=some_unchecked_string; " + "index_latest=some_unchecked_string; " + "latest_time=some_unchecked_string; " + "max_count=4; " + "max_time=5; " + "namespace=some_unchecked_string; " + "now=some_unchecked_string; " + "reduce_freq=8; " + "reload_macros=f; " + "remote_server_list=some_unchecked_string; " + "reuse_max_seconds_ago=9; " + "rf=some_unchecked_string; " + "rf=some_other_uncheck_string; " + "rt_blocking=t; " + "rt_indexfilter=t; " + "rt_maxblocksecs=6; " + "rt_queue_size=7; " + "search=some_unchecked_string; " + "search_listener=some_unchecked_string; " + "search_mode=realtime; " + "spawn_process=f; " + "status_buckets=10; " + "sync_bundle_replication=t; " + "time_format=some_unchecked_string; " + "timeout=11", args.ToString()); Assert.Equal(new List <Argument>() { new Argument("auto_cancel", "1"), new Argument("auto_finalize_ec", "2"), new Argument("auto_pause", "3"), new Argument("earliest_time", "some_unchecked_string"), new Argument("enable_lookups", "f"), new Argument("exec_mode", "blocking"), new Argument("force_bundle_replication", "t"), new Argument("id", "some_unchecked_string"), new Argument("index_earliest", "some_unchecked_string"), new Argument("index_latest", "some_unchecked_string"), new Argument("latest_time", "some_unchecked_string"), new Argument("max_count", "4"), new Argument("max_time", "5"), new Argument("namespace", "some_unchecked_string"), new Argument("now", "some_unchecked_string"), new Argument("reduce_freq", "8"), new Argument("reload_macros", "f"), new Argument("remote_server_list", "some_unchecked_string"), new Argument("reuse_max_seconds_ago", "9"), new Argument("rf", "some_unchecked_string"), new Argument("rf", "some_other_uncheck_string"), new Argument("rt_blocking", "t"), new Argument("rt_indexfilter", "t"), new Argument("rt_maxblocksecs", "6"), new Argument("rt_queue_size", "7"), new Argument("search", "some_unchecked_string"), new Argument("search_listener", "some_unchecked_string"), new Argument("search_mode", "realtime"), new Argument("spawn_process", "f"), new Argument("status_buckets", "10"), new Argument("sync_bundle_replication", "t"), new Argument("time_format", "some_unchecked_string"), new Argument("timeout", "11") }, args); }
public virtual async Task <Job> Create(string search, int count = 0, // This version doesn't wait ExecutionMode mode = ExecutionMode.Normal, JobArgs args = null, CustomJobArgs customArgs = null) { var arguments = new Argument[] { new Argument("search", search), new Argument("count", count) } .AsEnumerable(); if (args != null) { arguments = arguments.Concat(args); } if (customArgs != null) { arguments = arguments.Concat(customArgs); } var job = await this.Create(arguments).ConfigureAwait(false); return(job); }