1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
8
<title>Class: PbServer</title>
10
<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />
12
<script src="./js/jquery.js" type="text/javascript"
13
charset="utf-8"></script>
14
<script src="./js/thickbox-compressed.js" type="text/javascript"
15
charset="utf-8"></script>
16
<script src="./js/quicksearch.js" type="text/javascript"
17
charset="utf-8"></script>
18
<script src="./js/darkfish.js" type="text/javascript"
19
charset="utf-8"></script>
25
<div id="home-metadata">
26
<div id="home-section" class="section">
27
<h3 class="section-header">
28
<a href="./index.html">Home</a>
29
<a href="./index.html#classes">Classes</a>
30
<a href="./index.html#methods">Methods</a>
35
<div id="file-metadata">
36
<div id="file-list-section" class="section">
37
<h3 class="section-header">In Files</h3>
38
<div class="section-body">
41
<li><a href="./lib/pbserver_rb.html?TB_iframe=true&height=550&width=785"
42
class="thickbox" title="lib/pbserver.rb">lib/pbserver.rb</a></li>
51
<div id="class-metadata">
55
<div id="parent-class-section" class="section">
56
<h3 class="section-header">Parent</h3>
58
<p class="link"><a href="Object.html">Object</a></p>
63
<!-- Namespace Contents -->
66
<!-- Method Quickref -->
68
<div id="method-list-section" class="section">
69
<h3 class="section-header">Methods</h3>
70
<ul class="link-list">
72
<li><a href="#method-c-is_running">::is_running</a></li>
74
<li><a href="#method-c-listen_port">::listen_port</a></li>
76
<li><a href="#method-c-listen_ssl_port">::listen_ssl_port</a></li>
78
<li><a href="#method-c-name">::name</a></li>
80
<li><a href="#method-c-pb_script">::pb_script</a></li>
82
<li><a href="#method-c-proxy_port">::proxy_port</a></li>
84
<li><a href="#method-c-public_directory">::public_directory</a></li>
86
<li><a href="#method-c-restart">::restart</a></li>
88
<li><a href="#method-c-server_ports">::server_ports</a></li>
90
<li><a href="#method-c-start">::start</a></li>
92
<li><a href="#method-c-stop">::stop</a></li>
98
<!-- Included Modules -->
102
<div id="project-metadata">
106
<div id="classindex-section" class="section project-section">
107
<h3 class="section-header">Class/Module Index
108
<span class="search-toggle"><img src="./images/find.png"
109
height="16" width="16" alt="[+]"
110
title="show/hide quicksearch" /></span></h3>
111
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
113
<legend>Quicksearch</legend>
114
<input type="text" name="quicksearch" value=""
115
class="quicksearch-field" />
119
<ul class="link-list">
121
<li><a href="./AppControllerClient.html">AppControllerClient</a></li>
123
<li><a href="./BlobServer.html">BlobServer</a></li>
125
<li><a href="./Collectd.html">Collectd</a></li>
127
<li><a href="./CronHelper.html">CronHelper</a></li>
129
<li><a href="./Djinn.html">Djinn</a></li>
131
<li><a href="./DjinnJobData.html">DjinnJobData</a></li>
133
<li><a href="./DjinnServer.html">DjinnServer</a></li>
135
<li><a href="./Ejabberd.html">Ejabberd</a></li>
137
<li><a href="./GodInterface.html">GodInterface</a></li>
139
<li><a href="./HAProxy.html">HAProxy</a></li>
141
<li><a href="./HelperFunctions.html">HelperFunctions</a></li>
143
<li><a href="./JSONClient.html">JSONClient</a></li>
145
<li><a href="./LoadBalancer.html">LoadBalancer</a></li>
147
<li><a href="./Monitoring.html">Monitoring</a></li>
149
<li><a href="./Nginx.html">Nginx</a></li>
151
<li><a href="./Object.html">Object</a></li>
153
<li><a href="./PbServer.html">PbServer</a></li>
155
<li><a href="./RabbitMQ.html">RabbitMQ</a></li>
157
<li><a href="./Repo.html">Repo</a></li>
159
<li><a href="./UserAppClient.html">UserAppClient</a></li>
161
<li><a href="./ZKInterface.html">ZKInterface</a></li>
164
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
171
<div id="documentation">
172
<h1 class="class">PbServer</h1>
174
<div id="description">
176
<p>A class to wrap all the interactions with the <a
177
href="PbServer.html">PbServer</a></p>
183
<div id="constants-list" class="section">
184
<h3 class="section-header">Constants</h3>
187
<dt><a name="NUM_PBSERVERS">NUM_PBSERVERS</a></dt>
189
<dd class="description"></dd>
192
<dt><a name="SERVER_PORTS">SERVER_PORTS</a></dt>
194
<dd class="description"></dd>
197
<dt><a name="PROXY_PORT">PROXY_PORT</a></dt>
199
<dd class="description"></dd>
202
<dt><a name="LISTEN_PORT_NO_SSL">LISTEN_PORT_NO_SSL</a></dt>
204
<dd class="description"></dd>
207
<dt><a name="LISTEN_PORT_WITH_SSL">LISTEN_PORT_WITH_SSL</a></dt>
209
<dd class="description"></dd>
212
<dt><a name="DBS_NEEDING_ONE_PBSERVER">DBS_NEEDING_ONE_PBSERVER</a></dt>
214
<dd class="description"></dd>
217
<dt><a name="DBS_WITH_NATIVE_PBSERVER">DBS_WITH_NATIVE_PBSERVER</a></dt>
219
<dd class="description"></dd>
231
<div id="public-class-method-details" class="method-section section">
232
<h3 class="section-header">Public Class Methods</h3>
235
<div id="is_running-method" class="method-detail ">
236
<a name="method-c-is_running"></a>
239
<div class="method-heading">
240
<span class="method-name">is_running</span><span
241
class="method-args">(my_ip)</span>
242
<span class="method-click-advice">click to toggle source</span>
246
<div class="method-description">
252
<div class="method-source-code"
253
id="is_running-source">
255
<span class="ruby-comment"># File lib/pbserver.rb, line 85</span>
256
def self.is_running(my_ip)
257
`curl http://#{my_ip}:#{PROXY_PORT}`
269
<div id="listen_port-method" class="method-detail ">
270
<a name="method-c-listen_port"></a>
273
<div class="method-heading">
274
<span class="method-name">listen_port</span><span
275
class="method-args">()</span>
276
<span class="method-click-advice">click to toggle source</span>
280
<div class="method-description">
286
<div class="method-source-code"
287
id="listen_port-source">
289
<span class="ruby-comment"># File lib/pbserver.rb, line 65</span>
291
<span class="ruby-constant">LISTEN_PORT_NO_SSL</span>
303
<div id="listen_ssl_port-method" class="method-detail ">
304
<a name="method-c-listen_ssl_port"></a>
307
<div class="method-heading">
308
<span class="method-name">listen_ssl_port</span><span
309
class="method-args">()</span>
310
<span class="method-click-advice">click to toggle source</span>
314
<div class="method-description">
320
<div class="method-source-code"
321
id="listen_ssl_port-source">
323
<span class="ruby-comment"># File lib/pbserver.rb, line 69</span>
324
def self.listen_ssl_port
325
<span class="ruby-constant">LISTEN_PORT_WITH_SSL</span>
337
<div id="name-method" class="method-detail ">
338
<a name="method-c-name"></a>
341
<div class="method-heading">
342
<span class="method-name">name</span><span
343
class="method-args">()</span>
344
<span class="method-click-advice">click to toggle source</span>
348
<div class="method-description">
354
<div class="method-source-code"
357
<span class="ruby-comment"># File lib/pbserver.rb, line 57</span>
359
<span class="ruby-string">"as_pbserver"</span>
371
<div id="pb_script-method" class="method-detail ">
372
<a name="method-c-pb_script"></a>
375
<div class="method-heading">
376
<span class="method-name">pb_script</span><span
377
class="method-args">(table)</span>
378
<span class="method-click-advice">click to toggle source</span>
382
<div class="method-description">
388
<div class="method-source-code"
389
id="pb_script-source">
391
<span class="ruby-comment"># File lib/pbserver.rb, line 89</span>
392
def self.pb_script(table)
393
if <span class="ruby-constant">DBS_WITH_NATIVE_PBSERVER</span>.include?(table)
394
return "#{APPSCALE_HOME}/AppDB/appscale_server_#{table}.py"
396
return "#{APPSCALE_HOME}/AppDB/appscale_server.py"
409
<div id="proxy_port-method" class="method-detail ">
410
<a name="method-c-proxy_port"></a>
413
<div class="method-heading">
414
<span class="method-name">proxy_port</span><span
415
class="method-args">()</span>
416
<span class="method-click-advice">click to toggle source</span>
420
<div class="method-description">
426
<div class="method-source-code"
427
id="proxy_port-source">
429
<span class="ruby-comment"># File lib/pbserver.rb, line 81</span>
431
<span class="ruby-constant">PROXY_PORT</span>
443
<div id="public_directory-method" class="method-detail ">
444
<a name="method-c-public_directory"></a>
447
<div class="method-heading">
448
<span class="method-name">public_directory</span><span
449
class="method-args">()</span>
450
<span class="method-click-advice">click to toggle source</span>
454
<div class="method-description">
460
<div class="method-source-code"
461
id="public_directory-source">
463
<span class="ruby-comment"># File lib/pbserver.rb, line 61</span>
464
def self.public_directory
465
<span class="ruby-string">"/root/appscale/AppDB/public"</span>
477
<div id="restart-method" class="method-detail ">
478
<a name="method-c-restart"></a>
481
<div class="method-heading">
482
<span class="method-name">restart</span><span
483
class="method-args">(master_ip, my_ip, table, zklocations)</span>
484
<span class="method-click-advice">click to toggle source</span>
488
<div class="method-description">
494
<div class="method-source-code"
497
<span class="ruby-comment"># File lib/pbserver.rb, line 52</span>
498
def self.restart(master_ip, my_ip, table, zklocations)
500
self.start(master_ip, my_ip, table, zklocations)
512
<div id="server_ports-method" class="method-detail ">
513
<a name="method-c-server_ports"></a>
516
<div class="method-heading">
517
<span class="method-name">server_ports</span><span
518
class="method-args">(table)</span>
519
<span class="method-click-advice">click to toggle source</span>
523
<div class="method-description">
529
<div class="method-source-code"
530
id="server_ports-source">
532
<span class="ruby-comment"># File lib/pbserver.rb, line 73</span>
533
def self.server_ports(table)
534
if <span class="ruby-constant">DBS_NEEDING_ONE_PBSERVER</span>.include?(table)
535
return <span class="ruby-constant">SERVER_PORTS</span>.first(1)
537
return <span class="ruby-constant">SERVER_PORTS</span>
550
<div id="start-method" class="method-detail ">
551
<a name="method-c-start"></a>
554
<div class="method-heading">
555
<span class="method-name">start</span><span
556
class="method-args">(master_ip, db_local_ip, my_ip, table, zklocations)</span>
557
<span class="method-click-advice">click to toggle source</span>
561
<div class="method-description">
567
<div class="method-source-code"
570
<span class="ruby-comment"># File lib/pbserver.rb, line 22</span>
571
def self.start(master_ip, db_local_ip, my_ip, table, zklocations)
572
pbserver = self.pb_script(table)
573
ports = self.server_ports(table)
576
<span class="ruby-string">'APPSCALE_HOME'</span> => <span class="ruby-constant">ENV</span>[<span class="ruby-string">'APPSCALE_HOME'</span>],
577
<span class="ruby-string">"MASTER_IP"</span> => master_ip,
578
<span class="ruby-string">"LOCAL_DB_IP"</span> => db_local_ip
582
start_cmd = ["/usr/bin/python2.6 #{pbserver} -p #{port}",
583
"--no_encryption --type #{table} -z \'#{zklocations}\'",
584
"-s #{HelperFunctions.get_secret} -a #{my_ip} --key"].join(<span class="ruby-string">" "</span>)
586
stop_cmd = <span class="ruby-string">"pkill -9 appscale_server"</span>
588
<span class="ruby-constant">GodInterface</span>.start(:pbserver, start_cmd, stop_cmd, port, env_vars)
601
<div id="stop-method" class="method-detail ">
602
<a name="method-c-stop"></a>
605
<div class="method-heading">
606
<span class="method-name">stop</span><span
607
class="method-args">(table)</span>
608
<span class="method-click-advice">click to toggle source</span>
612
<div class="method-description">
618
<div class="method-source-code"
621
<span class="ruby-comment"># File lib/pbserver.rb, line 43</span>
623
<span class="ruby-constant">GodInterface</span>.stop(:pbserver)
625
<span class="ruby-comment">#ports = self.server_ports(table)</span>
626
<span class="ruby-comment">#ports.each { |pbserver_port|</span>
627
<span class="ruby-comment"># Kernel.system "start-stop-daemon --stop --pidfile /var/appscale/appscale-appscaleserver-#{pbserver_port}.pid"</span>
628
<span class="ruby-comment">#}</span>
645
<div id="validator-badges">
646
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
647
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
648
Rdoc Generator</a> 2</small>.</p>