From 6ce401dd555cf7928e1129d9ab31aa7be4bc7e9f Mon Sep 17 00:00:00 2001 From: David Reiss Date: Tue, 24 Mar 2009 20:01:58 +0000 Subject: [PATCH] THRIFT-136. s/async/oneway/ in misc places This is mostly an internal-only change. It affects docstrings, messages, variables, test cases, etc. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@757992 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/parse/t_function.h | 2 +- lib/erl/README | 2 +- lib/erl/src/thrift_processor.erl | 6 +++--- .../test/org/apache/thrift/test/TestClient.java | 16 ++++++++-------- .../test/org/apache/thrift/test/TestServer.java | 4 ++-- lib/py/src/server/TNonblockingServer.py | 2 +- test/ThriftTest.thrift | 2 +- test/cpp/src/TestClient.cpp | 8 ++++---- test/cpp/src/TestServer.cpp | 6 +++--- test/csharp/ThriftTest/TestClient.cs | 4 ++-- test/csharp/ThriftTest/TestServer.cs | 6 +++--- test/erl/src/test_disklog.erl | 8 ++++---- test/erl/src/test_server.erl | 2 +- test/hs/Server.hs | 2 +- test/ocaml/server/TestServer.ml | 2 +- test/py/TestClient.py | 6 +++--- test/py/TestServer.py | 4 ++-- 17 files changed, 41 insertions(+), 41 deletions(-) diff --git a/compiler/cpp/src/parse/t_function.h b/compiler/cpp/src/parse/t_function.h index c437d0e2..c2de77e7 100644 --- a/compiler/cpp/src/parse/t_function.h +++ b/compiler/cpp/src/parse/t_function.h @@ -43,7 +43,7 @@ class t_function : public t_doc { oneway_(oneway) { if (oneway_ && !xceptions_->get_members().empty()) { - throw std::string("Async methods can't throw exceptions."); + throw std::string("Oneway methods can't throw exceptions."); } } diff --git a/lib/erl/README b/lib/erl/README index 7147381e..815e1fb0 100644 --- a/lib/erl/README +++ b/lib/erl/README @@ -9,7 +9,7 @@ t). {error,{bad_args,testVoid,[asdf]}} 121> thrift_client:call(C, testI32, [123]). {ok,123} -122> thrift_client:call(C, testAsync, [1]). +122> thrift_client:call(C, testOneway, [1]). {ok,ok} 123> catch thrift_client:call(C, testXception, ["foo"]). {error,{no_function,testXception}} diff --git a/lib/erl/src/thrift_processor.erl b/lib/erl/src/thrift_processor.erl index 2f5a81b5..33446660 100644 --- a/lib/erl/src/thrift_processor.erl +++ b/lib/erl/src/thrift_processor.erl @@ -62,13 +62,13 @@ handle_function(State=#thrift_processor{in_protocol = IProto, handle_function_catch(State = #thrift_processor{service = Service}, Function, ErrType, ErrData) -> - IsAsync = Service:function_info(Function, reply_type) =:= async_void, + IsOneway = Service:function_info(Function, reply_type) =:= async_void, case {ErrType, ErrData} of - _ when IsAsync -> + _ when IsOneway -> Stack = erlang:get_stacktrace(), error_logger:warning_msg( - "async void ~p threw error which must be ignored: ~p", + "oneway void ~p threw error which must be ignored: ~p", [Function, {ErrType, ErrData, Stack}]), ok; diff --git a/lib/java/test/org/apache/thrift/test/TestClient.java b/lib/java/test/org/apache/thrift/test/TestClient.java index 91b3ec59..324bc92b 100644 --- a/lib/java/test/org/apache/thrift/test/TestClient.java +++ b/lib/java/test/org/apache/thrift/test/TestClient.java @@ -354,17 +354,17 @@ public class TestClient { System.out.print("}\n"); // Test oneway - System.out.print("testAsync(3)..."); - long startAsync = System.nanoTime(); - testClient.testAsync(3); - long asyncElapsedMillis = (System.nanoTime() - startAsync) / 1000000; - if (asyncElapsedMillis > 200) { - throw new Exception("Async test failed: took " + - Long.toString(asyncElapsedMillis) + + System.out.print("testOneway(3)..."); + long startOneway = System.nanoTime(); + testClient.testOneway(3); + long onewayElapsedMillis = (System.nanoTime() - startOneway) / 1000000; + if (onewayElapsedMillis > 200) { + throw new Exception("Oneway test failed: took " + + Long.toString(onewayElapsedMillis) + "ms"); } else { System.out.println("Success - took " + - Long.toString(asyncElapsedMillis) + + Long.toString(onewayElapsedMillis) + "ms"); } diff --git a/lib/java/test/org/apache/thrift/test/TestServer.java b/lib/java/test/org/apache/thrift/test/TestServer.java index 989fbe69..2b36ad0f 100644 --- a/lib/java/test/org/apache/thrift/test/TestServer.java +++ b/lib/java/test/org/apache/thrift/test/TestServer.java @@ -233,8 +233,8 @@ public class TestServer { return result; } - public void testAsync(int sleepFor) { - System.out.println("testAsync(" + Integer.toString(sleepFor) + + public void testOneway(int sleepFor) { + System.out.println("testOneway(" + Integer.toString(sleepFor) + ") => sleeping..."); try { Thread.sleep(sleepFor * 1000); diff --git a/lib/py/src/server/TNonblockingServer.py b/lib/py/src/server/TNonblockingServer.py index 816827cc..2f8b76b3 100644 --- a/lib/py/src/server/TNonblockingServer.py +++ b/lib/py/src/server/TNonblockingServer.py @@ -148,7 +148,7 @@ class Connection: This function is the only function witch can be called asynchronous. The ready can switch Connection to three states: - WAIT_LEN if request was async. + WAIT_LEN if request was oneway. SEND_ANSWER if request was processed in normal way. CLOSED if request throws unexpected exception. diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index c93fed58..fe3eba16 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -103,7 +103,7 @@ service ThriftTest Xtruct testMultiException(string arg0, string arg1) throws(Xception err1, Xception2 err2) /* Test oneway void */ - async void testAsync(1:i32 secondsToSleep) + async void testOneway(1:i32 secondsToSleep) } service SecondService diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp index b12a4b56..232bca23 100644 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -422,10 +422,10 @@ int main(int argc, char** argv) { /* test oneway void */ { - printf("testClient.testAsync(3) =>"); - uint64_t startAsync = now(); - testClient.testAsync(3); - uint64_t elapsed = now() - startAsync; + printf("testClient.testOneway(3) =>"); + uint64_t startOneway = now(); + testClient.testOneway(3); + uint64_t elapsed = now() - startOneway; if (elapsed > 200 * 1000) { // 0.2 seconds printf(" FAILURE - took %.2f ms\n", (double)elapsed/1000.0); } else { diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 56068f1b..a579db8d 100644 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -261,10 +261,10 @@ class TestHandler : public ThriftTestIf { } } - void testAsync(int sleepFor) { - printf("testAsync(%d): Sleeping...\n", sleepFor); + void testOneway(int sleepFor) { + printf("testOneway(%d): Sleeping...\n", sleepFor); sleep(sleepFor); - printf("testAsync(%d): done sleeping!\n", sleepFor); + printf("testOneway(%d): done sleeping!\n", sleepFor); } }; diff --git a/test/csharp/ThriftTest/TestClient.cs b/test/csharp/ThriftTest/TestClient.cs index 42b21b8a..becfb4c6 100644 --- a/test/csharp/ThriftTest/TestClient.cs +++ b/test/csharp/ThriftTest/TestClient.cs @@ -399,8 +399,8 @@ namespace Test Console.Write(" = Xtruct(byte_thing:" + multiResponse.Byte_thing + ",String_thing:" + multiResponse.String_thing + ",i32_thing:" + multiResponse.I32_thing + ",i64_thing:" + multiResponse.I64_thing + ")\n"); - Console.WriteLine("Test Async(1)"); - client.testAsync(1); + Console.WriteLine("Test Oneway(1)"); + client.testOneway(1); } } } diff --git a/test/csharp/ThriftTest/TestServer.cs b/test/csharp/ThriftTest/TestServer.cs index 18952d44..dd16bf4b 100644 --- a/test/csharp/ThriftTest/TestServer.cs +++ b/test/csharp/ThriftTest/TestServer.cs @@ -269,11 +269,11 @@ namespace Test } } - public void testAsync(int arg) + public void testOneway(int arg) { - Console.WriteLine("testAsync(" + arg + "), sleeping..."); + Console.WriteLine("testOneway(" + arg + "), sleeping..."); System.Threading.Thread.Sleep(arg * 1000); - Console.WriteLine("testAsync finished"); + Console.WriteLine("testOneway finished"); } } // class TestHandler diff --git a/test/erl/src/test_disklog.erl b/test/erl/src/test_disklog.erl index 0cc03bc2..30366826 100644 --- a/test/erl/src/test_disklog.erl +++ b/test/erl/src/test_disklog.erl @@ -16,12 +16,12 @@ t() -> % We have to make oneway calls into this client only since otherwise it will try % to read from the disklog and go boom. - {ok, ok} = thrift_client:call(Client, testAsync, [16#deadbeef]), + {ok, ok} = thrift_client:call(Client, testOneway, [16#deadbeef]), io:format("Call written~n"), % Use the send_call method to write a non-oneway call into the log ok = thrift_client:send_call(Client, testString, [<<"hello world">>]), - io:format("Non-async call sent~n"), + io:format("Non-oneway call sent~n"), ok = thrift_client:close(Client), io:format("Client closed~n"), @@ -48,12 +48,12 @@ t_base64() -> % We have to make oneway calls into this client only since otherwise it will try % to read from the disklog and go boom. - {ok, ok} = thrift_client:call(Client, testAsync, [16#deadbeef]), + {ok, ok} = thrift_client:call(Client, testOneway, [16#deadbeef]), io:format("Call written~n"), % Use the send_call method to write a non-oneway call into the log ok = thrift_client:send_call(Client, testString, [<<"hello world">>]), - io:format("Non-async call sent~n"), + io:format("Non-oneway call sent~n"), ok = thrift_client:close(Client), io:format("Client closed~n"), diff --git a/test/erl/src/test_server.erl b/test/erl/src/test_server.erl index c4326aa4..45143b76 100644 --- a/test/erl/src/test_server.erl +++ b/test/erl/src/test_server.erl @@ -150,6 +150,6 @@ handle_function(testMultiException, {Arg0, Arg1}) -> {reply, #xtruct{string_thing = Arg1}} end; -handle_function(testAsync, {Seconds}) -> +handle_function(testOneway, {Seconds}) -> timer:sleep(1000 * Seconds), ok. diff --git a/test/hs/Server.hs b/test/hs/Server.hs index 511d01e4..69b1fc9d 100644 --- a/test/hs/Server.hs +++ b/test/hs/Server.hs @@ -28,7 +28,7 @@ instance ThriftTest_Iface TestHandler where testMulti a a1 a2 a3 a4 a5 a6 = return (Xtruct Nothing Nothing Nothing Nothing) testException a c = throwDyn (Xception (Just 1) (Just "bya")) testMultiException a c1 c2 = return (Xtruct Nothing Nothing Nothing Nothing) - testAsync a (Just i) = do print i + testOneway a (Just i) = do print i main = do (run_basic_server TestHandler process 9090) `catchDyn` (\(TransportExn s t) -> print s) diff --git a/test/ocaml/server/TestServer.ml b/test/ocaml/server/TestServer.ml index 67157383..1118a55f 100644 --- a/test/ocaml/server/TestServer.ml +++ b/test/ocaml/server/TestServer.ml @@ -97,7 +97,7 @@ object (self) let res = new xtruct in res#set_string_thing (sod a1); res - method testAsync i = + method testOneway i = Unix.sleep (sod i) end;; diff --git a/test/py/TestClient.py b/test/py/TestClient.py index 944e3846..c5c8bdcc 100755 --- a/test/py/TestClient.py +++ b/test/py/TestClient.py @@ -104,12 +104,12 @@ class AbstractTest(unittest.TestCase): except Exception: # type is undefined pass - def testAsync(self): + def testOneway(self): start = time.time() - self.client.testAsync(0.5) + self.client.testOneway(0.5) end = time.time() self.assertTrue(end - start < 0.2, - "async sleep took %f sec" % (end - start)) + "oneway sleep took %f sec" % (end - start)) class NormalBinaryTest(AbstractTest): protocol_factory = TBinaryProtocol.TBinaryProtocolFactory() diff --git a/test/py/TestServer.py b/test/py/TestServer.py index 7abb624d..ab966660 100755 --- a/test/py/TestServer.py +++ b/test/py/TestServer.py @@ -54,8 +54,8 @@ class TestHandler: elif str == "throw_undeclared": raise ValueError("foo") - def testAsync(self, seconds): - print 'testAsync(%d) => sleeping...' % seconds + def testOneway(self, seconds): + print 'testOneway(%d) => sleeping...' % seconds time.sleep(seconds) print 'done sleeping' -- 2.17.1