Revision 9470
Added by Jing Tao almost 9 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
52 | 52 |
import org.apache.log4j.Logger; |
53 | 53 |
import org.apache.log4j.PropertyConfigurator; |
54 | 54 |
|
55 |
|
|
55 | 56 |
import edu.ucsb.nceas.metacat.common.query.EnabledQueryEngines; |
56 | 57 |
import edu.ucsb.nceas.metacat.database.DBConnection; |
57 | 58 |
import edu.ucsb.nceas.metacat.database.DBConnectionPool; |
... | ... | |
850 | 851 |
SessionService.getInstance().validateSession(out, response, idToValidate); |
851 | 852 |
out.close(); |
852 | 853 |
|
853 |
// handle shrink DBConnection request |
|
854 |
} else if (action.equals("shrink")) { |
|
855 |
PrintWriter out = response.getWriter(); |
|
856 |
boolean success = false; |
|
857 |
// If all DBConnection in the pool are free and DBConnection |
|
858 |
// pool |
|
859 |
// size is greater than initial value, shrink the connection |
|
860 |
// pool |
|
861 |
// size to initial value |
|
862 |
success = DBConnectionPool.shrinkConnectionPoolSize(); |
|
863 |
if (success) { |
|
864 |
// if successfully shrink the pool size to initial value |
|
865 |
out.println("DBConnection Pool shrunk successfully."); |
|
866 |
}// if |
|
867 |
else { |
|
868 |
out.println("DBConnection pool not shrunk successfully."); |
|
869 |
} |
|
870 |
// close out put |
|
871 |
out.close(); |
|
872 |
|
|
873 | 854 |
// aware of session expiration on every request |
874 | 855 |
} else { |
875 | 856 |
SessionData sessionData = RequestUtil.getSessionData(request); |
... | ... | |
1121 | 1102 |
ResponseUtil.DELETE_SCHEDULED_WORKFLOW_ERROR, be); |
1122 | 1103 |
return; |
1123 | 1104 |
} |
1124 |
|
|
1105 |
} else if (action.equals("shrink")) { |
|
1106 |
// handle shrink DBConnection request |
|
1107 |
PrintWriter out = response.getWriter(); |
|
1108 |
if(!AuthUtil.isAdministrator(userName, groupNames)){ |
|
1109 |
out.println("The user "+userName+ " is not the administrator of the Metacat and doesn't have the permission to call the method."); |
|
1110 |
out.close(); |
|
1111 |
return; |
|
1112 |
} |
|
1113 |
boolean success = false; |
|
1114 |
// If all DBConnection in the pool are free and DBConnection |
|
1115 |
// pool |
|
1116 |
// size is greater than initial value, shrink the connection |
|
1117 |
// pool |
|
1118 |
// size to initial value |
|
1119 |
success = DBConnectionPool.shrinkConnectionPoolSize(); |
|
1120 |
if (success) { |
|
1121 |
// if successfully shrink the pool size to initial value |
|
1122 |
out.println("DBConnection Pool shrunk successfully."); |
|
1123 |
}// if |
|
1124 |
else { |
|
1125 |
out.println("DBConnection pool did not shrink successfully."); |
|
1126 |
} |
|
1127 |
// close out put |
|
1128 |
out.close(); |
|
1125 | 1129 |
} else { |
1126 | 1130 |
//try the plugin handler if it has an entry for handling this action |
1127 | 1131 |
MetacatHandlerPlugin handlerPlugin = MetacatHandlerPluginManager.getInstance().getHandler(action); |
Also available in: Unified diff
Add the check that only the administrator can shrink the connection pool.