Flume+Hadoop+Hive的离线分析系统基本架构 - 图文(5)

2019-08-03 13:18

192. } 193. }

[plain] view plain copy

1. package com.guludada.dataparser; 2.

3. import java.text.ParseException; 4. import java.text.SimpleDateFormat; 5. import java.util.Date; 6. import java.util.Locale; 7.

8. import com.guludada.javabean.WebLogSessionBean; 9.

10. public class SessionParser { 11.

12. SimpleDateFormat sdf_origin = new SimpleDateFormat(\

\

13. SimpleDateFormat sdf_final = new SimpleDateFormat(\

; 14.

15. public String parser(WebLogSessionBean sessionBean,String sessionID) { 16.

17. sessionBean.setSession(sessionID); 18. return sessionBean.toString(); 19. } 20.

21. public WebLogSessionBean loadBean(String sessionContent) { 22.

23. WebLogSessionBean weblogSession = new WebLogSessionBean(); 24.

25. String[] contents = sessionContent.split(\ 26. weblogSession.setTime(timeTransform(contents[1])); 27. weblogSession.setIP_addr(contents[0]); 28. weblogSession.setRequest_URL(contents[3]); 29. weblogSession.setReferal(contents[7]); 30.

31. return weblogSession; 32. } 33.

34. private String timeTransform(String time) { 35.

36. Date standard_time = null; 37. try {

38. standard_time = sdf_origin.parse(time); 39. } catch (ParseException e) {

40. // TODO Auto-generated catch block 41. e.printStackTrace(); 42. }

43. return sdf_final.format(standard_time); 44. } 45. }

[plain] view plain copy

1. package com.guludada.javabean; 2.

3. import java.text.ParseException; 4. import java.text.SimpleDateFormat; 5. import java.util.Date; 6.

7. public class WebLogSessionBean { 8.

9. String time; 10. String IP_addr; 11. String session; 12. String request_URL; 13. String referal; 14. 15.

16. public String getTime() { 17. return time; 18. }

19. public void setTime(String time) { 20. this.time = time; 21. }

22. public String getIP_addr() { 23. return IP_addr; 24. }

25. public void setIP_addr(String iP_addr) { 26. IP_addr = iP_addr; 27. }

28. public String getSession() { 29. return session; 30. }

31. public void setSession(String session) { 32. this.session = session; 33. }

34. public String getRequest_URL() { 35. return request_URL; 36. }

37. public void setRequest_URL(String request_URL) { 38. this.request_URL = request_URL; 39. }

40. public String getReferal() { 41. return referal; 42. }

43. public void setReferal(String referal) { 44. this.referal = referal; 45. } 46.

47. public Date getTimeWithDateFormat() { 48.

49. SimpleDateFormat sdf_final = new SimpleDateFormat(\

ss\

50. if(this.time != null && this.time != \ 51. try {

52. return sdf_final.parse(this.time); 53. } catch (ParseException e) {

54. // TODO Auto-generated catch block 55. e.printStackTrace(); 56. } 57. }

58. return null; 59. } 60.

61. @Override

62. public String toString() {

63. return time + \ 64. + request_URL + \ 65. } 66. 67. 68. 69. }

第二次清理出来的Session信息结构如下: 时间 IP SessionID 请求页面URL Referal URL www.http://www.wodefanwen.com/ 2015-05-30 192.168.12.130 Session1 /blog/me 19:38:00 2015-05-30 192.168.12.130 Session1 /blog/me/details www.mysite.com/blog/me 19:39:00 2015-05-30 192.168.12.40 Session2 /blog/me 19:38:00 www.http://www.wodefanwen.com/


Flume+Hadoop+Hive的离线分析系统基本架构 - 图文(5).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:砂浆合同

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: