protected RiakString UpdateMap(TModel model, UpdateMap.MapOperation mapOperation, bool fetchFirst = false) { byte[] context = null; if (fetchFirst) { MapResponse response = FetchMap(model); context = response.Context; } var builder = new UpdateMap.Builder(mapOperation) .WithBucketType(BucketType) .WithBucket(Bucket); if (!string.IsNullOrEmpty(model.ID)) { builder.WithKey(model.ID); } UpdateMap cmd = builder.Build(); RiakResult rslt = client.Execute(cmd); CheckResult(rslt); return(cmd.Response.Key); }
protected void RiakMinVersion(ushort major, ushort minor, ushort build) { if (client == null) { throw new InvalidOperationException("Expected a client!"); } if (riakVersion == null) { var serverInfo = new FetchServerInfo(); RiakResult rslt = client.Execute(serverInfo); Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage); var serverVersion = serverInfo.Response.Value.ServerVersion; if (!Version.TryParse(serverVersion, out riakVersion)) { Assert.Fail("Could not parse server version: {0}", serverVersion); } } if (!(riakVersion.Major >= major && riakVersion.Minor >= minor && riakVersion.Build >= build)) { Assert.Pass("Test requires a newer version of Riak. Skipping!"); } }
private static void FetchServerInfo() { Console.WriteLine("[ChaosMonkeyApp] fetch server info thread starting"); IRiakClient client = cluster.CreateClient(); try { while (true) { var cmd = new FetchServerInfo(); var rslt = client.Execute(cmd); if (rslt.IsSuccess) { var rsp = cmd.Response; var n = rsp.Value.Node; var v = rsp.Value.ServerVersion; // Console.WriteLine("[ChaosMonkeyApp] got server info: {0}, {1}", n, v); } else { Console.WriteLine("[ChaosMonkeyApp] error getting server info: {0}", rslt.ErrorMessage); } Thread.Sleep(fetchDataInterval); ct.ThrowIfCancellationRequested(); } } finally { Console.WriteLine("[ChaosMonkeyApp] fetch server info thread stopping"); } }
private async Task InsertMessagesIntoDatabase(string table, List <Message> allMessages) { IRiakEndPoint cluster = RiakCluster.FromConfig("riakConfig"); IRiakClient client = cluster.CreateClient(); while (allMessages.Count() > 0) { List <Message> messages = allMessages.Take(80).ToList(); allMessages.RemoveRange(0, messages.Count()); var rows = new List <Row>(); foreach (Message message in messages) { var cells = new Cell[] { new Cell("LT"), new Cell(message.SerialNo), new Cell(message.DeviceName), new Cell(message.Timestamp), new Cell(message.Value) }; rows.Add(new Row(cells)); } var columns = new Column[] { new Column("Country", ColumnType.Varchar), new Column("SerialNo", ColumnType.Varchar), new Column("DeviceName", ColumnType.Varchar), new Column("Time", ColumnType.Timestamp), new Column("Value", ColumnType.Double) }; var cmd = new Store.Builder() .WithTable(table) .WithColumns(columns) .WithRows(rows) .Build(); RiakResult rslt = client.Execute(cmd); if (!rslt.IsSuccess) { throw new Exception("Connection to Riak was not successful. AllMessages: " + allMessages.Count()); } } }
private void InsertMessageIntoDatabase(string table, Message message) { IRiakEndPoint cluster = RiakCluster.FromConfig("riakConfig"); IRiakClient client = cluster.CreateClient(); var cells = new Cell[] { new Cell("LT"), new Cell(message.SerialNo), new Cell(message.DeviceName), new Cell(message.Timestamp), new Cell(message.Value) }; var rows = new Row[] { new Row(cells) }; var columns = new Column[] { new Column("Country", ColumnType.Varchar), new Column("SerialNo", ColumnType.Varchar), new Column("DeviceName", ColumnType.Varchar), new Column("Time", ColumnType.Timestamp), new Column("Value", ColumnType.Double) }; var cmd = new Store.Builder() .WithTable(table) .WithColumns(columns) .WithRows(rows) .Build(); RiakResult rslt = client.Execute(cmd); if (!rslt.IsSuccess) { throw new Exception("Connection to Riak was not successful."); } }
public virtual RiakResult Execute() { return(Assert(_client.Execute(_command))); }
/// <inheritdoc/> public Task <RiakResult> Execute(IRiakCommand command) { return(Task.Factory.StartNew(() => client.Execute(command))); }