1 | /******************************************************************************
|
---|
2 | * SAGE - Scalable Adaptive Graphics Environment
|
---|
3 | *
|
---|
4 | * Module: sageBridge.h
|
---|
5 | * Author : Byungil Jeong
|
---|
6 | *
|
---|
7 | * Copyright (C) 2004 Electronic Visualization Laboratory,
|
---|
8 | * University of Illinois at Chicago
|
---|
9 | *
|
---|
10 | * All rights reserved.
|
---|
11 | *
|
---|
12 | * Redistribution and use in source and binary forms, with or without
|
---|
13 | * modification, are permitted provided that the following conditions are met:
|
---|
14 | *
|
---|
15 | * * Redistributions of source code must retain the above copyright
|
---|
16 | * notice, this list of conditions and the following disclaimer.
|
---|
17 | * * Redistributions in binary form must reproduce the above
|
---|
18 | * copyright notice, this list of conditions and the following disclaimer
|
---|
19 | * in the documentation and/or other materials provided with the distribution.
|
---|
20 | * * Neither the name of the University of Illinois at Chicago nor
|
---|
21 | * the names of its contributors may be used to endorse or promote
|
---|
22 | * products derived from this software without specific prior written permission.
|
---|
23 | *
|
---|
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
25 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
26 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
27 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
---|
28 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
29 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
30 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
31 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
---|
32 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
---|
33 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
34 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
35 | *
|
---|
36 | * Direct questions, comments etc about SAGE to sage_users@listserv.uic.edu or
|
---|
37 | * http://www.evl.uic.edu/cavern/forum/
|
---|
38 | *
|
---|
39 | *****************************************************************************/
|
---|
40 |
|
---|
41 | #ifndef SAGEBRIDGE_H_
|
---|
42 | #define SAGEBRIDGE_H_
|
---|
43 |
|
---|
44 | #include "sage.h"
|
---|
45 |
|
---|
46 | #define MAX_BRIDGE_NODE 100
|
---|
47 |
|
---|
48 | class messageInterface;
|
---|
49 | class sageBridge;
|
---|
50 | class streamProtocol;
|
---|
51 | class bridgeSharedData;
|
---|
52 | class sageTcpModule;
|
---|
53 | class sageUdpModule;
|
---|
54 | class sageNwConfig;
|
---|
55 | class appInstance;
|
---|
56 | class sageSyncServer;
|
---|
57 | class syncGroup;
|
---|
58 | class sageEvent;
|
---|
59 | class sageAudioBridge;
|
---|
60 |
|
---|
61 |
|
---|
62 | typedef struct {
|
---|
63 | sageBridge *This;
|
---|
64 | streamProtocol *nwObj;
|
---|
65 | } nwCheckThreadParam;
|
---|
66 |
|
---|
67 | class sageBridge {
|
---|
68 | protected:
|
---|
69 | bridgeSharedData *shared;
|
---|
70 | sageTcpModule *tcpObj;
|
---|
71 | sageUdpModule *udpObj;
|
---|
72 | sageNwConfig *nwCfg;
|
---|
73 | sageAudioBridge *audioBridge;
|
---|
74 |
|
---|
75 | bool master;
|
---|
76 | char masterIP[SAGE_IP_LEN];
|
---|
77 | int streamPort, msgPort, syncPort, audioPort;
|
---|
78 | int slaveNum;
|
---|
79 | int memSize;
|
---|
80 | int allocPolicy;
|
---|
81 | char slaveIPs[MAX_BRIDGE_NODE][SAGE_IP_LEN];
|
---|
82 | int slaveList[MAX_BRIDGE_NODE];
|
---|
83 |
|
---|
84 | messageInterface *msgInf;
|
---|
85 | std::vector<appInstance*> appInstList;
|
---|
86 | int instNum;
|
---|
87 | sageSyncServer *syncServerObj;
|
---|
88 | //sageSyncClient *syncClientObj;
|
---|
89 |
|
---|
90 | bool bridgeEnd;
|
---|
91 | int syncGroupID;
|
---|
92 |
|
---|
93 | int initMaster(const char *cFile);
|
---|
94 | int initSlave(char *data);
|
---|
95 | int launchSlaves();
|
---|
96 | int regApp(sageMessage &msg, int clientID);
|
---|
97 | int shareApp(char *msgData, int clientID);
|
---|
98 | int connectApp(appInstance *inst);
|
---|
99 | int sendStreamInfo(appInstance *inst);
|
---|
100 |
|
---|
101 | appInstance* findApp(int id, int& index);
|
---|
102 |
|
---|
103 | int connectToFSManager(appInstance *inst);
|
---|
104 | int connectToFSManager(appInstance *inst, char *ip, int port);
|
---|
105 | syncGroup* addSyncGroup();
|
---|
106 |
|
---|
107 | appInstance* clientIDtoAppInstance(int clientID, int &orgIdx);
|
---|
108 | appInstance* forwardToAppinstance(sageMessage &msg, int clientID);
|
---|
109 | appInstance* findAppInstance(int instID);
|
---|
110 | appInstance* delieverMessage(sageMessage &msg, int clientID);
|
---|
111 | int parseMessage(sageMessage &msg, int clientID);
|
---|
112 | int parseEvent(sageEvent *event);
|
---|
113 |
|
---|
114 | int findMinLoadNode();
|
---|
115 | int startPerformanceReport(sageMessage &msg);
|
---|
116 | int stopPerformanceReport(sageMessage &msg);
|
---|
117 | int perfReport();
|
---|
118 | int shutdownApp(int instID, bool fsmToApp);
|
---|
119 | int forwardToSail(int instID, sageMessage &msg);
|
---|
120 | int shutdownAllApps();
|
---|
121 |
|
---|
122 | int initNetworks();
|
---|
123 | int checkNetworks();
|
---|
124 | int initStreams(char *msg, streamProtocol *nwObj);
|
---|
125 |
|
---|
126 |
|
---|
127 | static void* msgCheckThread(void *args);
|
---|
128 | static void* perfReportThread(void *args);
|
---|
129 | static void* nwCheckThread(void *args);
|
---|
130 |
|
---|
131 | public:
|
---|
132 | sageBridge(int argc, char **argv);
|
---|
133 | ~sageBridge();
|
---|
134 | void mainLoop();
|
---|
135 |
|
---|
136 | friend class appInstance;
|
---|
137 | };
|
---|
138 |
|
---|
139 | #endif
|
---|