paper3—Algorithm2-Engine-Trigger-on-SMD—temp
2016-05-04 20:55
274 查看
//source code: /run/media/root/E6B2798BB279614B/.../PAPER/paper-3/twin-engine-trigger-code/server-client-pthread-c
----------------------------------------------------------------------------------
Description: guest access FCD by using SMD, there are two parts: browser on SMD and daemon written in c language
//browser on SMD:
guest access server on FCD by using browser on SMD;
socket(); //use WebSocket
connect(); //connect to daemon on SMD
send username to daemon WAIT on the same SMD;
executing tasks in brower; // take some time
if finish tasks then
send finish=1 to daemon WAIT on the same SMD;
end if
//---------------------------------------------------------
//daemon WAIT on SMD that waiting data sent by brower
PROCEDURE: WAIT
socket();
bind();
recvfrom();
if receive username from browser then
write username to pipe;
end if
if receive finish=1 from browser then
write finish=1 to pipe; // send to daemon MAIN
end if
END PROCEDURE
//daemon MAIN on SMD
PROCEDURE: MAIN
socket();
connect(); //connect to TCP Socket on FCD;
//fcdtime: time of sending heartbeat to FCD last;
fcdtime = currenttime;
pthread_create(WAIT); //daemon WAIT on SMD
while true do
read from pipe; //receive from daemon WAIT
if read username from pipe then
send heartbeat to FCD;
send username, processid to FCD;
if receive heartbeat from FCD then
SMD receive current process information from FCD;
update correlative tables in database;
end if
period = currenttime - fcdtime;
if period < 5 then //connectiong to FCD is normal
fcdtime = currenttime;
else if period > 30 then //server shutdown or connectiong to FCD is abnormal
trigger SMD;
redirect to localhost and invoke task in SMD
while true do
send heartbeat to FCD; //probe whether FCD is active
if receive heartbeat from FCD then
read from pipe; //receive from daemon WAIT
if finish=1 then
send finish to FCD;
send information for current process to FCD;
exit;
else
stop accessing MPE;
send information for current process to FCD;
sleep 3s; //waiting for FCD to update it's database
trigger FCD;
redirect to FCD and invoke task in FCD;
end if
end if
sleep 60s;
done //end while
end if
else if read finish=1 from pipe
send finish to FCD;
send information for current process to FCD;
exit;
end if
sleep 5s; //send heartbeat request every 5s to FPE
done
END PROCEDURE
----------------------------------------------------------------------------------
Description: guest access FCD by using SMD, there are two parts: browser on SMD and daemon written in c language
//browser on SMD:
guest access server on FCD by using browser on SMD;
socket(); //use WebSocket
connect(); //connect to daemon on SMD
send username to daemon WAIT on the same SMD;
executing tasks in brower; // take some time
if finish tasks then
send finish=1 to daemon WAIT on the same SMD;
end if
//---------------------------------------------------------
//daemon WAIT on SMD that waiting data sent by brower
PROCEDURE: WAIT
socket();
bind();
recvfrom();
if receive username from browser then
write username to pipe;
end if
if receive finish=1 from browser then
write finish=1 to pipe; // send to daemon MAIN
end if
END PROCEDURE
//daemon MAIN on SMD
PROCEDURE: MAIN
socket();
connect(); //connect to TCP Socket on FCD;
//fcdtime: time of sending heartbeat to FCD last;
fcdtime = currenttime;
pthread_create(WAIT); //daemon WAIT on SMD
while true do
read from pipe; //receive from daemon WAIT
if read username from pipe then
send heartbeat to FCD;
send username, processid to FCD;
if receive heartbeat from FCD then
SMD receive current process information from FCD;
update correlative tables in database;
end if
period = currenttime - fcdtime;
if period < 5 then //connectiong to FCD is normal
fcdtime = currenttime;
else if period > 30 then //server shutdown or connectiong to FCD is abnormal
trigger SMD;
redirect to localhost and invoke task in SMD
while true do
send heartbeat to FCD; //probe whether FCD is active
if receive heartbeat from FCD then
read from pipe; //receive from daemon WAIT
if finish=1 then
send finish to FCD;
send information for current process to FCD;
exit;
else
stop accessing MPE;
send information for current process to FCD;
sleep 3s; //waiting for FCD to update it's database
trigger FCD;
redirect to FCD and invoke task in FCD;
end if
end if
sleep 60s;
done //end while
end if
else if read finish=1 from pipe
send finish to FCD;
send information for current process to FCD;
exit;
end if
sleep 5s; //send heartbeat request every 5s to FPE
done
END PROCEDURE
相关文章推荐
- paper3—Algorithm1-Engine-Trigger-on-FCD—temp
- POJ 2195 Going Home(最小权匹配、KM算法)
- Spark组件之GraphX学习15--we-Google.txt大图分析
- Django笔记:1.创建一个项目
- 使用visual studio code开发Go程序
- Go--基础知识学习二
- 在Visual Studio Code中配置GO开发环境
- Windows环境下vscode-go安装笔记
- Leangoo大讲堂:免费Scrum敏捷开发实战—武汉站
- GO--基础知识学习一
- Go 性能优化技巧 9/10
- Go 性能优化技巧 8/10
- Go 性能优化技巧 7/10
- Go 性能优化技巧 6/10
- Go 性能优化技巧 5/10
- Go 性能优化技巧 4/10
- Go 性能优化技巧 3/10
- Go 性能优化技巧 2/10
- django使用静态文件
- ROS(indigo)机器人操作系统学习资料和常用功能包汇总整理(ubuntu14.04LTS)