Vishwas Vishwas - 1 year ago 161
R Question

How to resolve exception "eval failed, request status: error code: 127" in R and Java?

I am using R and Java for displaying prediction.

I have data of 5 hours. I want to predict 5th-hour data from four hours' data (memory with respect to date).
By using 4 hours' data I am creating new collection and inserting the 5th hour's predicted data in a new collection. But I am getting the following error:

The Exception is eval failed, request status: error code: 127
org.rosuda.REngine.Rserve.RserveException: eval failed, request status: error code: 127
at org.rosuda.REngine.Rserve.RConnection.eval(
at scheduler.scheduler.predictions.getPredictionsofData(
at pack.GetCollectionMultithreaded.getPredictionAndInsert(
at pack.GetCollectionMultithreaded.runCustomerListAndPredictionEvery5Min(
at pack.GetCollectionMultithreaded.main(

Here is code:

public class predictions {

public void getPredictionsofData(DB dbObj){
FileInputStream fis = null;

DBCollection network_device_realtime = dbObj.getCollection("mycollectionname");
DBObject return_dobject = null;

// For Network device1 realtime
List<String> listOfIps = network_device_realtime.distinct("hostId");
RConnection c = new RConnection(Rhost,Rport);
c.eval(" db <- mongoDbConnect('demo','localhost',27017)");
for( int i= 0 ;i<listOfIps.size(); i++){
float my_predicted_date = 0 ;
BasicDBObject criteria = new BasicDBObject();
BasicDBObject projections = new BasicDBObject();
projections.put("runtimeMillis", 1);
DBCursor cursor = network_device_realtime.find(criteria,projections).sort(new BasicDBObject("runtimeMillis",-1)).limit(1);
while(cursor.hasNext()) {
BasicDBObject obj = (BasicDBObject);
my_predicted_date = (float) obj.getDouble("runtimeMillis");
// Set predict date for testing purpose
my_predicted_date = my_predicted_date-(4*60*60*1000);

// for calculating predictions next 24 hrs
for(int j = 1; j <= 12 ;j++){
my_predicted_date = my_predicted_date+(300*1000);//j*60*60*1000calculating next hrs data
System.out.println("Date Gen in network: " +my_predicted_date);

c.eval("query <- dbGetQuery(db,'"+network_device_realtime+"','{\"hostId\":\""+listOfIps.get(i)+"\",\"cpuUtilization\":{\"$ne\":\"null\"},\"memoryUtilization\":{\"$ne\":\"NaN\"},\"runtimeMillis\":{\"$ne\":\"null\"}}')");

c.eval("date <- query$runtimeMillis");
c.eval("host_id <- query$hostId");
c.eval("cpu <- query$cpuUtilization ");
c.eval("memory <- query$memoryutil");
c.eval("training<- all_data");

c.eval("df <- data.frame(date="+my_predicted_date+ ")");
REXP memory_predictions= c.eval("predictions");
c.eval("df <- data.frame(date="+my_predicted_date+ ")");
REXP cpu_predictions= c.eval("predictions");
String json = "";
json ="{\"memoryUtilization\":"+ memory_predictions + ",\"cpuUtilization\" : "+ cpu_predictions + ",\"hostId\" : \""+ listOfIps.get(i) + "\",\"runtimeMillis\":"+my_predicted_date+",\"deviceType\":\"snmp\"}";
return_dobject=(DBObject) JSON.parse(json);
catch(Exception e){
System.out.println("ERROR: In Connection to R ");
System.out.println("The Exception is "+ e.getMessage());

In this code I am getting error on this line:


How do I resolve this error?

Answer Source

This exception mainly occurs due to data in statement


contains null.

This is might be due to bug in your data framing. Please check it once.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download