示例#1
0
 /**
  * Creates a new instance of {@link DataServerHandler}.
  *
  * @param blockWorker the block worker handle
  * @param tachyonConf Tachyon configuration
  */
 public DataServerHandler(final BlockWorker blockWorker, TachyonConf tachyonConf) {
   mBlockWorker = Preconditions.checkNotNull(blockWorker);
   mTachyonConf = Preconditions.checkNotNull(tachyonConf);
   mStorageTierAssoc = new WorkerStorageTierAssoc(mTachyonConf);
   mTransferType =
       mTachyonConf.getEnum(
           Constants.WORKER_NETWORK_NETTY_FILE_TRANSFER_TYPE, FileTransferType.class);
 }
示例#2
0
  private ServerBootstrap createBootstrap() {
    final ServerBootstrap boot =
        createBootstrapOfType(
            mTachyonConf.getEnum(Constants.WORKER_NETWORK_NETTY_CHANNEL, ChannelType.class));

    // use pooled buffers
    boot.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
    boot.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);

    // set write buffer
    // this is the default, but its recommended to set it in case of change in future netty.
    boot.childOption(
        ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK,
        (int) mTachyonConf.getBytes(Constants.WORKER_NETWORK_NETTY_WATERMARK_HIGH));
    boot.childOption(
        ChannelOption.WRITE_BUFFER_LOW_WATER_MARK,
        (int) mTachyonConf.getBytes(Constants.WORKER_NETWORK_NETTY_WATERMARK_LOW));

    // more buffer settings on Netty socket option, one can tune them by specifying
    // properties, e.g.:
    // tachyon.worker.network.netty.backlog=50
    // tachyon.worker.network.netty.buffer.send=64KB
    // tachyon.worker.network.netty.buffer.receive=64KB
    if (mTachyonConf.containsKey(Constants.WORKER_NETWORK_NETTY_BACKLOG)) {
      boot.option(
          ChannelOption.SO_BACKLOG, mTachyonConf.getInt(Constants.WORKER_NETWORK_NETTY_BACKLOG));
    }
    if (mTachyonConf.containsKey(Constants.WORKER_NETWORK_NETTY_BUFFER_SEND)) {
      boot.option(
          ChannelOption.SO_SNDBUF,
          (int) mTachyonConf.getBytes(Constants.WORKER_NETWORK_NETTY_BUFFER_SEND));
    }
    if (mTachyonConf.containsKey(Constants.WORKER_NETWORK_NETTY_BUFFER_RECEIVE)) {
      boot.option(
          ChannelOption.SO_RCVBUF,
          (int) mTachyonConf.getBytes(Constants.WORKER_NETWORK_NETTY_BUFFER_RECEIVE));
    }
    return boot;
  }
示例#3
0
  /**
   * Logs in based on the LoginModules.
   *
   * @param conf Tachyon configuration
   * @return the login user
   * @throws IOException if login fails
   */
  private static User login(TachyonConf conf) throws IOException {
    AuthType authType = conf.getEnum(Constants.SECURITY_AUTHENTICATION_TYPE, AuthType.class);
    checkSecurityEnabled(authType);

    try {
      Subject subject = new Subject();

      LoginContext loginContext =
          new LoginContext(authType.getAuthName(), subject, null, new TachyonJaasConfiguration());
      loginContext.login();

      Set<User> userSet = subject.getPrincipals(User.class);
      if (userSet.isEmpty()) {
        throw new LoginException("No Tachyon User is found.");
      }
      if (userSet.size() > 1) {
        throw new LoginException("More than one Tachyon User is found");
      }
      return userSet.iterator().next();
    } catch (LoginException e) {
      throw new IOException("Fail to login", e);
    }
  }
示例#4
0
 public DataServerHandler(final BlockDataManager dataManager, TachyonConf tachyonConf) {
   mDataManager = dataManager;
   mTachyonConf = tachyonConf;
   mTransferType =
       mTachyonConf.getEnum(Constants.WORKER_NETTY_FILE_TRANSFER_TYPE, FileTransferType.TRANSFER);
 }