appswarm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +124 -0
- data/History.txt +7 -0
- data/Manifest.txt +304 -0
- data/README.txt +373 -0
- data/Rakefile +153 -0
- data/TODO +7 -0
- data/apps/README.txt +17 -0
- data/apps/admin/admin.rb +79 -0
- data/apps/admin/controllers/admin.rb +81 -0
- data/apps/admin/controllers/settings.rb +63 -0
- data/apps/admin/controllers/users.rb +3 -0
- data/apps/admin/features/access.feature +21 -0
- data/apps/admin/features/mountLocal.feature +12 -0
- data/apps/admin/features/settings.feature +68 -0
- data/apps/admin/features/startApps.feature +27 -0
- data/apps/admin/layouts/main.rhtml +10 -0
- data/apps/admin/lib/settings.rb +52 -0
- data/apps/admin/static/admin.css +23 -0
- data/apps/admin/views/_log.rhtml +21 -0
- data/apps/admin/views/index.rhtml +43 -0
- data/apps/admin/views/info.rhtml +7 -0
- data/apps/admin/views/settings.rhtml +9 -0
- data/apps/admin/views/settings/_http_app.rhtml +15 -0
- data/apps/admin/views/settings/_web_server.rhtml +32 -0
- data/apps/admin/views/settings/index.rhtml +3 -0
- data/apps/admin/views/users/index.rhtml +6 -0
- data/apps/application_provider/application_provider.rb +11 -0
- data/apps/blog/blog.rb +27 -0
- data/apps/blog/controllers/blog.rb +29 -0
- data/apps/blog/views/index.rhtml +27 -0
- data/apps/browser_starter/browser_starter.rb +32 -0
- data/apps/crypto/crypto.rb +47 -0
- data/apps/crypto/crypto_rsa.rb +102 -0
- data/apps/crypto/spec/crypto_spec.rb +10 -0
- data/apps/directory_service/directory_service.rb +107 -0
- data/apps/directory_service/net_application.rb +92 -0
- data/apps/directory_service/spec/directory_service_spec.rb +36 -0
- data/apps/directory_service/spec/net_application_spec.rb +3 -0
- data/apps/global_application_interface/global_application.rb +52 -0
- data/apps/global_application_interface/global_application_interface.rb +84 -0
- data/apps/global_application_interface/spec/app_api_spec.rb +5 -0
- data/apps/global_tuple_space/global_tuple_space.rb +27 -0
- data/apps/global_web_proxy/features/session_handling.feature +7 -0
- data/apps/global_web_proxy/global_web_proxy.rb +221 -0
- data/apps/global_web_proxy/proxy/HTTPProxyServer-Dateien/rdoc-style.css +208 -0
- data/apps/global_web_proxy/proxy/HTTPProxyServer.html +566 -0
- data/apps/global_web_proxy/proxy/dnstest.rb +30 -0
- data/apps/global_web_proxy/proxy/proxy.rb +86 -0
- data/apps/global_web_proxy/proxy/wiki.html +267 -0
- data/apps/global_web_proxy/proxy/wiki.rb +115 -0
- data/apps/global_web_proxy/spec/res1 +112 -0
- data/apps/global_web_proxy/spec/res2 +125 -0
- data/apps/global_web_proxy/spec/web_proxy_spec.rb +88 -0
- data/apps/global_web_server/global_web_server.rb +120 -0
- data/apps/global_web_server/global_web_servlet.rb +6 -0
- data/apps/hello_world/controllers/hello_world.rb +11 -0
- data/apps/hello_world/features/show_on_local_web_server.feature +44 -0
- data/apps/hello_world/features/starting_apps.feature +6 -0
- data/apps/hello_world/features/through_global.feature +12 -0
- data/apps/hello_world/hello_world.rb +3 -0
- data/apps/hello_world/views/get.rhtml +10 -0
- data/apps/hello_world/views/index.rhtml +9 -0
- data/apps/hello_world/views/post.rhtml +10 -0
- data/apps/home/controllers/home.rb +11 -0
- data/apps/home/home.rb +12 -0
- data/apps/home/layouts/main.rhtml +16 -0
- data/apps/home/static/Zeichnung.svg +240 -0
- data/apps/home/static/home.css +134 -0
- data/apps/home/static/menu.css +99 -0
- data/apps/home/views/_appInfo.rhtml +22 -0
- data/apps/home/views/_dummy_fill.rhtml +3 -0
- data/apps/home/views/_info.rhtml +6 -0
- data/apps/home/views/_menu.rhtml +17 -0
- data/apps/home/views/index.rhtml +4 -0
- data/apps/home/views/overview.rhtml +2 -0
- data/apps/local_chunk_store/chunk_store.rb +15 -0
- data/apps/local_chunk_store/local_chunk_store.rb +123 -0
- data/apps/local_chunk_store/spec/local_chunk_store_spec.rb +30 -0
- data/apps/local_file_store/app_configuration.rb +78 -0
- data/apps/local_file_store/app_file_store.rb +32 -0
- data/apps/local_file_store/cached_file_store.rb +94 -0
- data/apps/local_file_store/features/testbed_handling_of_directories.feature +20 -0
- data/apps/local_file_store/local_file_store.rb +47 -0
- data/apps/local_file_store/spec/app_configuration_spec.rb +30 -0
- data/apps/local_file_store/spec/local_file_store_spec.rb +54 -0
- data/apps/local_object_storage/lib/cell.rb +29 -0
- data/apps/local_object_storage/lib/cellmgr.rb +57 -0
- data/apps/local_object_storage/lib/index.rb +43 -0
- data/apps/local_object_storage/lib/marshal.rb +96 -0
- data/apps/local_object_storage/lib/pagefile.rb +6 -0
- data/apps/local_object_storage/lib/persistent_object.rb +126 -0
- data/apps/local_object_storage/local_object_storage.rb +148 -0
- data/apps/local_object_storage/spec/local_object_storage_spec.rb +123 -0
- data/apps/local_secure_file_store/local_secure_file_store.rb +64 -0
- data/apps/local_secure_file_store/spec/local_secure_file_store_spec.rb +23 -0
- data/apps/local_tuple_space/local_tuple_space.rb +92 -0
- data/apps/local_tuple_space/spec/tuple_space_spec.rb +25 -0
- data/apps/local_web_server/features/parsing_args.feature +18 -0
- data/apps/local_web_server/local_web_server.rb +166 -0
- data/apps/logger/logger.rb +27 -0
- data/apps/master/master.rb +46 -0
- data/apps/master/spec/master_spec.rb +31 -0
- data/apps/my_spec_spec.rb +15 -0
- data/apps/name_service/name_service.rb +75 -0
- data/apps/name_service/spec/name_service_spec.rb +51 -0
- data/apps/network_discovery/network_discovery.rb +45 -0
- data/apps/network_discovery_localstore/network_discovery_localstore.rb +20 -0
- data/apps/network_discovery_udp/network_discovery_udp.rb +51 -0
- data/apps/network_lookup/network_lookup.rb +61 -0
- data/apps/network_node/abstract_node.rb +104 -0
- data/apps/network_node/drb_node.rb +90 -0
- data/apps/network_node/network_app.rb +9 -0
- data/apps/network_node/network_node.rb +471 -0
- data/apps/network_node/remote_service.rb +45 -0
- data/apps/network_node/secure_node.rb +125 -0
- data/apps/network_node/spec/drb_spec.rb +41 -0
- data/apps/network_node/spec/network_node_spec_not.rb +264 -0
- data/apps/new_network_node/new_network_node.rb +427 -0
- data/apps/new_network_node/spec/new_network_node_spec.rb +186 -0
- data/apps/node_broadcast/node_broadcast.rb +167 -0
- data/apps/node_broadcast/spec/node_broadcast_spec.rb +59 -0
- data/apps/permaspace/permaspace.rb +47 -0
- data/apps/plaindb/lib/btree.rb +38 -0
- data/apps/plaindb/plaindb.rb +199 -0
- data/apps/plaindb/spec/table_write_spec.rb +36 -0
- data/apps/routed_network/routed_network.rb +23 -0
- data/apps/routed_network/spec/routed_network_spec.rb +17 -0
- data/apps/session_manager/session_manager.rb +18 -0
- data/apps/spec_output.html +222 -0
- data/apps/todo/controllers/todo.rb +87 -0
- data/apps/todo/model/comment.rb +10 -0
- data/apps/todo/model/project.rb +20 -0
- data/apps/todo/model/todo.rb +16 -0
- data/apps/todo/model/user.rb +5 -0
- data/apps/todo/todo.rb +21 -0
- data/apps/todo/views/_commentList.rhtml +7 -0
- data/apps/todo/views/_createProject.rhtml +5 -0
- data/apps/todo/views/_partList.rhtml +12 -0
- data/apps/todo/views/_projectList.rhtml +16 -0
- data/apps/todo/views/edit.rhtml +11 -0
- data/apps/todo/views/editPart.rhtml +10 -0
- data/apps/todo/views/index.rhtml +2 -0
- data/apps/todo/views/question.rhtml +4 -0
- data/apps/transparent_network/transparent_network.rb +7 -0
- data/apps/udp_network/big_transfer.rb +97 -0
- data/apps/udp_network/features/information.feature +7 -0
- data/apps/udp_network/message_queue.rb +84 -0
- data/apps/udp_network/network_interface_api.rb +39 -0
- data/apps/udp_network/qos_queue.rb +186 -0
- data/apps/udp_network/simple_api.rb +180 -0
- data/apps/udp_network/spec/big_transfer_spec.rb +0 -0
- data/apps/udp_network/spec/qos_queue_spec.rb +99 -0
- data/apps/udp_network/spec/simple_api_spec.rb +35 -0
- data/apps/udp_network/spec/udp_network_spec.rb +115 -0
- data/apps/udp_network/spec/udp_transceiver_spec.rb +90 -0
- data/apps/udp_network/udp_network.rb +196 -0
- data/apps/udp_network/udp_transceiver.rb +329 -0
- data/apps/wiki/controllers/wiki.rb +56 -0
- data/apps/wiki/features/editing.feature +21 -0
- data/apps/wiki/layouts/main.rhtml +18 -0
- data/apps/wiki/lib/media_wiki_html.rb +35 -0
- data/apps/wiki/lib/wikicreole.rb +2147 -0
- data/apps/wiki/lib/wikicreole.tt +135 -0
- data/apps/wiki/lib/wikitest.rb +158 -0
- data/apps/wiki/lib/wikitest.tt +17 -0
- data/apps/wiki/model/menu.rb +15 -0
- data/apps/wiki/model/page.rb +31 -0
- data/apps/wiki/spec/wiki_creole_spec.rb +20 -0
- data/apps/wiki/spec/wiki_spec.rb +19 -0
- data/apps/wiki/static/Zeichnung.svg +240 -0
- data/apps/wiki/static/home.css +134 -0
- data/apps/wiki/static/mainMenu.css +32 -0
- data/apps/wiki/static/menu.css +99 -0
- data/apps/wiki/views/_mainMenu.rhtml +3 -0
- data/apps/wiki/views/_menu.rhtml +13 -0
- data/apps/wiki/views/edit.rhtml +13 -0
- data/apps/wiki/views/index.rhtml +2 -0
- data/apps/wiki/views/save.rhtml +1 -0
- data/apps/wiki/wiki.rb +17 -0
- data/bin/appswarm +47 -0
- data/cucumber.yml +2 -0
- data/data/PermaspaceApp/AFS_WikiApp_wiki_config +6 -0
- data/data/draft.txt +63 -0
- data/docs/appswarm_motivation.graffle +0 -0
- data/docs/appswarm_pics.graffle/QuickLook/Preview.pdf +0 -0
- data/docs/appswarm_pics.graffle/QuickLook/Thumbnail.tiff +0 -0
- data/docs/appswarm_pics.graffle/data.plist +63494 -0
- data/docs/appswarm_pics.graffle/image1.tiff +0 -0
- data/docs/appswarm_pics.graffle/image2.tif +0 -0
- data/docs/appswarm_pics.graffle/image3.tif +0 -0
- data/docs/appswarm_pics.graffle/image4.tif +0 -0
- data/docs/appswarm_pics.graffle/image5.tiff +0 -0
- data/docs/routing.graffle +0 -0
- data/features/step_definitions/appstart_steps.rb +28 -0
- data/features/step_definitions/cluster_steps.rb +18 -0
- data/features/step_definitions/testbed_steps.rb +64 -0
- data/features/step_definitions/webapp_steps.rb +257 -0
- data/features/support/env.rb +7 -0
- data/lib/appswarm.rb +127 -0
- data/lib/appswarm/README.txt +67 -0
- data/lib/appswarm/app_config.rb +19 -0
- data/lib/appswarm/application.rb +267 -0
- data/lib/appswarm/breaking_mutex.rb +41 -0
- data/lib/appswarm/cluster_funcs.rb +157 -0
- data/lib/appswarm/cross_spectool.rb +153 -0
- data/lib/appswarm/crypt.rb +10 -0
- data/lib/appswarm/crypt/crypto.rb +90 -0
- data/lib/appswarm/crypt/rsa_key +15 -0
- data/lib/appswarm/crypt/rsa_key.pub +5 -0
- data/lib/appswarm/crypt/test.rb +27 -0
- data/lib/appswarm/dir_tool.rb +41 -0
- data/lib/appswarm/event_api.rb +7 -0
- data/lib/appswarm/features_helper.rb +44 -0
- data/lib/appswarm/global_service.rb +38 -0
- data/lib/appswarm/http.rb +1 -0
- data/lib/appswarm/http/http_app.rb +257 -0
- data/lib/appswarm/http/http_controller.rb +267 -0
- data/lib/appswarm/http/http_provider.rb +80 -0
- data/lib/appswarm/http/static/favicon.ico +0 -0
- data/lib/appswarm/http/static/javascript/._prototype.js +0 -0
- data/lib/appswarm/http/static/javascript/prototype.js +2515 -0
- data/lib/appswarm/http/webrick_logger.rb +12 -0
- data/lib/appswarm/net_service.rb +69 -0
- data/lib/appswarm/package.rb +88 -0
- data/lib/appswarm/parallel_each.rb +46 -0
- data/lib/appswarm/protocols/protocol_dice.rb +25 -0
- data/lib/appswarm/proxy_testing.rb +48 -0
- data/lib/appswarm/public_api.rb +35 -0
- data/lib/appswarm/routing/matrix_math.rb +57 -0
- data/lib/appswarm/routing/pca.rb +211 -0
- data/lib/appswarm/routing/routetest.rb +85 -0
- data/lib/appswarm/routing/routing.rb +326 -0
- data/lib/appswarm/routing/spec/nods_spec.rb +23 -0
- data/lib/appswarm/routing/spec/pca_spec.rb +27 -0
- data/lib/appswarm/routing/spec/routing_spec.rb +91 -0
- data/lib/appswarm/secure_con.rb +437 -0
- data/lib/appswarm/secure_connection.rb +79 -0
- data/lib/appswarm/secure_marshal.rb +137 -0
- data/lib/appswarm/service.rb +76 -0
- data/lib/appswarm/simple_marshal.rb +96 -0
- data/lib/appswarm/simple_marshal_parser.rb +1243 -0
- data/lib/appswarm/simple_marshal_parser.tt +158 -0
- data/lib/appswarm/spec/application_spec.rb +50 -0
- data/lib/appswarm/spec/cluster_spec.rb +2 -0
- data/lib/appswarm/spec/hexdist_spec.rb +13 -0
- data/lib/appswarm/spec/http_controller_spec.rb +18 -0
- data/lib/appswarm/spec/main_spec.rb +6 -0
- data/lib/appswarm/spec/parallel_each_spec.rb +30 -0
- data/lib/appswarm/spec/secure_connection_spec.rb +108 -0
- data/lib/appswarm/spec/secure_marshal_spec.rb +93 -0
- data/lib/appswarm/spec/simple_marshal_spec.rb +87 -0
- data/lib/appswarm/spec/tools_spec.rb +13 -0
- data/lib/appswarm/spec/whiteboard_spec.rb +20 -0
- data/lib/appswarm/spec_helper.rb +18 -0
- data/lib/appswarm/test_bed.rb +207 -0
- data/lib/appswarm/tools.rb +284 -0
- data/lib/appswarm/tools/http_tunnel_client.rb +139 -0
- data/lib/appswarm/tools/http_tunnel_common.rb +8 -0
- data/lib/appswarm/tools/http_tunnel_server.rb +78 -0
- data/lib/appswarm/tools/parser/example_data.simple +102 -0
- data/lib/appswarm/tools/parser/match_test.rb +14 -0
- data/lib/appswarm/tools/parser/parser_lib.rb +165 -0
- data/lib/appswarm/tools/parser/parser_test.rb +104 -0
- data/lib/appswarm/tools/parser/spec/parser_spec.rb +44 -0
- data/lib/appswarm/tools/pipes.rb +95 -0
- data/lib/appswarm/tools/spec/tracing_spec.rb +16 -0
- data/lib/appswarm/tools/spec/waiting_queue_spec.rb +15 -0
- data/lib/appswarm/tools/thread_tool.rb +61 -0
- data/lib/appswarm/tools/tracing.rb +84 -0
- data/lib/appswarm/tools/treetop_test.rb +20 -0
- data/lib/appswarm/tools/treetop_test_grammar.rb +114 -0
- data/lib/appswarm/tools/treetop_test_grammar.tt +7 -0
- data/lib/appswarm/tools/waiting_prio_queue.rb +47 -0
- data/lib/appswarm/tools/waiting_queue.rb +34 -0
- data/lib/appswarm/whiteboard.rb +73 -0
- data/nettest.rb +50 -0
- data/packages/README.txt +1 -0
- data/packages/msandbox/data/packages/store/my.txt +1 -0
- data/packages/msandbox/interfaces.rb +172 -0
- data/packages/msandbox/old/defa.rb +3 -0
- data/packages/msandbox/old/test.rb +14 -0
- data/packages/msandbox/old/test2.rb +56 -0
- data/packages/msandbox/package.rb +67 -0
- data/packages/msandbox/packages/store/config.yml +1 -0
- data/packages/msandbox/packages/store/main.rb +27 -0
- data/packages/msandbox/packages/store/myinclude.rb +7 -0
- data/packages/msandbox/packages/store_test/config.yml +1 -0
- data/packages/msandbox/packages/store_test/main.rb +9 -0
- data/packages/msandbox/server.rb +146 -0
- data/packages/msandbox/test.rb +13 -0
- data/packages/msandbox/test2.rb +29 -0
- data/templates/web/appswarm/controllers/appswarm.rb +41 -0
- data/templates/web/appswarm/layouts/main.rhtml +20 -0
- data/templates/web/appswarm/models/asmenu.rb +14 -0
- data/templates/web/appswarm/models/asuser.rb +30 -0
- data/templates/web/appswarm/static/custom.css +15 -0
- data/templates/web/appswarm/static/home.css +134 -0
- data/templates/web/appswarm/static/mainMenu.css +32 -0
- data/templates/web/appswarm/static/menu.css +99 -0
- data/templates/web/appswarm/views/_mainMenu.rhtml +5 -0
- data/templates/web/appswarm/views/_menu.rhtml +13 -0
- data/templates/web/appswarm/views/_userInfo.rhtml +7 -0
- data/templates/web/appswarm/views/login.rhtml +9 -0
- data/tools/checkPort.rb +11 -0
- metadata +379 -0
@@ -0,0 +1,84 @@
|
|
1
|
+
class GlobalApplicationInterfaceApp<Service
|
2
|
+
provides :globalApp
|
3
|
+
|
4
|
+
class ApplicationNotFoundException<Exception
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
class Application
|
9
|
+
attr_reader :name, :instance
|
10
|
+
def initialize(name,instance,interface)
|
11
|
+
@interface=interface
|
12
|
+
@name=name
|
13
|
+
@instance=instance
|
14
|
+
|
15
|
+
@mutex=Mutex.new
|
16
|
+
|
17
|
+
getApi
|
18
|
+
end
|
19
|
+
|
20
|
+
def info
|
21
|
+
[name,instance]
|
22
|
+
end
|
23
|
+
|
24
|
+
def method_missing(name,*args)
|
25
|
+
@interface.callRemote(self,name,args)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def getApi
|
30
|
+
# FIXME: get api from somewhere
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def initialize(cluster,options)
|
36
|
+
super(cluster,options,:globalApp)
|
37
|
+
|
38
|
+
@appNodes={}
|
39
|
+
@mutex=Mutex.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def get(name,instance=nil)
|
43
|
+
Application.new(name,instance,self)
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def callRemote(app,funcName,args)
|
48
|
+
serviceName=[app.name,app.instance]
|
49
|
+
nodes=getNodes(serviceName)
|
50
|
+
#pp "SERVICE ",serviceName
|
51
|
+
#pp nodes
|
52
|
+
raise ApplicationNotFoundException.new(app) if nodes.nil? or nodes.length==0
|
53
|
+
# take one node
|
54
|
+
nodes.shuffle!
|
55
|
+
loop do
|
56
|
+
node=nodes.shift
|
57
|
+
|
58
|
+
begin
|
59
|
+
result=getApp(:fullNetworkNode).api.send(node,:globalApp,app.info,funcName,args)
|
60
|
+
result=result.wait
|
61
|
+
return result
|
62
|
+
#rescue RemoteException=>e
|
63
|
+
# simply take next node
|
64
|
+
end
|
65
|
+
end
|
66
|
+
# FIXME - raise Exception
|
67
|
+
end
|
68
|
+
|
69
|
+
def getNodes(appName)
|
70
|
+
@mutex.synchronize {
|
71
|
+
return @appNodes[appName].dup if @appNodes[appName]
|
72
|
+
}
|
73
|
+
|
74
|
+
key=[:appNodes,appName]
|
75
|
+
result=getApp(:directoryService).lookup(key)
|
76
|
+
|
77
|
+
#result=getApp(:directoryService).get(k)
|
78
|
+
|
79
|
+
#result=@appNodes[appName].dup
|
80
|
+
|
81
|
+
result
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'service.rb'
|
2
|
+
|
3
|
+
class GlobalTupleSpaceApp<Service
|
4
|
+
def initialize(cluster,options)
|
5
|
+
super(cluster,options,:globalTupleSpace)
|
6
|
+
end
|
7
|
+
|
8
|
+
def put(name,value)
|
9
|
+
|
10
|
+
end
|
11
|
+
def get(name)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
def allSpaces
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
def getAllServers
|
21
|
+
master.getAllServers
|
22
|
+
end
|
23
|
+
|
24
|
+
def master
|
25
|
+
cluster.getApp(:networkLookup).getMaster
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
require 'webrick/httpproxy'
|
2
|
+
require 'application.rb'
|
3
|
+
|
4
|
+
# FIXME: compress this
|
5
|
+
|
6
|
+
RequestArgs=Struct.new(:args,:getArgs,:postArgs)
|
7
|
+
class RequestArgs
|
8
|
+
alias :orig_init :initialize
|
9
|
+
def initialize(*args)
|
10
|
+
if args.length==0
|
11
|
+
self.args={}
|
12
|
+
self.getArgs=[]
|
13
|
+
self.postArgs=[]
|
14
|
+
else
|
15
|
+
orig_init(*args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def addGet(name,value)
|
20
|
+
self.args[name]=value
|
21
|
+
self.getArgs<<[name,value]
|
22
|
+
end
|
23
|
+
def addPost(name,value)
|
24
|
+
self.args[name]=value
|
25
|
+
self.postArgs<<[name,value]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
GlobalWebRequest=Struct.new(:instance,:host,:path,:query_string,:path_info,:query,:args,:sessionId)
|
30
|
+
class GlobalWebRequest
|
31
|
+
def initialize(*args)
|
32
|
+
|
33
|
+
if args.length==2 and args[1].is_a?(WEBrick::HTTPRequest)
|
34
|
+
instance=args[0]
|
35
|
+
req=args[1]
|
36
|
+
|
37
|
+
|
38
|
+
#if path
|
39
|
+
# if path.length>0 and path[-1..-1]!='/' and req.path_info[0..0]!='/'
|
40
|
+
# path+='/'
|
41
|
+
# end
|
42
|
+
#else
|
43
|
+
# path=''
|
44
|
+
#end
|
45
|
+
args=RequestArgs.new
|
46
|
+
if req.query
|
47
|
+
|
48
|
+
req.query.each{|k,v|
|
49
|
+
if req.request_method=="POST"
|
50
|
+
args.addPost(k,v)
|
51
|
+
else
|
52
|
+
args.addGet(k,v)
|
53
|
+
end
|
54
|
+
}
|
55
|
+
end
|
56
|
+
if req.query_string and req.request_method=="POST"
|
57
|
+
req.query_string.split("&").each{|p|
|
58
|
+
n,v=p.split("=")
|
59
|
+
args.addGet(n,v)
|
60
|
+
}
|
61
|
+
end
|
62
|
+
super(instance,req.host,req.path,req.query_string,req.path_info,req.query,args)
|
63
|
+
|
64
|
+
|
65
|
+
#self.path.gsub!(/\/*$/,"")
|
66
|
+
else
|
67
|
+
super
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
class GlobalWebProxyApp<Application
|
75
|
+
requires :nameService
|
76
|
+
requires :globalApp
|
77
|
+
|
78
|
+
class MProxy< WEBrick::HTTPProxyServer
|
79
|
+
def initialize(port,web,app)
|
80
|
+
@web=web
|
81
|
+
@app=app
|
82
|
+
mbind= "127.0.0.1"
|
83
|
+
mport=port
|
84
|
+
super(:BindAddress => mbind,
|
85
|
+
:Port => mport,
|
86
|
+
:AccessLog=>[],
|
87
|
+
:Logger=>WebrickLogger.new(app)
|
88
|
+
)
|
89
|
+
trap("INT"){ shutdown }
|
90
|
+
|
91
|
+
end
|
92
|
+
def proxy_service(req, res)
|
93
|
+
begin
|
94
|
+
host,path=@web[req.request_uri]
|
95
|
+
|
96
|
+
|
97
|
+
# FIXME !!!!!
|
98
|
+
sessionId=43
|
99
|
+
|
100
|
+
if host
|
101
|
+
result=host.get(req,sessionId)
|
102
|
+
#pp "CRESULT:",result
|
103
|
+
if result
|
104
|
+
ctype=result.content_type
|
105
|
+
text=result.body
|
106
|
+
res.body=text
|
107
|
+
|
108
|
+
#FIXME header,etc
|
109
|
+
|
110
|
+
if text
|
111
|
+
res.content_length=res.body.length # somehow content-length is set to zero ???
|
112
|
+
end
|
113
|
+
end
|
114
|
+
#pp "RES:",res
|
115
|
+
res["content-type"]=ctype
|
116
|
+
return
|
117
|
+
end
|
118
|
+
begin
|
119
|
+
super
|
120
|
+
rescue Object=>e
|
121
|
+
@app.log e,e.backtrace
|
122
|
+
end
|
123
|
+
rescue Object=>e
|
124
|
+
@app.log e,e.backtrace
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
def marshalRequest(req,path)
|
130
|
+
mr=GlobalWebRequest.new(req,path)
|
131
|
+
@app.log "MARSHAL:",mr
|
132
|
+
mr
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
GlobalWebHost=Struct.new(:app,:path,:instance)
|
139
|
+
class GlobalWebHost
|
140
|
+
def method_missing(name,req,sessionId)
|
141
|
+
begin
|
142
|
+
gr=GlobalWebRequest.new(instance,req)
|
143
|
+
gr.sessionId=sessionId
|
144
|
+
|
145
|
+
gr.path=gr.path.gsub(/^#{path}/,'')
|
146
|
+
gr.path_info=gr.path_info.gsub(/^#{path}/,'')
|
147
|
+
gr.instance=instance
|
148
|
+
self.app.send(name,gr)
|
149
|
+
rescue Object=>e
|
150
|
+
pp e
|
151
|
+
pp e.backtrace
|
152
|
+
raise
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
attr_reader :port
|
158
|
+
|
159
|
+
def initialize(cluster,ops)
|
160
|
+
super
|
161
|
+
@port=7890
|
162
|
+
end
|
163
|
+
|
164
|
+
def run
|
165
|
+
web=self
|
166
|
+
@proxy=MProxy.new(@port,web,self)
|
167
|
+
Thread.new {@proxy.start }
|
168
|
+
super
|
169
|
+
end
|
170
|
+
|
171
|
+
def stop
|
172
|
+
@proxy.shutdown
|
173
|
+
super
|
174
|
+
end
|
175
|
+
|
176
|
+
def get(req,res)
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
def [](uri)
|
181
|
+
|
182
|
+
|
183
|
+
if uri.host=~/\.appswarm/
|
184
|
+
|
185
|
+
cur=""
|
186
|
+
all=[]
|
187
|
+
uri.path.split("/").each{|p|
|
188
|
+
a=(cur+"/"+p).gsub(/^\/\//,'/')
|
189
|
+
cur=cur+"/"+p
|
190
|
+
all<<a
|
191
|
+
}
|
192
|
+
all.reverse!
|
193
|
+
host=uri.host
|
194
|
+
all.each{|path|
|
195
|
+
url=host+path
|
196
|
+
|
197
|
+
ns=getApp(:nameService)
|
198
|
+
serviceAddress=ns.get(url)
|
199
|
+
if serviceAddress
|
200
|
+
|
201
|
+
instance,*xy=serviceAddress
|
202
|
+
|
203
|
+
globalApps=getApp(:globalApp)
|
204
|
+
found=globalApps.get(:global_web,[instance])
|
205
|
+
unless found
|
206
|
+
pp "NOT FOUND:",[:global_web,[instance]]
|
207
|
+
end
|
208
|
+
return nil unless found
|
209
|
+
pa=uri.path.gsub(/^#{path}/,'')
|
210
|
+
ho=GlobalWebHost.new(found,path,instance)
|
211
|
+
|
212
|
+
return [ho,pa]
|
213
|
+
end
|
214
|
+
}
|
215
|
+
nil
|
216
|
+
else
|
217
|
+
nil
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
|
2
|
+
body {
|
3
|
+
font-family: Verdana,Arial,Helvetica,sans-serif;
|
4
|
+
font-size: 90%;
|
5
|
+
margin: 0;
|
6
|
+
margin-left: 40px;
|
7
|
+
padding: 0;
|
8
|
+
background: white;
|
9
|
+
}
|
10
|
+
|
11
|
+
h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
|
12
|
+
h1 { font-size: 150%; }
|
13
|
+
h2,h3,h4 { margin-top: 1em; }
|
14
|
+
|
15
|
+
a { background: #eef; color: #039; text-decoration: none; }
|
16
|
+
a:hover { background: #039; color: #eef; }
|
17
|
+
|
18
|
+
/* Override the base stylesheet's Anchor inside a table cell */
|
19
|
+
td > a {
|
20
|
+
background: transparent;
|
21
|
+
color: #039;
|
22
|
+
text-decoration: none;
|
23
|
+
}
|
24
|
+
|
25
|
+
/* and inside a section title */
|
26
|
+
.section-title > a {
|
27
|
+
background: transparent;
|
28
|
+
color: #eee;
|
29
|
+
text-decoration: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
/* === Structural elements =================================== */
|
33
|
+
|
34
|
+
div#index {
|
35
|
+
margin: 0;
|
36
|
+
margin-left: -40px;
|
37
|
+
padding: 0;
|
38
|
+
font-size: 90%;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
div#index a {
|
43
|
+
margin-left: 0.7em;
|
44
|
+
}
|
45
|
+
|
46
|
+
div#index .section-bar {
|
47
|
+
margin-left: 0px;
|
48
|
+
padding-left: 0.7em;
|
49
|
+
background: #ccc;
|
50
|
+
font-size: small;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
div#classHeader, div#fileHeader {
|
55
|
+
width: auto;
|
56
|
+
color: white;
|
57
|
+
padding: 0.5em 1.5em 0.5em 1.5em;
|
58
|
+
margin: 0;
|
59
|
+
margin-left: -40px;
|
60
|
+
border-bottom: 3px solid #006;
|
61
|
+
}
|
62
|
+
|
63
|
+
div#classHeader a, div#fileHeader a {
|
64
|
+
background: inherit;
|
65
|
+
color: white;
|
66
|
+
}
|
67
|
+
|
68
|
+
div#classHeader td, div#fileHeader td {
|
69
|
+
background: inherit;
|
70
|
+
color: white;
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
div#fileHeader {
|
75
|
+
background: #057;
|
76
|
+
}
|
77
|
+
|
78
|
+
div#classHeader {
|
79
|
+
background: #048;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
.class-name-in-header {
|
84
|
+
font-size: 180%;
|
85
|
+
font-weight: bold;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
div#bodyContent {
|
90
|
+
padding: 0 1.5em 0 1.5em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#description {
|
94
|
+
padding: 0.5em 1.5em;
|
95
|
+
background: #efefef;
|
96
|
+
border: 1px dotted #999;
|
97
|
+
}
|
98
|
+
|
99
|
+
div#description h1,h2,h3,h4,h5,h6 {
|
100
|
+
color: #125;;
|
101
|
+
background: transparent;
|
102
|
+
}
|
103
|
+
|
104
|
+
div#validator-badges {
|
105
|
+
text-align: center;
|
106
|
+
}
|
107
|
+
div#validator-badges img { border: 0; }
|
108
|
+
|
109
|
+
div#copyright {
|
110
|
+
color: #333;
|
111
|
+
background: #efefef;
|
112
|
+
font: 0.75em sans-serif;
|
113
|
+
margin-top: 5em;
|
114
|
+
margin-bottom: 0;
|
115
|
+
padding: 0.5em 2em;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
/* === Classes =================================== */
|
120
|
+
|
121
|
+
table.header-table {
|
122
|
+
color: white;
|
123
|
+
font-size: small;
|
124
|
+
}
|
125
|
+
|
126
|
+
.type-note {
|
127
|
+
font-size: small;
|
128
|
+
color: #DEDEDE;
|
129
|
+
}
|
130
|
+
|
131
|
+
.xxsection-bar {
|
132
|
+
background: #eee;
|
133
|
+
color: #333;
|
134
|
+
padding: 3px;
|
135
|
+
}
|
136
|
+
|
137
|
+
.section-bar {
|
138
|
+
color: #333;
|
139
|
+
border-bottom: 1px solid #999;
|
140
|
+
margin-left: -20px;
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
.section-title {
|
145
|
+
background: #79a;
|
146
|
+
color: #eee;
|
147
|
+
padding: 3px;
|
148
|
+
margin-top: 2em;
|
149
|
+
margin-left: -30px;
|
150
|
+
border: 1px solid #999;
|
151
|
+
}
|
152
|
+
|
153
|
+
.top-aligned-row { vertical-align: top }
|
154
|
+
.bottom-aligned-row { vertical-align: bottom }
|
155
|
+
|
156
|
+
/* --- Context section classes ----------------------- */
|
157
|
+
|
158
|
+
.context-row { }
|
159
|
+
.context-item-name { font-family: monospace; font-weight: bold; color: black; }
|
160
|
+
.context-item-value { font-size: small; color: #448; }
|
161
|
+
.context-item-desc { color: #333; padding-left: 2em; }
|
162
|
+
|
163
|
+
/* --- Method classes -------------------------- */
|
164
|
+
.method-detail {
|
165
|
+
background: #efefef;
|
166
|
+
padding: 0;
|
167
|
+
margin-top: 0.5em;
|
168
|
+
margin-bottom: 1em;
|
169
|
+
border: 1px dotted #ccc;
|
170
|
+
}
|
171
|
+
.method-heading {
|
172
|
+
color: black;
|
173
|
+
background: #ccc;
|
174
|
+
border-bottom: 1px solid #666;
|
175
|
+
padding: 0.2em 0.5em 0 0.5em;
|
176
|
+
}
|
177
|
+
.method-signature { color: black; background: inherit; }
|
178
|
+
.method-name { font-weight: bold; }
|
179
|
+
.method-args { font-style: italic; }
|
180
|
+
.method-description { padding: 0 0.5em 0 0.5em; }
|
181
|
+
|
182
|
+
/* --- Source code sections -------------------- */
|
183
|
+
|
184
|
+
a.source-toggle { font-size: 90%; }
|
185
|
+
div.method-source-code {
|
186
|
+
background: #262626;
|
187
|
+
color: #ffdead;
|
188
|
+
margin: 1em;
|
189
|
+
padding: 0.5em;
|
190
|
+
border: 1px dashed #999;
|
191
|
+
overflow: hidden;
|
192
|
+
}
|
193
|
+
|
194
|
+
div.method-source-code pre { color: #ffdead; overflow: hidden; }
|
195
|
+
|
196
|
+
/* --- Ruby keyword styles --------------------- */
|
197
|
+
|
198
|
+
.standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
|
199
|
+
|
200
|
+
.ruby-constant { color: #7fffd4; background: transparent; }
|
201
|
+
.ruby-keyword { color: #00ffff; background: transparent; }
|
202
|
+
.ruby-ivar { color: #eedd82; background: transparent; }
|
203
|
+
.ruby-operator { color: #00ffee; background: transparent; }
|
204
|
+
.ruby-identifier { color: #ffdead; background: transparent; }
|
205
|
+
.ruby-node { color: #ffa07a; background: transparent; }
|
206
|
+
.ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
|
207
|
+
.ruby-regexp { color: #ffa07a; background: transparent; }
|
208
|
+
.ruby-value { color: #7fffd4; background: transparent; }
|