Ejemplo n.º 1
0
 public void PopulateCache()
 {
     defaultCache = remoteManager.GetCache<String,String>();
     defaultCache.Put("key1", "hydrogen");
     defaultCache.Put("key2", "helium");
     defaultCache.Put("key3", "lithium");
 }
Ejemplo n.º 2
0
 public void BeforeClass()
 {
     ConfigurationBuilder conf = new ConfigurationBuilder();
     conf.AddServer().Host("127.0.0.1").Port(11222);
     conf.ConnectionTimeout(90000).SocketTimeout(6000);
     RemoteCacheManager remoteManager = new RemoteCacheManager(conf.Build(), true);
     cache = remoteManager.GetCache<String, String>();
 }
Ejemplo n.º 3
0
 public static void LoadTestCache(IRemoteCache<String, String> cache, String fileName)
 {
     System.IO.StreamReader file = new System.IO.StreamReader(fileName);
     try
     {
         String line;
         int counter = 0;
         while ((line = file.ReadLine()) != null)
         {
             cache.Put("line" + counter++, line);
         }
     }
     finally
     {
         file.Close();
     }
 }
Ejemplo n.º 4
0
        static void addMemo(IRemoteCache <int, Person> cache)
        {
            int    id = readInt("Enter person id: ");
            Person p  = cache.Get(id);

            if (p == null)
            {
                Console.Error.WriteLine("Person not found");
                return;
            }

            Console.WriteLine(p.ToString());

            String text = readString("Enter memo text: ");
            var    m    = new Person.Types.Memo();

            m.Text = text;
            p.Memo.Add(m);
            cache.Put(id, p);
        }
Ejemplo n.º 5
0
        public void BeforeClass()
        {
            ConfigurationBuilder conf = new ConfigurationBuilder();

            conf.AddServer().Host("127.0.0.1").Port(11222).ProtocolVersion("2.6");
            conf.ConnectionTimeout(90000).SocketTimeout(6000);
            conf.Marshaller(new ProtobufMarshaller());
            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");
            }

            IRemoteCache <int, User> userCache = remoteManager.GetCache <int, User>(NAMED_CACHE);
        }
Ejemplo n.º 6
0
        private static void NewMethod(IRemoteCache <string, string> cache, string key, string val)
        {
            var count = 0;

            while (true)
            {
                ++count;
                if (count % 1000 == 0)
                {
                    System.Console.Write("." + count + " " + System.Threading.Thread.CurrentThread);
                }
                cache.Put(key + count, val + count);
                if (count % 1000 == 0)
                {
                    System.Console.WriteLine("+" + count);
                }
                System.Threading.Thread.Sleep(10);
                cache.Get(key);
                System.Threading.Thread.Sleep(10);
            }
        }
Ejemplo n.º 7
0
        public void AsyncRemoteTaskExecTest()
        {
            InitializeRemoteCacheManager(true);
            // Register on the server a js routine that takes 3 sec to return a value
            string script_name = "script.js";
            string script      = "// mode=local,language=javascript\n "
                                 + "var cache = cacheManager.getCache(\"default\"); "
                                 + "cache.put(\"a\", \"abc\"); "
                                 + "cache.put(\"b\", \"b\"); "
                                 + "var start = (new Date().getTime()); "
                                 + "// Now just wait 3 seconds\n"
                                 + "for (var i = 0; i < 1000000000; i++) "
                                 + "{ "
                                 + "  if ((new Date().getTime()) > start + 3000) "
                                 + "  { "
                                 + "    break; "
                                 + "  }; "
                                 + "}; "
                                 + "cache.get(\"a\");";

            IRemoteCache <string, string> sCache = remoteManager.GetCache <string, string>(PROTOBUF_SCRIPT_CACHE_NAME);
            IRemoteCache <string, string> cache  = remoteManager.GetCache <string, string>("default");
            var df = new DataFormat();

            df.KeyMediaType   = "application/x-jboss-marshalling";
            df.ValueMediaType = "application/x-jboss-marshalling";
            var testCache   = cache.WithDataFormat(df);
            var scriptCache = sCache.WithDataFormat(df);

            scriptCache.Put(script_name, script);

            Dictionary <string, object> scriptArgs = new Dictionary <string, object>();
            Task <string> futureExec = Task.Factory.StartNew <string>(() => (string)testCache.Execute(script_name, scriptArgs));

            // Do something in the meanwhile
            testCache.Put("syncKey", "syncVal");
            Assert.AreEqual("syncVal", testCache.Get("syncKey"));
            // Get the async result
            Assert.AreEqual("abc", futureExec.Result);
        }
