Ejemplo n.º 1
0
        public void BeforeClass()
        {
            ConfigurationBuilder conf = new ConfigurationBuilder();

            conf.AddServer().Host("127.0.0.1").Port(11222);
            conf.ConnectionTimeout(90000).SocketTimeout(6000);
            conf.Marshaller(new BasicTypesProtoStreamMarshaller());
            remoteManager = new RemoteCacheManager(conf.Build(), true);

            IRemoteCache <String, String> metadataCache = remoteManager.GetCache <String, String>(PROTOBUF_METADATA_CACHE_NAME);

            metadataCache.Remove(ERRORS_KEY_SUFFIX);
            metadataCache.Put("sample_bank_account/bank.proto", File.ReadAllText("proto2/bank.proto"));
            if (metadataCache.ContainsKey(ERRORS_KEY_SUFFIX))
            {
                Assert.Fail("fail: error in registering .proto model");
            }
            remoteManager.Administration().CreateCacheWithXml <object, object>(NAMED_CACHE,
                                                                               "<infinispan><cache-container><distributed-cache name=\"" + NAMED_CACHE + "\">" +
                                                                               "            <indexing> " +
                                                                               "           <indexed-entities> " +
                                                                               "             <indexed-entity>sample_bank_account.User</indexed-entity>" +
                                                                               "             <indexed-entity>sample_bank_account.Transaction</indexed-entity>" +
                                                                               "         </indexed-entities>" +
                                                                               "     </indexing> " +
                                                                               " </distributed-cache> " +
                                                                               " </cache-container></infinispan>");
            IRemoteCache <String, Transaction> transactionCache = remoteManager.GetCache <String, Transaction>(NAMED_CACHE);

            Assert.NotNull(transactionCache);
            PutTransactions(transactionCache);
        }
Ejemplo n.º 2
0
        public void alreadyExistingCacheTest()
        {
            // Remove cache if exists
            string cacheName = "alreadyExistingCache";

            try
            {
                remoteManager.Administration().RemoveCache(cacheName);
            }
            catch (Exception)
            {
            }
            remoteManager.Administration().CreateCache <string, string>(cacheName, "template");
            var ex = Assert.Throws <Infinispan.HotRod.Exceptions.HotRodClientException>(() =>
                                                                                        { remoteManager.Administration().CreateCache <string, string>(cacheName, "template"); });

            StringAssert.Contains("ISPN000507:", ex.Message);
        }
Ejemplo n.º 3
0
        public void permanentCacheTest()
        {
            String cacheName = "cache4PermanentTest";
            var    flags     = new HashSet <AdminFlag>();

            flags.Add(AdminFlag.PERMANENT);
            remoteManager.Administration().WithFlags(flags).CreateCache <string, string>(cacheName, "template");
            remoteManager.Stop();
            ClusterTestSuite.server1.ShutDownHotrodServer();
            ClusterTestSuite.server2.ShutDownHotrodServer();
            ClusterTestSuite.server1.StartHotRodServer();
            ClusterTestSuite.server2.StartHotRodServer();
            remoteManager = ClusterTestSuite.getRemoteCacheManager();
            var ex = Assert.Throws <Infinispan.HotRod.Exceptions.HotRodClientException>(() =>
                                                                                        { remoteManager.Administration().CreateCache <string, string>(cacheName, "template"); });

            StringAssert.Contains("ISPN000507:", ex.Message);
        }