Examples of TachyonFile


Examples of tachyon.client.TachyonFile

            + mLocalTachyonCluster.getMasterPort() + "/destFileURI";
    // when
    String[] argv = new String[] {"touch", tachyonURI};
    mFsShell.touch(argv);
    // then
    TachyonFile tFile = mTfs.getFile(new TachyonURI("/destFileURI"));
    assertThat(tFile, notNullValue());
    assertThat(getCommandOutput(argv), equalTo(mOutput.toString()));
    assertThat(tFile.isFile(), equalTo(true));
  }
View Full Code Here

Examples of tachyon.client.TachyonFile

  }

  private void write(TachyonFS client, TachyonURI filePath, WriteType writeType,
      boolean deleteIfExists, int length) throws IOException {
    // If the file exists already, we will override it.
    TachyonFile file = getOrCreate(client, filePath, deleteIfExists);
    DataOutputStream os = new DataOutputStream(file.getOutStream(writeType));
    try {
      os.writeInt(length);
      for (int i = 0; i < length; i ++) {
        os.writeInt(i);
      }
View Full Code Here

Examples of tachyon.client.TachyonFile

    }
  }

  private TachyonFile getOrCreate(TachyonFS client, TachyonURI filePath, boolean deleteIfExists)
      throws IOException {
    TachyonFile file = client.getFile(filePath);
    if (file == null) {
      // file doesn't exist yet, so create it
      int fileId = client.createFile(filePath);
      file = client.getFile(fileId);
    } else if (deleteIfExists) {
      // file exists, so delete it and recreate
      client.delete(new TachyonURI(file.getPath()), false);

      int fileId = client.createFile(filePath);
      file = client.getFile(fileId);
    }
    return file;
View Full Code Here

Examples of tachyon.client.TachyonFile

    return file;
  }

  private boolean read(TachyonFS client, TachyonURI filePath, ReadType readType)
      throws IOException {
    TachyonFile file = client.getFile(filePath);
    DataInputStream input = new DataInputStream(file.getInStream(readType));
    boolean passes = true;
    try {
      int length = input.readInt();
      for (int i = 0; i < length; i ++) {
        passes &= (input.readInt() == i);
View Full Code Here

Examples of tachyon.client.TachyonFile

  private boolean readFile(TachyonFS tachyonClient) throws IOException {
    boolean pass = true;
    for (int i = 0; i < mNumFiles; i ++) {
      TachyonURI filePath = new TachyonURI(mFileFolder + "/part-" + i);
      LOG.debug("Reading data from {}", filePath);
      TachyonFile file = tachyonClient.getFile(filePath);
      TachyonByteBuffer buf = file.readByteBuffer(0);
      if (buf == null) {
        file.recache();
        buf = file.readByteBuffer(0);
      }
      buf.mData.order(ByteOrder.nativeOrder());
      for (int k = 0; k < mNumFiles; k ++) {
        pass = pass && (buf.mData.getInt() == k);
      }
View Full Code Here

Examples of tachyon.client.TachyonFile

        buf.putInt(k);
      }
      buf.flip();
      TachyonURI filePath = new TachyonURI(mFileFolder + "/part-" + i);
      LOG.debug("Writing data to {}", filePath);
      TachyonFile file = tachyonClient.getFile(filePath);
      OutputStream os = file.getOutStream(WriteType.ASYNC_THROUGH);
      os.write(buf.array());
      os.close();
    }
  }
View Full Code Here

Examples of tachyon.client.TachyonFile

    buf.flip();
    LOG.debug("Writing data...");
    buf.flip();

    long startTimeMs = CommonUtils.getCurrentMs();
    TachyonFile file = tachyonClient.getFile(mFilePath);
    OutStream os = file.getOutStream(mWriteType);
    os.write(buf.array());
    os.close();

    CommonUtils.printTimeTakenMs(startTimeMs, LOG, "writeFile to file " + mFilePath);
  }
View Full Code Here

Examples of tachyon.client.TachyonFile

  private boolean readFile(TachyonFS tachyonClient) throws IOException {
    boolean pass = true;
    LOG.debug("Reading data...");

    final long startTimeMs = CommonUtils.getCurrentMs();
    TachyonFile file = tachyonClient.getFile(mFilePath);
    TachyonByteBuffer buf = file.readByteBuffer(0);
    if (buf == null) {
      file.recache();
      buf = file.readByteBuffer(0);
    }
    buf.mData.order(ByteOrder.nativeOrder());
    for (int k = 0; k < mNumbers; k ++) {
      pass = pass && (buf.mData.getInt() == k);
    }
View Full Code Here

Examples of tachyon.client.TachyonFile

      }

      mBuf.flip();
      for (int pId = mLeft; pId < mRight; pId ++) {
        final long startTimeMs = System.currentTimeMillis();
        TachyonFile file = mTC.getFile(new TachyonURI(sFileName + (pId + sBaseFileNumber)));
        OutStream os = file.getOutStream(WriteType.MUST_CACHE);
        for (int k = 0; k < sBlocskPerFile; k ++) {
          mBuf.putInt(0, k + mWorkerId);
          os.write(mBuf.array());
        }
        os.close();
View Full Code Here

Examples of tachyon.client.TachyonFile

      TachyonByteBuffer buf;
      if (sDebugMode) {
        LOG.info("Verifying the reading data...");

        for (int pId = mLeft; pId < mRight; pId ++) {
          TachyonFile file = mTC.getFile(new TachyonURI(sFileName + (pId + sBaseFileNumber)));
          buf = file.readByteBuffer(0);
          IntBuffer intBuf;
          intBuf = buf.mData.order(ByteOrder.nativeOrder()).asIntBuffer();
          for (int i = 0; i < sBlocskPerFile; i ++) {
            for (int k = 0; k < sBlockSizeBytes / 4; k ++) {
              int tmp = intBuf.get();
              if ((k == 0 && tmp == (i + mWorkerId)) || (k != 0 && tmp == k)) {
                LOG.debug("Partition at {} is {}", k, tmp);
              } else {
                throw new IllegalStateException("WHAT? " + tmp + " " + k);
              }
            }
          }
          buf.close();
        }
      }

      long sum = 0;
      if (sTachyonStreamingRead) {
        for (int pId = mLeft; pId < mRight; pId ++) {
          final long startTimeMs = System.currentTimeMillis();
          TachyonFile file = mTC.getFile(new TachyonURI(sFileName + (pId + sBaseFileNumber)));
          InputStream is = file.getInStream(ReadType.CACHE);
          long len = sBlocskPerFile * sBlockSizeBytes;

          while (len > 0) {
            int r = is.read(mBuf.array());
            len -= r;
            Preconditions.checkState(r != -1, "R == -1");
          }
          is.close();
          logPerIteration(startTimeMs, pId, "th ReadTachyonFile @ Worker ", pId);
        }
      } else {
        for (int pId = mLeft; pId < mRight; pId ++) {
          final long startTimeMs = System.currentTimeMillis();
          TachyonFile file = mTC.getFile(new TachyonURI(sFileName + (pId + sBaseFileNumber)));
          buf = file.readByteBuffer(0);
          for (int i = 0; i < sBlocskPerFile; i ++) {
            buf.mData.get(mBuf.array());
          }
          sum += mBuf.get(pId % 16);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.