Esempio n. 1
0
 public _Callable_178(Server.Call call, int pause, int input, int failureOutput, bool
                      success)
 {
     this.call          = call;
     this.pause         = pause;
     this.input         = input;
     this.failureOutput = failureOutput;
     this.success       = success;
 }
Esempio n. 2
0
        public virtual void TestRetryAfterFailure()
        {
            // Previous operation failed
            Server.Call call  = NewCall();
            int         input = r.Next();

            Server.GetCurCall().Set(call);
            testServer.Echo(input, input + 1, 5, false);
            TestOperations(input, 25, 0, false, true, call);
        }
Esempio n. 3
0
        public virtual void TestRetryAfterSuccess()
        {
            // Previous operation successfully completed
            Server.Call call  = NewCall();
            int         input = r.Next();

            Server.GetCurCall().Set(call);
            testServer.Echo(input, input + 1, 5, true);
            TestOperations(input, 25, 0, true, true, call);
        }
Esempio n. 4
0
        /// <exception cref="System.Exception"/>
        /// <exception cref="ExecutionException"/>
        public virtual void TestOperations(int input, int numberOfThreads, int pause, bool
                                           success, bool attemptedBefore, Server.Call call)
        {
            int                   failureOutput   = input + 1;
            ExecutorService       executorService = Executors.NewFixedThreadPool(numberOfThreads);
            IList <Future <int> > list            = new AList <Future <int> >();

            for (int i = 0; i < numberOfThreads; i++)
            {
                Callable <int> worker = new _Callable_178(call, pause, input, failureOutput, success
                                                          );
                Future <int> submit = executorService.Submit(worker);
                list.AddItem(submit);
            }
            Assert.Equal(numberOfThreads, list.Count);
            foreach (Future <int> future in list)
            {
                if (success)
                {
                    Assert.Equal(input, future.Get());
                }
                else
                {
                    Assert.Equal(failureOutput, future.Get());
                }
            }
            if (success)
            {
                // If the operation was successful, all the subsequent operations
                // by other threads should be retries. Operation count should be 1.
                int retries = numberOfThreads + (attemptedBefore ? 0 : -1);
                Assert.Equal(1, testServer.operationCount.Get());
                Assert.Equal(retries, testServer.retryCount.Get());
            }
            else
            {
                // If the operation failed, all the subsequent operations
                // should execute once more, hence the retry count should be 0 and
                // operation count should be the number of tries
                int opCount = numberOfThreads + (attemptedBefore ? 1 : 0);
                Assert.Equal(opCount, testServer.operationCount.Get());
                Assert.Equal(0, testServer.retryCount.Get());
            }
        }
 public static void ResetCall()
 {
     Server.Call call = new Server.Call(RpcConstants.InvalidCallId, 1, null, null, RPC.RpcKind
                                        .RpcProtocolBuffer, RpcConstants.DummyClientId);
     Org.Apache.Hadoop.Ipc.Server.GetCurCall().Set(call);
 }
 /// <summary>Set the current Server RPC call</summary>
 public static void NewCall()
 {
     Server.Call call = new Server.Call(++callId, 1, null, null, RPC.RpcKind.RpcProtocolBuffer
                                        , ClientId);
     Org.Apache.Hadoop.Ipc.Server.GetCurCall().Set(call);
 }