Author: roger
Date: Tue Mar 4 22:15:01 2014
New Revision: 1574224
URL: http://svn.apache.org/r1574224
Log:
content/index.md: no 4 spaces or tab to avoid md double rendering
content/tutorial/cpp.md: use html entities < and >
Modified:
thrift/site/content/index.md
thrift/site/content/tutorial/cpp.md
thrift/site/publish/index.html
thrift/site/publish/tutorial/cpp/index.html
thrift/site/publish/tutorial/index.html
Modified: thrift/site/content/index.md
URL:
http://svn.apache.org/viewvc/thrift/site/content/index.md?rev=1574224&r1=1574223&r2=1574224&view=diff
==============================================================================
--- thrift/site/content/index.md (original)
+++ thrift/site/content/index.md Tue Mar 4 22:15:01 2014
@@ -74,67 +74,67 @@ title: "Home"
<div class="tab-content">
<div class="tab-pane active" id="1">
<pre><code>
- struct UserProfile {
- 1: i32 uid,
- 2: string name,
- 3: string blurb
- }
- service UserStorage {
- void store(1: UserProfile user),
- UserProfile retrieve(1: i32 uid)
- }
+struct UserProfile {
+ 1: i32 uid,
+ 2: string name,
+ 3: string blurb
+}
+service UserStorage {
+ void store(1: UserProfile user),
+ UserProfile retrieve(1: i32 uid)
+}
</code></pre>
</div>
<div class="tab-pane" id="2">
<pre><code class="language-python">
- # Make an object
- up = UserProfile(uid=1,
- name="Test User",
- blurb="Thrift is great")
-
- # Talk to a server via TCP sockets, using a binary protocol
- transport = TSocket.TSocket("localhost", 9090)
- transport.open()
- protocol = TBinaryProtocol.TBinaryProtocol(transport)
-
- # Use the service we already defined
- service = UserStorage.Client(protocol)
- service.store(up)
+# Make an object
+up = UserProfile(uid=1,
+ name="Test User",
+ blurb="Thrift is great")
+
+# Talk to a server via TCP sockets, using a binary protocol
+transport = TSocket.TSocket("localhost", 9090)
+transport.open()
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+
+# Use the service we already defined
+service = UserStorage.Client(protocol)
+service.store(up)
- # Retrieve something as well
- up2 = service.retrieve(2)
+# Retrieve something as well
+up2 = service.retrieve(2)
</code></pre>
</div>
<div class="tab-pane" id="3">
- <pre><code class="language-c">
- class UserStorageHandler : virtual public UserStorageIf {
- public:
- UserStorageHandler() {
- // Your initialization goes here
- }
-
- void store(const UserProfile& user) {
- // Your implementation goes here
- printf("store\n");
- }
-
- void retrieve(UserProfile& _return, const int32_t uid) {
- // Your implementation goes here
- printf("retrieve\n");
- }
- };
-
- int main(int argc, char **argv) {
- int port = 9090;
- shared_ptr<UserStorageHandler> handler(new UserStorageHandler());
- shared_ptr<TProcessor> processor(new UserStorageProcessor(handler));
- shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
- shared_ptr<TTransportFactory> transportFactory(new
TBufferedTransportFactory());
- shared_ptr<TProtocolFactory> protocolFactory(new
TBinaryProtocolFactory());
- TSimpleServer server(processor, serverTransport, transportFactory,
protocolFactory);
- server.serve();
- return 0;
- }
+ <pre><code class="language-cplusplus">
+class UserStorageHandler : virtual public UserStorageIf {
+ public:
+ UserStorageHandler() {
+ // Your initialization goes here
+ }
+
+ void store(const UserProfile& user) {
+ // Your implementation goes here
+ printf("store\n");
+ }
+
+ void retrieve(UserProfile& _return, const int32_t uid) {
+ // Your implementation goes here
+ printf("retrieve\n");
+ }
+};
+
+int main(int argc, char **argv) {
+ int port = 9090;
+ shared_ptr<UserStorageHandler> handler(new UserStorageHandler());
+ shared_ptr<TProcessor> processor(new UserStorageProcessor(handler));
+ shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
+ shared_ptr<TTransportFactory> transportFactory(new
TBufferedTransportFactory());
+ shared_ptr<TProtocolFactory> protocolFactory(new
TBinaryProtocolFactory());
+ TSimpleServer server(processor, serverTransport, transportFactory,
protocolFactory);
+ server.serve();
+ return 0;
+}
</code></pre>
</div>
</div>
Modified: thrift/site/content/tutorial/cpp.md
URL:
http://svn.apache.org/viewvc/thrift/site/content/tutorial/cpp.md?rev=1574224&r1=1574223&r2=1574224&view=diff
==============================================================================
--- thrift/site/content/tutorial/cpp.md (original)
+++ thrift/site/content/tutorial/cpp.md Tue Mar 4 22:15:01 2014
@@ -9,9 +9,9 @@ library_lang: "cpp"
### Client
<pre><code class="language-cpp">
- shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
- shared_ptr<TTransport> transport(new TBufferedTransport(socket));
- shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
+ shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
+ shared_ptr<TTransport> transport(new TBufferedTransport(socket));
+ shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
CalculatorClient client(protocol);
try {
@@ -55,11 +55,11 @@ library_lang: "cpp"
### Server
<pre><code class="language-cpp">
- shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
- shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
- shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
- shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
- shared_ptr<TTransportFactory> transportFactory(new
TBufferedTransportFactory());
+ shared_ptr<TProtocolFactory> protocolFactory(new
TBinaryProtocolFactory());
+ shared_ptr<CalculatorHandler> handler(new CalculatorHandler());
+ shared_ptr<TProcessor> processor(new CalculatorProcessor(handler));
+ shared_ptr<TServerTransport> serverTransport(new TServerSocket(9090));
+ shared_ptr<TTransportFactory> transportFactory(new
TBufferedTransportFactory());
TSimpleServer server(processor,
serverTransport,
@@ -148,8 +148,8 @@ protected:
### Example ThreadPool Server
<pre><code class="language-cpp">
- shared_ptr<ThreadManager> threadManager =
ThreadManager::newSimpleThreadManager(workerCount);
- shared_ptr<PosixThreadFactory> threadFactory =
shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
+ shared_ptr<ThreadManager> threadManager =
ThreadManager::newSimpleThreadManager(workerCount);
+ shared_ptr<PosixThreadFactory> threadFactory =
shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
TThreadPoolServer server(processor,
@@ -164,4 +164,4 @@ protected:
protocolFactory);
</code></pre>
-
\ No newline at end of file
+
Modified: thrift/site/publish/index.html
URL:
http://svn.apache.org/viewvc/thrift/site/publish/index.html?rev=1574224&r1=1574223&r2=1574224&view=diff
==============================================================================
--- thrift/site/publish/index.html (original)
+++ thrift/site/publish/index.html Tue Mar 4 22:15:01 2014
@@ -76,7 +76,7 @@
<p>
</p>
<ul>
- <li>
+<li>
<b>Download Apache Thrift</b>
<p>To get started, <a href="/download/">download</a> a copy of
Thrift.</p>
</li>
@@ -96,9 +96,7 @@
<p>The sample tutorial.thrift file used for all the client and
server tutorials can be found <a
href="https://git-wip-us.apache.org/repos/asf/thrift/?p=thrift.git;a=tree;f=tutorial">here</a>.
</p>
</li>
</ul>
-
- <br>
- <p>
+<br><p>
To learn more about Apache Thrift <a
href="/static/files/thrift-20070401.pdf">Read the Whitepaper</a>
</p>
</div>
@@ -126,87 +124,84 @@
</div>
</div>
-<hr>
-
-<p></p><h3>Example<h3>
+<hr><p></p><h3>Example<h3>
</h3>
</h3><p>Apache Thrift allows you to define data types and service interfaces
in a simple definition file. Taking that file as input, the compiler generates
code to be used to easily build RPC clients and servers that communicate
seamlessly across programming languages. Instead of writing a load of
boilerplate code to serialize and transport your objects and invoke remote
methods, you can get right down to business.
</p>
<p>The following example is a simple service to store user objects for a web
front end.</p>
<div class="tabbable">
<ul class="nav nav-tabs">
- <li class="active"><a href="#1" data-toggle="tab">Thrift Definition
File</a></li>
+<li class="active"><a href="#1" data-toggle="tab">Thrift Definition
File</a></li>
<li><a href="#2" data-toggle="tab">Python Client</a></li>
<li><a href="#3" data-toggle="tab">C++ Server</a></li>
</ul>
- <div class="tab-content">
+<div class="tab-content">
<div class="tab-pane active" id="1">
<pre><code>
- struct UserProfile {
- 1: i32 uid,
- 2: string name,
- 3: string blurb
- }
- service UserStorage {
- void store(1: UserProfile user),
- UserProfile retrieve(1: i32 uid)
- }
+struct UserProfile {
+ 1: i32 uid,
+ 2: string name,
+ 3: string blurb
+}
+service UserStorage {
+ void store(1: UserProfile user),
+ UserProfile retrieve(1: i32 uid)
+}
</code></pre>
</div>
<div class="tab-pane" id="2">
- <div class="CodeRay"><div class="code"><pre><code
class="language-python"><span style="color:#777"># Make an object</span>
+ <div class="CodeRay"><div class="code"><pre><code
class="language-python">Make an <span
style="color:#369;font-weight:bold">object</span>
+
up = UserProfile(uid=<span style="color:#00D">1</span>,
name=<span
style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">Test User</span><span
style="color:#710">"</span></span>,
blurb=<span
style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">Thrift is great</span><span
style="color:#710">"</span></span>)
- <span style="color:#777"># Talk to a server via TCP sockets, using a binary
protocol</span>
- transport = TSocket.TSocket(<span
style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">localhost</span><span
style="color:#710">"</span></span>, <span style="color:#00D">9090</span>)
- transport.open()
- protocol = TBinaryProtocol.TBinaryProtocol(transport)
-
- <span style="color:#777"># Use the service we already defined</span>
- service = UserStorage.Client(protocol)
- service.store(up)
-
- <span style="color:#777"># Retrieve something as well</span>
- up2 = service.retrieve(<span style="color:#00D">2</span>)
- </code></pre>
-</div>
-</div></div>
-<div class="tab-pane" id="3">
-<div class="CodeRay"><div class="code"><pre><code class="language-c">
- <span style="color:#080;font-weight:bold">class</span> <span
style="color:#B06;font-weight:bold">UserStorageHandler</span> : virtual public
UserStorageIf {
- public:
- UserStorageHandler() {
- // Your initialization goes here
- }
-
- void store(const UserProfile& user) {
- // Your implementation goes here
- printf(<span style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">store</span><span
style="color:#b0b">\n</span><span style="color:#710">"</span></span>);
- }
-
- void retrieve(UserProfile& _return, const int32_t uid) {
- // Your implementation goes here
- printf(<span style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">retrieve</span><span
style="color:#b0b">\n</span><span style="color:#710">"</span></span>);
- }
- };
-
- <span style="color:#369;font-weight:bold">int</span> main(<span
style="color:#369;font-weight:bold">int</span> argc, char **argv) {
- <span style="color:#369;font-weight:bold">int</span> port = <span
style="color:#00D">9090</span>;
- shared_ptr<UserStorageHandler> handler(new UserStorageHandler());
- shared_ptr<TProcessor> processor(new UserStorageProcessor(handler));
- shared_ptr<TServerTransport> serverTransport(new
TServerSocket(port));
- shared_ptr<TTransportFactory> transportFactory(new
TBufferedTransportFactory());
- shared_ptr<TProtocolFactory> protocolFactory(new
TBinaryProtocolFactory());
- TSimpleServer server(processor, serverTransport, transportFactory,
protocolFactory);
- server.serve();
- <span style="color:#080;font-weight:bold">return</span> <span
style="color:#00D">0</span>;
+Talk to a server via TCP sockets, using a binary protocol
+
+transport = TSocket.TSocket(<span
style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">localhost</span><span
style="color:#710">"</span></span>, <span style="color:#00D">9090</span>)
+transport.open()
+protocol = TBinaryProtocol.TBinaryProtocol(transport)
+
+Use the service we already defined
+
+service = UserStorage.Client(protocol)
+service.store(up)
+
+Retrieve something <span style="color:#080;font-weight:bold">as</span> well
+
+up2 = service.retrieve(<span
style="color:#00D">2</span>)</code></pre></div></div>
+ </div>
+ <div class="tab-pane" id="3">
+ <div class="CodeRay"><div class="code"><pre><code
class="language-cplusplus"><span
style="color:#080;font-weight:bold">class</span> <span
style="color:#B06;font-weight:bold">UserStorageHandler</span> : <span
style="color:#088;font-weight:bold">virtual</span> <span
style="color:#088;font-weight:bold">public</span> UserStorageIf {
+ <span style="color:#088;font-weight:bold">public</span>:
+ UserStorageHandler() {
+ <span style="color:#777">// Your initialization goes here</span>
}
- </code></pre>
-</div></div></div>
-</div>
-</div>
+
+<span style="color:#088;font-weight:bold">void</span> store(<span
style="color:#088;font-weight:bold">const</span> UserProfile& user) {
+ <span style="color:#777">// Your implementation goes here</span>
+ printf(<span style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">store</span><span
style="color:#b0b">\n</span><span style="color:#710">"</span></span>);
+ }
+
+<span style="color:#088;font-weight:bold">void</span>
retrieve(UserProfile& <span
style="color:#080;font-weight:bold">return</span>, <span
style="color:#088;font-weight:bold">const</span> int32t uid) {
+ <span style="color:#777">// Your implementation goes here</span>
+ printf(<span style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">retrieve</span><span
style="color:#b0b">\n</span><span style="color:#710">"</span></span>);
+ }
+};
+
+<span style="color:#0a5;font-weight:bold">int</span> main(<span
style="color:#0a5;font-weight:bold">int</span> argc, <span
style="color:#0a5;font-weight:bold">char</span> **argv) {
+ <span style="color:#0a5;font-weight:bold">int</span> port = <span
style="color:#00D">9090</span>;
+ sharedptr<UserStorageHandler> handler(<span
style="color:#080;font-weight:bold">new</span> UserStorageHandler());
+ sharedptr<TProcessor> processor(<span
style="color:#080;font-weight:bold">new</span> UserStorageProcessor(handler));
+ sharedptr<TServerTransport> serverTransport(<span
style="color:#080;font-weight:bold">new</span> TServerSocket(port));
+ sharedptr<TTransportFactory> transportFactory(<span
style="color:#080;font-weight:bold">new</span> TBufferedTransportFactory());
+ shared_ptr<TProtocolFactory> protocolFactory(<span
style="color:#080;font-weight:bold">new</span> TBinaryProtocolFactory());
+ TSimpleServer server(processor, serverTransport, transportFactory,
protocolFactory);
+ server.serve();
+ <span style="color:#080;font-weight:bold">return</span> <span
style="color:#00D">0</span>;
+}</code></pre></div></div>
+ </div>
+ </div>
</div>
</div>
<div class="container">
Modified: thrift/site/publish/tutorial/cpp/index.html
URL:
http://svn.apache.org/viewvc/thrift/site/publish/tutorial/cpp/index.html?rev=1574224&r1=1574223&r2=1574224&view=diff
==============================================================================
--- thrift/site/publish/tutorial/cpp/index.html (original)
+++ thrift/site/publish/tutorial/cpp/index.html Tue Mar 4 22:15:01 2014
@@ -85,9 +85,9 @@
<h3>Client</h3>
-<div class="CodeRay"><div class="code"><pre><code class="language-cpp">
shared_ptr socket(<span style="color:#080;font-weight:bold">new</span>
TSocket(<span style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">localhost</span><span
style="color:#710">"</span></span>, <span style="color:#00D">9090</span>));
- shared_ptr transport(<span style="color:#080;font-weight:bold">new</span>
TBufferedTransport(socket));
- shared_ptr protocol(<span style="color:#080;font-weight:bold">new</span>
TBinaryProtocol(transport));
+<div class="CodeRay"><div class="code"><pre><code class="language-cpp">
shared_ptr<TTransport> socket(<span
style="color:#080;font-weight:bold">new</span> TSocket(<span
style="background-color:hsla(0,100%,50%,0.05)"><span
style="color:#710">"</span><span style="color:#D20">localhost</span><span
style="color:#710">"</span></span>, <span style="color:#00D">9090</span>));
+ shared_ptr<TTransport> transport(<span
style="color:#080;font-weight:bold">new</span> TBufferedTransport(socket));
+ shared_ptr<TProtocol> protocol(<span
style="color:#080;font-weight:bold">new</span> TBinaryProtocol(transport));
CalculatorClient client(protocol);
<span style="color:#080;font-weight:bold">try</span> {
@@ -130,11 +130,11 @@
<h3>Server</h3>
-<div class="CodeRay"><div class="code"><pre><code class="language-cpp">
shared_ptr protocolFactory(<span style="color:#080;font-weight:bold">new</span>
TBinaryProtocolFactory());
- shared_ptr handler(<span style="color:#080;font-weight:bold">new</span>
CalculatorHandler());
- shared_ptr processor(<span style="color:#080;font-weight:bold">new</span>
CalculatorProcessor(handler));
- shared_ptr serverTransport(<span
style="color:#080;font-weight:bold">new</span> TServerSocket(<span
style="color:#00D">9090</span>));
- shared_ptr transportFactory(<span
style="color:#080;font-weight:bold">new</span> TBufferedTransportFactory());
+<div class="CodeRay"><div class="code"><pre><code class="language-cpp">
shared_ptr<TProtocolFactory> protocolFactory(<span
style="color:#080;font-weight:bold">new</span> TBinaryProtocolFactory());
+ shared_ptr<CalculatorHandler> handler(<span
style="color:#080;font-weight:bold">new</span> CalculatorHandler());
+ shared_ptr<TProcessor> processor(<span
style="color:#080;font-weight:bold">new</span> CalculatorProcessor(handler));
+ shared_ptr<TServerTransport> serverTransport(<span
style="color:#080;font-weight:bold">new</span> TServerSocket(<span
style="color:#00D">9090</span>));
+ shared_ptr<TTransportFactory> transportFactory(<span
style="color:#080;font-weight:bold">new</span> TBufferedTransportFactory());
TSimpleServer server(processor,
serverTransport,
@@ -218,8 +218,8 @@
<h3>Example ThreadPool Server</h3>
-<div class="CodeRay"><div class="code"><pre><code class="language-cpp">
shared_ptr threadManager = ThreadManager::newSimpleThreadManager(workerCount);
- shared_ptr threadFactory = shared_ptr(<span
style="color:#080;font-weight:bold">new</span> PosixThreadFactory());
+<div class="CodeRay"><div class="code"><pre><code class="language-cpp">
shared_ptr<ThreadManager> threadManager =
ThreadManager::newSimpleThreadManager(workerCount);
+ shared_ptr<PosixThreadFactory> threadFactory =
shared_ptr<PosixThreadFactory>(<span
style="color:#080;font-weight:bold">new</span> PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
TThreadPoolServer server(processor,
Modified: thrift/site/publish/tutorial/index.html
URL:
http://svn.apache.org/viewvc/thrift/site/publish/tutorial/index.html?rev=1574224&r1=1574223&r2=1574224&view=diff
==============================================================================
--- thrift/site/publish/tutorial/index.html (original)
+++ thrift/site/publish/tutorial/index.html Tue Mar 4 22:15:01 2014
@@ -98,7 +98,7 @@ See the <a href="/docs/BuildingFromSourc
<pre><code>thrift --gen <language> <Thrift filename>
</code></pre>
-<p>The sample <a
href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a>
file defines a basic calculator service. This will be used to demonstrate both
the client and server.</p>
+<p>The sample <a
href="https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/tutorial.thrift">tutorial.thrift</a>
file defines a basic calculator service. This will be used to demonstrate both
the client and server. </p>
</li>
</ul><h2>Examples Clients and Servers</h2>