/// <summary> /// Gets active notification listeners. /// </summary> public static ICollection GetActiveNotificationListeners(this IIgniteClient client) { var failoverSocket = GetPrivateField <ClientFailoverSocket>(client, "_socket"); var socket = GetPrivateField <ClientSocket>(failoverSocket, "_socket"); return(GetPrivateField <ICollection>(socket, "_notificationListeners")); }
public void GlobalSetup() { _client = new Client(Params.Instance.Value.Host).Start(); _cacheA = _client.GetOrCreateCache <int, ModelA>(typeof(ModelA).Name); _cacheB = _client.GetOrCreateCache <int, ModelB>(typeof(ModelB).Name); _cacheC = _client.GetOrCreateCache <int, ModelC>(typeof(ModelC).Name); _cacheD = _client.GetOrCreateCache <int, ModelD>(typeof(ModelD).Name); _cacheE = _client.GetOrCreateCache <int, ModelE>(typeof(ModelE).Name); _cacheF = _client.GetOrCreateCache <AffinityKey, ModelA>(typeof(ModelA).Name + "Affinity"); _cacheG = _client.GetOrCreateCache <AffinityKey, ModelB>(typeof(ModelB).Name + "Affinity"); _cacheH = _client.GetOrCreateCache <AffinityKey, ModelC>(typeof(ModelC).Name + "Affinity"); _cacheI = _client.GetOrCreateCache <AffinityKey, ModelD>(typeof(ModelD).Name + "Affinity"); _cacheJ = _client.GetOrCreateCache <AffinityKey, ModelE>(typeof(ModelE).Name + "Affinity"); _max = Params.Instance.Value.TotalObjects; var data = new Data(); var keys = Enumerable.Range(0, _max).ToArray(); FillCache(_cacheA, keys, data.GetModelsA()); FillCache(_cacheB, keys, data.GetModelsB()); FillCache(_cacheC, keys, data.GetModelsC()); FillCache(_cacheD, keys, data.GetModelsD()); FillCache(_cacheE, keys, data.GetModelsE()); var affinityKeys = Enumerable.Range(0, _max).Select(k => new AffinityKey(k, k / 10)).ToArray(); FillCache(_cacheF, affinityKeys, data.GetModelsA()); FillCache(_cacheG, affinityKeys, data.GetModelsB()); FillCache(_cacheH, affinityKeys, data.GetModelsC()); FillCache(_cacheI, affinityKeys, data.GetModelsD()); FillCache(_cacheJ, affinityKeys, data.GetModelsE()); }
/// <summary> /// Gets the logs. /// </summary> protected List<ListLogger.Entry> GetLogs(IIgniteClient client) { var igniteClient = (IgniteClient) client; var logger = igniteClient.GetConfiguration().Logger; var listLogger = (ListLogger) logger; return listLogger.Entries; }
public static void Main() { using (IIgniteClient ignite = Ignition.StartClient(Utils.GetThinClientConfiguration())) { Console.WriteLine(); Console.WriteLine(">>> Optimistic transaction example started."); // Create Transactional cache. var cacheCfg = new CacheClientConfiguration(CacheName) { AtomicityMode = CacheAtomicityMode.Transactional }; var cache = ignite.GetOrCreateCache <int, int>(cacheCfg); // Put a value. cache[1] = 0; // Increment a value in parallel within a transaction. var transactions = ignite.GetTransactions(); var task1 = Task.Factory.StartNew(() => IncrementCacheValue(cache, transactions, 1)); var task2 = Task.Factory.StartNew(() => IncrementCacheValue(cache, transactions, 2)); Task.WaitAll(task1, task2); Console.WriteLine(); Console.WriteLine(">>> Resulting value in cache: " + cache[1]); Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); } }
public static void Main() { var cfg = new IgniteClientConfiguration("127.0.0.1"); using (IIgniteClient igniteClient = Ignition.StartClient(cfg)) { Console.WriteLine(); Console.WriteLine(">>> Cache query client example started."); // Configure query entities to enable SQL. var cacheCfg = new CacheClientConfiguration { Name = CacheName, QueryEntities = new[] { new QueryEntity(typeof(int), typeof(Employee)), } }; ICacheClient <int, Employee> cache = igniteClient.GetOrCreateCache <int, Employee>(cacheCfg); // Populate cache with sample data entries. PopulateCache(cache); // Run examples. SqlExample(cache); LinqExample(cache); LinqFieldsExample(cache); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
static void Main(string[] args) { var cfg = new IgniteClientConfiguration { Host = "127.0.0.1" }; using (IIgniteClient client = Ignition.StartClient(cfg)) { var cache = client.GetCache <string, Forex>("myCache"); var forexWritten = Forex.CreateBuilder() .SetCommon(CommonFields.CreateBuilder().SetId("EUR").SetName("EUR").SetTimestamp(misysdatamodel.DateTime.DefaultInstance).SetSourceRef("tt").SetInstanceRef("zzz").Build()) .AddQuotes(Forex.Types.ForexQuote.CreateBuilder().SetLast(12).Build()) .Build(); cache.Put("EUR", forexWritten); var f = cache.Get("EUR"); //for (int i = 0; i < 10; i++) // cache.Put(i, i.ToString()); //for (int i = 0; i < 10; i++) // Console.WriteLine("Got [key={0}, val={1}]", i, cache.Get(i)); } }
/// <summary> /// Execute individual Put and Get, getting value in binary format, without de-serializing it. /// </summary> /// <param name="ignite">Ignite instance.</param> private static void PutGetBinary(IIgniteClient ignite) { ICacheClient <int, Organization> cache = ignite.GetCache <int, Organization>(CacheName); // Create new Organization to store in cache. Organization org = new Organization( "Microsoft", new Address("1096 Eddy Street, San Francisco, CA", 94109), OrganizationType.Private, DateTime.Now ); // Put created data entry to cache. cache.Put(1, org); // Create projection that will get values as binary objects. var binaryCache = cache.WithKeepBinary <int, IBinaryObject>(); // Get recently created organization as a binary object. var binaryOrg = binaryCache.Get(1); // Get organization's name from binary object (note that object doesn't need to be fully deserialized). string name = binaryOrg.GetField <string>("name"); Console.WriteLine(); Console.WriteLine(">>> Retrieved organization name from binary object: " + name); }
public PerperTriggerValueBinder(JObject trigger, IIgniteClient ignite, PerperBinarySerializer serializer, ILogger logger) { _trigger = trigger; _ignite = ignite; _serializer = serializer; _logger = logger; }
public static void Main() { var cfg = new IgniteClientConfiguration { Host = "127.0.0.1" }; using (IIgniteClient igniteClient = Ignition.StartClient(cfg)) { Console.WriteLine(); Console.WriteLine(">>> Cache query client example started."); ICacheClient <int, Employee> cache = igniteClient.GetOrCreateCache <int, Employee>(CacheName); // Populate cache with sample data entries. PopulateCache(cache); // Run scan query example. ScanQueryExample(cache); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (IIgniteClient ignite = Ignition.StartClient(Utils.GetThinClientConfiguration())) { Console.WriteLine(); Console.WriteLine(">>> Cache scan query example started."); var employeeCache = ignite.GetOrCreateCache <int, Employee>( new CacheClientConfiguration(EmployeeCacheName, new QueryEntity(typeof(int), typeof(Employee)))); Utils.PopulateCache(employeeCache); const int zip = 94109; var qry = employeeCache.Query(new ScanQuery <int, Employee>(new ScanQueryFilter(zip))); Console.WriteLine(); Console.WriteLine(">>> Employees with zipcode {0} (scan):", zip); foreach (var entry in qry) { Console.WriteLine(">>> " + entry.Value); } Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public IgniteViewModel() { Task.Run(() => { var cfg = new IgniteClientConfiguration { Host = "127.0.0.1" }; try { Console.WriteLine("Connecting..."); _client = Ignition.StartClient(cfg); var cacheNames = _client.GetCacheNames(); Status = $"Connected to Ignite cluster. Found {cacheNames.Count} caches."; Caches = cacheNames.Select(x => new CacheViewModel(_client, x)).ToArray(); Console.WriteLine("CONNECTED."); } catch (Exception e) { Status = "Failed to connect: " + e; Console.WriteLine(e); throw; } }); }
public void PopulateMessages() { List <ChatMessege> messages = new List <ChatMessege> { new ChatMessege { Name = "abc", CreatedDateTime = "1562770732" }, new ChatMessege { Name = "abc", CreatedDateTime = "1562770728" }, new ChatMessege { Name = "abc-1", CreatedDateTime = "1562770724" }, new ChatMessege { Name = "abc-3", CreatedDateTime = "1562770742" }, new ChatMessege { Name = "abc-3", CreatedDateTime = "1562770743" } }; foreach (var mess in messages) { using (IIgniteClient client = Ignition.StartClient(this._igniteClientConfiguration)) { //get cache configuraation var cache = client.GetOrCreateCache <string, ChatMessege>(GetOrCreaeMessageCacheConfig("messages")); cache.Put(mess.Name, mess); Console.WriteLine(cache.Get(mess.Name).Name); } } }
public void QueryLinq() { try { using (IIgniteClient client = Ignition.StartClient(this._igniteClientConfiguration)) { //get cache configuraation var cache = client.GetCache <string, ChatMessege>("messages"); //var data = cache.Query(new SqlFieldsQuery("select * from ChatMessege Where Name = 'abc'")).GetAll(); //Console.WriteLine(JsonConvert.SerializeObject(data)); //IQueryable<ICacheEntry<string, ChatMessege>> msgs = cache.AsCacheQueryable().OrderByDescending(msg => msg.Value.CreatedDateTime).Where(msg => msg.Value.Name == "abc").Take(2); var cache0 = cache.AsCacheQueryable(); //Compiled Query //var compileQuery = CompiledQuery.Compile((IQueryable<ICacheEntry<string,ChatMessege>> query,string name) => query.Where(msg => msg.Value.Name == name)); // var compileQuery = CompiledQuery.Compile((string name) => cache0.Where(msg => msg.Value.Name == name)); //IQueryable<ICacheEntry<string, ChatMessege>> qry = (from msg in msgs orderby msg.Value.CreatedDateTime descending select msg).Take(2); foreach (ICacheEntry <string, ChatMessege> entry in compile.Invoke(cache0, "abc")) { Console.WriteLine(">>> " + entry.Value.CreatedDateTime + "\t" + entry.Value.Name); } } } catch (Exception ex) { } }
public void PopulateEmployees() { List <Employee> messages = new List <Employee> { new Employee { Name = "abc", Salary = 100, EmpId = "1" }, new Employee { Name = "abc-1", Salary = 200, EmpId = "2" }, new Employee { Name = "abc-2", Salary = 400, EmpId = "3" }, new Employee { Name = "abc-3", Salary = 300, EmpId = "4" }, new Employee { Name = "abc-4", Salary = 200, EmpId = "5" }, }; ICacheClient <string, Employee> cache = null; foreach (var mess in messages) { using (IIgniteClient client = Ignition.StartClient(this._igniteClientConfiguration)) { //get cache configuraation cache = client.GetOrCreateCache <string, Employee>(GetOrCreateEmployeeCacheConfig("Employees")); cache.Put(mess.EmpId, mess); Console.WriteLine(cache.Get(mess.EmpId).Name); } } }
/// <summary> /// Queries employees that have specific salary with a compiled query. /// </summary> /// <param name="cache">Cache.</param> private void CompiledQueryExample() { using (IIgniteClient client = Ignition.StartClient(this._igniteClientConfiguration)) { var cache = client.GetCache <string, Employee>("Employees"); const int minSalary = 200; var queryable = cache.AsCacheQueryable(); //this query causing issue Func <string, IQueryCursor <ICacheEntry <string, Employee> > > issueqry = CompiledQuery.Compile((string empName) => queryable.Where(emp => emp.Value.Name == empName)); //with this no issue Func <int, IQueryCursor <ICacheEntry <string, Employee> > > qry = CompiledQuery.Compile((int min) => queryable.Where(emp => emp.Value.Salary == min)); foreach (var entry in qry(minSalary)) { Console.WriteLine(">>> " + entry.Value.Name); } foreach (var entry in issueqry("abc")) { Console.WriteLine(">>> " + entry.Value.Name); } } }
/// <summary> /// Gets or creates transactional cache /// </summary> private ICacheClient <int, int> GetTransactionalCache(IIgniteClient client, string cacheName = null) { return(client.GetOrCreateCache <int, int>(new CacheClientConfiguration { Name = cacheName ?? GetCacheName(), AtomicityMode = CacheAtomicityMode.Transactional })); }
public Context(FabricService fabric, PerperInstanceData instance, IIgniteClient ignite, PerperBinarySerializer serializer, IState state, ILogger <Context> logger) { _fabric = fabric; _ignite = ignite; _instance = instance; _serializer = serializer; _state = state; _logger = logger; }
private static ICacheClient <int, int> CreateCache(IIgniteClient client) { return(client.CreateCache <int, int>(new CacheClientConfiguration { Name = TestUtils.TestName, CacheMode = CacheMode.Replicated, WriteSynchronizationMode = CacheWriteSynchronizationMode.FullSync, RebalanceMode = CacheRebalanceMode.Sync })); }
public static void ClientCluster() { var cfg = new IgniteClientConfiguration(); //tag::client-cluster[] IIgniteClient client = Ignition.StartClient(cfg); IClientCluster cluster = client.GetCluster(); cluster.SetActive(true); cluster.EnableWal("my-cache"); //end::client-cluster[] }
public PerperTriggerListener(FabricService fabric, string @delegate, IIgniteClient ignite, ITriggeredFunctionExecutor executor, ILogger logger) { _fabric = fabric; _delegate = @delegate; _ignite = ignite; _executor = executor; _logger = logger; _listenCancellationTokenSource = new CancellationTokenSource(); }
public static void Services() { var cfg = new IgniteClientConfiguration(); //tag::client-services[] IIgniteClient client = Ignition.StartClient(cfg); IServicesClient services = client.GetServices(); IMyService serviceProxy = services.GetServiceProxy <IMyService>("MyService"); serviceProxy.MyServiceMethod("hello"); //end::client-services[] }
public CacheViewModel(IIgniteClient ignite, string cacheName) { // TODO: Binary mode. _cache = ignite.GetCache <object, object>(cacheName) .WithKeepBinary <object, object>(); Task.Run(() => { CacheEntries = _cache.Query(new ScanQuery <object, object>()).Take(10).ToArray(); }); }
public IgniteBookCache(ILogger logger, IIgniteClient igniteClient, IgniteClientConfiguration configuration) { this.logger = logger; this.igniteClient = igniteClient; bookCache = this.igniteClient.GetOrCreateCache <BookKey, Book>(new CacheClientConfiguration { Name = "Books", AtomicityMode = CacheAtomicityMode.Transactional, DataRegionName = configuration.DataRegion }); }
public IgniteBookReservationQueueCache(ILogger logger, IIgniteClient igniteClient, IgniteClientConfiguration configuration) { this.logger = logger; this.igniteClient = igniteClient; reservationCache = this.igniteClient.GetOrCreateCache <BookQueueKey, List <Reservation> >(new CacheClientConfiguration { Name = "Reservations", AtomicityMode = CacheAtomicityMode.Transactional, DataRegionName = configuration.DataRegion }); }
public static void ClientClusterGroups() { var cfg = new IgniteClientConfiguration(); //tag::client-cluster-groups[] IIgniteClient client = Ignition.StartClient(cfg); IClientClusterGroup serversInDc1 = client.GetCluster().ForServers().ForAttribute("dc", "dc1"); foreach (IClientClusterNode node in serversInDc1.GetNodes()) { Console.WriteLine($"Node ID: {node.Id}"); } //end::client-cluster-groups[] }
public static ICacheClient <FrameKey, FrameData> GetOrCreateFrameCache(IIgniteClient ignite, string cacheName) { void Extend(CacheClientConfiguration cfg) { cfg.KeyConfiguration = new CacheKeyConfiguration[] { new CacheKeyConfiguration { TypeName = typeof(FrameKey).FullName, AffinityKeyFieldName = nameof(FrameKey.FlowKeyHash) } }; } return(GetOrCreateCache <FrameKey, FrameData>(ignite, cacheName, Extend)); }
public IgniteUserCache(ILogger logger, IIgniteClient igniteClient, AdminLibrarian adminLibrarian, IgniteClientConfiguration configuration) { this.igniteClient = igniteClient; this.logger = logger; userCache = this.igniteClient.GetOrCreateCache <UserKey, User>(new CacheClientConfiguration { Name = "Users", AtomicityMode = CacheAtomicityMode.Transactional, DataRegionName = configuration.DataRegion }); StoreUser(adminLibrarian); }
private void Close() { if (this._client != null) { this._client.Dispose(); this._client = null; } if (this._timer != null) { this._timer.Stop(); this._timer = null; } }
public PerperTriggerBinding(ParameterInfo parameter, PerperTriggerAttribute attribute, FabricService fabric, IIgniteClient ignite, IServiceProvider services, ILogger <PerperTriggerBinding> logger) { _parameter = parameter; _fabric = fabric; _ignite = ignite; _services = services; _logger = logger; _parameterExpression = attribute.ParameterExpression is null ? null : JObject.Parse(attribute.ParameterExpression); BindingDataContract = CreateBindingDataContract(); }
private async Task ProcessFile(IIgniteClient client, FileInfo fileInfo, FastPcapFileReaderDevice device) { device.Open(); var frameKeyProvider = new FrameKeyProvider(); var packetCache = CacheFactory.GetOrCreateFrameCache(client, FrameCacheName ?? fileInfo.Name); var frameIndex = 0; var frameArray = new KeyValuePair <FrameKey, FrameData> [ChunkSize]; var cacheStoreTask = Task.CompletedTask; var currentChunkBytes = 0; var currentChunkNumber = 0; RawCapture rawCapture = null; while ((rawCapture = device.GetNextPacket()) != null) { currentChunkBytes += rawCapture.Data.Length + 4 * sizeof(int); var frame = new FrameData { LinkLayer = (LinkLayerType)rawCapture.LinkLayerType, Timestamp = rawCapture.Timeval.ToUnixTimeMilliseconds(), Data = rawCapture.Data }; var frameKey = new FrameKey(frameIndex, frameKeyProvider.GetKeyHash(frame)); frameArray[frameIndex % ChunkSize] = KeyValuePair.Create(frameKey, frame); // Is CHUNK full? if (frameIndex % ChunkSize == ChunkSize - 1) { OnChunkLoaded?.Invoke(this, currentChunkNumber, currentChunkBytes); cacheStoreTask = cacheStoreTask.ContinueWith(CreateStoreAction(packetCache, frameArray, ChunkSize, currentChunkNumber, currentChunkBytes)); frameArray = new KeyValuePair <FrameKey, FrameData> [ChunkSize]; currentChunkNumber++; currentChunkBytes = 0; } frameIndex++; } OnChunkLoaded?.Invoke(this, currentChunkNumber, currentChunkBytes); cacheStoreTask = cacheStoreTask.ContinueWith(CreateStoreAction(packetCache, frameArray, frameIndex % ChunkSize, currentChunkNumber, currentChunkBytes)); await cacheStoreTask; device.Close(); }