public ConnectionManager(HazelcastClient client) { _client = client; _loadBalancer = client.LoadBalancer; // var config = client.ClientConfig; _networkConfig = config.GetNetworkConfig(); IsSmartRoutingEnabled = _networkConfig.IsSmartRouting(); _labels = client.ClientConfig.Labels; var connectionTimeout = _networkConfig.GetConnectionTimeout(); _connectionTimeout = connectionTimeout == 0 ? int.MaxValue : connectionTimeout; //TODO outboundPorts // this.networking = initNetworking(); // this.outboundPorts.addAll(getOutboundPorts()); // this.outboundPortCount = outboundPorts.size(); _heartbeat = new HeartbeatManager(client, this); _authenticationTimeout = _heartbeat.HeartbeatTimeout; _shuffleMemberList = EnvironmentUtil.ReadBool("hazelcast.client.shuffle.member.list") ?? false; _waitStrategy = InitializeWaitStrategy(client.ClientConfig); var connectionStrategyConfig = client.ClientConfig.GetConnectionStrategyConfig(); _asyncStart = connectionStrategyConfig.AsyncStart; _reconnectMode = connectionStrategyConfig.ReconnectMode; }
static void Main131231(string[] args) { /*************************************************************** * 3.2 ***************************************************************/ Hazelcast.Config.ClientConfig cc = new Hazelcast.Config.ClientConfig(); Hazelcast.Config.ClientNetworkConfig nc = new Hazelcast.Config.ClientNetworkConfig(); nc.AddAddress("127.0.0.1"); //nc.AddAddress("192.168.10.16:5703"); cc.SetNetworkConfig(nc); //Hazelcast.Config.GroupConfig gc = new Hazelcast.Config.GroupConfig(); //gc.SetName("test"); //gc.SetPassword("test1234"); //cc.SetGroupConfig(gc); Hazelcast.Core.IHazelcastInstance hc = HazelcastClient.NewHazelcastClient(cc); test myTestInstance = new test(); myTestInstance.myNumber = 999; Hazelcast.Core.IMap <int, test> a; a = hc.GetMap <int, test>((string)"test"); a.Put(999, myTestInstance); test myTestInstance2 = a.Get(999); int abc = myTestInstance2.myNumber; }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var set = client.GetSet <string>("set-example"); set.Add("item1"); set.Add("item2"); set.Add("item3"); set.Add("item3"); Console.WriteLine("Enumerator : " + string.Join(", ", set)); Console.WriteLine("Contains: " + string.Join(", ", set.Contains("item2"))); Console.WriteLine("Count: " + string.Join(", ", set.Count)); set.Destroy(); client.Shutdown(); }
public ClientConnectionManager(HazelcastClient client) { _client = client; var config = client.GetClientConfig(); _networkConfig = config.GetNetworkConfig(); config.GetNetworkConfig().IsRedoOperation(); _credentials = config.GetCredentials(); //init socketInterceptor var sic = config.GetNetworkConfig().GetSocketInterceptorConfig(); if (sic != null && sic.IsEnabled()) { //TODO Socket interceptor throw new NotImplementedException("Socket Interceptor not yet implemented."); } _socketInterceptor = null; const int defaultHeartbeatInterval = 5000; const int defaultHeartbeatTimeout = 60000; var heartbeatTimeoutMillis = EnvironmentUtil.ReadInt("hazelcast.client.heartbeat.timeout") ?? defaultHeartbeatInterval; var heartbeatIntervalMillis = EnvironmentUtil.ReadInt("hazelcast.client.heartbeat.interval") ?? defaultHeartbeatTimeout; _heartbeatTimeout = TimeSpan.FromMilliseconds(heartbeatTimeoutMillis); _heartbeatInterval = TimeSpan.FromMilliseconds(heartbeatIntervalMillis); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var map = client.GetMap <string, string>("map-lock-example"); map.Put("key", "value"); map.Lock("key"); var task = Task.Factory.StartNew(() => { map.Put("key", "newValue"); Console.WriteLine("Put new value"); }); try { var value = map.Get("key"); //do something with the value.. Thread.Sleep(5000); } finally { map.Unlock("key"); } task.Wait(); Console.WriteLine("New value: " + map.Get("key")); }
public static void Run(string[] args) { // Start the Hazelcast Client and connect to an already running Hazelcast Cluster on 127.0.0.1 var clientConfig = new ClientConfig(); clientConfig.GetSerializationConfig() .AddPortableFactory(PortableFactory.FactoryId, new PortableFactory()); var hz = HazelcastClient.NewHazelcastClient(clientConfig); // Get a Distributed Map called "users" var users = hz.GetMap <string, User>("users"); // Add some users to the Distributed Map GenerateUsers(users); // Create a Predicate from a String (a SQL like Where clause) var sqlQuery = Predicates.Sql("active AND age BETWEEN 18 AND 21)"); // Creating the same Predicate as above but with a builder var criteriaQuery = Predicates.And( Predicates.IsEqual("active", true), Predicates.IsBetween("age", 18, 21) ); // Get result collections using the two different Predicates var result1 = users.Values(sqlQuery); var result2 = users.Values(criteriaQuery); // Print out the results Console.WriteLine(result1); Console.WriteLine(result2); // Shutdown this Hazelcast Client hz.Shutdown(); }
public static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetSerializationConfig().AddPortableFactory(1, new ExamplePortableFactory()); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var map = client.GetMap <int, Customer>("portable-example"); var customer = new Customer { Id = 1, LastOrder = DateTime.UtcNow, Name = "first-customer" }; Console.WriteLine("Adding customer: " + customer); map.Put(customer.Id, customer); var c = map.Get(customer.Id); Console.WriteLine("Gotten customer: " + c); client.Shutdown(); }
public IHazelcastInstance CreateClient(Action <ClientConfig> configure) { var config = new ClientConfig(); configure(config); return(HazelcastClient.NewHazelcastClient(config)); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var clientConfig = new ClientConfig(); var clientNetworkConfig = clientConfig.GetNetworkConfig(); clientNetworkConfig.GetCloudConfig() .SetEnabled(true) .SetDiscoveryToken("DISCOVERY_TOKEN_HASH"); //Discovery token copied from Cloud console //Server certificate will be validated by OS, //Download and register the server trust store to your OS clientNetworkConfig.GetSSLConfig().SetEnabled(true); //in order to disable certificate validating uncomment below line //clientNetworkConfig.GetSSLConfig().SetProperty(SSLConfig.ValidateCertificateChain, "false"); //Client certificate file path downloaded from cloud console clientNetworkConfig.GetSSLConfig().SetProperty(SSLConfig.CertificateFilePath, "CLIENT_PFX_CERTIFICATE_PATH"); var client = HazelcastClient.NewHazelcastClient(clientConfig); var map = client.GetMap <string, string>("ssl-example"); map.Put("key", "value"); Console.WriteLine("Key: " + map.Get("key")); map.Destroy(); client.Shutdown(); }
public static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var generator = client.GetIdGenerator("example-id-generator"); generator.Init(1000); Action generateId = () => { for (var i = 0; i < 100; i++) { Console.WriteLine("Generated id: " + generator.NewId()); } }; var task1 = Task.Factory.StartNew(generateId); var task2 = Task.Factory.StartNew(generateId); Task.WaitAll(task1, task2); generator.Destroy(); }
public ClientMembershipListener(HazelcastClient client) { _client = client; _connectionManager = (ClientConnectionManager)client.GetConnectionManager(); _partitionService = (ClientPartitionService)client.GetClientPartitionService(); _clusterService = (ClientClusterService)client.GetClientClusterService(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var list = client.GetList <string>("collection-listener-example"); var cdown = new CountdownEvent(3); list.AddItemListener(new ItemListener <string> { OnItemAdded = e => { Console.WriteLine("Item added: " + e.GetItem()); cdown.Signal(); }, OnItemRemoved = e => { Console.WriteLine("Item removed: " + e.GetItem()); cdown.Signal(); } }, true); list.Add("item1"); list.Add("item2"); list.Remove("item1"); cdown.Wait(); list.Destroy(); client.Shutdown(); }
public ClientMembershipListener(HazelcastClient client) { _client = client; _connectionManager = (ClientConnectionManager) client.GetConnectionManager(); _partitionService = (ClientPartitionService) client.GetClientPartitionService(); _clusterService = (ClientClusterService) client.GetClientClusterService(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var ringbuffer = client.GetRingbuffer <string>("ringbuffer-example"); var writer = Task.Factory.StartNew(() => { for (var i = 0; i < 100; i++) { ringbuffer.Add("item " + i); } }); var reader = Task.Factory.StartNew(() => { var sequence = ringbuffer.HeadSequence(); while (sequence < 100) { var item = ringbuffer.ReadOne(sequence++); Console.WriteLine("Reading value " + item); } }); Task.WaitAll(reader, writer); ringbuffer.Destroy(); client.Shutdown(); }
public ClientClusterService(HazelcastClient client) { _client = client; var listenerConfigs = client.GetClientConfig().GetListenerConfigs(); foreach (var listenerConfig in listenerConfigs) { var listener = listenerConfig.GetImplementation(); if (listener == null) { try { var className = listenerConfig.GetClassName(); var type = Type.GetType(className); if (type != null) { listener = Activator.CreateInstance(type) as IEventListener; } } catch (Exception e) { Logger.Severe(e); } } var membershipListener = listener as IMembershipListener; if (membershipListener != null) { AddMembershipListenerWithoutInit(membershipListener); } } }
static void Main111(string[] args) { var clientConfig = new ClientConfig(); clientConfig.GetNetworkConfig().AddAddress("127.0.0.1"); //clientConfig.GetNetworkConfig().AddAddress("10.0.0.2:5702"); //Portable Serialization setup up for Customer CLass clientConfig.GetSerializationConfig().AddPortableFactory(MyPortableFactory.FactoryId, new MyPortableFactory()); IHazelcastInstance client = HazelcastClient.NewHazelcastClient(clientConfig); //All cluster operations that you can do with ordinary HazelcastInstance IMap <string, Customer> mapCustomers = client.GetMap <string, Customer>("customers"); mapCustomers.Put("1", new Customer("Joe", "Smith")); mapCustomers.Put("2", new Customer("Ali", "Selam")); mapCustomers.Put("3", new Customer("Avi", "Noyan")); Customer customer1 = mapCustomers.Get("1"); Console.WriteLine(customer1); //ICollection<Customer> customers = mapCustomers.Values(); //foreach (var customer in customers) //{ // //customer //} }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new Configuration(); config.NetworkConfig.AddAddress("127.0.0.1"); var reset = new ManualResetEventSlim(); config.ListenerConfigs.Add(new ListenerConfig(new LifecycleListener(e => { Console.WriteLine("new state: " + e.GetState()); if (e.GetState() == LifecycleEvent.LifecycleState.ClientConnected) { reset.Set(); } }))); var client = HazelcastClient.NewHazelcastClient(config); reset.Wait(); client.Shutdown(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new Configuration(); config.NetworkConfig.AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var topic = client.GetTopic <string>("topic-example"); var countdown = new CountdownEvent(100); topic.AddMessageListener(m => { Console.WriteLine("Got message: " + m.GetMessageObject()); countdown.Signal(); }); var publisher = Task.Factory.StartNew(() => { for (var i = 0; i < 100; i++) { topic.Publish("Message " + i); } }); countdown.Wait(); topic.Destroy(); client.Shutdown(); }
public static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var latch = client.GetCountDownLatch("countdown-latch-example"); latch.TrySetCount(2); var task1 = Task.Factory.StartNew(() => { //do some work Thread.Sleep(5000); latch.CountDown(); }); var task2 = Task.Factory.StartNew(() => { //do some work Thread.Sleep(10000); latch.CountDown(); }); latch.Await(20, TimeUnit.Seconds); Console.WriteLine("Tasks completed"); latch.Destroy(); }
public static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var atomicLong = client.GetAtomicLong("atomic-long-exmaple"); Action increment = () => { for (var i = 0; i < 100; i++) { atomicLong.IncrementAndGet(); } }; var task1 = Task.Factory.StartNew(increment); var task2 = Task.Factory.StartNew(increment); Task.WaitAll(task1, task2); Console.WriteLine("Final value: " + atomicLong.Get()); atomicLong.Destroy(); }
public ClientConnectionManager(HazelcastClient client) { _client = client; var config = client.GetClientConfig(); _networkConfig = config.GetNetworkConfig(); config.GetNetworkConfig().IsRedoOperation(); _credentials = config.GetCredentials(); //init socketInterceptor var sic = config.GetNetworkConfig().GetSocketInterceptorConfig(); if (sic != null && sic.IsEnabled()) { //TODO Socket interceptor throw new NotImplementedException("Socket Interceptor not yet implemented."); } _socketInterceptor = null; var timeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.invocation.timeout.seconds"); if (timeout > 0) { ThreadUtil.TaskOperationTimeOutMilliseconds = timeout.Value * 1000; } _heartbeatTimeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.timeout") ?? _heartbeatTimeout; _heartbeatInterval = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.interval") ?? _heartbeatInterval; }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var clientConfig = new ClientConfig(); var clientNetworkConfig = clientConfig.GetNetworkConfig(); //replace with your actual server host/ip and port clientNetworkConfig.AddAddress("127.0.0.1:5701"); //Server certificate will be validated by OS, //signed certificates will just work, //self-signed certificates should be registered by OS depended way and allowed. clientNetworkConfig.GetSSLConfig().SetEnabled(true); //Providing a client pfx certificate will enable mutual authenticating if server also configured mutual auth. clientNetworkConfig.GetSSLConfig().SetProperty(SSLConfig.CertificateFilePath, "CLIENT_PFX_CERTIFICATE_PATH"); var client = HazelcastClient.NewHazelcastClient(clientConfig); var map = client.GetMap <string, string>("ssl-example"); map.Put("key", "value"); Console.WriteLine("Key: " + map.Get("key")); map.Destroy(); client.Shutdown(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var queue = client.GetQueue <string>("queue-example"); var producer = Task.Factory.StartNew(() => { for (var i = 0; i < 100; i++) { queue.Offer("value " + i); } }); var consumer = Task.Factory.StartNew(() => { var nConsumed = 0; string e; while (nConsumed++ < 100 && (e = queue.Take()) != null) { Console.WriteLine("Consuming " + e); } }); Task.WaitAll(producer, consumer); queue.Destroy(); client.Shutdown(); }
public static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); config.GetSerializationConfig() .AddDataSerializableFactory(EntryProcessorDataSerializableFactory.FactoryId, new EntryProcessorDataSerializableFactory()); var client = HazelcastClient.NewHazelcastClient(config); var map = client.GetMap <int, string>("entry-processor-example"); Console.WriteLine("Populating map"); for (int i = 0; i < 10; i++) { map.Put(i, "value" + i); } Console.WriteLine("Map size: " + map.Size()); var result = map.ExecuteOnEntries(new UpdateEntryProcessor("value-UPDATED"), Predicates.Sql("this==value5")); Console.WriteLine("Updated value result: " + result[5]); Console.WriteLine("The same value from the map: " + map.Get(5)); client.Shutdown(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var map = client.GetMap <string, string>("simple-example"); map.Put("key", "value"); map.Put("key2", "value2"); Console.WriteLine("Key: " + map.Get("key")); Console.WriteLine("Values : " + string.Join(", ", map.Values())); Console.WriteLine("KeySet: " + string.Join(", ", map.KeySet())); Console.WriteLine("Size: " + string.Join(", ", map.Size())); Console.WriteLine("EntrySet: " + string.Join(", ", map.EntrySet())); Console.WriteLine("ContainsKey: " + string.Join(", ", map.ContainsKey("key"))); Console.WriteLine("ContainsValue: " + string.Join(", ", map.ContainsValue("value"))); map.Destroy(); client.Shutdown(); }
public ClientConnectionManager(HazelcastClient client) { _client = client; var config = client.GetClientConfig(); _networkConfig = config.GetNetworkConfig(); config.GetNetworkConfig().IsRedoOperation(); _credentials = config.GetCredentials(); //init socketInterceptor var sic = config.GetNetworkConfig().GetSocketInterceptorConfig(); if (sic != null && sic.IsEnabled()) { //TODO Socket interceptor throw new NotImplementedException("Socket Interceptor not yet implemented."); } _socketInterceptor = null; var timeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.invocation.timeout.seconds"); if (timeout > 0) { ThreadUtil.TaskOperationTimeOutMilliseconds = timeout.Value*1000; } _heartbeatTimeout = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.timeout") ?? _heartbeatTimeout; _heartbeatInterval = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.heartbeat.interval") ?? _heartbeatInterval; }
public static void Run(string[] args) { var clientConfig = new Configuration(); clientConfig.NetworkConfig.AddAddress("127.0.0.1"); //clientConfig.NetworkConfig.AddAddress("10.0.0.2:5702"); var sc = new SerializerConfig() .SetImplementation(new CustomSerializer()) .SetTypeClass(typeof(Person)); //Custom Serialization setup up for Person Class. clientConfig.SerializationConfig.SerializerConfigs.Add(sc); IHazelcastInstance client = HazelcastClient.NewHazelcastClient(clientConfig); //All cluster operations that you can do with ordinary HazelcastInstance IMap <string, Person> mapCustomers = client.GetMap <string, Person>("persons"); mapCustomers.Put("1", new Person("Joe", "Smith")); mapCustomers.Put("2", new Person("Ali", "Selam")); mapCustomers.Put("3", new Person("Avi", "Noyan")); ICollection <Person> persons = mapCustomers.Values(); foreach (var person in persons) { Console.WriteLine(person.ToString()); } HazelcastClient.ShutdownAll(); Console.ReadKey(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var options = new TransactionOptions(); options.SetTransactionType(TransactionOptions.TransactionType.OnePhase); var ctx = client.NewTransactionContext(options); ctx.BeginTransaction(); try { var txMap = ctx.GetMap <string, string>("txn-map"); txMap.Put("foo", "bar"); ctx.CommitTransaction(); } catch { ctx.RollbackTransaction(); } var map = client.GetMap <string, string>("txn-map"); Console.WriteLine("Value of foo is " + map.Get("key")); map.Destroy(); client.Shutdown(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var map = client.GetMap <string, string>("simple-example"); var tasks = new List <Task>(); for (var i = 0; i < 100; i++) { var key = "key " + i; var task = map.PutAsync(key, " value " + i).ContinueWith(t => { Console.WriteLine("Added " + key); }); tasks.Add(task); } Task.WaitAll(tasks.ToArray()); map.Destroy(); client.Shutdown(); }
public static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); config.GetSerializationConfig() .AddDataSerializableFactory(ExampleDataSerializableFactory.FactoryId, new ExampleDataSerializableFactory()); var client = HazelcastClient.NewHazelcastClient(config); var map = client.GetMap <int, Employee>("identified-data-serializable-example"); var employee = new Employee { Id = 1, Name = "the employee" }; Console.WriteLine("Adding employee: " + employee); map.Put(employee.Id, employee); var e = map.Get(employee.Id); Console.WriteLine("Gotten employee: " + e); client.Shutdown(); }
private static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var reset = new ManualResetEventSlim(); config.AddListenerConfig(new ListenerConfig(new MembershipListener { OnMemberAdded = m => { Console.WriteLine("Added member: " + m.GetMember()); reset.Set(); } })); var client = HazelcastClient.NewHazelcastClient(config); reset.Wait(); client.Shutdown(); }
public static void Run(string[] args) { Environment.SetEnvironmentVariable("hazelcast.logging.level", "info"); Environment.SetEnvironmentVariable("hazelcast.logging.type", "console"); var config = new ClientConfig(); config.GetNetworkConfig().AddAddress("127.0.0.1"); var client = HazelcastClient.NewHazelcastClient(config); var map = client.GetMap <string, string>("listener-example"); var cdown = new CountdownEvent(2); map.AddEntryListener(new EntryAdapter <string, string> { Added = e => { Console.WriteLine("Key '{0}' with value ' {1}' was added.", e.GetKey(), e.GetValue()); cdown.Signal(); }, Removed = e => { Console.WriteLine("Key '{0}' with value ' {1}' was removed.", e.GetKey(), e.GetOldValue()); cdown.Signal(); } }, true); map.Put("key", "value"); map.Remove("key"); cdown.Wait(); map.Destroy(); }
public CacheManager(Statistics statistics, TraceFile traceFile, HazelcastClient client, string scenarioId, List<string> elementSetsPut, WebServiceManager webServiceManager) { this.statistics = statistics; this.traceFile = traceFile; this.client = client; this.scenarioId = scenarioId; this.elementSetsPut = elementSetsPut; this.webServiceManager = webServiceManager; }
public PrefetchManager(TraceFile traceFile, Statistics statistics, HazelcastClient hazelcastClient, string scenarioId, ArrayList outputLinks, ITimeSpan timeHorizon, bool isEnabled, WebServiceManager webServiceManager) { this.traceFile = traceFile; this.statistics = statistics; this.hazelcastClient = hazelcastClient; this.scenarioId = scenarioId; this.isEnabled = isEnabled; this.webServiceManager = webServiceManager; mapValueSet = hazelcastClient.getMap<string, ValueSetEntry>("valueSet"); queueValueSetRequest = hazelcastClient.getQueue<ValueSetRequestEntry>("valueSetRequest"); prefetchMonitor = new PrefetchMonitor(outputLinks, traceFile, timeHorizon); }
protected ClientInvocationService(HazelcastClient client) { _client = client; _redoOperations = client.GetClientConfig().GetNetworkConfig().IsRedoOperation(); var eventTreadCount = EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.event.thread.count") ?? DefaultEventThreadCount; _taskScheduler = new StripedTaskScheduler(eventTreadCount); _invocationTimeoutMillis = (EnvironmentUtil.ReadEnvironmentVar("hazelcast.client.invocation.timeout.seconds") ?? DefaultInvocationTimeout) * 1000; _clientConnectionManager = client.GetConnectionManager(); _clientConnectionManager.AddConnectionListener(this); }
public LifecycleService(HazelcastClient client) { this.client = client; IList<ListenerConfig> listenerConfigs = client.GetClientConfig().GetListenerConfigs(); if (listenerConfigs != null && listenerConfigs.Count > 0) { foreach (ListenerConfig listenerConfig in listenerConfigs) { if (listenerConfig.GetImplementation() is ILifecycleListener) { AddLifecycleListener((ILifecycleListener) listenerConfig.GetImplementation()); } } } FireLifecycleEvent(LifecycleEvent.LifecycleState.Starting); }
public ClientListenerService(HazelcastClient hazelcastClient) { _client = hazelcastClient; }
private void ConnectToInstance(string instanceAddr, string instancePort, List<WebServiceEntry> webServiceInfoList) { var clientConfig = new ClientConfig(); clientConfig.addAddress(instanceAddr + ":" + instancePort); clientConfig.GroupConfig = new GroupConfig("dev", "dev-pass"); clientConfig.TypeConverter = new MyTypeConverter(); // connect to the hazelcast instance while (client == null) { try { client = HazelcastClient.newHazelcastClient(clientConfig); } catch (Exception) { traceFile.Append("Failed to connect to " + instanceAddr + ":" + instancePort); Thread.Sleep(5000); } } // tell the instances that we're active var mapClient = client.getMap<string, string>("client"); mapClient.put(GetUniqueId(), "active"); var mapWebServiceInfo = client.getMap<String, WebServiceEntry>("webService"); foreach (var nextWebServiceInfo in webServiceInfoList) { mapWebServiceInfo.put(nextWebServiceInfo.Id, nextWebServiceInfo); } }
internal TransactionProxy(HazelcastClient client, TransactionOptions options, IMember txOwner) { _options = options; _client = client; _txOwner = txOwner; }
public ClientPartitionService(HazelcastClient client) { _client = client; }
public ClientSmartInvocationService(HazelcastClient client) : base(client) { }
internal TransactionProxy(HazelcastClient client, TransactionOptions options, IMember txOwner) { this.options = options; this.client = client; this.txOwner = txOwner; }