- file properties added in folder webapp/conf to read the param maxBytesLocalHeap at runtime and set the cache with this value in webapp/conf. Heap set to value 500 Mega.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@101519 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
970d4a3180
commit
bf4f59359f
|
@ -5,10 +5,13 @@ import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -100,6 +103,7 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
|
|
||||||
private static int smComputationQuerySamplingNumber;
|
private static int smComputationQuerySamplingNumber;
|
||||||
private static int cacheQuerySamplingHitsNumber;
|
private static int cacheQuerySamplingHitsNumber;
|
||||||
|
private static final String CACHE_MAX_HEAP_SIZE = "CACHE_MAX_HEAP_SIZE";
|
||||||
|
|
||||||
public GWTdbManagerServiceImpl() throws Exception {
|
public GWTdbManagerServiceImpl() throws Exception {
|
||||||
}
|
}
|
||||||
|
@ -193,8 +197,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// config.maxEntriesLocalHeap(10000);
|
// config.maxEntriesLocalHeap(10000);
|
||||||
config.diskExpiryThreadIntervalSeconds(120);
|
config.diskExpiryThreadIntervalSeconds(120);
|
||||||
config.maxBytesLocalDisk(2, MemoryUnit.GIGABYTES);
|
config.maxBytesLocalDisk(2, MemoryUnit.GIGABYTES);
|
||||||
|
long maxHeapSize = readProperty();
|
||||||
// config.maxBytesLocalHeap(200, MemoryUnit.MEGABYTES);
|
// config.maxBytesLocalHeap(200, MemoryUnit.MEGABYTES);
|
||||||
config.maxBytesLocalHeap(2, MemoryUnit.GIGABYTES);
|
config.maxBytesLocalHeap(maxHeapSize, MemoryUnit.MEGABYTES);
|
||||||
|
logger.info("dbmanager-> Max_Bytes_Local_Heap set to value in megabytes: "+ config.getMaxBytesLocalHeap());
|
||||||
|
// config.maxBytesLocalHeap(2, MemoryUnit.GIGABYTES);
|
||||||
config.diskSpoolBufferSizeMB(30);
|
config.diskSpoolBufferSizeMB(30);
|
||||||
config.overflowToDisk(true);
|
config.overflowToDisk(true);
|
||||||
config.diskPersistent(false);
|
config.diskPersistent(false);
|
||||||
|
@ -212,6 +219,23 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
+ e);
|
+ e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long readProperty() throws IOException{
|
||||||
|
Properties props = new Properties();
|
||||||
|
// HttpServletRequest request = this
|
||||||
|
// .getThreadLocalRequest();
|
||||||
|
|
||||||
|
String contextPath = this.getServletContext().getRealPath("");
|
||||||
|
logger.info("dbmanager-> path file config.properties"+ contextPath);
|
||||||
|
String propertyfile = contextPath + File.separator + "conf" + File.separator + "configs.properties";
|
||||||
|
File propsFile = new File(propertyfile);
|
||||||
|
FileInputStream fis = new FileInputStream(propsFile);
|
||||||
|
props.load(fis);
|
||||||
|
String property = props.getProperty(CACHE_MAX_HEAP_SIZE);
|
||||||
|
|
||||||
|
long value = Long.valueOf(property).longValue();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
@ -2741,6 +2765,19 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
||||||
// logger.trace("dbmanager-> element added in cache with key: " + key);
|
// logger.trace("dbmanager-> element added in cache with key: " + key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO ****TO REMOVE
|
||||||
|
if (outputParameters!=null){
|
||||||
|
logger.info("dbmanager-> ***print output ");
|
||||||
|
Set<String> keys = outputParameters.keySet();
|
||||||
|
Object[] array = keys.toArray();
|
||||||
|
|
||||||
|
for (int i=0;i<outputParameters.size();i++){
|
||||||
|
logger.info("dbmanager-> *** " + outputParameters
|
||||||
|
.get(array[i].toString())
|
||||||
|
.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return outputParameters;
|
return outputParameters;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue