/// <summary> /// This is the Sample Application that uses the Infinispan .NET client library. /// </summary> /// <param name="args">string</param> static void Main(string[] args) { //Create new Configuration, overriding the setting in the App.config file. ClientConfig conf= new ClientConfig("127.0.0.1",11222,"default",0,false); //Here we are using a custom Serializer Serializer s= new DefaultSerializer(); //Create a new RemoteCacheManager RemoteCacheManager manager = new RemoteCacheManager(conf, s); //Get hold of a cache from the remote cache manager RemoteCache cache = manager.getCache(); //First Check Whether the cache exists Console.WriteLine("Ping Result : "+cache.ping()); //Put a new value "germanium" with key "key 1" into cache cache.put<String, String>("key 1", "germanium", 0, 0); //Get the value of entry with key "key 1" Console.WriteLine("key 1 value : "+cache.get<String>("key 1")); //Put if absent is used to add entries if they are not existing in the cache cache.putIfAbsent<String, String>("key 1", "trinitrotoluene", 0, 0); cache.putIfAbsent<String, String>("key 2", "formaldehyde", 0, 0); Console.WriteLine("key 1 value after PutIfAbsent: " + cache.get<String>("key 1")); Console.WriteLine("Key 2 value after PutIfAbsent: " + cache.get<String>("key 2")); //Replace an existing value with a new one. // cache.replace<String, String>("key 1", "fluoride",0,0); Console.WriteLine("key 1 value after replace: " + cache.get<String>("key 1")); //Check whether a particular key exists Console.WriteLine("key 1 is exist ?: " + cache.containsKey("key 1")); //Remove a particular entry from the cache // cache.remove<String>("key 1"); Console.WriteLine("key 1 is exist after remove?: " + cache.containsKey("key 1")); Console.ReadLine(); }
public void StartHotrodServer() { UpdateConfiguration(); //TODO - we might want to make this an actual process at some point so that the window is no longer displayed // http://stackoverflow.com/questions/1113000/how-do-start-stop-services-using-net-stop-command-in-c-sharp string ispnHome = System.Environment.GetEnvironmentVariable("ISPN_HOME"); if (ispnHome == null) throw new Exception("you must set the ISPN_HOME variable pointing to the ISPN installation in order to be able to run the tests"); hrServer = new Process(); String nameOfBatchFile = ispnHome + "\\bin\\startServer.bat"; String nameOfBatchFile1 = ispnHome + "\\bin\\startServer1.bat"; string parameters; if (configFile == null) { parameters = String.Format("/k \"{0}\"" + " -r hotrod", nameOfBatchFile); } else { parameters = String.Format("/k \"{0}\"" + " -r hotrod -c testconfigs\\{1}", nameOfBatchFile, configFile); } hrServer.StartInfo.FileName = "cmd"; hrServer.StartInfo.Arguments = parameters; hrServer.StartInfo.WorkingDirectory = ispnHome + "\\bin"; hrServer.Start(); Thread.Sleep(sleepTime); //sleep in order to allow the hrServer to start remoteManager = new RemoteCacheManager(conf, serializer); }
public void StartHotrodServer() { //TODO - we might want to make this an actual process at some point so that the window is no longer displayed // http://stackoverflow.com/questions/1113000/how-do-start-stop-services-using-net-stop-command-in-c-sharp string ispnHome = System.Environment.GetEnvironmentVariable("ISPN_HOME"); if (ispnHome == null) throw new Exception("you must set the ISPN_HOME variable pointing to the ISPN installation in order to be able to run the tests"); hrServer1 = new Process(); hrServer2 = new Process(); String nameOfBatchFile1 = ispnHome + "\\bin\\startServer1.bat"; String nameOfBatchFile2 = ispnHome + "\\bin\\startServer2.bat"; string parameters1 = String.Format("/k \"{0}\"" + " -r hotrod -p 11222 -c etc/config-samples/distributed-udp.xml", nameOfBatchFile1); hrServer1.StartInfo.FileName = "cmd"; hrServer1.StartInfo.Arguments = parameters1; hrServer1.StartInfo.WorkingDirectory = ispnHome; hrServer1.Start(); Thread.Sleep(3000); string parameters2 = String.Format("/k \"{0}\"" + " -r hotrod -p 11223 -c etc/config-samples/distributed-udp.xml", nameOfBatchFile2); hrServer2.StartInfo.FileName = "cmd"; hrServer2.StartInfo.Arguments = parameters2; hrServer2.StartInfo.WorkingDirectory = ispnHome; hrServer2.Start(); Thread.Sleep(3000); Thread.Sleep(50000); remoteManager1 = new RemoteCacheManager(conf1, serializer1); }
/// <summary> /// The constructor of RemoteCacheImpl /// </summary> /// <param name="cacheManager">The CacheManager which holds the RemoteCache</param> /// <param name="configuration">Configuration of the client</param> /// <param name="cacheName">Pass the cachename if it differs from the default cache name</param> /// <param name="forceReturn">Pass ForceReturn value if it differs from the default falue</param> /// <param name="s">Serializer to be used to. Pass a custom serializer of DefaultSerializer</param> /// <param name="start">Boolean start</param> public RemoteCacheImpl(RemoteCacheManager cacheManager, ClientConfig configuration, String cacheName, bool forceReturn, Serializer s, TCPTransportFactory trans) { this.config = configuration; this.serializer = s; this.codec = new Codec(); this.config.ForceReturnValue = forceReturn; this.config.CacheName = cacheName; this.operationsFactory = new OperationsFactory(cacheName, config.TopologyId, forceReturn, this.codec); this.transportFactory = trans; }
/// <summary> /// This is the Sample Application that uses the Infinispan .NET client library. /// </summary> /// <param name="args">string</param> static void Main(string[] args) { //Important! Make sure that the hotrod server is started before running the line below. //Create new Configuration, overriding the setting in the App.config file. ClientConfig conf = new ClientConfig("127.0.0.1", 11222, "default", false); //Here we are using a custom Serializer ISerializer s = new StringSerializer(); //Create a new RemoteCacheManager RemoteCacheManager manager = new RemoteCacheManager(conf, s); //Get hold of a cache from the remote cache manager IRemoteCache<String, String> cache = manager.GetCache<String, String>(); //First Check Whether the cache exists Console.WriteLine("Ping Result : " + cache.Ping()); //Put a new value "germanium" with key "key 1" into cache cache.Put("key 1", "germanium", 0, 0); //Get the value of entry with key "key 1" Console.WriteLine("key 1 value : " + cache.Get("key 1")); //Put if absent is used to add entries if they are not existing in the cache cache.PutIfAbsent("key 1", "trinitrotoluene", 0, 0); cache.PutIfAbsent("key 2", "formaldehyde", 0, 0); Console.WriteLine("key 1 value after PutIfAbsent: " + cache.Get("key 1")); Console.WriteLine("Key 2 value after PutIfAbsent: " + cache.Get("key 2")); cache.Replace("key 1", "fluoride", 0, 0); Console.WriteLine("key 1 value after replace: " + cache.Get("key 1")); //Check whether a particular key exists Console.WriteLine("key 1 is exist ?: " + cache.ContainsKey("key 1")); //Remove a particular entry from the cache cache.Remove("key 1"); Console.WriteLine("key 1 is exist after remove?: " + cache.ContainsKey("key 1")); Console.WriteLine("Hit enter to exit!"); Console.ReadLine(); }
/// <summary> /// The constructor of RemoteCacheImpl /// </summary> /// <param name="cacheManager">The CacheManager which holds the RemoteCache</param> /// <param name="configuration">Configuration of the client</param> /// <param name="forceReturn">Pass ForceReturn value if it differs from the default falue</param> /// <param name="s">Serializer to be used to. Pass a custom serializer of DefaultSerializer</param> /// <param name="start">Boolean start</param> public RemoteCacheImpl(RemoteCacheManager cacheManager, ClientConfig configuration, bool forceReturn, Serializer s, TCPTransportFactory trans) : this(cacheManager, configuration, configuration.CacheName, forceReturn, s, trans) { }
/// <summary> /// The constructor of RemoteCacheImpl /// </summary> /// <param name="cacheManager">The CacheManager which holds the RemoteCache</param> /// <param name="configuration">Configuration of the client</param> /// <param name="cacheName">Pass the cachename if it differs from the default cache name</param> /// <param name="s">Serializer to be used to. Pass a custom serializer of DefaultSerializer</param> /// <param name="start">Boolean start</param> public RemoteCacheImpl(RemoteCacheManager cacheManager, ClientConfig configuration, String cacheName, Serializer s, TCPTransportFactory trans) : this(cacheManager, configuration, cacheName, configuration.ForceReturnValue, s, trans) { }