예제 #1
0
 /**
  * Create a data server with direct access to worker storage.
  *
  * @param address The address of the data server.
  * @param workerStorage The handler of the directly accessed worker storage.
  */
 public DataServer(InetSocketAddress address, WorkerStorage workerStorage) {
   LOG.info("Starting DataServer @ " + address);
   mAddress = address;
   mBlocksLocker = new BlocksLocker(workerStorage, Users.sDATASERVER_USER_ID);
   try {
     mSelector = initSelector();
   } catch (IOException e) {
     LOG.error(e.getMessage() + mAddress, e);
     CommonUtils.runtimeException(e);
   }
 }
예제 #2
0
파일: Users.java 프로젝트: TheTao/tachyon
  /**
   * Remove <code> userId </code> from user pool.
   *
   * @param userId The user to be removed.
   * @return The space quote the removed user occupied in bytes.
   */
  public synchronized long removeUser(long userId) {
    StringBuilder sb = new StringBuilder("Trying to cleanup user " + userId + " : ");
    UserInfo tUser = null;
    synchronized (USERS) {
      tUser = USERS.get(userId);
      USERS.remove(userId);
    }

    long returnedBytes = 0;
    if (tUser == null) {
      returnedBytes = 0;
      sb.append(" The user does not exist in the worker's current user pool.");
    } else {
      returnedBytes = tUser.getOwnBytes();
      String folder = getUserTempFolder(userId);
      sb.append(
          " The user returns "
              + returnedBytes
              + " bytes. Remove the user's folder "
              + folder
              + " ;");
      try {
        FileUtils.deleteDirectory(new File(folder));
      } catch (IOException e) {
        CommonUtils.runtimeException(e);
      }

      folder = getUserUnderfsTempFolder(userId);
      sb.append(" Also remove users underfs folder " + folder);
      try {
        UnderFileSystem.get(CommonConf.get().UNDERFS_ADDRESS).delete(folder, true);
      } catch (IOException e) {
        LOG.error(e);
      }
    }

    LOG.info(sb.toString());
    return returnedBytes;
  }