/** * Gets the {@link RawTableInfo} associated with the given path. * * @param path the path of the table * @return the table info * @throws IOException when operation fails */ public synchronized RawTableInfo getClientRawTableInfo(final TachyonURI path) throws IOException { return retryRPC(new RpcCallable<RawTableInfo>() { @Override public RawTableInfo call() throws TException { return mClient.getClientRawTableInfoByPath(path.getPath()); } }); }
/** * Updates the RawTable's meta data. * * Currently unsupported. * * @param id the raw table's id * @param metadata the new meta data * @throws IOException if the underlying master RPC fails */ public synchronized void updateRawTableMetadata(long id, ByteBuffer metadata) throws IOException { mRawTableMasterClient.updateRawTableMetadata(id, metadata); }
/** * Gets <code>RawTable</code> by id. * * Currently unsupported. * * @param id the id of the raw table * @return the RawTable * @throws IOException if the underlying master RPC fails */ public synchronized RawTable getRawTable(long id) throws IOException { RawTableInfo rawTableInfo = mRawTableMasterClient.getClientRawTableInfo(id); return new RawTable(this, rawTableInfo); }
/** * Creates a <code>RawTable</code> and returns its id. * * Currently unsupported. * * @param path the RawTable's path * @param columns number of columns it has * @param metadata the meta data of the RawTable * @return the id if succeed, {@link tachyon.util.IdUtils#INVALID_FILE_ID} otherwise * @throws IOException if the number of columns is invalid or the underlying master RPC fails */ public synchronized long createRawTable(TachyonURI path, int columns, ByteBuffer metadata) throws IOException { validateUri(path); int maxColumns = mTachyonConf.getInt(Constants.MAX_COLUMNS); if (columns < 1 || columns > maxColumns) { throw new IOException("Column count " + columns + " is smaller than 1 or " + "bigger than " + maxColumns); } return mRawTableMasterClient.createRawTable(path, columns, metadata); }
/** * Tries to execute a RPC defined as a {@link RpcCallable}, if error * happens in one execution, a reconnection will be tried through {@link #connect()} and the * action will be re-executed. * * @param rpc the {@link RpcCallable} to be executed * @param <V> type of return value of the RPC call * @return the return value of the RPC call * @throws IOException when retries exceeds {@link #RPC_MAX_NUM_RETRY} or {@link #close()} has * been called before calling this method or during the retry */ private <V> V retryRPC(RpcCallable<V> rpc) throws IOException { int retry = 0; while (!mClosed && (retry ++) <= RPC_MAX_NUM_RETRY) { connect(); try { return rpc.call(); } catch (TException e) { LOG.error(e.getMessage(), e); mConnected = false; } } throw new IOException("Failed after " + retry + " retries."); } }
private TachyonFS(TachyonConf tachyonConf) { super(tachyonConf); mMasterAddress = NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, tachyonConf); mZookeeperMode = mTachyonConf.getBoolean(Constants.ZOOKEEPER_ENABLED); mFSMasterClient = mCloser.register(FileSystemContext.INSTANCE.acquireMasterClient()); mBlockMasterClient = mCloser.register(BlockStoreContext.INSTANCE.acquireMasterClient()); mRawTableMasterClient = mCloser.register(new RawTableMasterClient(mMasterAddress, mTachyonConf)); mWorkerClient = mCloser.register(BlockStoreContext.INSTANCE.acquireWorkerClient()); mUserFailedSpaceRequestLimits = mTachyonConf.getInt(Constants.USER_FAILED_SPACE_REQUEST_LIMITS); String scheme = mZookeeperMode ? Constants.SCHEME_FT : Constants.SCHEME; String authority = mMasterAddress.getHostName() + ":" + mMasterAddress.getPort(); mRootUri = new TachyonURI(scheme, authority, TachyonURI.SEPARATOR); }
/** * Get the <code>RawTable</code> by path. * * Currently unsupported. * * @param path the path of the raw table * @return the RawTable * @throws IOException if the underlying master RPC fails */ public synchronized RawTable getRawTable(TachyonURI path) throws IOException { validateUri(path); RawTableInfo rawTableInfo = mRawTableMasterClient.getClientRawTableInfo(path); return new RawTable(this, rawTableInfo); }
/** * Gets the {@link RawTableInfo} associated with the given id. * * @param id the id of the table * @return the table info * @throws IOException when operation fails */ public synchronized RawTableInfo getClientRawTableInfo(final long id) throws IOException { return retryRPC(new RpcCallable<RawTableInfo>() { @Override public RawTableInfo call() throws TException { return mClient.getClientRawTableInfoById(id); } }); }
/** * Updates the metadata of a table. * * @param tableId The id of the table to update * @param metadata The new metadata to update the table with * @throws IOException when the operation fails */ public void updateRawTableMetadata(final long tableId, final ByteBuffer metadata) throws IOException { retryRPC(new RpcCallable<Void>() { @Override public Void call() throws TException { mClient.updateRawTableMetadata(tableId, metadata); return null; } }); }
/** * Creates a raw table. A table is a directory with sub-directories representing columns. * * @param path the path where the table is placed * @param columns the number of columns in the table, must be in range (0, tachyon.max.columns) * @param metadata additional metadata about the table, cannot be null * @return the id of the table * @throws IOException when creation fails */ public synchronized long createRawTable(final TachyonURI path, final int columns, final ByteBuffer metadata) throws IOException { return retryRPC(new RpcCallable<Long>() { @Override public Long call() throws TException { return mClient.createRawTable(path.getPath(), columns, metadata); } }); }