Exemple #1
0
  def prepare_service(self):

    config = systemsettings()
    if not config.configured():
      # For now assume JSON file
      config.applyConfig(self._name_app + '.json')

    # Default Settings
    home = os.getenv('HOME')
    alluxio_home = os.path.join(home, 'pkg', 'alluxio-1.0.0')
    self.workdir   = config.WORKDIR  #ini.get('workdir', '.')
    self.ramdisk = tempfile.mkdtemp()
    self.hdd = '/tmp/alluxio/hdd'
    os.environ['ALLUXIO_HOME'] = alluxio_home
    if self._role == 'SLAVE':
      os.environ['ALLUXIO_MASTER_ADDRESS'] = self.master
      self.launchcmd = 'alluxio-start.sh worker Mount -f'
    else:
      os.environ['ALLUXIO_MASTER_ADDRESS'] = 'localhost'
      self.launchcmd = 'alluxio-start.sh local -f'

    os.environ['DEFAULT_LIBEXEC_DIR'] = os.path.join(alluxio_home, 'libexec')
    os.environ['ALLUXIO_RAM_FOLDER'] = self.ramdisk
    os.environ['ALLUXIO_UNDERFS_ADDRESS'] = config.ALLUXIO_UNDERFS
    os.environ['ALLUXIO_WORKER_MEMORY_SIZE'] = config.ALLUXIO_WORKER_MEM

    if not os.path.exists(config.ALLUXIO_UNDERFS):
      os.mkdir(config.ALLUXIO_UNDERFS)

    if not os.path.exists(self.hdd):
      os.mkdir(self.hdd)

    # logdir = os.path.join(alluxio_home, 'logs', self._host)
    # if not os.path.exists(logdir):
    #   os.mkdir(logdir)
    # os.environ['ALLUXIO_LOGS_DIR'] = logdir

    self.MONITOR_WAIT_DELAY    = config.MONITOR_WAIT_DELAY #ini.get('monitor_wait_delay', 30)
    self.CATALOG_IDLE_THETA    = config.CATALOG_IDLE_THETA #ini.get('catalog_idle_theta', 300)
    self.CATALOG_STARTUP_DELAY = config.CATALOG_STARTUP_DELAY #ini.get('catalog_startup_delay', 10)

    logging.debug("Checking ENV:")
    logging.debug('  ALLUXIO_HOME=%s', executecmd('echo $ALLUXIO_HOME'))
    logging.debug('  ALLUXIO_MASTER_ADDRESS=%s', executecmd('echo $ALLUXIO_MASTER_ADDRESS'))
    logging.debug('  ALLUXIO_RAM_FOLDER=%s', executecmd('echo $ALLUXIO_RAM_FOLDER'))

    executecmd('alluxio format')

    self.shutdowncmd = 'alluxio-stop.sh all'
Exemple #2
0
  def ls(cls, destdir=''):
    args = ['/' + destdir]
    cmd = package_alluxio_cmd('ls', args)
    out = executecmd(cmd)


    return out
Exemple #3
0
 def ping(self, host='localhost', port=None):
   """Heartbeat to the local Redis Server
   """
   # TODO: curl cmd to web U/I
   cmd = 'alluxio fs touch /ping'
   results = executecmd(cmd)
   check = results.split()
   if len(check) == 0:
     return False
   return (check[0] == '/ping')
Exemple #4
0
 def ping(self, host='localhost', port=None):
   """Heartbeat to the local Redis Server
   """
   # TODO: Should wrap around try/catch and propagate an IO exception
   while True:
     if port is None:
       port = self._port
     ping_cmd = 'redis-cli -h %s -p %s ping' % (host, port)
     pong = executecmd(ping_cmd).strip()
     self.ping_count += 1
     if 'LOADING' in pong:
       time.sleep(1)
       continue
     break
   return (pong == 'PONG')
Exemple #5
0
 def ping(self, host='localhost', port=None):
     """Heartbeat to the local Redis Server
 """
     # TODO: Should wrap around try/catch and propagate an IO exception
     while True:
         if port is None:
             port = self._port
         ping_cmd = 'redis-cli -h %s -p %s ping' % (host, port)
         pong = executecmd(ping_cmd).strip()
         self.ping_count += 1
         if 'LOADING' in pong:
             time.sleep(1)
             continue
         break
     return (pong == 'PONG')
Exemple #6
0
 def touch(self, filename):
   cmd = 'alluxio fs mkdir /%s' % (filename)
   logging.debug('[AlxClient] touch cmd: %s', cmd)
   contents = executecmd(cmd)
   return (contents == '/%s has been created' % filename)
Exemple #7
0
 def mkdir(self, dirname):
   cmd = 'alluxio fs mkdir /%s' % (dirname)
   logging.debug('[AlxClient] mkdir cmd: %s', cmd)
   contents = executecmd(cmd)
   return contents
Exemple #8
0
 def cp(self, remotefile, destdir):
   cmd = 'alluxio fs copyToLocal /%s %s/%s' % (remotefile, destdir, remotefile)
   logging.debug('[AlxClient] cp cmd: %s', cmd)
   contents = executecmd(cmd)
   logging.debug('CP results: %s', contents)
   return contents
Exemple #9
0
 def get(self, destdir):
   cmd = 'alluxio fs cat %s /%s' % (localfile, destdir)
   contents = executecmd(cmd)
   return contents
Exemple #10
0
 def put(self, localfile, destdir=''):
   if not os.path.exists(localfile):
     logging.error('[AlluxioClient] File does not exist: %s', localfile)
     return
   cmd = 'alluxio fs copyFromLocal %s /%s' % (localfile, destdir)
   out = executecmd(cmd)