@Override public TachyonFS createClient(String uri) throws IOException { if (!uri.startsWith(PREFIX)) uri = PREFIX + uri; return TachyonFS.get(uri); } }
/** * {@inheritDoc} * * Sets up a lazy connection to Tachyon through mTFS. */ @Override public void initialize(URI uri, Configuration conf) throws IOException { super.initialize(uri, conf); LOG.info("initialize(" + uri + ", " + conf + "). Connecting to Tachyon: " + uri.toString()); Utils.addS3Credentials(conf); setConf(conf); mTachyonHeader = getScheme() + "://" + uri.getHost() + ":" + uri.getPort(); // Set the statistics member. Use mStatistics instead of the parent class's variable. mStatistics = statistics; // Load TachyonConf if any and merge to the one in TachyonFS TachyonConf siteConf = ConfUtils.loadFromHadoopConfiguration(conf); if (siteConf != null) { mTachyonConf.merge(siteConf); } mTachyonConf.set(Constants.MASTER_HOSTNAME, uri.getHost()); mTachyonConf.set(Constants.MASTER_PORT, Integer.toString(uri.getPort())); mTachyonConf.set(Constants.ZOOKEEPER_ENABLED, Boolean.toString(isZookeeperMode())); mTFS = TachyonFS.get(mTachyonConf); mUri = URI.create(mTachyonHeader); mUnderFSAddress = mTFS.getUfsAddress(); LOG.info(mTachyonHeader + " " + mUri + " " + mUnderFSAddress); }
/** * Creates a <code>TachyonFS</code> handler for the given Tachyon URI. * * @param tachyonURI a Tachyon URI to indicate master address. e.g., tachyon://localhost:19998, * tachyon://localhost:19998/ab/c.txt * @return the corresponding TachyonFS handler * @see #get(tachyon.TachyonURI, tachyon.conf.TachyonConf) */ @Deprecated public static synchronized TachyonFS get(final TachyonURI tachyonURI) { return get(tachyonURI, ClientContext.getConf()); }
/** * Returns a {@link tachyon.client.TachyonFS} client. This client does not need to be closed * directly, but can be closed by calling {@link #close()} on this object. * * @param tachyonConf Tachyon configuration * @return a TachyonFS client * @throws IOException when the operation fails */ public TachyonFS getClient(TachyonConf tachyonConf) throws IOException { final TachyonFS fs = TachyonFS.get(new TachyonURI(mUriSuppliers.get()), tachyonConf); mClients.add(fs); return fs; }
/** * Creates a <code>TachyonFS</code> handler for the given path. * * @param tachyonPath a Tachyon path contains master address. e.g., tachyon://localhost:19998, * tachyon://localhost:19998/ab/c.txt * @return the corresponding TachyonFS handler * @see #get(tachyon.TachyonURI, tachyon.conf.TachyonConf) */ @Deprecated public static synchronized TachyonFS get(String tachyonPath) { return get(new TachyonURI(tachyonPath), ClientContext.getConf()); }
/** * Loads files under path "ufsAddrRootPath" (excluding excludePathPrefix relative to the path) to * the given tfs under a given destination path. * * @param tfsAddrRootPath the mTachyonFS address and path to load the src files, like * "tachyon://host:port/dest". * @param ufsAddrRootPath the address and root path of the under FS, like "hdfs://host:port/src". * @param excludePaths paths to exclude from ufsRootPath, which will not be loaded in mTachyonFS. * @param tachyonConf the instance of {@link tachyon.conf.TachyonConf} to be used. * @throws IOException when an event that prevents the operation from completing is encountered */ private static void loadUfs(TachyonURI tfsAddrRootPath, TachyonURI ufsAddrRootPath, String excludePaths, TachyonConf tachyonConf) throws IOException { TachyonFS tfs = TachyonFS.get(tfsAddrRootPath, tachyonConf); PrefixList excludePathPrefix = new PrefixList(excludePaths, ";"); loadUfs(tfs, tfsAddrRootPath, ufsAddrRootPath, excludePathPrefix, tachyonConf); }
/** * Creates a <code>TachyonFS</code> handler for the given hostname, port, and Zookeeper mode. * * @param masterHost master host details * @param masterPort port master listens on * @param zkMode use zookeeper * @return the corresponding TachyonFS handler */ public static synchronized TachyonFS get(String masterHost, int masterPort, boolean zkMode) { TachyonConf tachyonConf = ClientContext.getConf(); tachyonConf.set(Constants.MASTER_HOSTNAME, masterHost); tachyonConf.set(Constants.MASTER_PORT, Integer.toString(masterPort)); tachyonConf.set(Constants.ZOOKEEPER_ENABLED, Boolean.toString(zkMode)); return get(tachyonConf); }
/** * Creates a <code>TachyonFS</code> handler for the given Tachyon URI and configuration. * * @param tachyonURI a Tachyon URI to indicate master address. e.g., tachyon://localhost:19998, * tachyon://localhost:19998/ab/c.txt * @param tachyonConf The TachyonConf instance. * @return the corresponding TachyonFS handler */ public static synchronized TachyonFS get(final TachyonURI tachyonURI, TachyonConf tachyonConf) { Preconditions.checkArgument(tachyonConf != null, "TachyonConf cannot be null."); Preconditions.checkArgument(tachyonURI != null, "Tachyon URI cannot be null. Use " + Constants.HEADER + "host:port/ ," + Constants.HEADER_FT + "host:port/."); String scheme = tachyonURI.getScheme(); Preconditions.checkNotNull(scheme, "Tachyon scheme cannot be null. Use " + Constants.SCHEME + " or " + Constants.SCHEME_FT + "."); Preconditions.checkNotNull(tachyonURI.getHost(), "Tachyon hostname cannot be null."); Preconditions.checkState(tachyonURI.getPort() != -1, "Tachyon URI must have a port number."); Preconditions.checkState( (Constants.SCHEME.equals(scheme) || Constants.SCHEME_FT.equals(scheme)), "Tachyon scheme must be either " + Constants.SCHEME + " or " + Constants.SCHEME_FT + "."); boolean useZookeeper = scheme.equals(Constants.SCHEME_FT); tachyonConf.set(Constants.ZOOKEEPER_ENABLED, Boolean.toString(useZookeeper)); tachyonConf.set(Constants.MASTER_HOSTNAME, tachyonURI.getHost()); tachyonConf.set(Constants.MASTER_PORT, Integer.toString(tachyonURI.getPort())); return get(tachyonConf); }
@Override public Boolean call() throws Exception { TachyonFS tachyonClient = TachyonFS.get(mMasterAddress, new TachyonConf()); createRawTable(tachyonClient); write(tachyonClient); return read(tachyonClient); }
sOldTfs = TachyonFS.get(ClientContext.getConf()); try { sTfs.delete(sTfs.open(new TachyonURI(sTestDir)));