public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName1, IndexType.NUMERIC); itask.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); client.Put(null, key, new Bin(binName1, i), new Bin(binName2, i)); } }
public static void Register(AerospikeClient client, Policy policy, string packageName) { string path = LuaDirectory + packageName; RegisterTask task = client.Register(policy, path, packageName, Language.LUA); task.Wait(); }
public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask task = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING, IndexCollectionType.MAPKEYS); task.Wait(); for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); Dictionary <string, string> map = new Dictionary <string, string>(); map[mapKeyPrefix + 1] = mapValuePrefix + i; if (i % 2 == 0) { map[mapKeyPrefix + 2] = mapValuePrefix + i; } if (i % 3 == 0) { map[mapKeyPrefix + 3] = mapValuePrefix + i; } Bin bin = new Bin(binName, map); client.Put(null, key, bin); } }
public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask rtask = client.Register(null, assembly, "Aerospike.Test.Resources.filter_example.lua", "filter_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.STRING); itask.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } WriteRecord(keyPrefix + 1, "Charlie", "cpass"); WriteRecord(keyPrefix + 2, "Bill", "hknfpkj"); WriteRecord(keyPrefix + 3, "Doug", "dj6554"); }
public QueryExecuteInit() { Assembly assembly = typeof(QueryExecuteInit).GetTypeInfo().Assembly; RegisterTask rtask = client.Register(null, assembly, "AerospikeTest.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask itask = client.CreateIndex(policy, args.ns, args.set, TestQueryExecute.indexName, TestQueryExecute.binName1, IndexType.NUMERIC); itask.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } for (int i = 1; i <= TestQueryExecute.size; i++) { Key key = new Key(args.ns, args.set, TestQueryExecute.keyPrefix + i); client.Put(null, key, new Bin(TestQueryExecute.binName1, i), new Bin(TestQueryExecute.binName2, i)); } }
private void addTaskButton_Click(object sender, EventArgs e) { DateTime?deadline = null; if (hasDeadlineCheckBox.Checked) { deadline = deadlineDateTimePicker.Value; } string priority = taskPriorityComboBox.SelectedItem.ToString(); string title = titleTextBox.Text; var registerTask = new RegisterTask(_projectId, title, priority, deadline); try { _commandDispatcher.Send(registerTask); if (TaskRegistered != null) { var eventArgs = new TaskRegisteredEventArgs(_projectId, title, priority, deadline); TaskRegistered(this, eventArgs); } Close(); } catch (TaskWithSameTitleExistsInProjectException ex) { _logger.Error(ex, "A task with title {title} already exists in project {projectId}", registerTask.Title, _projectId); MessageBox.Show("A task with this title already exists in the project", "Error", MessageBoxButtons.OK); } }
public bool RegisterToGlobal(string name, Action <CfrV8Value> action) { var rb = remoteBrowser; if (rb == null) { return(false); } try { var ctx = rb.CreateRemoteCallContext(); ctx.Enter(); try { var taskRunner = CfrTaskRunner.GetForThread(CfxThreadId.Renderer); var task = new RegisterTask(this, name, JSInvokeMode.Inherit, action); taskRunner.PostTask(task); return(true); } finally { ctx.Exit(); } } catch (CfxRemotingException) { return(false); } }
public static void Register(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask task = client.Register(null, assembly, "Aerospike.Test.Resources.record_example.lua", "record_example.lua", Language.LUA); task.Wait(); }
public UDFInit() { Assembly assembly = typeof(UDFInit).GetTypeInfo().Assembly; RegisterTask task = client.Register(null, assembly, "AerospikeTest.record_example.lua", "record_example.lua", Language.LUA); task.Wait(); }
} //batchGetUserTweets public void updatePasswordUsingUDF() { //Assembly assembly = Assembly.GetExecutingAssembly(); ////Policy policy = new Policy(); ////policy.SetTimeout(100); //RegisterTask rtask = client.Register(policy, "updateUserPwd.lua", "updateUserPwd.lua", Language.LUA); //rtask.Wait(); Record userRecord = null; Key userKey = null; // Get username string username; Console.WriteLine("\nEnter username:"******"test", "users", username); userRecord = client.Get(null, userKey); if (userRecord != null) { // Get new password string password; Console.WriteLine("Enter new password for " + username + ":"); password = Console.ReadLine(); //string luaDirectory = @"..\..\udf"; //LuaConfig.PackagePath = luaDirectory + @"\?.lua"; //string filename = "updateUserPwd.lua"; //string path = Path.Combine(luaDirectory, filename); //RegisterTask rt = client.Register(null, path, filename, Language.LUA); //rt.Wait(); Assembly assembly = Assembly.GetExecutingAssembly(); Policy policy = new Policy(); policy.SetTimeout(100); RegisterTask rtask = client.Register(policy, "updateUserPwd.lua", "updateUserPwd.lua", Language.LUA); rtask.Wait(); string updatedPassword = client.Execute(null, userKey, "updateUserPwd", "updatePassword", Value.Get(password)).ToString(); Console.WriteLine("\nINFO: The password has been set to: " + updatedPassword); } else { Console.WriteLine("ERROR: User record not found!"); } } else { Console.WriteLine("ERROR: User record not found!"); } } //updatePasswordUsingUDF
private void Register(AerospikeClient client, Arguments args, string packageContents) { string packageName = "sum_example.lua"; console.Info("Register: " + packageName); RegisterTask task = client.RegisterUdfString(null, packageContents, packageName, Language.LUA); task.Wait(); }
} //updatePasswordUsingUDF public void aggregateUsersByTweetCountByRegion() { ResultSet rs = null; try { int min; int max; Console.WriteLine("\nEnter Min Tweet Count:"); min = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Max Tweet Count:"); max = int.Parse(Console.ReadLine()); // NOTE: UDF registration has been included here for convenience and to demonstrate the syntax. // NOTE: The recommended way of registering UDFs in production env is via AQL string luaDirectory = @"..\..\udf"; LuaConfig.PackagePath = luaDirectory + @"\?.lua"; string filename = "aggregationByRegion.lua"; string path = Path.Combine(luaDirectory, filename); RegisterTask rt = client.Register(null, path, filename, Language.LUA); rt.Wait(); string[] bins = { "tweetcount", "region" }; Statement stmt = new Statement(); stmt.SetNamespace("test"); stmt.SetSetName("users"); stmt.SetIndexName("tweetcount_index"); stmt.SetBinNames(bins); stmt.SetFilters(Filter.Range("tweetcount", min, max)); Console.WriteLine("\nAggregating users with " + min + "-" + max + " tweets by region. Hang on...\n"); rs = client.QueryAggregate(null, stmt, "aggregationByRegion", "sum"); if (rs.Next()) { Dictionary <object, object> result = (Dictionary <object, object>)rs.Object; Console.WriteLine("Total Users in North: " + result["n"]); Console.WriteLine("Total Users in South: " + result["s"]); Console.WriteLine("Total Users in East: " + result["e"]); Console.WriteLine("Total Users in West: " + result["w"]); } } finally { if (rs != null) { // Close record set rs.Close(); } } } //aggregateUsersByTweetCountByRegion
} //getUserTweets public void updatePasswordUsingUDF() { Record userRecord = null; Key userKey = null; // Get username string username; Console.WriteLine("\nEnter username:"******"test", "users", username); userRecord = client.Get(null, userKey); if (userRecord != null) { //Get new password string password; Console.WriteLine("Enter new password for " + username + ":"); password = Console.ReadLine(); // TODO: Update userRecord using UDF // Exercise R2 // NOTE: UDF registration has been included here for convenience and to demonstrate the syntax. // NOTE: The recommended way of registering UDFs in production env is via AQL string luaDirectory = @"..\..\udf"; LuaConfig.PackagePath = luaDirectory + @"\?.lua"; string filename = "updateUserPwd.lua"; string path = Path.Combine(luaDirectory, filename); RegisterTask rt = client.Register(null, path, filename, Language.LUA); rt.Wait(); // TODO: Execute the UDF updatePassword.lua // Exercise R2 string updatedPassword = client.Execute(null, userKey, "updateUserPwd", "updatePassword", Value.Get(password)).ToString(); // TODO: Output the updated passord returned by the UDF // Exercise R2 Console.WriteLine("\nINFO: The password has been set to: " + updatedPassword); } else { Console.WriteLine("\nERROR: User record not found."); } } else { Console.WriteLine("\nERROR: Invalid user name."); } } //updatePasswordUsingUDF
private void RegisterUDF() { string packageContents = @" local function setTTL(r) local vt = r['vt'] if vt ~= nil then -- Get last update time in seconds since Aerospike epoch (2010/1/1 UTC). local lut = math.floor(record.last_update_time(r) / 1000) -- Get current time in seconds since Aerospike epoch (2010/1/1 UTC). local now = os.time() - 1262304000 -- Get new ttl in seconds. local ttl = now - lut + record.ttl(r) -- Adjust ttl if greater than absolute void time. if vt > 0 and ttl + now > vt then ttl = vt - now end -- Only set a valid ttl. -- Otherwise, let record expire. if ttl >= 1 then -- Set ttl. record.set_ttl(r, ttl) aerospike:update(r) end end end -- Read bin and reset ttl when applicable. function readTouch(r,name) if not aerospike:exists(r) then return nil end setTTL(r) return r[name] end -- Reset ttl when applicable. function touch(r) if not aerospike:exists(r) then return end setTTL(r) end "; RegisterTask task = client.RegisterUdfString(null, packageContents, "readtouch.lua", Language.LUA); task.Wait(); }
public void Can_Register_A_Task_With_Same_Title_Under_Several_Projects() { var firstProjectId = new ProjectId(Fixture.Create <string>()); var secondProjectId = new ProjectId(Fixture.Create <string>()); var taskTitle = Fixture.Create <string>(); var registerTaskUnderFirstProject = new RegisterTask(firstProjectId, taskTitle, TaskPriority.Low.DisplayName, null); var registerTaskUnderSecondProject = new RegisterTask(secondProjectId, taskTitle, TaskPriority.Low.DisplayName, null); var registerTaskCommandHandler = new RegisterTaskCommandHandler(_eventStoreRepository); Assert.DoesNotThrow(() => registerTaskCommandHandler.Handle(registerTaskUnderFirstProject)); Assert.DoesNotThrow(() => registerTaskCommandHandler.Handle(registerTaskUnderSecondProject)); }
} //getUser public void updatePasswordUsingUDF() { Record userRecord = null; Key userKey = null; // Get username string username; Console.WriteLine("\nEnter username:"******"test", "users", username); userRecord = client.Get(null, userKey); if (userRecord != null) { // Get new password string password; Console.WriteLine("Enter new password for " + username + ":"); password = Console.ReadLine(); // NOTE: UDF registration has been included here for convenience and to demonstrate the syntax. The recommended way of registering UDFs in production env is via AQL string luaDirectory = @"..\..\udf"; LuaConfig.PackagePath = luaDirectory + @"\?.lua"; string filename = "updateUserPwd.lua"; string path = Path.Combine(luaDirectory, filename); RegisterTask rt = client.Register(null, path, filename, Language.LUA); rt.Wait(); string updatedPassword = client.Execute(null, userKey, "updateUserPwd", "updatePassword", Value.Get(password)).ToString(); Console.WriteLine("\nINFO: The password has been set to: " + updatedPassword); } else { Console.WriteLine("ERROR: User record not found!"); } } else { Console.WriteLine("ERROR: User record not found!"); } } //updatePasswordUsingUDF
public QueryCollectionInit() { Assembly assembly = typeof(QueryCollectionInit).GetTypeInfo().Assembly; RegisterTask rtask = client.Register(null, assembly, "AerospikeTest.record_example.lua", "record_example.lua", Language.LUA); rtask.Wait(); Policy policy = new Policy(); policy.totalTimeout = 0; // Do not timeout on index create. try { IndexTask task = client.CreateIndex(policy, args.ns, args.set, TestQueryCollection.indexName, TestQueryCollection.binName, IndexType.STRING, IndexCollectionType.MAPKEYS); task.Wait(); } catch (AerospikeException ae) { if (ae.Result != ResultCode.INDEX_ALREADY_EXISTS) { throw; } } for (int i = 1; i <= TestQueryCollection.size; i++) { Key key = new Key(args.ns, args.set, TestQueryCollection.keyPrefix + i); Dictionary <string, string> map = new Dictionary <string, string>(); map[TestQueryCollection.mapKeyPrefix + 1] = TestQueryCollection.mapValuePrefix + i; if (i % 2 == 0) { map[TestQueryCollection.mapKeyPrefix + 2] = TestQueryCollection.mapValuePrefix + i; } if (i % 3 == 0) { map[TestQueryCollection.mapKeyPrefix + 3] = TestQueryCollection.mapValuePrefix + i; } Bin bin = new Bin(TestQueryCollection.binName, map); client.Put(null, key, bin); } }
public static void Prepare(TestContext testContext) { Assembly assembly = Assembly.GetExecutingAssembly(); RegisterTask task = client.Register(null, assembly, "Aerospike.Test.Resources.average_example.lua", "average_example.lua", Language.LUA); task.Wait(); Policy policy = new Policy(); policy.timeout = 0; // Do not timeout on index create. IndexTask itask = client.CreateIndex(policy, args.ns, args.set, indexName, binName, IndexType.NUMERIC); itask.Wait(); for (int i = 1; i <= size; i++) { Key key = new Key(args.ns, args.set, keyPrefix + i); Bin bin = new Bin("l1", i); client.Put(null, key, bin, new Bin("l2", 1)); } }
} //main public void aggregateUsersByTweetCountByRegion(AerospikeClient client) { ResultSet rs = null; try { int min; int max; Console.WriteLine("\nEnter Min Tweet Count:"); min = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Max Tweet Count:"); max = int.Parse(Console.ReadLine()); Console.WriteLine("\nAggregating users with " + min + "-" + max + " tweets by region. Hang on...\n"); // NOTE: Index creation has been included in here for convenience and to demonstrate the syntax. // NOTE: The recommended way of creating indexes in production env is via AQL. IndexTask task = client.CreateIndex(null, "test", "testusers", "tweetcountindex", "tweetcount", IndexType.NUMERIC); task.Wait(); // NOTE: UDF registration has been included here for convenience and to demonstrate the syntax. // NOTE: The recommended way of registering UDFs in production env is via AQL string luaDirectory = @"..\..\udf"; LuaConfig.PackagePath = luaDirectory + @"\?.lua"; string filename = "aggregationByRegion.lua"; string path = Path.Combine(luaDirectory, filename); RegisterTask rt = client.Register(null, path, filename, Language.LUA); rt.Wait(); Statement stmt = new Statement(); stmt.SetNamespace("test"); stmt.SetSetName("testusers"); stmt.SetIndexName("tweetcountindex"); stmt.SetFilters(Filter.Range("tweetcount", min, max)); rs = client.QueryAggregate(null, stmt, "aggregationByRegion", "sum"); if (rs.Next()) { Dictionary <object, object> result = (Dictionary <object, object>)rs.Object; Console.WriteLine("Here's the breakdown...\n"); Console.WriteLine("Total Users in North: " + result["n"]); Console.WriteLine("Total Users in South: " + result["s"]); Console.WriteLine("Total Users in East: " + result["e"]); Console.WriteLine("Total Users in West: " + result["w"]); } } catch (AerospikeException e) { Console.WriteLine("AerospikeException - Message: " + e.Message); Console.WriteLine("AerospikeException - StackTrace: " + e.StackTrace); } finally { if (rs != null) { // Close record set rs.Close(); } } } //aggregateUsersByTweetCountByRegion
} //updatePasswordUsingCAS public void aggregateUsersByTweetCountByRegion() { // TODO: Create NUMERIC index on tweetcount in users set (Same as Exercise Q4) // Exercise A2 // NOTE: Index creation has been included in here for convenience and to demonstrate the syntax // The recommended way of creating indexes in production env is via AQL // or create once using a standalone application. //IndexTask task = client.CreateIndex(null, "test", "users", "tweetcount_index", "tweetcount", IndexType.NUMERIC); //task.Wait(); ResultSet rs = null; try { int min; int max; Console.WriteLine("\nEnter Min Tweet Count:"); min = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Max Tweet Count:"); max = int.Parse(Console.ReadLine()); // TODO: Register UDF // Exercise A2 // NOTE: UDF registration has been included here for convenience and to demonstrate the syntax. // The recommended way of registering UDFs in production env is via AQL // or standalone application using code similar to below. string luaDirectory = @"..\..\udf"; LuaConfig.PackagePath = luaDirectory + @"\?.lua"; string filename = "aggregationByRegion.lua"; string path = Path.Combine(luaDirectory, filename); RegisterTask rt = client.Register(null, path, filename, Language.LUA); rt.Wait(); // TODO: Create string array of bins that you would like to retrieve // In this example, we want to display which region has how many tweets. // Exercise A2 string[] bins = { "tweetcount", "region" }; // TODO: Create Statement instance // Exercise A2 Statement stmt = new Statement(); // TODO: Set namespace on the instance of the Statement // Exercise A2 stmt.SetNamespace("test"); // TODO: Set the name of the set on the instance of the Statement // Exercise A2 stmt.SetSetName("users"); // TODO: Set the name of index on the instance of the Statement // Exercise A2 stmt.SetIndexName("tweetcount_index"); // TODO: Set the list of bins to retrieve on the instance of the Statement // Exercise A2 stmt.SetBinNames(bins); // TODO: Set the range Filter on tweetcount on the instance of the Statement // Exercise A2 stmt.SetFilters(Filter.Range("tweetcount", min, max)); Console.WriteLine("\nAggregating users with " + min + "-" + max + " tweets by region. Hang on...\n"); // TODO: Execute the Aggregation Query passing null policy and Statement instance, // Lua Module and module function to call. // Exercise A2 rs = client.QueryAggregate(null, stmt, "aggregationByRegion", "sum"); if (rs.Next()) { // TODO: Iterate through returned RecordSet and output text in format "Total Users in <region>: <#>" // Exercise A2 Dictionary <object, object> result = (Dictionary <object, object>)rs.Object; Console.WriteLine("Total Users in North: " + result["n"]); Console.WriteLine("Total Users in South: " + result["s"]); Console.WriteLine("Total Users in East: " + result["e"]); Console.WriteLine("Total Users in West: " + result["w"]); } } finally { // TODO: Close the RecordSet // Exercise A2 if (rs != null) { // Close record set rs.Close(); } } } //aggregateUsersByTweetCountByRegion
private void CreateAccountButtonClicked() { task = new RegisterTask(); task.Execute(this); }
} //updatePasswordUsingUDF public void aggregateUsersByTweetCountByRegion() { RecordSet rs = null; //ResultSet asd try { int min; int max; Console.WriteLine("\nEnter Min Tweet Count:"); min = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Max Tweet Count:"); max = int.Parse(Console.ReadLine()); Console.WriteLine("\nAggregating users with " + min + "-" + max + " tweets by region. Hang on...\n"); //string luaDirectory = @"..\..\udf"; //LuaConfig.PackagePath = luaDirectory + @"\?.lua"; //string filename = "aggregationByRegion.lua"; //string path = Path.Combine(luaDirectory, filename); //RegisterTask rt = client.Register(null, path, filename, Language.LUA); //rt.Wait(); Assembly assembly = Assembly.GetExecutingAssembly(); Policy policy = new Policy(); policy.SetTimeout(100); RegisterTask rtask = client.Register(policy, "aggregationByRegion.lua", "aggregationByRegion.lua", Language.LUA); rtask.Wait(); string[] bins = { "tweetcount", "region" }; Statement stmt = new Statement(); stmt.SetNamespace("test"); stmt.SetSetName("users"); stmt.SetIndexName("tweetcount_index"); stmt.SetBinNames(bins); stmt.SetFilter(Filter.Range("tweetcount", min, max)); stmt.SetAggregateFunction("aggregationByRegion", "sum"); //QueryAggregateExecutor queryAggregateExecutor = new QueryAggregateExecutor(null, null, stmt); //rs = queryAggregateExecutor.ResultSet; rs = client.Query(null, stmt); //rs = client.QueryAggregate(null, stmt, "aggregationByRegion", "sum"); if (rs.Next()) { //Dictionary<object, object> result = (Dictionary<object, object>)rs.Record.; //Console.WriteLine("Total Users in North: " + result["n"]); //Console.WriteLine("Total Users in South: " + result["s"]); //Console.WriteLine("Total Users in East: " + result["e"]); //Console.WriteLine("Total Users in West: " + result["w"]); } } finally { if (rs != null) { // Close record set rs.Close(); } } } //aggregateUsersByTweetCountByRegion