Script To Access Private

From Observer GigaFlow Support | VIAVI Solutions Inc.
Jump to: navigation, search

Private field access

var cm = actions.ros.getClass().getDeclaredField("servers");
cm.setAccessible(true);
log.warn(cm)
 var value = cm.get(actions.ros);
log.warn(value)


var ep = actions.ros.zeromqEndpoint
log.warn(ep);
log.warn("CZMQtotalStoredSize:"+ep.totalStoredSize)
log.warn("CZMQgetPersistSize:"+ep.getPersistSize())
log.warn("CZMQavailablefiles:"+ep.availablefiles.size())
log.warn("CZMQgetZEROMQExpireMessageDuration:"+actions.ros.getZEROMQExpireMessageDuration())
var cm = actions.ros.zeromqEndpoint.getClass().getDeclaredField("cm");
log.warn(cm)
cm.setAccessible(true);
log.warn(cm)
var cm2 = actions.ros.zeromqEndpoint.getCM() ;
//log.warn(cm2)
//log.warn(cm2.getClass().getDeclaredMethods().length)
//log.warn(cm2.class.getDeclaredMethods().length)
//log.warn(cm2.getDeclaredMethods().length)
//log.warn(cm2.class.getDeclaredMethods())
//var methods=cm2.class.getDeclaredMethods()
//log.warn(methods)
//  for (var i=0;i<methods.length;i++) {
//    var method=methods[i]
//  log.warn(method.getName());
//  }
log.warn(cm2.getClass().getDeclaredMethod("removeFile"))
log.warn(cm2.class.getDeclaredMethod("removeFile"))
 var privateMethod= cm2.class.getDeclaredMethod("removeFile");

log.warn(privateMethod);

            // Set the accessibility as true
            privateMethod.setAccessible(true);
while ((ep.totalStoredSize/1000000)>actions.ros.getZEROMQExpireMessageDuration()){
     log.warn("CZMQ remove files"+(ep.totalStoredSize/1000000)+">"+actions.ros.getZEROMQExpireMessageDuration()+ " "+((ep.totalStoredSize/1000000)>actions.ros.getZEROMQExpireMessageDuration()))
     privateMethod.invoke(cm2)
}
//else{
 //    log.warn("CZMQ not remove files"+(ep.totalStoredSize/1000000)+">"+actions.ros.getZEROMQExpireMessageDuration()+ " "+((ep.totalStoredSize/1000000)>actions.ros.getZEROMQExpireMessageDuration()))
//}
//for (var i=0;i<1000;i++){
//privateMethod.invoke(cm2)
//}
log.warn("CZMQ Called")
log.warn(cm)
log.warn("CZMQtotalStoredSize:"+ep.totalStoredSize)
log.warn("CZMQgetPersistSize:"+ep.getPersistSize())
log.warn("CZMQavailablefiles:"+ep.availablefiles.size())
//var thisOldestAllowedTime = cm.getClass().getDeclaredField("thisOldestAllowedTime");
//var thisOldestAllowedTime = cm.getClass().getDeclaredField("thisOldestAllowedTime");
//var oldestAllowedTime = cm.getClass().getDeclaredField("oldestAllowedTime");
//thisOldestAllowedTime.setAccessible(true);
//oldestAllowedTime.setAccessible(true);
//log.warn(cm)
//log.warn("cm.thisOldestAllowedTime:"+thisOldestAllowedTime)
//log.warn("cm.oldestAllowedTime:"+oldestAllowedTime)