Ejemplo n.º 8
0
        public void FilterEventsTest()
        {
            LoggingEventListener <string> listener = new LoggingEventListener <string>();
            IRemoteCache <string, string> cache    = remoteManager.GetCache <string, string>();

            Event.ClientListener <string, string> cl = new Event.ClientListener <string, string>();
            try
            {
                cache.Clear();
                cl.filterFactoryName    = "string-is-equal-filter-factory";
                cl.converterFactoryName = "";
                cl.AddListener(listener.CreatedEventAction);
                cl.AddListener(listener.ModifiedEventAction);
                cl.AddListener(listener.RemovedEventAction);
                cl.AddListener(listener.ExpiredEventAction);
                cl.AddListener(listener.CustomEventAction);
                cache.AddClientListener(cl, new string[] { "wantedkeyprefix" }, new string[] { }, null);
                AssertNoEvents(listener);
                cache.Put("key1", "value1");
                cache.Put("wantedkeyprefix_key1", "value2");
                //only one received; one is ignored
                AssertOnlyCreated("wantedkeyprefix_key1", listener);
                AssertNoEvents(listener);
                cache.Replace("key1", "modified");
                cache.Replace("wantedkeyprefix_key1", "modified");
                AssertOnlyModified("wantedkeyprefix_key1", listener);
                AssertNoEvents(listener);
                cache.Remove("key1");
                cache.Remove("wantedkeyprefix_key1");
                AssertOnlyRemoved("wantedkeyprefix_key1", listener);
                AssertNoEvents(listener);
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }
Ejemplo n.º 9
0
        public void TestRemoteTaskExec(IRemoteCache <string, string> cache, IRemoteCache <string, string> scriptCache, IMarshaller marshaller)
        {
            string scriptName = "script.js";
            string script     = "//mode=local,language=javascript\n "
                                + "var cache = cacheManager.getCache(\"default\");\n "
                                + "cache.put(\"k1\", value);\n"
                                + "cache.get(\"k1\");\n";
            DataFormat df = new DataFormat();

            df.KeyMediaType   = "application/x-jboss-marshalling";
            df.ValueMediaType = "application/x-jboss-marshalling";
            IRemoteCache <String, String> dfScriptCache = scriptCache.WithDataFormat(df);

            dfScriptCache.Put(scriptName, script);
            IRemoteCache <String, String> dfCache    = cache.WithDataFormat(df);
            Dictionary <string, object>   scriptArgs = new Dictionary <string, object>();

            scriptArgs.Add("value", "v1");
            string ret1 = (string)dfCache.Execute(scriptName, scriptArgs);

            Assert.AreEqual("v1", ret1);
        }
Ejemplo n.º 10
0
        public void RemoteTaskEmptyArgsTest()
        {
            // Register on the server a js routine that takes 3 sec to return a value
            string scriptName = "script.js";
            string script     = "// mode=local,language=javascript\n "
                                + "var cache = cacheManager.getCache(\"default\");\n"
                                + "cache.put(\"argsKey1\", \"argValue1\");\n"
                                + "cache.get(\"argsKey1\");\n";
            IRemoteCache <string, string> scriptCache = remoteManager.GetCache <string, string>(PROTOBUF_SCRIPT_CACHE_NAME, new JBasicMarshaller());
            IRemoteCache <string, long>   testCache   = remoteManager.GetCache <string, long>();

            try
            {
                scriptCache.Put(scriptName, script);
                string ret1 = (string)testCache.Execute(scriptName);
                Assert.AreEqual("argValue1", ret1);
            }
            finally
            {
                testCache.Clear();
            }
        }
Ejemplo n.º 11
0
        private void ConfigureSecuredCaches(string serverCAFile, string clientCertFile, string sni = "")
        {
            ConfigurationBuilder conf = new ConfigurationBuilder();

            conf.AddServer().Host("127.0.0.1").Port(11222).ConnectionTimeout(90000).SocketTimeout(900);
            marshaller = new JBasicMarshaller();
            conf.Marshaller(marshaller);
            SslConfigurationBuilder sslConf = conf.Ssl();

            conf.Security().Authentication()
            .Enable()
            .SaslMechanism("EXTERNAL")
            .ServerFQDN("node0");

            RegisterServerCAFile(sslConf, serverCAFile, sni);
            RegisterClientCertificateFile(sslConf, clientCertFile);

            RemoteCacheManager remoteManager = new RemoteCacheManager(conf.Build(), true);

            testCache   = remoteManager.GetCache <string, string>();
            scriptCache = remoteManager.GetCache <string, string>("___script_cache");
        }
Ejemplo n.º 12
0
        public void ConflictsAndFail()
        {
            InitializeRemoteCacheManager(true);
            InitializeNonTxRemoteCacheManager(true);
            IRemoteCache <string, string> cache      = remoteManager.GetCache <string, string>("non_xa", true);
            IRemoteCache <string, string> nonTxCache = nonTxRemoteManager.GetCache <string, string>("non_xa", true);
            var txManager = remoteManager.GetTransactionManager();

            string k1 = "key13";
            string v1 = "boron";
            string k2 = "key14";
            string v2 = "helium";
            string vx = "calcium";

            cache.Clear();
            try
            {
                txManager.Begin();

                string oldv1 = cache.Put(k1, v1);
                string oldv2 = cache.Put(k2, v2);
                // Check the correct value from the tx context
                string rv1 = nonTxCache.Put(k1, vx);
                Assert.IsNull(rv1);
                Assert.Throws <Infinispan.HotRod.Exceptions.HotRodClientRollbackException>(() =>
                {
                    txManager.Commit();
                });
            }
            catch (Exception ex)
            {
                // try to release the tx resources
                txManager.Rollback();
                throw ex;
            }
            Assert.AreEqual(cache.Get(k1), vx);
            Assert.IsNull(cache.Get(k2));
        }
Ejemplo n.º 13
0
        public void ReadCommittedAndNonTxRead()
        {
            InitializeRemoteCacheManager(true);
            InitializeNonTxRemoteCacheManager(true);
            IRemoteCache <string, string> cache      = remoteManager.GetCache <string, string>("non_xa", true);
            IRemoteCache <string, string> nonTxCache = nonTxRemoteManager.GetCache <string, string>("non_xa", true);
            var txManager = remoteManager.GetTransactionManager();

            string k1 = "key13";
            string v1 = "boron";
            string rv1;
            string nontxrv1;

            cache.Clear();
            try
            {
                txManager.Begin();

                cache.Put(k1, v1);
                // Check the correct value from the tx context
                rv1 = cache.Get(k1);
                Assert.AreEqual(rv1, v1);
                nontxrv1 = nonTxCache.Get(k1);
                Assert.IsNull(nontxrv1);
                txManager.Commit();
            }
            catch (Exception ex)
            {
                // try to release the tx resources
                txManager.Rollback();
                throw ex;
            }
            // Check the correct value from remote cache
            rv1 = cache.Get(k1);
            Assert.AreEqual(rv1, v1);
            nontxrv1 = nonTxCache.Get(k1);
            Assert.AreEqual(nontxrv1, v1);
        }
Ejemplo n.º 14
0
        public void EntityBasicContQueryTest()
        {
            int joined = 0, updated = 0, leaved = 0;

            try
            {
                IRemoteCache <int, User> userCache = remoteManager.GetCache <int, User>(NAMED_CACHE);
                userCache.Clear();
                Semaphore    s  = new Semaphore(0, 1);
                QueryRequest qr = new QueryRequest();
                // JpqlString will be deprecated please use QueryString
                // qr.JpqlString = "from sample_bank_account.User";
                qr.QueryString = "from sample_bank_account.User";

                Event.ContinuousQueryListener <int, User> cql = new Event.ContinuousQueryListener <int, User>(qr.QueryString);
                cql.JoiningCallback = (int k, User v) => { joined++; };
                cql.LeavingCallback = (int k, User v) => { leaved++; s.Release(); };
                cql.UpdatedCallback = (int k, User v) => { updated++; };
                userCache.AddContinuousQueryListener(cql);

                User u = CreateUser1(userCache);
                userCache.Put(1, u);
                u.Name    = "Jerry";
                u.Surname = "Mouse";
                userCache.Put(1, u);
                userCache.Remove(1);
                s.WaitOne(10000);
                userCache.RemoveContinuousQueryListener(cql);
                userCache.Clear();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Assert.AreEqual(1, joined);
            Assert.AreEqual(1, updated);
            Assert.AreEqual(1, leaved);
        }
Ejemplo n.º 15
0
        private IRemoteCache <String, String> InitCache(string user, string password, string cacheName = AUTH_CACHE)
        {
            ConfigurationBuilder conf = new ConfigurationBuilder();

            conf.ProtocolVersion("2.8").AddServer()
            .Host(HOTROD_HOST)
            .Port(HOTROD_PORT)
            .ConnectionTimeout(90000)
            .SocketTimeout(900);
            AuthenticationConfigurationBuilder authBuilder = conf.Security().Authentication();

            authBuilder.Enable()
            .SaslMechanism(GetMech())
            .ServerFQDN("node0")
            .SetupCallback(user, password, REALM);
            marshaller = new JBasicMarshaller();
            conf.Marshaller(marshaller);
            Configuration                 c             = conf.Build();
            RemoteCacheManager            remoteManager = new RemoteCacheManager(c, true);
            IRemoteCache <string, string> cache         = remoteManager.GetCache <string, string>(cacheName);

            return(cache);
        }
Ejemplo n.º 16
0
        private static void addPhone(IRemoteCache <int, Person> cache)
        {
            int    id = readInt("Enter person id: ");
            Person p  = cache.Get(id);

            if (p == null)
            {
                Console.Error.WriteLine("Person not found");
                return;
            }
            Console.WriteLine(p.ToString());
            var pn = new Person.Types.PhoneNumber();

            pn.Number = readString("Enter phone number: ");
            try
            {
                pn.Type = (Person.Types.PhoneType)Enum.Parse(typeof(Person.Types.PhoneType), readString("Enter phone type: "));
                p.Phone.Add(pn);
                cache.Put(id, p);
            }
            catch
            { }
        }
Ejemplo n.º 17
0
        public void BasicEventsTest()
        {
            LoggingEventListener <string> listener = new LoggingEventListener <string>();
            IRemoteCache <string, string> cache    = remoteManager.GetCache <string, string>();

            Event.ClientListener <string, string> cl = new Event.ClientListener <string, string>();
            try
            {
                cache.Clear();
                cl.filterFactoryName    = "";
                cl.converterFactoryName = "";
                cl.AddListener(listener.CreatedEventAction);
                cl.AddListener(listener.ModifiedEventAction);
                cl.AddListener(listener.RemovedEventAction);
                cl.AddListener(listener.ExpiredEventAction);
                cl.AddListener(listener.CustomEventAction);
                cache.AddClientListener(cl, new string[] { }, new string[] { }, null);
                AssertNoEvents(listener);
                cache.Put("key1", "value1");
                AssertOnlyCreated("key1", listener);
                cache.Put("key1", "value1bis");
                AssertOnlyModified("key1", listener);
                cache.Remove("key1");
                AssertOnlyRemoved("key1", listener);
                cache.Put("key1", "value1", 100, TimeUnit.MILLISECONDS);
                AssertOnlyCreated("key1", listener);
                TimeUtils.WaitFor(() => { return(cache.Get("key1") == null); });
                AssertOnlyExpired("key1", listener);
            }
            finally
            {
                if (cl.listenerId != null)
                {
                    cache.RemoveClientListener(cl);
                }
            }
        }
Ejemplo n.º 18
0
        private static void removePhone(IRemoteCache <int, Person> cache)
        {
            int    id = readInt("Enter person id: ");
            Person p  = cache.Get(id);

            if (p == null)
            {
                Console.Error.WriteLine("Person not found");
                return;
            }

            Console.WriteLine(p.ToString());

            int phone_index = readInt("Enter phone index: ");

            if ((phone_index < 0) || (phone_index >= p.Phone.Count))
            {
                Console.Error.WriteLine("Phone index '" + phone_index + "' is out of range.");
                return;
            }

            p.Phone.RemoveAt(phone_index);
            cache.Put(id, p);
        }
Ejemplo n.º 19
0
        public void RemoteTaskWithIntArgs()
        {
            ConfigurationBuilder conf = new ConfigurationBuilder();

            conf.AddServer().Host("127.0.0.1").Port(11222);
            conf.ConnectionTimeout(90000).SocketTimeout(6000);
            remoteManager = new RemoteCacheManager(conf.Build(), true);
            string script = "// mode=local,language=javascript \n"
                            + "var x = k+v; \n"
                            + "x; \n";
            LoggingEventListener <string> listener    = new LoggingEventListener <string>();
            IRemoteCache <string, string> testCache   = remoteManager.GetCache <string, string>();
            IRemoteCache <string, string> scriptCache = remoteManager.GetCache <string, string>(PROTOBUF_SCRIPT_CACHE_NAME, new JBasicMarshaller());
            const string scriptName = "putit-get.js";

            scriptCache.Put(scriptName, script);
            Dictionary <string, object> scriptArgs = new Dictionary <string, object>();

            scriptArgs.Add("k", (int)1);
            scriptArgs.Add("v", (int)2);
            object v = testCache.Execute(scriptName, scriptArgs);

            Assert.AreEqual(3, v);
        }
Ejemplo n.º 20
0
        public void RepeatableGetForTxClient()
        {
            InitializeRemoteCacheManager(true);
            InitializeNonTxRemoteCacheManager(true);
            IRemoteCache <string, string> cache      = remoteManager.GetCache <string, string>("non_xa", true);
            IRemoteCache <string, string> nonTxCache = nonTxRemoteManager.GetCache <string, string>("non_xa", true);
            var txManager = remoteManager.GetTransactionManager();

            string k1 = "key13";
            string v1 = "boron";
            string v2 = "helium";
            string rv1;

            cache.Clear();
            try
            {
                txManager.Begin();

                string oldv1 = nonTxCache.Put(k1, v1);
                // Check the correct value from the tx context
                rv1 = cache.Get(k1);
                Assert.AreEqual(rv1, v1);
                // This goes to the server
                oldv1 = nonTxCache.Put(k1, v2);
                // But this values comes from the tx context
                rv1 = cache.Get(k1);
                Assert.AreEqual(rv1, v1);
                cache.Remove(k1);
                rv1 = cache.Get(k1);
                Assert.IsNull(rv1);
            } finally {
                txManager.Rollback();
            }
            rv1 = nonTxCache.Get(k1);
            Assert.AreEqual(rv1, v2);
        }
Ejemplo n.º 21
0
        public void EqHybridQueryWithParamTest()
        {
            IRemoteCache <int, User> userCache = remoteManager.GetCache <int, User>(NAMED_CACHE);

            QueryRequest.Types.NamedParameter param = new QueryRequest.Types.NamedParameter();
            WrappedMessage wm = new WrappedMessage();

            wm.WrappedString = "Doe";
            param.Name       = "surnameParam";
            param.Value      = wm;

            QueryRequest qr = new QueryRequest();

            // JpqlString will be deprecated please use QueryString
            // qr.JpqlString = "from sample_bank_account.User u where (u.notes = \"Lorem ipsum dolor sit amet\") and (u.surname = :surnameParam)";
            qr.QueryString = "from sample_bank_account.User u where (u.notes = \"Lorem ipsum dolor sit amet\") and (u.surname = :surnameParam)";
            qr.NamedParameters.Add(param);

            QueryResponse result      = userCache.Query(qr);
            List <User>   listOfUsers = RemoteQueryUtils.unwrapResults <User>(result);

            Assert.AreEqual(1, listOfUsers.Count);
            Assert.AreEqual(1, listOfUsers.ElementAt(0).Id);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Used level 1 memory, plus level 2 remote (e.g. Memcached via Windows Azure Worker Role)
 /// </summary>
 public static void Initialize(IRemoteCache level2Cache)
 {
     Level1Cache = new Level1MemoryCfPerfCache();
     Level2Cache = level2Cache;
 }
Ejemplo n.º 23
0
        private void PutTransactions(IRemoteCache <String, Transaction> remoteCache)
        {
            Transaction transaction0 = new Transaction();

            transaction0.Id          = 0;
            transaction0.Description = "Birthday present";
            transaction0.AccountId   = 1;
            transaction0.Amount      = 1800;
            transaction0.Date        = MakeDate("2012-09-07");
            transaction0.IsDebit     = false;
            transaction0.IsValid     = true;

            remoteCache.Put("transaction_" + transaction0.Id, transaction0);

            Transaction transaction1 = new Transaction();

            transaction1.Id              = 1;
            transaction1.Description     = "Feb. rent payment";
            transaction1.LongDescription = "Feb. rent payment";
            transaction1.AccountId       = 1;
            transaction1.Amount          = 1500;
            transaction1.Date            = MakeDate("2013-01-05");
            transaction1.IsDebit         = true;
            transaction1.IsValid         = true;

            remoteCache.Put("transaction_" + transaction1.Id, transaction1);

            Transaction transaction2 = new Transaction();

            transaction2.Id              = 2;
            transaction2.Description     = "Starbucks";
            transaction2.LongDescription = "Starbucks";
            transaction2.AccountId       = 1;
            transaction2.Amount          = 23;
            transaction2.Date            = MakeDate("2013-01-09");
            transaction2.IsDebit         = true;
            transaction2.IsValid         = true;

            remoteCache.Put("transaction_" + transaction2.Id, transaction2);

            Transaction transaction3 = new Transaction();

            transaction3.Id          = 3;
            transaction3.Description = "Hotel";
            transaction3.AccountId   = 2;
            transaction3.Amount      = 45;
            transaction3.Date        = MakeDate("2013-02-27");
            transaction3.IsDebit     = true;
            transaction3.IsValid     = true;

            remoteCache.Put("transaction_" + transaction3.Id, transaction3);

            Transaction transaction4 = new Transaction();

            transaction4.Id              = 4;
            transaction4.Description     = "Last january";
            transaction4.LongDescription = "Last january";
            transaction4.AccountId       = 2;
            transaction4.Amount          = 95;
            transaction4.Date            = MakeDate("2013-01-31");
            transaction4.IsDebit         = true;
            transaction4.IsValid         = true;

            remoteCache.Put("transaction_" + transaction4.Id, transaction4);

            Transaction transaction5 = new Transaction();

            transaction5.Id              = 5;
            transaction5.Description     = "-Popcorn";
            transaction5.LongDescription = "-Popcorn";
            transaction5.AccountId       = 2;
            transaction5.Amount          = 5;
            transaction5.Date            = MakeDate("2013-01-01");
            transaction5.IsDebit         = true;
            transaction5.IsValid         = true;

            remoteCache.Put("transaction_" + transaction5.Id, transaction5);

            for (int i = 0; i < 50; i++)
            {
                Transaction transaction = new Transaction();
                transaction.Id              = 50 + i;
                transaction.Description     = "Expensive shoes " + i;
                transaction.LongDescription = "Expensive shoes. Just beer, really " + i;
                transaction.AccountId       = 2;
                transaction.Amount          = 100 + i;
                transaction.Date            = MakeDate("2013-08-20");
                transaction.IsDebit         = true;
                transaction.IsValid         = true;
                remoteCache.Put("transaction_" + transaction.Id, transaction);
            }
        }
Ejemplo n.º 24
0
 protected void TestCommonSupervisorAdminOps(IRemoteCache <String, String> hotrodCache, IRemoteCache <String, String> scriptCache, IMarshaller marshaller)
 {
     TestPutClear(hotrodCache);
     TestPutClearAsync(hotrodCache);
     TestPutContains(hotrodCache);
     TestPutGet(hotrodCache);
     TestPutGetAsync(hotrodCache);
     TestPutGetBulk(hotrodCache);
     TestPutGetVersioned(hotrodCache);
     TestPutGetWithMetadata(hotrodCache);
     TestPutAll(hotrodCache);
     TestPutAllAsync(hotrodCache);
     TestPutIfAbsent(hotrodCache); //requires both READ and WRITE permissions
     TestPutIfAbsentAsync(hotrodCache);
     TestPutRemoveContains(hotrodCache);
     TestPutRemoveAsyncContains(hotrodCache);
     TestPutRemoveWithVersion(hotrodCache);
     TestPutRemoveWithVersionAsync(hotrodCache);
     TestPutReplaceWithFlag(hotrodCache);
     TestPutReplaceWithVersion(hotrodCache);
     TestPutReplaceWithVersionAsync(hotrodCache);
     TestPutSize(hotrodCache);
     TestRemoteTaskExec(hotrodCache, scriptCache, marshaller);
     //see ISPN-8059 - test this only for Admin user
     //TestPutKeySet(cache);
 }
Ejemplo n.º 25
0
        private void PutAccounts(IRemoteCache<int, Account> remoteCache)
        {
            Account account1 = new Account();
            account1.Id = 1;
            account1.Description = "John Doe's first bank account";
            account1.CreationDate = MakeDate("2013-01-03");

            remoteCache.Put(4, account1);

            Account account2 = new Account();
            account2.Id = 2;
            account2.Description = "John Doe's second bank account";
            account2.CreationDate = MakeDate("2013-01-04");

            remoteCache.Put(5, account2);

            Account account3 = new Account();
            account3.Id = 3;
            account3.CreationDate = MakeDate("2013-01-20");

            remoteCache.Put(6, account3);
        }
Ejemplo n.º 26
0
 public static void LoadScriptCache(IRemoteCache<String, String> cache, String scriptKey, String fileName)
 {
     string text = System.IO.File.ReadAllText(fileName);
     cache.Put(scriptKey, text);
 }
Ejemplo n.º 27
0
        private void PutUsers(IRemoteCache<int, User> remoteCache)
        {
            User user1 = new User();
            user1.Id = 1;
            user1.Name = "John";
            user1.Surname = "Doe";
            user1.Gender = User.Types.Gender.MALE;
            user1.Age = 22;
            user1.Notes = "Lorem ipsum dolor sit amet";
            List<String> accountIds = new List<String>();
            accountIds.Add("1");
            accountIds.Add("2");
            user1.AccountIds.Add(accountIds);
            User.Types.Address address1 = new User.Types.Address();
            address1.Street = "Main Street";
            address1.PostCode = "X1234";
            address1.Number = 156;
            List<User.Types.Address> addresses = new List<User.Types.Address>();
            addresses.Add(address1);
            user1.Addresses.Add(addresses);

            remoteCache.Put(1, user1);

            User user2 = new User();
            user2.Id = 2;
            user2.Name = "Spider";
            user2.Surname = "Man";
            user2.Gender = User.Types.Gender.MALE;
            accountIds = new List<String>();
            accountIds.Add("3");
            user2.AccountIds.Add(accountIds);
            User.Types.Address address2 = new User.Types.Address();
            address2.Street = "Old Street";
            address2.PostCode = "Y12";
            address2.Number = -12;
            User.Types.Address address3 = new User.Types.Address();
            address3.Street = "Bond Street";
            address3.PostCode = "ZZ";
            address3.Number = 312;
            addresses = new List<User.Types.Address>();
            addresses.Add(address2);
            addresses.Add(address3);
            user2.Addresses.Add(addresses);

            remoteCache.Put(2, user2);

            User user3 = new User();
            user3.Id = 3;
            user3.Name = "Spider";
            user3.Surname = "Woman";
            user3.Gender = User.Types.Gender.FEMALE;

            remoteCache.Put(3, user3);
            accountIds = new List<String>();
            user3.AccountIds.Add(accountIds);
        }
Ejemplo n.º 28
0
        protected void TestStats(IRemoteCache <string, string> cache)
        {
            ServerStatistics stats = cache.Stats();

            Assert.NotNull(stats);
        }
Ejemplo n.º 29
0
 protected void TestPutSize(IRemoteCache <string, string> cache)
 {
     cache.Put(K1, V1);
     Assert.IsTrue(cache.Size() != 0);
 }
        private void PutTransactions(IRemoteCache<String, Transaction> remoteCache)
        {
            Transaction transaction0 = new Transaction();
            transaction0.Id = 0;
            transaction0.Description = "Birthday present";
            transaction0.AccountId = 1;
            transaction0.Amount = 1800;
            transaction0.Date = MakeDate("2012-09-07");
            transaction0.IsDebit = false;
            transaction0.IsValid = true;

            remoteCache.Put("transaction_" + transaction0.Id, transaction0);

            Transaction transaction1 = new Transaction();
            transaction1.Id = 1;
            transaction1.Description = "Feb. rent payment";
            transaction1.LongDescription = "Feb. rent payment";
            transaction1.AccountId = 1;
            transaction1.Amount = 1500;
            transaction1.Date = MakeDate("2013-01-05");
            transaction1.IsDebit = true;
            transaction1.IsValid = true;

            remoteCache.Put("transaction_" + transaction1.Id, transaction1);

            Transaction transaction2 = new Transaction();
            transaction2.Id = 2;
            transaction2.Description = "Starbucks";
            transaction2.LongDescription = "Starbucks";
            transaction2.AccountId = 1;
            transaction2.Amount = 23;
            transaction2.Date = MakeDate("2013-01-09");
            transaction2.IsDebit = true;
            transaction2.IsValid = true;

            remoteCache.Put("transaction_" + transaction2.Id, transaction2);

            Transaction transaction3 = new Transaction();
            transaction3.Id = 3;
            transaction3.Description = "Hotel";
            transaction3.AccountId = 2;
            transaction3.Amount = 45;
            transaction3.Date = MakeDate("2013-02-27");
            transaction3.IsDebit = true;
            transaction3.IsValid = true;

            remoteCache.Put("transaction_" + transaction3.Id, transaction3);

            Transaction transaction4 = new Transaction();
            transaction4.Id = 4;
            transaction4.Description = "Last january";
            transaction4.LongDescription = "Last january";
            transaction4.AccountId = 2;
            transaction4.Amount = 95;
            transaction4.Date = MakeDate("2013-01-31");
            transaction4.IsDebit = true;
            transaction4.IsValid = true;

            remoteCache.Put("transaction_" + transaction4.Id, transaction4);

            Transaction transaction5 = new Transaction();
            transaction5.Id = 5;
            transaction5.Description = "-Popcorn";
            transaction5.LongDescription = "-Popcorn";
            transaction5.AccountId = 2;
            transaction5.Amount = 5;
            transaction5.Date = MakeDate("2013-01-01");
            transaction5.IsDebit = true;
            transaction5.IsValid = true;

            remoteCache.Put("transaction_" + transaction5.Id, transaction5);

            for (int i = 0; i < 50; i++)
            {
                Transaction transaction = new Transaction();
                transaction.Id = 50 + i;
                transaction.Description = "Expensive shoes " + i;
                transaction.LongDescription = "Expensive shoes. Just beer, really " + i;
                transaction.AccountId = 2;
                transaction.Amount = 100 + i;
                transaction.Date = MakeDate("2013-08-20");
                transaction.IsDebit = true;
                transaction.IsValid = true;
                remoteCache.Put("transaction_" + transaction.Id, transaction);
            }
        }
Ejemplo n.º 31
0
 public void BeforeTest()
 {
     cache = remoteManager.GetCache <String, String>();
 }
Ejemplo n.º 32
0
 /// <summary>
 /// Used level 1 memory, plus level 2 remote (e.g. Memcached via Windows Azure Worker Role)
 /// </summary>
 public static void Initialize(IRemoteCache <CfCacheIndexEntry> level2Cache)
 {
     Level1Cache = new Level1MemoryCfCacheIndex();
     Level2Cache = level2Cache;
 }
Ejemplo n.º 33
0
        private void PutTransactions(IRemoteCache<int, Transaction> remoteCache)
        {
            Transaction transaction0 = new Transaction();
            transaction0.Id = 0;
            transaction0.Description = "Birthday present";
            transaction0.AccountId = 1;
            transaction0.Amount = 1800;
            transaction0.Date = MakeDate("2012-09-07");
            transaction0.IsDebit = false;
            transaction0.IsValid = true;

            remoteCache.Put(7, transaction0);

            Transaction transaction1 = new Transaction();
            transaction1.Id = 1;
            transaction1.Description = "Feb. rent payment";
            transaction1.AccountId = 1;
            transaction1.Amount = 1500;
            transaction1.Date = MakeDate("2013-01-05");
            transaction1.IsDebit = true;
            transaction1.IsValid = true;

            remoteCache.Put(8, transaction1);

            Transaction transaction2 = new Transaction();
            transaction2.Id = 2;
            transaction2.Description = "Starbucks";
            transaction2.AccountId = 1;
            transaction2.Amount = 23;
            transaction2.Date = MakeDate("2013-01-09");
            transaction2.IsDebit = true;
            transaction2.IsValid = true;

            remoteCache.Put(9, transaction2);

            Transaction transaction3 = new Transaction();
            transaction3.Id = 3;
            transaction3.Description = "Hotel";
            transaction3.AccountId = 2;
            transaction3.Amount = 45;
            transaction3.Date = MakeDate("2013-02-27");
            transaction3.IsDebit = true;
            transaction3.IsValid = true;

            remoteCache.Put(10, transaction3);

            Transaction transaction4 = new Transaction();
            transaction4.Id = 4;
            transaction4.Description = "Last january";
            transaction4.AccountId = 2;
            transaction4.Amount = 95;
            transaction4.Date = MakeDate("2013-01-31");
            transaction4.IsDebit = true;
            transaction4.IsValid = true;

            remoteCache.Put(11, transaction4);

            Transaction transaction5 = new Transaction();
            transaction5.Id = 5;
            transaction5.Description = "-Popcorn";
            transaction5.AccountId = 2;
            transaction5.Amount = 4;
            transaction5.Date = MakeDate("2013-01-01");
            transaction5.IsDebit = true;
            transaction5.IsValid = true;

            remoteCache.Put(12, transaction5);
        }
Ejemplo n.º 34
0
        private void PutTransactions(IRemoteCache <int, Transaction> remoteCache)
        {
            Transaction transaction0 = new Transaction();

            transaction0.Id          = 0;
            transaction0.Description = "Birthday present";
            transaction0.AccountId   = 1;
            transaction0.Amount      = 1800;
            transaction0.Date        = MakeDate("2012-09-07");
            transaction0.IsDebit     = false;
            transaction0.IsValid     = true;

            remoteCache.Put(7, transaction0);

            Transaction transaction1 = new Transaction();

            transaction1.Id          = 1;
            transaction1.Description = "Feb. rent payment";
            transaction1.AccountId   = 1;
            transaction1.Amount      = 1500;
            transaction1.Date        = MakeDate("2013-01-05");
            transaction1.IsDebit     = true;
            transaction1.IsValid     = true;

            remoteCache.Put(8, transaction1);

            Transaction transaction2 = new Transaction();

            transaction2.Id          = 2;
            transaction2.Description = "Starbucks";
            transaction2.AccountId   = 1;
            transaction2.Amount      = 23;
            transaction2.Date        = MakeDate("2013-01-09");
            transaction2.IsDebit     = true;
            transaction2.IsValid     = true;

            remoteCache.Put(9, transaction2);

            Transaction transaction3 = new Transaction();

            transaction3.Id          = 3;
            transaction3.Description = "Hotel";
            transaction3.AccountId   = 2;
            transaction3.Amount      = 45;
            transaction3.Date        = MakeDate("2013-02-27");
            transaction3.IsDebit     = true;
            transaction3.IsValid     = true;

            remoteCache.Put(10, transaction3);

            Transaction transaction4 = new Transaction();

            transaction4.Id          = 4;
            transaction4.Description = "Last january";
            transaction4.AccountId   = 2;
            transaction4.Amount      = 95;
            transaction4.Date        = MakeDate("2013-01-31");
            transaction4.IsDebit     = true;
            transaction4.IsValid     = true;

            remoteCache.Put(11, transaction4);

            Transaction transaction5 = new Transaction();

            transaction5.Id          = 5;
            transaction5.Description = "-Popcorn";
            transaction5.AccountId   = 2;
            transaction5.Amount      = 4;
            transaction5.Date        = MakeDate("2013-01-01");
            transaction5.IsDebit     = true;
            transaction5.IsValid     = true;

            remoteCache.Put(12, transaction5);
        }
Ejemplo n.º 35
0
 public void TestWriterPerformsSupervisorOps(IRemoteCache <String, String> hotrodCache, IRemoteCache <String, String> scriptCache, IMarshaller marshaller)
 {
     AssertError(hotrodCache, cache => TestPutClear(cache));
     AssertError(hotrodCache, cache => TestPutContains(cache));
     AssertError(hotrodCache, cache => TestPutGetBulk(cache));
     AssertError(hotrodCache, cache => TestPutGetVersioned(cache));
     AssertError(hotrodCache, cache => TestPutGetWithMetadata(cache));
     AssertError(hotrodCache, cache => TestPutAll(cache));
     AssertError(hotrodCache, cache => TestPutIfAbsent(cache));
     AssertError(hotrodCache, cache => TestPutRemoveContains(cache));
     AssertError(hotrodCache, cache => TestPutRemoveWithVersion(cache));
     AssertError(hotrodCache, cache => TestPutReplaceWithFlag(cache));
     AssertError(hotrodCache, cache => TestPutReplaceWithVersion(cache));
     AssertError(hotrodCache, cache => TestPutSize(cache));
     AssertError(hotrodCache, cache => TestRemoteTaskExec(cache, scriptCache, marshaller));
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Used 2-tiered memory (only for development purposes)
 /// </summary>
 public static void Initialize()
 {
     Level1Cache = new Level1MemoryCfCacheIndex();
     Level2Cache = new Level2MemoryCfCacheIndex();
 }
Ejemplo n.º 37
0
 public void TestSupervisorSuccess(IRemoteCache <String, String> hotrodCache, IRemoteCache <String, String> scriptCache, IMarshaller marshaller)
 {
     TestCommonSupervisorAdminOps(hotrodCache, scriptCache, marshaller);
 }
Ejemplo n.º 38
0
 public void BeforeTest()
 {
     cache = remoteManager.GetCache<String, String>();
 }
Ejemplo n.º 39
0
 public void TestSupervisorPerformsAdminOps(IRemoteCache <String, String> hotrodCache)
 {
     AssertError(hotrodCache, cache => TestStats(cache));
     AssertError(hotrodCache, cache => TestAddRemoveListener(cache));
 }