更新时间:2024-08-03 GMT+08:00

查看Manager应用调测结果

操作场景

Manager应用程序运行完成后,可通过如下方式查看运行结果:

  • 通过IntelliJ IDEA运行结果查看应用程序运行情况,可通过配置文件“conf\log4j.properties”配置日志打印信息。
  • 登录主管理节点查看系统日志“/var/log/Bigdata/tomcat/web.log”

操作步骤

  • 运行“UserManager”类,运行成功会有如下日志信息:
    2020-10-19 14:22:52,111 INFO  [main] Enter main. rest.UserManager.main(UserManager.java:43)
    2020-10-19 14:22:52,113 INFO  [main] Get the web info and user info from file .\conf\UserInfo.properties  rest.UserManager.main(UserManager.java:56)
    2020-10-19 14:22:52,113 INFO  [main] The user name is : admin. rest.UserManager.main(UserManager.java:63)
    2020-10-19 14:22:52,113 INFO  [main] The webUrl is : https://10.112.16.93:28443/web/. rest.UserManager.main(UserManager.java:75)
    2020-10-19 14:22:52,113 INFO  [main] Begin to get httpclient and first access. rest.UserManager.main(UserManager.java:84)
    2020-10-19 14:22:52,117 INFO  [main] Enter loginAndAccess. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:56)
    2020-10-19 14:22:52,120 INFO  [main] 1.Get http client for sending https request, username is admin, webUrl is https://10.112.16.93:28443/web/. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:66)
    2020-10-19 14:22:52,121 INFO  [main] Enter getHttpClient. basicAuth.BasicAuthAccess.getHttpClient(BasicAuthAccess.java:98)
    2020-10-19 14:22:52,693 INFO  [main] Exit getHttpClient. basicAuth.BasicAuthAccess.getHttpClient(BasicAuthAccess.java:104)
    2020-10-19 14:22:52,693 INFO  [main] The new http client is: org.apache.http.impl.client.DefaultHttpClient@66d2e7d9. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:70)
    2020-10-19 14:22:52,693 INFO  [main] 2.Construct basic authentication,username is admin. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:76)
    2020-10-19 14:22:52,694 INFO  [main] the authentication is Basic YWRtaW46QmlnZGF0YV8yMDEz . basicAuth.BasicAuthAccess.constructAuthentication(BasicAuthAccess.java:122)
    2020-10-19 14:22:52,695 INFO  [main] 3. Send first access request, usename is admin. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:86)
    2020-10-19 14:22:53,555 INFO  [main] First access status is HTTP/1.1 200  basicAuth.BasicAuthAccess.firstAccessResp(BasicAuthAccess.java:162)
    2020-10-19 14:22:53,556 INFO  [main] Response content is [{"infoType":1,"infoContent":"","alarmStat":[{"level":"Critical","num":0},{"level":"Major","num":6},{"level":"Minor","num":0},{"level":"Warning","num":0}],"timestamp":1603088492362,"timezoneOffset":-480}]  basicAuth.BasicAuthAccess.firstAccessResp(BasicAuthAccess.java:168)
    2020-10-19 14:22:53,556 INFO  [main] User admin first access success basicAuth.BasicAuthAccess.firstAccessResp(BasicAuthAccess.java:174)
    2020-10-19 14:22:53,556 INFO  [main] Start to access REST API. rest.UserManager.main(UserManager.java:88)
    2020-10-19 14:22:53,557 INFO  [main] Enter sendHttpPostRequest for userOperation AddUser. basicAuth.HttpManager.sendHttpPostRequest(HttpManager.java:93)
    2020-10-19 14:22:53,558 INFO  [main] The json content = {"userName":"user888","userType":"HM","password":"XXX","confirmPassword":"XXX","userGroups":["supergroup"],"userRoles":[],"primaryGroup":"supergroup","description":"Add user"}. basicAuth.HttpManager.sendHttpPostRequest(HttpManager.java:148)
    2020-10-19 14:22:55,437 INFO  [main] The AddUser status is HTTP/1.1 204 . basicAuth.HttpManager.handleHttpResponse(HttpManager.java:425)
    2020-10-19 14:22:55,437 INFO  [main] sendHttpPostRequest completely. basicAuth.HttpManager.sendHttpPostRequest(HttpManager.java:178)
    2020-10-19 14:22:55,437 INFO  [main] Enter sendHttpGetRequest for userOperation QueryUserList. basicAuth.HttpManager.sendHttpGetRequest(HttpManager.java:48)
    2020-10-19 14:22:55,437 INFO  [main] The operationUrl is:https://10.112.16.93:28443/web/api/v2/permission/users?limit=10&offset=0&filter=&order=ASC&order_by=userName basicAuth.HttpManager.sendHttpGetRequest(HttpManager.java:60)
    2020-10-19 14:22:55,565 INFO  [main] The QueryUserList status is HTTP/1.1 200 . basicAuth.HttpManager.handleHttpResponse(HttpManager.java:425)
    2020-10-19 14:22:55,565 INFO  [main] The response lineContent is {"users":[{"userName":"admin","userType":"HM","description":"Administrator of FusionInsight Manager.","password":"","createTime":"2020-09-30T10:31:44+08:00","defaultUser":true,"primaryGroup":"compcommon","locked":false,"userRoles":["Manager_administrator"],"userGroups":[],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"developuser","userType":"MM","description":"","password":"","createTime":"2020-10-15T19:16:37+08:00","defaultUser":false,"primaryGroup":"elasticsearch","locked":false,"userRoles":["System_administrator"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"hue1","userType":"HM","description":"","password":"","createTime":"2020-10-09T17:39:57+08:00","defaultUser":false,"primaryGroup":"hive","locked":false,"userRoles":["System_administrator"],"userGroups":["hive","hadoop","supergroup"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"user888","userType":"HM","description":"Add user","password":"","createTime":"2020-10-19T14:21:32+08:00","defaultUser":false,"primaryGroup":"supergroup","locked":false,"userRoles":[],"userGroups":["supergroup"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"yangtong","userType":"MM","description":"","password":"","createTime":"2020-10-19T10:50:52+08:00","defaultUser":false,"primaryGroup":"supergroup","locked":false,"userRoles":["System_administrator"],"userGroups":["supergroup"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false}],"totalCount":5}. basicAuth.HttpManager.handleHttpResponse(HttpManager.java:430)
    2020-10-19 14:22:55,565 INFO  [main] SendHttpGetRequest completely. basicAuth.HttpManager.sendHttpGetRequest(HttpManager.java:69)
    2020-10-19 14:22:55,565 INFO  [main] The QueryUserList response is {"users":[{"userName":"admin","userType":"HM","description":"Administrator of FusionInsight Manager.","password":"","createTime":"2020-09-30T10:31:44+08:00","defaultUser":true,"primaryGroup":"compcommon","locked":false,"userRoles":["Manager_administrator"],"userGroups":[],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"developuser","userType":"MM","description":"","password":"","createTime":"2020-10-15T19:16:37+08:00","defaultUser":false,"primaryGroup":"elasticsearch","locked":false,"userRoles":["System_administrator"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"hue1","userType":"HM","description":"","password":"","createTime":"2020-10-09T17:39:57+08:00","defaultUser":false,"primaryGroup":"hive","locked":false,"userRoles":["System_administrator"],"userGroups":["hive","hadoop","supergroup"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"user888","userType":"HM","description":"Add user","password":"","createTime":"2020-10-19T14:21:32+08:00","defaultUser":false,"primaryGroup":"supergroup","locked":false,"userRoles":[],"userGroups":["supergroup"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false},{"userName":"yangtong","userType":"MM","description":"","password":"","createTime":"2020-10-19T10:50:52+08:00","defaultUser":false,"primaryGroup":"supergroup","locked":false,"userRoles":["System_administrator"],"userGroups":["supergroup"],"indepdtType":"NONE","domainUser":false,"synchroStatus":"SYNCHRO","userSource":"MRS_MANAGER_USER","iamCustomPolicyUser":false}],"totalCount":5}. rest.UserManager.main(UserManager.java:105)
    2020-10-19 14:22:55,565 INFO  [main] Enter sendHttpPutRequest for userOperation ModifyUser. basicAuth.HttpManager.sendHttpPutRequest(HttpManager.java:239)
    2020-10-19 14:22:55,566 INFO  [main] The json content = {"userName":"user888","userType":"HM","password":"XXX","confirmPassword":"XXX","userGroups":["supergroup"],"primaryGroup":"supergroup","userRoles":["Manager_administrator"],"description":"Modify user"}. basicAuth.HttpManager.sendHttpPutRequest(HttpManager.java:293)
    2020-10-19 14:22:56,299 INFO  [main] The ModifyUser status is HTTP/1.1 204 . basicAuth.HttpManager.handleHttpResponse(HttpManager.java:425)
    2020-10-19 14:22:56,299 INFO  [main] sendHttpPutRequest completely. basicAuth.HttpManager.sendHttpPutRequest(HttpManager.java:304)
    2020-10-19 14:22:56,299 INFO  [main] The operationUrl is:https://10.112.16.93:28443/web/api/v2/permission/users basicAuth.HttpManager.sendHttpDeleteRequest(HttpManager.java:389)
    2020-10-19 14:22:56,299 INFO  [main] Enter sendHttpDeleteMessage for operation DeleteUser. basicAuth.HttpManager.sendHttpDeleteRequest(HttpManager.java:390)
    2020-10-19 14:22:57,463 INFO  [main] The DeleteUser status is HTTP/1.1 204 . basicAuth.HttpManager.handleHttpResponse(HttpManager.java:425)
    2020-10-19 14:22:57,463 INFO  [main] sendHttpDeleteMessage for DeleteUser completely. basicAuth.HttpManager.sendHttpDeleteRequest(HttpManager.java:406)
    2020-10-19 14:22:57,463 INFO  [main] Exit main. rest.UserManager.main(UserManager.java:120)

    从日志信息中可以看到:执行UserManager类中的main方法时,依次调用loginAndAccess、sendHttpPostRequest、sendHttpGetRequest、sendHttpPutRequest、sendHttpDeleteRequest方法,发送POST、GET、PUT、DELETE请求,执行登录认证、添加用户、查找用户、修改用户、删除用户的操作。

  • 运行“ExportUsers”类,运行成功会有如下日志信息:
    2020-10-19 14:25:02,845 INFO  [main] Enter main. rest.ExportUsers.main(ExportUsers.java:41)
    2020-10-19 14:25:02,847 INFO  [main] Get the web info and user info from file .\conf\UserInfo.properties  rest.ExportUsers.main(ExportUsers.java:54)
    2020-10-19 14:25:02,847 INFO  [main] The user name is : admin. rest.ExportUsers.main(ExportUsers.java:61)
    2020-10-19 14:25:02,847 INFO  [main] The webUrl is : https://10.112.16.93:28443/web/. rest.ExportUsers.main(ExportUsers.java:73)
    2020-10-19 14:25:02,847 INFO  [main] Begin to get httpclient and first access. rest.ExportUsers.main(ExportUsers.java:82)
    2020-10-19 14:25:02,851 INFO  [main] Enter loginAndAccess. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:56)
    2020-10-19 14:25:02,854 INFO  [main] 1.Get http client for sending https request, username is admin, webUrl is https://10.112.16.93:28443/web/. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:66)
    2020-10-19 14:25:02,855 INFO  [main] Enter getHttpClient. basicAuth.BasicAuthAccess.getHttpClient(BasicAuthAccess.java:98)
    2020-10-19 14:25:03,414 INFO  [main] Exit getHttpClient. basicAuth.BasicAuthAccess.getHttpClient(BasicAuthAccess.java:104)
    2020-10-19 14:25:03,414 INFO  [main] The new http client is: org.apache.http.impl.client.DefaultHttpClient@66d2e7d9. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:70)
    2020-10-19 14:25:03,414 INFO  [main] 2.Construct basic authentication,username is admin. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:76)
    2020-10-19 14:25:03,415 INFO  [main] the authentication is Basic YWRtaW46QmlnZGF0YV8yMDEz . basicAuth.BasicAuthAccess.constructAuthentication(BasicAuthAccess.java:122)
    2020-10-19 14:25:03,415 INFO  [main] 3. Send first access request, usename is admin. basicAuth.BasicAuthAccess.loginAndAccess(BasicAuthAccess.java:86)
    2020-10-19 14:25:04,205 INFO  [main] First access status is HTTP/1.1 200  basicAuth.BasicAuthAccess.firstAccessResp(BasicAuthAccess.java:162)
    2020-10-19 14:25:04,206 INFO  [main] Response content is [{"infoType":1,"infoContent":"","alarmStat":[{"level":"Critical","num":0},{"level":"Major","num":6},{"level":"Minor","num":0},{"level":"Warning","num":0}],"timestamp":1603088623013,"timezoneOffset":-480}]  basicAuth.BasicAuthAccess.firstAccessResp(BasicAuthAccess.java:168)
    2020-10-19 14:25:04,206 INFO  [main] User admin first access success basicAuth.BasicAuthAccess.firstAccessResp(BasicAuthAccess.java:174)
    2020-10-19 14:25:04,207 INFO  [main] Start to access REST API. rest.ExportUsers.main(ExportUsers.java:86)
    2020-10-19 14:25:04,208 INFO  [main] Enter sendHttpPostRequest for userOperation ExportUsers. basicAuth.HttpManager.sendHttpPostRequestWithString(HttpManager.java:193)
    2020-10-19 14:25:04,418 INFO  [main] The ExportUsers status is HTTP/1.1 200 . basicAuth.HttpManager.handleHttpResponse(HttpManager.java:425)
    2020-10-19 14:25:04,418 INFO  [main] The response lineContent is {"fileName":"userInfo_2020-10-19-14-23-43.zip"}. basicAuth.HttpManager.handleHttpResponse(HttpManager.java:430)
    2020-10-19 14:25:04,418 INFO  [main] SendHttpPostRequest completely. basicAuth.HttpManager.sendHttpPostRequestWithString(HttpManager.java:216)
    2020-10-19 14:25:04,464 INFO  [main] Enter sendHttpGetRequest for userOperation DownloadUsers. basicAuth.HttpManager.sendHttpGetRequest(HttpManager.java:48)
    2020-10-19 14:25:04,464 INFO  [main] The operationUrl is:https://10.112.16.93:28443/web/api/v2/permission/users/download?file_name=userInfo_2020-10-19-14-23-43.zip basicAuth.HttpManager.sendHttpGetRequest(HttpManager.java:60)
    2020-10-19 14:25:04,508 INFO  [main] The DownloadUsers status is HTTP/1.1 200 . basicAuth.HttpManager.handleHttpResponse(HttpManager.java:425)

    从日志信息中可以看出,执行ExportUsers类中的main方法时,依次调用loginAndAccess、sendHttpPostRequestWithString、sendHttpGetRequest方法,发送POST、GET请求,执行登录认证、导出用户、下载用户。

  • 通过在“conf\log4j.properties”文件中配置日志打印信息,便于查看程序运行过程和结果。
    默认已配置,具体填写示例如下:
    ##set log4j  DEBUG < INFO < WARN < ERROR < FATAL
    log4j.logger.rest=INFO,A1,A2
    log4j.logger.basicAuth=INFO,A1,A2
    log4j.logger.org.apache.http=INFO,A1,A2
    
    #print to the console?A1
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    log4j.appender.A1.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] %m %l%n
    
    #log file
    log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.A2.File=./log/rest.log
    log4j.appender.A2.Append = true
    log4j.appender.A2.layout=org.apache.log4j.PatternLayout
    log4j.appender.A2.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t] %m %l%n