text: 'use strict';
  var k8sutil = require('./k8sutil');
  var logger = require('../plugins/logutil').getLogger('icpcontroller.js');
  var EventEmitter = require('events').EventEmitter;
  var event = new EventEmitter();
  var count = 1;
  
  var intervalObj;
  
  function ICPController() {
      intervalObj = setInterval(controlConn, 1000);
      intervalObj.unref();
  }
  
  function controlConn() {
      count++;
      if (count > 10) {
          logger.debug('Emit conn_ready_on_icp event with timeout.');
          event.emit('conn_ready_on_icp', 1);
          clearInterval(intervalObj);
          return;
      }
      logger.debug('check ICp evn.', k8sutil.getIngressUrl());
      if (!k8sutil.getIngressUrl()) {
          return;
      }
      if (k8sutil.getNodeIPs().length <= 0) {
          return;
      }
      logger.debug('Emit conn_ready_on_icp event.');
      event.emit('conn_ready_on_icp', 0);
      clearInterval(intervalObj);
  
  };
  
  ICPController.prototype.getEvent = function getEvent() {
      return event;
  };
  
  ICPController.prototype.stop = function() {
      logger.debug('Stop ICPController.');
      if (intervalObj) {
          clearInterval(intervalObj);
      }
  };
  
  module.exports = new ICPController();
  