- some logger.info and logger.trace moved and added in order to improve the debug.
commented code not useful removed. Also the commented methods not useful has been removed: getDatabaseManagerAlgorithms, getParameters, getSubmitQueryResult, getSubmitQueryResultParsed, updateSubmitQueryResultParsed, removeResultParsed, updateSubmitQueryResultMap, removeResult git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100945 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c65cba2a56
commit
2508eed0b6
|
@ -100,17 +100,14 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws ServletException {
|
public void init() throws ServletException {
|
||||||
|
|
||||||
super.init();
|
super.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// cache folder
|
// cache folder
|
||||||
String cachePath = System.getenv("CATALINA_TMPDIR") + "/DBManager";
|
String cachePath = System.getenv("CATALINA_TMPDIR") + "/DBManager";
|
||||||
logger.info("dbmanager-> Creating cache in folder: " + cachePath);
|
logger.info("dbmanager-> Creating cache in folder: " + cachePath);
|
||||||
|
|
||||||
// CacheManager cacheManager = CacheManager.create();
|
// CacheManager cacheManager = CacheManager.create();
|
||||||
|
|
||||||
cacheManager = CacheManager.create();
|
cacheManager = CacheManager.create();
|
||||||
|
|
||||||
if (cacheManager == null) {
|
if (cacheManager == null) {
|
||||||
|
@ -1455,144 +1452,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
return elements;
|
return elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
// not called
|
|
||||||
// private List<String> getDatabaseManagerAlgorithms() {
|
|
||||||
// ArrayList<String> dbAlg = new ArrayList<String>();
|
|
||||||
// StatisticalManagerFactory factory = getFactory();
|
|
||||||
// // get and print algorithms
|
|
||||||
// SMListGroupedAlgorithms groups = factory.getAlgorithms();
|
|
||||||
//
|
|
||||||
// if (groups == null)
|
|
||||||
// logger.info("dbmanager-> GROUPS OF ALGORITHMS IS NULL!");
|
|
||||||
// else
|
|
||||||
// logger.info("dbmanager-> GROUPS OF ALGORITHMS IS NOT NULL!");
|
|
||||||
//
|
|
||||||
// // get list categories
|
|
||||||
// for (SMGroupedAlgorithms group : groups.thelist()) {
|
|
||||||
// for (SMAlgorithm algorithm : group.thelist()) {
|
|
||||||
// dbAlg.add(algorithm.name());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return dbAlg;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// not used
|
|
||||||
// private List<Parameter> getParameters(String algorithmId) {
|
|
||||||
// StatisticalManagerFactory factory = getFactory();
|
|
||||||
// SMParameters smParams = factory.getAlgorithmParameters(algorithmId);
|
|
||||||
// List<Parameter> params = new ArrayList<Parameter>();
|
|
||||||
//
|
|
||||||
// for (SMParameter smParam : smParams.list()) {
|
|
||||||
// SMTypeParameter smType = smParam.type();
|
|
||||||
// StatisticalServiceType smTypeName = smType.name();
|
|
||||||
//
|
|
||||||
// String paramName = smParam.name();
|
|
||||||
// String paramDescription = smParam.description();
|
|
||||||
// String defaultValue = smParam.defaultValue();
|
|
||||||
// String objectType = smType.values().get(0);
|
|
||||||
//
|
|
||||||
// // print CHECK
|
|
||||||
// // logger.info("parameters: ");
|
|
||||||
// // logger.info(paramName);
|
|
||||||
// // logger.info(paramDescription);
|
|
||||||
// // logger.info(objectType);
|
|
||||||
// // logger.info(defaultValue);
|
|
||||||
//
|
|
||||||
// Parameter objectParam = new Parameter(paramName, paramDescription,
|
|
||||||
// objectType, defaultValue);
|
|
||||||
// params.add(objectParam);
|
|
||||||
// }
|
|
||||||
// return params;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private synchronized List<Result> getSubmitQueryResult(String
|
|
||||||
// submitQueryUID) {
|
|
||||||
// ASLSession session = SessionUtil.getAslSession(this
|
|
||||||
// .getThreadLocalRequest().getSession());
|
|
||||||
// HashMap<String, List<Result>> submitQueryResult = (HashMap<String,
|
|
||||||
// List<Result>>) session
|
|
||||||
// .getAttribute("submitQueryResult");
|
|
||||||
// if (submitQueryResult.containsKey(submitQueryUID)) {
|
|
||||||
// return submitQueryResult.get(submitQueryUID);
|
|
||||||
// } else {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private synchronized List<Row> getSubmitQueryResultParsed(
|
|
||||||
// String submitQueryUID) {
|
|
||||||
// ASLSession session = SessionUtil.getAslSession(this
|
|
||||||
// .getThreadLocalRequest().getSession());
|
|
||||||
// HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String,
|
|
||||||
// List<Row>>) session
|
|
||||||
// .getAttribute("submitQueryResultParsed");
|
|
||||||
//
|
|
||||||
// if (submitQueryResultParsed.containsKey(submitQueryUID)) {
|
|
||||||
// // System.out.println("ResultParsed: UID contained");
|
|
||||||
// return submitQueryResultParsed.get(submitQueryUID);
|
|
||||||
// } else {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private synchronized void updateSubmitQueryResultParsed(
|
|
||||||
// String submitQueryUID, List<Row> data) {
|
|
||||||
// ASLSession session = SessionUtil.getAslSession(this
|
|
||||||
// .getThreadLocalRequest().getSession());
|
|
||||||
// HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String,
|
|
||||||
// List<Row>>) session
|
|
||||||
// .getAttribute("submitQueryResultParsed");
|
|
||||||
// // add data
|
|
||||||
// if (data.size() != 0) {
|
|
||||||
// submitQueryResultParsed.put(submitQueryUID, data);
|
|
||||||
// session.setAttribute("submitQueryResultParsed",
|
|
||||||
// submitQueryResultParsed);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private synchronized void removeResultParsed(String submitQueryUID) {
|
|
||||||
// ASLSession session = SessionUtil.getAslSession(this
|
|
||||||
// .getThreadLocalRequest().getSession());
|
|
||||||
// HashMap<String, List<Row>> submitQueryResultParsed = (HashMap<String,
|
|
||||||
// List<Row>>) session
|
|
||||||
// .getAttribute("submitQueryResultParsed");
|
|
||||||
// if (submitQueryResultParsed.containsKey(submitQueryUID)) {
|
|
||||||
// // remove data parsed
|
|
||||||
// submitQueryResultParsed.remove(submitQueryUID);
|
|
||||||
// // update
|
|
||||||
// session.setAttribute("submitQueryResultParsed",
|
|
||||||
// submitQueryResultParsed);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private synchronized void updateSubmitQueryResultMap(String
|
|
||||||
// submitQueryUID,
|
|
||||||
// List<Result> result) {
|
|
||||||
// if (submitQueryUID != null) {
|
|
||||||
// ASLSession session = SessionUtil.getAslSession(this
|
|
||||||
// .getThreadLocalRequest().getSession());
|
|
||||||
// HashMap<String, List<Result>> submitQueryResult = (HashMap<String,
|
|
||||||
// List<Result>>) session
|
|
||||||
// .getAttribute("submitQueryResult");
|
|
||||||
// submitQueryResult.put(submitQueryUID, result);
|
|
||||||
// session.setAttribute("submitQueryResult", submitQueryResult);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private synchronized void removeResult(String submitQueryUID) {
|
|
||||||
// ASLSession session = SessionUtil.getAslSession(this
|
|
||||||
// .getThreadLocalRequest().getSession());
|
|
||||||
// HashMap<String, List<Result>> submitQueryResult = (HashMap<String,
|
|
||||||
// List<Result>>) session
|
|
||||||
// .getAttribute("submitQueryResult");
|
|
||||||
// if (submitQueryResult.containsKey(submitQueryUID)) {
|
|
||||||
// // remove data parsed
|
|
||||||
// submitQueryResult.remove(submitQueryUID);
|
|
||||||
// // update
|
|
||||||
// session.setAttribute("submitQueryResult", submitQueryResult);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// update job with the related status
|
// update job with the related status
|
||||||
private synchronized void updateJobStatus(String jobID, String status) {
|
private synchronized void updateJobStatus(String jobID, String status) {
|
||||||
if (jobID != null) {
|
if (jobID != null) {
|
||||||
|
@ -2070,46 +1929,30 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void insertDataIntoCache(net.sf.ehcache.Element data) {
|
private synchronized void insertDataIntoCache(net.sf.ehcache.Element data) throws Exception{
|
||||||
logger.info("dbmanager-> disk store path for the cache: " + cacheManager.getDiskStorePath());
|
|
||||||
|
|
||||||
if(cacheManager.cacheExists("DBCache")){
|
if(cacheManager.cacheExists("DBCache")){
|
||||||
|
logger.info("dbmanager-> disk store path for cache: " + cacheManager.getDiskStorePath() +"Cache Status: "+DBCache.getStatus().toString());
|
||||||
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
||||||
logger.info("dbmanager-> Cache Status:"+ "STATUS_ALIVE");
|
|
||||||
|
|
||||||
DBCache.put(data);
|
DBCache.put(data);
|
||||||
// logger.info("dbmanager-> element added in cache with key: " + data.getKey().toString());
|
logger.trace("dbmanager-> element with key: " + data.getKey().toString()+" added in cache");
|
||||||
|
|
||||||
}else{
|
|
||||||
logger.info("dbmanager-> Cache Status:"+ DBCache.getStatus().toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// if (DBCache != null) {
|
}
|
||||||
// DBCache.put(data);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized net.sf.ehcache.Element getDataFromCache(String key) {
|
private synchronized net.sf.ehcache.Element getDataFromCache(String key) throws Exception{
|
||||||
net.sf.ehcache.Element data = null;
|
net.sf.ehcache.Element data = null;
|
||||||
logger.info("dbmanager-> disk store path for the cache: " + cacheManager.getDiskStorePath());
|
|
||||||
|
|
||||||
if(cacheManager.cacheExists("DBCache")){
|
if(cacheManager.cacheExists("DBCache")){
|
||||||
|
logger.info("dbmanager-> disk store path for cache: " + cacheManager.getDiskStorePath() +". Cache Status: "+DBCache.getStatus().toString());
|
||||||
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
||||||
logger.info("dbmanager-> Cache Status:"+ "STATUS_ALIVE");
|
|
||||||
|
|
||||||
data = DBCache.get(key);
|
data = DBCache.get(key);
|
||||||
// System.out.println("element get from cache with key " + key);
|
if (data!=null){
|
||||||
|
logger.trace("dbmanager-> element with key: " + key +" is in cache");
|
||||||
}else{
|
}
|
||||||
logger.info("dbmanager-> Cache Status:"+ DBCache.getStatus().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return data;
|
||||||
// if (DBCache != null) {
|
|
||||||
// data = DBCache.get(key);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the cache on the user request
|
// clear the cache on the user request
|
||||||
|
@ -2117,7 +1960,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
LinkedHashMap<String, String> inputData, FileModel element)
|
LinkedHashMap<String, String> inputData, FileModel element)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
logger.info("dbmanager-> Refresh data request received. Starting to manage the request.");
|
logger.info("dbmanager-> Refresh data request received from element "+ElementType+". Starting to manage the request.");
|
||||||
|
|
||||||
// session check
|
// session check
|
||||||
if (isSessionExpired())
|
if (isSessionExpired())
|
||||||
|
@ -2174,13 +2017,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
+ ConstantsPortlet.ALGID_SUBMITQUERY + key;
|
+ ConstantsPortlet.ALGID_SUBMITQUERY + key;
|
||||||
|
|
||||||
refreshSubmittedQueryInCache(keyUsedForQueryRefresh);
|
refreshSubmittedQueryInCache(keyUsedForQueryRefresh);
|
||||||
// loader = new ThreadLoaderData(scope, "database",
|
|
||||||
// inputData.get("ResourceName"),
|
|
||||||
// inputData.get("DatabaseName"), null,
|
|
||||||
// element.getDatabaseType());
|
|
||||||
// loader = new ThreadLoaderData(scope, "database",
|
|
||||||
// inputData, ConstantsPortlet.POSTGRES);
|
|
||||||
|
|
||||||
dataQueue = new DataExchangedThroughQueue(scope,
|
dataQueue = new DataExchangedThroughQueue(scope,
|
||||||
ConstantsPortlet.DATABASE, inputData.get("ResourceName"),
|
ConstantsPortlet.DATABASE, inputData.get("ResourceName"),
|
||||||
inputData.get("DatabaseName"), null,
|
inputData.get("DatabaseName"), null,
|
||||||
|
@ -2211,20 +2048,6 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
refreshSamplingsInCache(keyUsedForSamplingsRefresh,
|
refreshSamplingsInCache(keyUsedForSamplingsRefresh,
|
||||||
keyUsedForSmartSamplingRefresh);
|
keyUsedForSmartSamplingRefresh);
|
||||||
|
|
||||||
// loader = new ThreadLoaderData(scope, "database",
|
|
||||||
// inputData, ConstantsPortlet.MYSQL);
|
|
||||||
|
|
||||||
// loader = new ThreadLoaderData(scope, "database",
|
|
||||||
// inputData.get("ResourceName"),
|
|
||||||
// inputData.get("DatabaseName"),
|
|
||||||
// inputData.get("SchemaName"),
|
|
||||||
// element.getDatabaseType());
|
|
||||||
|
|
||||||
// dataQueue = new DataExchangedThroughQueue(scope,
|
|
||||||
// ConstantsPortlet.DATABASE, inputData.get("ResourceName"),
|
|
||||||
// inputData.get("DatabaseName"),
|
|
||||||
// inputData.get("SchemaName"),
|
|
||||||
// element.getDatabaseType());
|
|
||||||
requestToAddInQueue = false;
|
requestToAddInQueue = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2252,26 +2075,18 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
refreshSamplingsInCache(keyUsedForSamplingsRefresh,
|
refreshSamplingsInCache(keyUsedForSamplingsRefresh,
|
||||||
keyUsedForSmartSamplingRefresh);
|
keyUsedForSmartSamplingRefresh);
|
||||||
|
|
||||||
// loader = new ThreadLoaderData(scope, "schema",
|
|
||||||
// inputData, ConstantsPortlet.POSTGRES);
|
|
||||||
|
|
||||||
// dataQueue = new DataExchangedThroughQueue(scope,
|
|
||||||
// ConstantsPortlet.SCHEMA, inputData.get("ResourceName"),
|
|
||||||
// inputData.get("DatabaseName"),
|
|
||||||
// inputData.get("SchemaName"),
|
|
||||||
// element.getDatabaseType());
|
|
||||||
requestToAddInQueue = false;
|
requestToAddInQueue = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("dbmanager-> Check if data of the node is present in cache with key: : " + key);
|
// logger.trace("dbmanager-> Check if data of the node is present in cache with key: : " + key);
|
||||||
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
|
net.sf.ehcache.Element dataFromCache = getDataFromCache(key);
|
||||||
|
|
||||||
if (dataFromCache != null) {
|
if (dataFromCache != null) {
|
||||||
logger.trace("dbmanager-> Data of the node is in cache");
|
// logger.trace("dbmanager-> Data of the node is in cache");
|
||||||
|
|
||||||
logger.info("dbmanager-> Starting the data removing process in cache from the node");
|
logger.info("dbmanager-> Starting the data removing process in cache from the node with key: " + key);
|
||||||
|
|
||||||
// refresh data in cache. Remove data related to the subtree
|
// refresh data in cache. Remove data related to the subtree
|
||||||
// with the selected element as root
|
// with the selected element as root
|
||||||
|
@ -2313,13 +2128,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the thread execution is terminated. If yes, a
|
// check if the thread execution is terminated. If yes, a
|
||||||
// new
|
// new thread is started otherwise no because the thread in
|
||||||
// thread is started otherwise no because the thread in
|
// running state will also serve this request received in the queue.
|
||||||
// running
|
|
||||||
// state will also serve this request received in the queue.
|
|
||||||
// The thread will run in backgroung to load the data
|
// The thread will run in backgroung to load the data
|
||||||
// related to
|
// related to the subtree with the item selected as root.
|
||||||
// the subtree with the item selected as root.
|
|
||||||
if(requestToAddInQueue==true){
|
if(requestToAddInQueue==true){
|
||||||
if (isThreadExecutionFinished()) {
|
if (isThreadExecutionFinished()) {
|
||||||
logger.info("dbmanager-> Starting the launch of the Thread DataLoader execution");
|
logger.info("dbmanager-> Starting the launch of the Thread DataLoader execution");
|
||||||
|
@ -2327,14 +2139,15 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
Thread t = new Thread(dataLoader);
|
Thread t = new Thread(dataLoader);
|
||||||
t.start();
|
t.start();
|
||||||
} else {
|
} else {
|
||||||
logger.info("dbmanager-> The Thread DataLoader is already running");
|
logger.info("dbmanager-> The Thread DataLoader is already running. Tree Refresh request put in Queue");
|
||||||
queue.offer(dataQueue);
|
queue.offer(dataQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
|
||||||
logger.trace("dbmanager-> Data of the node is not in cache");
|
|
||||||
}
|
}
|
||||||
|
// else{
|
||||||
|
// logger.trace("dbmanager-> Data of the node is not in cache");
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -2360,7 +2173,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
Object value = null;
|
Object value = null;
|
||||||
if (dataFromCache != null) {
|
if (dataFromCache != null) {
|
||||||
logger.info("dbmanager-> Data is in cache");
|
// logger.info("dbmanager-> Data is in cache");
|
||||||
|
|
||||||
value = dataFromCache.getObjectValue();
|
value = dataFromCache.getObjectValue();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -2371,8 +2184,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
List<FileModel> resources = (List<FileModel>) value;
|
List<FileModel> resources = (List<FileModel>) value;
|
||||||
// refresh cache
|
// refresh cache
|
||||||
refreshCache(key);
|
refreshCache(key);
|
||||||
logger.trace("dbmanager-> element: " + ElementType
|
// logger.trace("dbmanager-> element: " + ElementType
|
||||||
+ " with key: " + key + " removed in cache");
|
// + " with key: " + key + " removed in cache");
|
||||||
// apply the refresh on children
|
// apply the refresh on children
|
||||||
for (int i = 0; i < resources.size(); i++) {
|
for (int i = 0; i < resources.size(); i++) {
|
||||||
key = scope + resources.get(i).getName();
|
key = scope + resources.get(i).getName();
|
||||||
|
@ -2385,8 +2198,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
LinkedHashMap<String, FileModel> DBdata = (LinkedHashMap<String, FileModel>) value;
|
LinkedHashMap<String, FileModel> DBdata = (LinkedHashMap<String, FileModel>) value;
|
||||||
// refresh cache
|
// refresh cache
|
||||||
refreshCache(key);
|
refreshCache(key);
|
||||||
logger.trace("dbmanager-> element " + ElementType
|
// logger.trace("dbmanager-> element " + ElementType
|
||||||
+ " with key: " + key + " removed in cache");
|
// + " with key: " + key + " removed in cache");
|
||||||
// apply the refresh on children
|
// apply the refresh on children
|
||||||
HashMap<String, String> DBlist = new HashMap<String, String>();
|
HashMap<String, String> DBlist = new HashMap<String, String>();
|
||||||
|
|
||||||
|
@ -2456,8 +2269,8 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
List<FileModel> schemaList = (List<FileModel>) value;
|
List<FileModel> schemaList = (List<FileModel>) value;
|
||||||
|
|
||||||
refreshCache(key); // refresh schema
|
refreshCache(key); // refresh schema
|
||||||
logger.trace("dbmanager-> element " + ElementType
|
// logger.trace("dbmanager-> element " + ElementType
|
||||||
+ " with key: " + key + " removed in cache");
|
// + " with key: " + key + " removed in cache");
|
||||||
if (DBType.equals(ConstantsPortlet.POSTGRES)) {
|
if (DBType.equals(ConstantsPortlet.POSTGRES)) {
|
||||||
// SCHEMA
|
// SCHEMA
|
||||||
for (int i = 0; i < schemaList.size(); i++) {
|
for (int i = 0; i < schemaList.size(); i++) {
|
||||||
|
@ -2472,69 +2285,47 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// refresh tables
|
// refresh tables
|
||||||
key = key + "";
|
key = key + "";
|
||||||
refreshCache(key); // refresh tables
|
refreshCache(key); // refresh tables
|
||||||
logger.trace("dbmanager-> element " + ElementType
|
// logger.trace("dbmanager-> element " + ElementType
|
||||||
+ " with key: " + key
|
// + " with key: " + key
|
||||||
+ " removed in cache");
|
// + " removed in cache");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ConstantsPortlet.SCHEMA:
|
case ConstantsPortlet.SCHEMA:
|
||||||
// refresh tables (db postgres)
|
// refresh tables (db postgres)
|
||||||
refreshCache(key);
|
refreshCache(key);
|
||||||
logger.trace("dbmanager-> element " + ElementType
|
// logger.trace("dbmanager-> element " + ElementType
|
||||||
+ " with key: " + key + " removed in cache");
|
// + " with key: " + key + " removed in cache");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
logger.info("dbmanager-> Data not in cache");
|
// else {
|
||||||
}
|
// logger.info("dbmanager-> Data not in cache");
|
||||||
|
// }
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("dbmanager-> ", e);
|
logger.error("dbmanager-> ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void refreshCache(String key) throws Exception {
|
private synchronized void refreshCache(String key) throws Exception {
|
||||||
|
|
||||||
logger.info("dbmanager-> disk store path for the cache: " + cacheManager.getDiskStorePath());
|
|
||||||
|
|
||||||
if(cacheManager.cacheExists("DBCache")){
|
if(cacheManager.cacheExists("DBCache")){
|
||||||
|
logger.info("dbmanager-> disk store path for cache: " + cacheManager.getDiskStorePath() +"Cache Status: "+DBCache.getStatus().toString());
|
||||||
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
||||||
logger.info("dbmanager-> Cache Status:"+ Status.STATUS_ALIVE.toString());
|
|
||||||
|
|
||||||
DBCache.remove(key);
|
DBCache.remove(key);
|
||||||
// logger.info("dbmanager-> Element with key: " +key+ " removed.");
|
logger.trace("dbmanager-> element with key: " + key + " removed in cache");
|
||||||
}else{
|
|
||||||
logger.info("dbmanager-> Cache Status:"+ DBCache.getStatus().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try {
|
|
||||||
// System.out.println("SIZE CACHE PRE REMOVING: " + DBCache.getSize());
|
|
||||||
// DBCache.remove(key);
|
|
||||||
// System.out.println("SIZE CACHE POST REMOVING: " + DBCache.getSize());
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// TODO: handle exception
|
|
||||||
// logger.error("dbmanager-> ", e);
|
|
||||||
// throw new Exception("Failure to clear the cache. " + e);
|
|
||||||
// throw new Exception(
|
|
||||||
// "Error in server while loading data. Exception: " + e);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void refreshSubmittedQueryInCache(String key)
|
private synchronized void refreshSubmittedQueryInCache(String key)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
logger.info("dbmanager-> refreshing submitted queries in cache with key:"
|
|
||||||
+ key);
|
|
||||||
|
|
||||||
logger.info("dbmanager-> disk store path for the cache: " + cacheManager.getDiskStorePath());
|
|
||||||
|
|
||||||
if(cacheManager.cacheExists("DBCache")){
|
if(cacheManager.cacheExists("DBCache")){
|
||||||
|
logger.info("dbmanager-> disk store path for cache: " + cacheManager.getDiskStorePath() +"Cache Status: "+DBCache.getStatus().toString());
|
||||||
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
||||||
logger.info("dbmanager-> Cache Status:"+ "STATUS_ALIVE");
|
// logger.info("dbmanager-> Cache Status:"+ "STATUS_ALIVE");
|
||||||
|
|
||||||
List<String> keysInCache = DBCache.getKeys();
|
List<String> keysInCache = DBCache.getKeys();
|
||||||
int listSize = keysInCache.size();
|
int listSize = keysInCache.size();
|
||||||
|
@ -2550,46 +2341,20 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
// remove keys
|
// remove keys
|
||||||
DBCache.removeAll(keysToBeRemoved);
|
DBCache.removeAll(keysToBeRemoved);
|
||||||
// System.out.println("SubmittedQuery refreshed with key: " + key);
|
logger.trace("dbmanager-> submitted queries refreshed in cache with key:"
|
||||||
|
+ key);
|
||||||
}else{
|
|
||||||
logger.info("dbmanager-> Cache Status:"+ DBCache.getStatus().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// List<String> keysInCache = DBCache.getKeys();
|
|
||||||
// int listSize = keysInCache.size();
|
|
||||||
// List<String> keysToBeRemoved = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// // recover keys list that match the key
|
|
||||||
// for (int i = 0; i < listSize; i++) {
|
|
||||||
// if (keysInCache.get(i).startsWith(key)) {
|
|
||||||
// // System.out.println("data removed with key: " +
|
|
||||||
// // keysInCache.get(i));
|
|
||||||
// keysToBeRemoved.add(keysInCache.get(i));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // remove keys
|
|
||||||
// DBCache.removeAll(keysToBeRemoved);
|
|
||||||
// // System.out.println("SubmittedQuery refreshed with key: " + key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void refreshSamplingsInCache(
|
private synchronized void refreshSamplingsInCache(
|
||||||
String keyUsedForSamplingsRefresh,
|
String keyUsedForSamplingsRefresh,
|
||||||
String keyUsedForSmartSamplingRefresh) throws Exception {
|
String keyUsedForSmartSamplingRefresh) throws Exception {
|
||||||
|
|
||||||
logger.info("dbmanager-> refreshing samplings and smart sampling in cache with keys: "
|
|
||||||
+ keyUsedForSamplingsRefresh
|
|
||||||
+ " "
|
|
||||||
+ keyUsedForSmartSamplingRefresh);
|
|
||||||
|
|
||||||
logger.info("dbmanager-> disk store path for the cache: " + cacheManager.getDiskStorePath());
|
|
||||||
|
|
||||||
|
|
||||||
if(cacheManager.cacheExists("DBCache")){
|
if(cacheManager.cacheExists("DBCache")){
|
||||||
|
logger.info("dbmanager-> disk store path for cache: " + cacheManager.getDiskStorePath() +"Cache Status: "+DBCache.getStatus().toString());
|
||||||
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
if (DBCache.getStatus().toString().equals(Status.STATUS_ALIVE.toString())){
|
||||||
logger.info("dbmanager-> Cache Status:"+ "STATUS_ALIVE");
|
|
||||||
|
|
||||||
List<String> keysInCache = DBCache.getKeys();
|
List<String> keysInCache = DBCache.getKeys();
|
||||||
int listSize = keysInCache.size();
|
int listSize = keysInCache.size();
|
||||||
List<String> keysToBeRemoved = new ArrayList<>();
|
List<String> keysToBeRemoved = new ArrayList<>();
|
||||||
|
@ -2604,31 +2369,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
// remove keys
|
// remove keys
|
||||||
DBCache.removeAll(keysToBeRemoved);
|
DBCache.removeAll(keysToBeRemoved);
|
||||||
// System.out.println("Samplings refreshed with keys: "
|
logger.trace("dbmanager-> samplings and smart sampling refreshed in cache with keys: "
|
||||||
// + keyUsedForSamplingsRefresh + " "
|
+ keyUsedForSamplingsRefresh
|
||||||
// + keyUsedForSmartSamplingRefresh);
|
+ " "
|
||||||
}else{
|
+ keyUsedForSmartSamplingRefresh);
|
||||||
logger.info("dbmanager-> Cache Status:"+ DBCache.getStatus().toString());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// List<String> keysInCache = DBCache.getKeys();
|
|
||||||
// int listSize = keysInCache.size();
|
|
||||||
// List<String> keysToBeRemoved = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// // recover keys list that match the key
|
|
||||||
// for (int i = 0; i < listSize; i++) {
|
|
||||||
// if ((keysInCache.get(i).startsWith(keyUsedForSamplingsRefresh))
|
|
||||||
// || (keysInCache.get(i)
|
|
||||||
// .startsWith(keyUsedForSmartSamplingRefresh))) {
|
|
||||||
// keysToBeRemoved.add(keysInCache.get(i));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // remove keys
|
|
||||||
// DBCache.removeAll(keysToBeRemoved);
|
|
||||||
// // System.out.println("Samplings refreshed with keys: "
|
|
||||||
// // + keyUsedForSamplingsRefresh + " "
|
|
||||||
// // + keyUsedForSmartSamplingRefresh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String storeResultIntoCSVFile(List<Result> result, String n)
|
private String storeResultIntoCSVFile(List<Result> result, String n)
|
||||||
|
@ -2775,7 +2521,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
key, outputParameters);
|
key, outputParameters);
|
||||||
|
|
||||||
insertDataIntoCache(dataToCache);
|
insertDataIntoCache(dataToCache);
|
||||||
logger.trace("dbmanager-> element added in cache with key: " + key);
|
// logger.trace("dbmanager-> element added in cache with key: " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outputParameters;
|
return outputParameters;
|
||||||
|
@ -2868,7 +2614,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
key, outputParameters);
|
key, outputParameters);
|
||||||
|
|
||||||
insertDataIntoCache(dataToCache);
|
insertDataIntoCache(dataToCache);
|
||||||
logger.trace("dbmanager-> element added in cache with key: " + key);
|
// logger.trace("dbmanager-> element added in cache with key: " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outputParameters;
|
return outputParameters;
|
||||||
|
@ -2974,7 +2720,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
key, outputParameters);
|
key, outputParameters);
|
||||||
|
|
||||||
insertDataIntoCache(dataToCache);
|
insertDataIntoCache(dataToCache);
|
||||||
logger.trace("dbmanager-> element added in cache with key: " + key);
|
// logger.trace("dbmanager-> element added in cache with key: " + key);
|
||||||
// DBCache.put(dataToCache);
|
// DBCache.put(dataToCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3096,7 +2842,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
key, outputParameters);
|
key, outputParameters);
|
||||||
|
|
||||||
insertDataIntoCache(dataToCache);
|
insertDataIntoCache(dataToCache);
|
||||||
logger.trace("dbmanager-> element added in cache with key: " + key);
|
// logger.trace("dbmanager-> element added in cache with key: " + key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue