コード例 #1
0
        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();
        }
コード例 #2
0
 public void TestTxnTimeOut()
 {
     var options = new TransactionOptions();
     options.SetTimeout(100, TimeUnit.Milliseconds);
     var context = Client.NewTransactionContext(options);
     Thread.Sleep(500);
     context.CommitTransaction();
 }
コード例 #3
0
 internal TransactionProxy(HazelcastClient client, TransactionOptions options, IMember txOwner)
 {
     _options = options;
     _client = client;
     _txOwner = txOwner;
 }
コード例 #4
0
 public void TestNegativeTimeout()
 {
     var options = new TransactionOptions();
     options.SetTimeout(-1, TimeUnit.Milliseconds);
 }
コード例 #5
0
 public void TestNegativeDurability()
 {
     var options = new TransactionOptions();
     options.SetDurability(-1);
 }
コード例 #6
0
 internal TransactionProxy(HazelcastClient client, TransactionOptions options, IMember txOwner)
 {
     this.options = options;
     this.client =  client;
     this.txOwner = txOwner;
 }