/** * Returns the BlockInfo for a block id. * * @param blockId the block id to get the BlockInfo for * @return the BlockInfo * @throws IOException if an I/O error occurs */ public synchronized BlockInfo getBlockInfo(long blockId) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getBlockInfo(blockId); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Gets the total Tachyon capacity in bytes, on all the tiers of all the workers. * * @return total capacity in bytes * @throws IOException if an I/O error occurs */ public synchronized long getCapacityBytes() throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getCapacityBytes(); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Gets the total amount of used space in bytes, on all the tiers of all the workers. * * @return amount of used space in bytes * @throws IOException if an I/O error occurs */ public synchronized long getUsedBytes() throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getUsedBytes(); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); } }
/** * The method the worker should execute to register with the block master. * * @param workerId the worker id of the worker registering * @param totalBytesOnTiers list of total bytes on each tier * @param usedBytesOnTiers list of the used byes on each tier * @param currentBlocksOnTiers a mapping of each storage dir, to all the blocks on that storage * dir * @throws IOException if an I/O error occurs or the workerId doesn't exist */ // TODO: rename to workerBlockReport or workerInitialize? public synchronized void register(long workerId, List<Long> totalBytesOnTiers, List<Long> usedBytesOnTiers, Map<Long, List<Long>> currentBlocksOnTiers) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { mClient.workerRegister(workerId, totalBytesOnTiers, usedBytesOnTiers, currentBlocksOnTiers); return; } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); } }
/** * Commits a block on a worker. * * @param workerId the worker id committing the block * @param usedBytesOnTier the amount of used bytes on the tier the block is committing to * @param tier the tier the block is being committed to * @param blockId the block id being committed * @param length the length of the block being committed * @throws IOException if an I/O error occurs */ public synchronized void commitBlock(long workerId, long usedBytesOnTier, int tier, long blockId, long length) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { mClient.workerCommitBlock(workerId, usedBytesOnTier, tier, blockId, length); return; } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Returns a worker id for a workers net address. * * @param address the net address to get a worker id for * @return a worker id * @throws IOException if an I/O error occurs */ // TODO: rename to workerRegister? public synchronized long getId(NetAddress address) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.workerGetWorkerId(address); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * The method the worker should periodically execute to heartbeat back to the master. * * @param workerId the worker id * @param usedBytesOnTiers a list of used bytes on each tier * @param removedBlocks a list of block removed from this worker * @param addedBlocks the added blocks for each storage dir. It maps storage dir id, to a list of * added block for that storage dir. * @return an optional command for the worker to execute * @throws IOException if an I/O error occurs */ public synchronized Command heartbeat(long workerId, List<Long> usedBytesOnTiers, List<Long> removedBlocks, Map<Long, List<Long>> addedBlocks) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.workerHeartbeat(workerId, usedBytesOnTiers, removedBlocks, addedBlocks); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
/** * Gets the info of a list of workers. * * @return A list of worker info returned by master * @throws IOException if an I/O error occurs */ public synchronized List<WorkerInfo> getWorkerInfoList() throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return mClient.getWorkerInfoList(); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); }
@Override protected void afterConnect() { mClient = new BlockMasterService.Client(mProtocol); }
@Override protected void afterConnect() { mClient = new BlockMasterService.Client(mProtocol); }