/** * @param readType the {@link tachyon.client.ReadType} for this operation. Setting this will * override the TachyonStorageType. * @return the builder */ public Builder setReadType(ReadType readType) { mTachyonStorageType = readType.getTachyonStorageType(); return this; }
/** * @return the {@link tachyon.client.TachyonStorageType} associated with this read type */ public TachyonStorageType getTachyonStorageType() { if (isPromote()) { // CACHE_PROMOTE return TachyonStorageType.PROMOTE; } if (isCache()) { // CACHE return TachyonStorageType.STORE; } // NO_CACHE return TachyonStorageType.NO_STORE; }
public static ReadType option(String[] args, int index, ReadType defaultValue) { if (index < args.length && index >= 0) { try { return ReadType.valueOf(args[index]); } catch (IllegalArgumentException e) { System.err.println("Unable to parse ReadType;" + e.getMessage()); System.err.println("Defaulting to " + defaultValue); return defaultValue; } } else { return defaultValue; } }
public static void main(String[] args) throws IllegalArgumentException { if (args.length != 4) { System.out.println("java -cp " + Constants.TACHYON_JAR + " " + BasicOperations.class.getName() + " <ReadType (CACHE_PROMOTE | CACHE | NO_CACHE)> <WriteType (MUST_CACHE | CACHE_THROUGH" + " | THROUGH)>"); System.exit(-1); } Utils.runExample(new BasicOperations(new TachyonURI(args[0]), new TachyonURI(args[1]), ReadType.valueOf(args[2]), WriteType.valueOf(args[3]))); } }
/** * Creates a new builder for {@link InStreamOptions}. * * @param conf a Tachyon configuration */ public Builder(TachyonConf conf) { ReadType defaultReadType = conf.getEnum(Constants.USER_FILE_READ_TYPE_DEFAULT, ReadType.class); mTachyonStorageType = defaultReadType.getTachyonStorageType(); }
public static void main(String[] args) throws IllegalArgumentException { if (args.length != 4) { System.out.println("java -cp " + Constants.TACHYON_JAR + " " + BasicRawTableOperations.class.getName() + " <master address> <file path> " + " <ReadType (CACHE_PROMOTE | CACHE | NO_CACHE)> <WriteType (MUST_CACHE | CACHE_THROUGH" + " | THROUGH)>"); System.exit(-1); } Utils.runExample(new BasicRawTableOperations(new TachyonURI(args[0]), new TachyonURI(args[1]), ReadType.valueOf(args[2]), WriteType.valueOf(args[3]))); } }
/** * Return the {@code InStream} of this file based on the specified read type. If it has no block, * return an {@code EmptyBlockInStream}; if it has only one block, return a {@code BlockInStream} * of the block; otherwise return a {@code FileInStream}. * * @param readType the InStream's read type * @return the <code>InStream</code> * @throws IOException when an event that prevents the operation from completing is encountered */ public FileInStream getInStream(ReadType readType) throws IOException { if (readType == null) { throw new IOException("ReadType can not be null."); } if (!isCompleted()) { throw new IOException("The file " + this + " is not complete."); } if (isDirectory()) { throw new IOException("Cannot open a directory for reading."); } FileInfo info = getUnCachedFileStatus(); TachyonURI uri = new TachyonURI(info.getPath()); InStreamOptions.Builder optionsBuilder = new InStreamOptions.Builder(mTachyonConf); optionsBuilder.setTachyonStorageType(readType.getTachyonStorageType()); try { tachyon.client.file.TachyonFile newFile = mTFS.open(uri); return mTFS.getInStream(newFile, optionsBuilder.build()); } catch (TachyonException e) { throw new IOException(e); } }