This commit is contained in:
Gianpaolo Coro 2012-06-08 15:37:57 +00:00
parent c65adbc7f3
commit 8d4d96013c
3 changed files with 16 additions and 6 deletions

View File

@ -35,6 +35,7 @@ public class LocalSplitGenerator implements Generator {
private SessionFactory dbHibConnection;
private boolean stopInterrupt;
private boolean flushInterrupt;
private boolean forceflush;
private SpatialProbabilityDistributionTable distributionModel;
private int processedSpeciesCounter;
private int spaceVectorsNumber;
@ -107,6 +108,7 @@ public class LocalSplitGenerator implements Generator {
AnalysisLogger.setLogger(config.getConfigPath() + AlgorithmConfiguration.defaultLoggerFile);
stopInterrupt = false;
flushInterrupt = false;
forceflush=false;
initDBSession();
try {
initModel();
@ -282,7 +284,7 @@ public class LocalSplitGenerator implements Generator {
long computationT0 = System.currentTimeMillis();
// pre process for single species
distributionModel.singleStepPreprocess(species, spaceVectorsNumber);
AnalysisLogger.getLogger().trace("-> species " + distributionModel.getMainInfoID(species) + " - n. " + (processedSpeciesCounter + 1));
AnalysisLogger.getLogger().trace("-------------------------------------------------> species " + distributionModel.getMainInfoID(species) + " - n. " + (processedSpeciesCounter + 1));
// CALCULATION CORE
for (int k = 0; k < numOfChunks; k++) {
// get the starting index
@ -330,6 +332,7 @@ public class LocalSplitGenerator implements Generator {
// post process for single species
distributionModel.singleStepPostprocess(species, spaceVectorsNumber);
// if the process was stopped then interrupt the processing
if (stopInterrupt)
break;
}
@ -415,11 +418,18 @@ public class LocalSplitGenerator implements Generator {
public void run() {
try {
if (stopInterrupt) {
if (forceflush){
AnalysisLogger.getLogger().trace("\t...flushing on db");
// flush the objects
flushBuffer();
AnalysisLogger.getLogger().trace("\t...finished flushing on db");
forceflush=false;
}
if (stopInterrupt) {
AnalysisLogger.getLogger().trace("\t...finally flushing on db");
// flush the objects
flushBuffer();
AnalysisLogger.getLogger().trace("\t...finished finally flushing on db");
flushInterrupt = true;
this.cancel();
} else if ((probabilityBuffer != null) && (probabilityBuffer.size() > AlgorithmConfiguration.chunkSize)) {
@ -442,7 +452,7 @@ public class LocalSplitGenerator implements Generator {
writeOnDB(AlgorithmConfiguration.chunkSize);
writeOnDB(probabilityBuffer.size());
}
}
private void writeOnDB(int endIndex) {
@ -450,7 +460,6 @@ public class LocalSplitGenerator implements Generator {
if (endIndex > 0) {
StringBuffer sb = new StringBuffer();
// AnalysisLogger.getLogger().trace("writeOnDB()->PROBABILITIES BUFFER SIZE DELETION");
for (int i = 0; i < endIndex; i++) {
sb.append("(" + distributionModel.filterProbabiltyRow(probabilityBuffer.poll()) + ")");
if (i < endIndex - 1) {
@ -458,6 +467,7 @@ public class LocalSplitGenerator implements Generator {
}
}
String insertionString = String.format(probabilityInsertionStatement, config.getParam("DistributionTable"), sb.toString());
try {

View File

@ -167,7 +167,7 @@ public class AquamapsSuitable implements SpatialProbabilityDistributionTable{
@Override
public boolean isSynchronousProbabilityWrite() {
return false;
return true;
}
@Override

View File

@ -10,7 +10,7 @@ public class PerformanceTests {
String configPath = "./cfg/";
String csquareTable = "hcaf_d";
String preprocessedTable = "maxminlat_hspen";
String envelopeTable = "hspen";
String envelopeTable = "hspen_mini_1";
int numberOfResources = 4;
String speciesCode = "Fis-22747";
String userName = "gianpaolo.coro";