private void ScanAll(ScanPolicy scanPolicy, List <MessageData> list) { this._client.ScanAll(scanPolicy, defaultNs, defaultSetName, (key, record) => list.Add(ConvertRecordToMessages(record))); }
/// <summary> /// Copy scan policy from another scan policy. /// </summary> public ScanPolicy(ScanPolicy other) : base(other) { this.scanPercent = other.scanPercent; this.maxConcurrentNodes = other.maxConcurrentNodes; this.concurrentNodes = other.concurrentNodes; this.includeBinData = other.includeBinData; this.failOnClusterChange = other.failOnClusterChange; }
} // public void scanAllTweetsForAllUsers() { ScanPolicy policy = new ScanPolicy(); policy.includeBinData = true; client.ScanAll(policy, "test", "tweets", scanTweetsCallback, "tweet"); } //scanAllTweetsForAllUsers
} //updateUser public void scanAllTweetsForAllUsers() { ScanPolicy policy = new ScanPolicy(); policy.concurrentNodes = true; policy.priority = Priority.LOW; policy.includeBinData = true; client.ScanAll(policy, "test", "tweets", scanTweetsCallback, "tweet"); } //scanAllTweets
public AerospikeDataAccess(IBinarySerializer binarySerializer) { this._binarySerializer = binarySerializer; _client = new AsyncClient(Hostname, 3000); _writePolicy = new WritePolicy(); _policy = new Policy(); _scanPolicy = new ScanPolicy(); }
public void AsyncScan() { recordCount = 0; ScanPolicy policy = new ScanPolicy(); client.ScanAll(policy, new RecordSequenceHandler(this), args.ns, args.set); WaitTillComplete(); }
public void ScanBenchmark() { ScanPolicy policy = new ScanPolicy(); policy.concurrentNodes = true; policy.priority = Priority.DEFAULT; policy.includeBinData = true; _client.ScanAll(policy, Namespace, Set, ScanCallback); }
/// <summary> /// Asynchronous scan example. /// </summary> public override void RunExample(AsyncClient client, Arguments args) { console.Info("Asynchronous scan: namespace=" + args.ns + " set=" + args.set); recordCount = 0; completed = false; DateTime begin = DateTime.Now; ScanPolicy policy = new ScanPolicy(); client.ScanAll(policy, new RecordSequenceHandler(this, begin), args.ns, args.set); WaitTillComplete(); }
/// <summary> /// This command can be used to set scan, connection, and advertising filtering parameters based on the local /// devices white list.See also Whitelist Append command. /// </summary> /// <param name="scanPolicy"></param> /// <param name="advPolicy"></param> /// <param name="scanDuplicateFiltering"> /// <para>0: Do not filter duplicate advertisers</para> /// <para>1: Filter duplicates</para> /// </param> /// <returns></returns> public async Task SetFilteringAsync(ScanPolicy scanPolicy, AdvertisingPolicy advPolicy, byte scanDuplicateFiltering) { var scanPolicyValue = (byte)scanPolicy; var advPolicyValue = (byte)advPolicy; var commandValue = new[] { scanPolicyValue, advPolicyValue, scanDuplicateFiltering }; var responseValue = await WriteAsync(0x06, commandValue); var errorCode = BitConverter.ToUInt16(responseValue, 0); if (errorCode != 0) { throw new ErrorException(errorCode); } }
} //updateUserUsingOperate public void scanAllTweetsForAllUsers() { // Scan all records // TODO: Create ScanPolicy instance with concurrentNodes, LOW priority and includeBinData // Exercise K4 ScanPolicy policy = null; // policy = .... //policy.concurrentNodes = .... //policy.priority = .... //policy.includeBinData = .... // TODO: Initiate scan operation that invokes callback for outputting tweets to the console. // Exercise K4 //client.ScanAll(.... } //scanAllTweets
} //updateUserUsingOperate public void scanAllTweetsForAllUsers() { // Scan all records // TODO: Create ScanPolicy instance with concurrentNodes, LOW priority and includeBinData // Exercise K4 ScanPolicy policy = new ScanPolicy(); policy.concurrentNodes = true; policy.priority = Priority.LOW; policy.includeBinData = true; // TODO: Initiate scan operation that invokes callback for outputting tweets to the console. // Exercise K4 client.ScanAll(policy, "test", "tweets", scanTweetsCallback, "tweet"); } //scanAllTweets
/// <summary> /// Scan all nodes in series and read all records in all sets. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { console.Info("Scan series: namespace=" + args.ns + " set=" + args.set); setMap.Clear(); ScanPolicy policy = new ScanPolicy(); policy.recordsPerSecond = 5000; // Low scan priority will take more time, but it will reduce the load on the server. // policy.priority = Priority.LOW; Node[] nodes = client.Nodes; DateTime begin = DateTime.Now; foreach (Node node in nodes) { console.Info("Scan node " + node.Name); client.ScanNode(policy, node, args.ns, args.set, ScanCallback); foreach (KeyValuePair <string, Metrics> entry in setMap) { console.Info("Node " + node.Name + " set " + entry.Key + " count: " + entry.Value.count); entry.Value.total += entry.Value.count; entry.Value.count = 0; } } DateTime end = DateTime.Now; double seconds = end.Subtract(begin).TotalSeconds; console.Info("Elapsed time: " + seconds + " seconds"); long total = 0; foreach (KeyValuePair <string, Metrics> entry in setMap) { console.Info("Total set " + entry.Key + " count: " + entry.Value.total); total += entry.Value.total; } console.Info("Grand total: " + total); double performance = Math.Round((double)total / seconds); console.Info("Records/second: " + performance); }
/// <summary> /// Scan all nodes in parallel and read all records in a set. /// </summary> public override void RunExample(AerospikeClient client, Arguments args) { console.Info("Scan parallel: namespace=" + args.ns + " set=" + args.set); recordCount = 0; DateTime begin = DateTime.Now; ScanPolicy policy = new ScanPolicy(); client.ScanAll(policy, args.ns, args.set, ScanCallback); DateTime end = DateTime.Now; double seconds = end.Subtract(begin).TotalSeconds; console.Info("Total records returned: " + recordCount); console.Info("Elapsed time: " + seconds + " seconds"); double performance = Math.Round((double)recordCount / seconds); console.Info("Records/second: " + performance); }
public AsyncScan( AsyncMultiExecutor parent, AsyncCluster cluster, AsyncNode node, ScanPolicy policy, RecordSequenceListener listener, string ns, string setName, string[] binNames, ulong taskId ) : base(parent, cluster, node, true) { this.policy = policy; this.listener = listener; this.ns = ns; this.setName = setName; this.binNamesScan = binNames; this.taskId = taskId; }
public AsyncScan ( AsyncMultiExecutor parent, AsyncCluster cluster, AsyncNode node, ScanPolicy policy, RecordSequenceListener listener, string ns, string setName, string[] binNames, long taskId ) : base(parent, cluster, node, true) { this.policy = policy; this.listener = listener; this.ns = ns; this.setName = setName; this.binNamesScan = binNames; this.taskId = taskId; }
public AsyncScan ( AsyncMultiExecutor parent, AsyncCluster cluster, AsyncNode node, ScanPolicy scanPolicy, RecordSequenceListener listener, string ns, string setName, string[] binNames, ulong taskId ) : base(parent, cluster, scanPolicy, node, scanPolicy.socketTimeout, scanPolicy.totalTimeout) { this.scanPolicy = scanPolicy; this.listener = listener; this.ns = ns; this.setName = setName; this.binNamesScan = binNames; this.taskId = taskId; }
public void ScanSeries() { // Use low scan priority. This will take more time, but it will reduce // the load on the server. ScanPolicy policy = new ScanPolicy(); policy.maxRetries = 1; policy.priority = Priority.LOW; Node[] nodes = client.Nodes; foreach (Node node in nodes) { client.ScanNode(policy, node, args.ns, args.set, ScanCallback); foreach (KeyValuePair <string, Metrics> entry in setMap) { entry.Value.count = 0; } } }
static void Delete(string host, int port, string asnamespace, string sets, int days, long limit, long rangeStart, long rangeEnd) { Console.WriteLine($"Host: {host}, Port: {port}, Namespace: {asnamespace}, Sets: {sets}, Days: {days}, Limit: {limit}, RangeStart: {rangeStart}, RangeEnd: {rangeEnd}"); DateTime dt = DateTime.UtcNow.AddDays(days); Console.WriteLine($"Date: {dt}"); _thresholdTime = UtcDateTimeToASTime(dt); _deleteSets = sets; _deleteLimit = limit; _deleteRangeStart = rangeStart; _deleteRangeEnd = rangeEnd; _count = _rewritecount = _total = 0; try { _client = new AerospikeClient(host, port); ScanPolicy scanPolicy = new ScanPolicy(); // Scan the entire Set using ScanAll(). This will scan each node // in the cluster and return the record Digest to the call back object _watch = Stopwatch.StartNew(); _client.ScanAll(scanPolicy, asnamespace, null, ScanCallback, new string[] { }); _watch.Stop(); Log($"Deleted {_count} records from set {sets}. Rewrites: {_rewritecount}"); } catch (AerospikeException ex) { int resultCode = ex.Result; Log(ResultCode.GetResultString(resultCode)); Log("Error details: " + ex.ToString()); } return; }
public AsyncScanPartition ( AsyncMultiExecutor executor, AsyncCluster cluster, ScanPolicy scanPolicy, RecordSequenceListener listener, string ns, string setName, string[] binNames, ulong taskId, PartitionTracker tracker, NodePartitions nodePartitions ) : base(executor, cluster, scanPolicy, (AsyncNode)nodePartitions.node, tracker.socketTimeout, tracker.totalTimeout) { this.scanPolicy = scanPolicy; this.listener = listener; this.ns = ns; this.setName = setName; this.binNames = binNames; this.taskId = taskId; this.tracker = tracker; this.nodePartitions = nodePartitions; }
private List <string> WriteToDB(string word) { HtmlAgilityPack.HtmlWeb web = new HtmlAgilityPack.HtmlWeb(); // var _client = new MongoClient(); // var _database = _client.GetDatabase("SignLanguage"); // var _collection = _database.GetCollection<SynonymsModel>("Synonyms"); AerospikeClient client = new AerospikeClient(configuration["AppSettings:AerospikeClient"], 3000); Policy policy = new Policy(); List <string> synonyms = new List <string>(); Key key = new Key("sign-language", "Synonyms", word); Record record = client.Get(policy, key); ScanPolicy policyScan = new ScanPolicy(); if (record != null) { foreach (KeyValuePair <string, object> entry in record.bins) { var syns = ""; if (entry.Key == "Synonyms") { syns = entry.Value.ToString(); } synonyms = syns.Split(",").ToList(); return(synonyms); } } //client.ScanAll(policyScan, "sign-language", "Synonyms", ScanCallback); //var node = new Uri("http://192.168.0.36:9200"); //var settings = new ConnectionSettings( // node //).DefaultIndex("synonyms"); //var client = new ElasticClient(settings); List <string> links = new List <string>(); List <string> articleTexts = new List <string>(); //var searchResponse = client.Search<SynonymsModel>(s => s // .From(0) // .Size(10) // .Query(q => q // .Match(m => m // .Field(f => f.Word) // .Query(word) // ) // ) //); //var synonymES = searchResponse.Documents.ToList(); //if (synonymES.Count > 0) //{ // foreach (var synonym in synonymES) // { // synonyms.Add(synonym.Synonym); // } // return synonyms; //} List <string> synonymsList = new List <string>(); // if (_collection.Find(x => x.Word == word.Trim()).Count() > 0) // { // foreach(var syn in _collection.Find(x => x.Word == word.Trim()).ToList()) // { // synonymsList.Add(syn.Synonym); // } // return synonymsList; // } HtmlAgilityPack.HtmlDocument doc = web.Load("http://www.makedonski.info/synonyms/show/" + word); Regex regex = new Regex("(synonyms/show)", RegexOptions.IgnoreCase); var synsA = doc.DocumentNode.SelectNodes(".//a"); if (synsA != null) { var regexMatch = synsA.Where(a => regex.IsMatch(a.Attributes["href"].Value)).ToList <HtmlNode>(); var synsString = ""; for (var i = 1; i < regexMatch.Count; i++) { var a = regexMatch[i]; var syn = a.InnerText.Split('(')[0]; SynonymsModel plural = new SynonymsModel() { Word = word, Synonym = syn }; //var indexResponse = client.IndexDocument(plural); //_collection.InsertOne(plural); synsString += syn; if (i != regexMatch.Count - 1) { synsString += ","; } synonyms.Add(syn); } WritePolicy policyWrite = new WritePolicy(); policy.SetTimeout(50); // 50 millisecond timeout. Key keyWrite = new Key("sign-language", "Synonyms", word); Bin binVerb = new Bin("Word", word); Bin binInf = new Bin("Synonym", synsString); client.Put(policyWrite, keyWrite, binVerb, binInf); return(synonyms); } return(null); }
public void ScanParallel() { ScanPolicy policy = new ScanPolicy(); client.ScanAll(policy, args.ns, args.set, ScanCallback); }