AttributeType reliability = null;
if (!optUtil.disableDBCaching) // will not check for cached execution results
{
System.out.println(" checking for cached execution result in the DB");
ModelExecutionResult res = super.checkExecutionResult(model, daoFactory, optUtil.convertResourceMapToSet(inputs), null, null);
if (res != null)
{
System.out.println(" found a model execution result, which is returned");
return res;
}
System.out.println(" did not find a matching existing execution result in the DB");
}
System.out.println(" executing " + model.getName());
// Add some sleep time to simulate some wait time if a model had been executed
Thread.sleep(executionTime);
// This would be a point at which an application model would be executed,
// which could be done with the ModelExecuter class in pes-common.
// Since we do not provide an excutable application model, this sample
// wrapper calculates a reliability (probability of achieving some QoS
// constraints) based on a simple hard coded formula that has been invented
// for this simple test.
output = optUtil.roundDouble(getReliability(inputs), 3);
System.out.println(" reliability calculated as " + output);
// create an output set for the ModelExecutionResult object
outputs = new HashSet<AttributeType>();
reliability = new AttributeType();
reliability.setName("reliability");
reliability.setType(BasicType.convert("double"));
reliability.addAValue(new ValueType(String.valueOf(output), MetricType.DEFAULT));
outputs.add(reliability);
if (!optUtil.disableDBCaching)
return super.saveExecutionResult(model, daoFactory, optUtil.convertResourceMapToSet(inputs), null, null, outputs, null);
else
return new ModelExecutionResult(model, optUtil.convertResourceMapToSet(inputs), outputs);
}