Exemplo n.º 1
0
  /**
   * Creates a new instance of {@link FileSystemWorker}.
   *
   * @param blockWorker the block worker handle
   * @param workerId a reference to the id of this worker
   * @throws IOException if an I/O error occurs
   */
  public DefaultFileSystemWorker(BlockWorker blockWorker, AtomicReference<Long> workerId)
      throws IOException {
    super(
        Executors.newFixedThreadPool(
            3, ThreadFactoryUtils.build("file-system-worker-heartbeat-%d", true)));
    mWorkerId = workerId;
    mSessions = new Sessions();
    UnderFileSystem ufs = UnderFileSystem.get(Configuration.get(PropertyKey.UNDERFS_ADDRESS));
    mFileDataManager =
        new FileDataManager(
            Preconditions.checkNotNull(blockWorker),
            ufs,
            RateLimiter.create(Configuration.getBytes(PropertyKey.WORKER_FILE_PERSIST_RATE_LIMIT)));
    mUnderFileSystemManager = new UnderFileSystemManager();

    // Setup AbstractMasterClient
    mFileSystemMasterWorkerClient =
        new FileSystemMasterClient(NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC));

    // Setup session cleaner
    mSessionCleaner =
        new SessionCleaner(
            new SessionCleanupCallback() {
              /** Cleans up after sessions, to prevent zombie sessions holding ufs resources. */
              @Override
              public void cleanupSessions() {
                for (long session : mSessions.getTimedOutSessions()) {
                  mSessions.removeSession(session);
                  mUnderFileSystemManager.cleanupSession(session);
                }
              }
            });

    mServiceHandler = new FileSystemWorkerClientServiceHandler(this);
  }
Exemplo n.º 2
0
 /**
  * Creates a new instance of {@link BlockMaster} with the default {@link MasterSource}.
  *
  * @param masterContext context for the master
  * @param journal the journal to use for tracking master operations
  */
 public BlockMaster(MasterContext masterContext, Journal journal) {
   super(
       masterContext,
       journal,
       new SystemClock(),
       Executors.newFixedThreadPool(2, ThreadFactoryUtils.build("BlockMaster-%d", true)));
 }