/// <summary> /// Initializes a new instance of the <see cref="ClientQueryCursor{TK, TV}" /> class. /// </summary> /// <param name="ignite">The ignite.</param> /// <param name="cursorId">The cursor identifier.</param> /// <param name="keepBinary">Keep binary flag.</param> /// <param name="initialBatchStream">Optional stream with initial batch.</param> /// <param name="getPageOp">The get page op.</param> public ClientQueryCursor(IgniteClient ignite, long cursorId, bool keepBinary, IBinaryStream initialBatchStream, ClientOp getPageOp) : base(ignite, cursorId, keepBinary, initialBatchStream, getPageOp, r => new CacheEntry <TK, TV>(r.ReadObject <TK>(), r.ReadObject <TV>())) { // No-op. }
/// <summary> /// Initializes a new instance of the <see cref="ClientQueryCursor{TK, TV}" /> class. /// </summary> /// <param name="ignite">The ignite.</param> /// <param name="cursorId">The cursor identifier.</param> /// <param name="keepBinary">Keep binary flag.</param> /// <param name="initialBatchStream">Optional stream with initial batch.</param> public ClientQueryCursor(IgniteClient ignite, long cursorId, bool keepBinary, IBinaryStream initialBatchStream) : base(ignite.Marshaller, keepBinary, initialBatchStream) { _ignite = ignite; _cursorId = cursorId; }
public async void Launch(PlayerCredentialsDto playerCredentialsDto) { _playerCredentialsDto = playerCredentialsDto; _ignite = new IgniteClient(playerCredentialsDto); //Console.WriteLine("{0} {1} {2} {3}", playerCredentialsDto.serverIp, playerCredentialsDto.serverPort, playerCredentialsDto.encryptionKey, playerCredentialsDto.summonerId); //return; new System.Threading.Tasks.Task(() => _ignite.Start()).Start(); var timer = new Timer(); timer.Interval = TimeSpan.FromMinutes(5).TotalMilliseconds; timer.Elapsed += (s, e) => { if (!_ignite.Connected) { Flash.Log.Write("[{0}] Time out reached.", playerCredentialsDto.summonerName); _ignite.Exit(); _ignite = new IgniteClient(_playerCredentialsDto); new System.Threading.Tasks.Task(() => _ignite.Start()).Start(); return; } (s as Timer).Stop(); }; timer.Start(); }
public async Task TestClientRetriesComputeJobOnPrimaryAndDefaultNodes() { using var server1 = new FakeServer(shouldDropConnection: cnt => cnt % 2 == 0, nodeName: "s1"); using var server2 = new FakeServer(shouldDropConnection: cnt => cnt % 2 == 0, nodeName: "s2"); var clientCfg = new IgniteClientConfiguration { Endpoints = { server1.Node.Address.ToString(), server2.Node.Address.ToString() }, RetryPolicy = new RetryLimitPolicy { RetryLimit = 2 } }; using var client = await IgniteClient.StartAsync(clientCfg); // ReSharper disable once AccessToDisposedClosure TestUtils.WaitForCondition(() => client.GetConnections().Count == 2); for (int i = 0; i < 100; i++) { var node = i % 2 == 0 ? server1.Node : server2.Node; var res = await client.Compute.ExecuteAsync <string>(nodes : new[] { node }, jobClassName : string.Empty); Assert.AreEqual(node.Name, res); } }
public async Task TestClientSendsComputeJobToTargetNodeWhenDirectConnectionExists() { using var server1 = new FakeServer(nodeName: "s1"); using var server2 = new FakeServer(nodeName: "s2"); using var server3 = new FakeServer(nodeName: "s3"); var clientCfg = new IgniteClientConfiguration { Endpoints = { server1.Node.Address.ToString(), server2.Node.Address.ToString(), server3.Node.Address.ToString() } }; using var client = await IgniteClient.StartAsync(clientCfg); // ReSharper disable once AccessToDisposedClosure TestUtils.WaitForCondition(() => client.GetConnections().Count == 3); var res2 = await client.Compute.ExecuteAsync <string>(nodes : new[] { server2.Node }, jobClassName : string.Empty); var res3 = await client.Compute.ExecuteAsync <string>(nodes : new[] { server3.Node }, jobClassName : string.Empty); Assert.AreEqual("s2", res2); Assert.AreEqual("s3", res3); Assert.AreEqual(ClientOp.ComputeExecute, server2.ClientOps.Single()); Assert.AreEqual(ClientOp.ComputeExecute, server3.ClientOps.Single()); Assert.IsEmpty(server1.ClientOps); }
public void TestStartAsyncThrowsExceptionOnEmptyEndpoints() { var ex = Assert.ThrowsAsync <IgniteClientException>( async() => await IgniteClient.StartAsync(new IgniteClientConfiguration())); Assert.AreEqual("Invalid IgniteClientConfiguration: Endpoints is empty. Nowhere to connect.", ex !.Message); }
/// <summary> /// Initializes a new instance of the <see cref="ClientQueryCursorBase{T}" /> class. /// </summary> /// <param name="ignite">The ignite.</param> /// <param name="cursorId">The cursor identifier.</param> /// <param name="keepBinary">Keep binary flag.</param> /// <param name="initialBatchStream">Optional stream with initial batch.</param> /// <param name="getPageOp">The get page op.</param> /// <param name="readFunc">Read func.</param> public ClientQueryCursorBase(IgniteClient ignite, long cursorId, bool keepBinary, IBinaryStream initialBatchStream, ClientOp getPageOp, Func <BinaryReader, T> readFunc) : base(ignite.Marshaller, keepBinary, readFunc, initialBatchStream) { _ignite = ignite; _cursorId = cursorId; _getPageOp = getPageOp; }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> /// <param name="marsh">Marshaller.</param> public ClientCluster(IgniteClient ignite, Marshaller marsh) { Debug.Assert(ignite != null); Debug.Assert(marsh != null); _ignite = ignite; _marsh = marsh; }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> /// <param name="projection">Projection.</param> /// <param name="predicate">Predicate.</param> private ClientClusterGroup(IgniteClient ignite, ClientClusterGroupProjection projection, Func <IClientClusterNode, bool> predicate = null) { Debug.Assert(ignite != null); _ignite = ignite; _projection = projection; _predicate = predicate; }
public async Task OneTimeSetUp() { _eventListener = new TestEventListener(); Client = await IgniteClient.StartAsync(GetConfig()); Table = (await Client.Tables.GetTableAsync(TableName)) !; TupleView = Table.RecordBinaryView; PocoView = Table.GetRecordView <Poco>(); }
public async Task TestStartAsyncConnectsToServer() { using var client = await IgniteClient.StartAsync(GetConfig ()); Assert.IsNotNull(client); var tables = await client.Tables.GetTablesAsync(); Assert.Greater(tables.Count, 0); }
/// <summary> /// Initializes a new instance of the <see cref="CacheClient{TK, TV}" /> class. /// </summary> /// <param name="ignite">Ignite.</param> /// <param name="name">Cache name.</param> public CacheClient(IgniteClient ignite, string name) { Debug.Assert(ignite != null); Debug.Assert(name != null); _name = name; _ignite = ignite; _marsh = _ignite.Marshaller; _id = BinaryUtils.GetCacheId(name); }
/// <summary> /// Initializes a new instance of <see cref="ComputeClient"/>. /// </summary> internal ComputeClient( IgniteClient ignite, ComputeClientFlags flags, TimeSpan?timeout, IClientClusterGroup clusterGroup) { _ignite = ignite; _flags = flags; _timeout = timeout ?? TimeSpan.Zero; _clusterGroup = clusterGroup; }
/// <summary> /// Initializes a new instance of the <see cref="CacheClient{TK, TV}" /> class. /// </summary> /// <param name="ignite">Ignite.</param> /// <param name="name">Cache name.</param> /// <param name="keepBinary">Binary mode flag.</param> /// /// <param name="expiryPolicy">Expire policy.</param> public CacheClient(IgniteClient ignite, string name, bool keepBinary = false, IExpiryPolicy expiryPolicy = null) { Debug.Assert(ignite != null); Debug.Assert(name != null); _name = name; _ignite = ignite; _marsh = _ignite.Marshaller; _id = BinaryUtils.GetCacheId(name); _keepBinary = keepBinary; _expiryPolicy = expiryPolicy; }
private static async Task <string> ConnectAndGetLog(TimeSpan heartbeatInterval) { var logger = new ListLogger(); var cfg = new IgniteClientConfiguration(GetConfig()) { Logger = logger, HeartbeatInterval = heartbeatInterval }; using var client = await IgniteClient.StartAsync(cfg); return(logger.GetLogString()); }
/// <summary> /// Initializes a new instance of <see cref="ServicesClient"/> class. /// </summary> public ServicesClient( IgniteClient ignite, IClientClusterGroup clusterGroup = null, bool keepBinary = false, bool serverKeepBinary = false, TimeSpan timeout = default(TimeSpan)) { Debug.Assert(ignite != null); _ignite = ignite; _clusterGroup = clusterGroup; _keepBinary = keepBinary; _serverKeepBinary = serverKeepBinary; _timeout = timeout; }
private static async Task <Exception?> TryConnect(int port) { try { var cfg = new IgniteClientConfiguration("127.0.0.1:" + port); using var client = await IgniteClient.StartAsync(cfg); var tables = await client.Tables.GetTablesAsync(); return(tables.Count > 0 ? null : new InvalidOperationException("No tables found on server")); } catch (Exception e) { Log(e.ToString()); return(e); } }
public async Task TestServerDoesNotDisconnectIdleClientWithHeartbeats() { var logger = new ListLogger(); var cfg = new IgniteClientConfiguration(GetConfig()) { Logger = logger }; using var client = await IgniteClient.StartAsync(cfg); logger.Clear(); await Task.Delay(ServerIdleTimeout * 3); Assert.DoesNotThrowAsync(async() => await client.Tables.GetTablesAsync()); Assert.IsEmpty(logger.GetLogString(), "No disconnects or reconnects should be logged."); }
/// <summary> /// Initializes a new instance of the <see cref="ClientQueryCursor{TK, TV}" /> class. /// </summary> /// <param name="ignite">The ignite.</param> /// <param name="cursorId">The cursor identifier.</param> /// <param name="keepBinary">Keep binary flag.</param> /// <param name="initialBatchStream">Optional stream with initial batch.</param> /// <param name="getPageOp">The get page op.</param> /// <param name="columns">The columns.</param> public ClientFieldsQueryCursor(IgniteClient ignite, long cursorId, bool keepBinary, IBinaryStream initialBatchStream, ClientOp getPageOp, IList <string> columns) : base(ignite, cursorId, keepBinary, initialBatchStream, getPageOp, r => { var res = new List <object>(columns.Count); for (var i = 0; i < columns.Count; i++) { res.Add(r.ReadObject <object>()); } return(res); }) { Debug.Assert(columns != null); FieldNames = new ReadOnlyCollection <string>(columns); }
public async Task GlobalSetup() { _javaServer = await JavaServer.StartAsync(); _client = await IgniteClient.StartAsync(new IgniteClientConfiguration("127.0.0.1:" + _javaServer.Port)); _table = (await _client.Tables.GetTableAsync("PUB.tbl1")) !.RecordBinaryView; var tuple = new IgniteTuple { ["key"] = 1, ["val"] = "foo" }; await _table.UpsertAsync(null, tuple); _keyTuple = new IgniteTuple { ["key"] = 1 }; }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> /// <param name="marsh">Marshaller.</param> public ClientCluster(IgniteClient ignite, Marshaller marsh) : base(ignite, marsh) { }
public T DoOutInOpExtension <T>(int extensionId, int opCode, Action <IBinaryRawWriter> writeAction, Func <IBinaryRawReader, T> readFunc) { // Should not be called, there are no usages for thin client. throw IgniteClient.GetClientNotSupportedException(); }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> public ClientCluster(IgniteClient ignite) : base(ignite) { // No-op. }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> public ClientCluster(IgniteClient ignite) { Debug.Assert(ignite != null); _ignite = ignite; }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> /// <param name="cfg"></param> public TransactionsClient(IgniteClient ignite, TransactionClientConfiguration cfg) { _ignite = ignite; _cfg = cfg ?? new TransactionClientConfiguration(); _txManager = new ClientCacheTransactionManager(this); }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> /// <param name="marsh">Marshaller.</param> internal ClientClusterGroup(IgniteClient ignite, Marshaller marsh) : this(ignite, marsh, ClientClusterGroupProjection.Empty) { // No-op. }
/// <summary> /// Constructor. /// </summary> /// <param name="ignite">Ignite.</param> internal ClientClusterGroup(IgniteClient ignite) : this(ignite, ClientClusterGroupProjection.Empty) { // No-op. }
/** <inheritdoc /> */ public List <IBinaryType> GetBinaryTypes() { throw IgniteClient.GetClientNotSupportedException(); }
/** <inheritdoc /> */ public BinaryType RegisterEnum(string typeName, IEnumerable <KeyValuePair <string, int> > values) { throw IgniteClient.GetClientNotSupportedException(); }