Converts wire type to proto type.

@param fileBlockInfo the wire representation to convert
@return converted proto representation
3939
public static alluxio.grpc.FileBlockInfo toProto(FileBlockInfo fileBlockInfo) {
    List<alluxio.grpc.WorkerNetAddress> ufsLocations = new ArrayList<>();
    for (String ufsLocation : fileBlockInfo.getUfsLocations()) {
      HostAndPort address = HostAndPort.fromString(ufsLocation);
      ufsLocations.add(alluxio.grpc.WorkerNetAddress.newBuilder().setHost(address.getHost())
          .setDataPort(address.getPortOrDefault(-1)).build());
    }
    return alluxio.grpc.FileBlockInfo.newBuilder()
        .setBlockInfo(toProto(fileBlockInfo.getBlockInfo())).setOffset(fileBlockInfo.getOffset())
        .addAllUfsLocations(ufsLocations).addAllUfsStringLocations(fileBlockInfo.getUfsLocations())
        .build();
  }
1200429
LocatedBlocksWithMetaInfo updateDatanodeInfo(LocatedBlocks locatedBlocks)
      throws IOException {
    if (locatedBlocks.getLocatedBlocks().size() == 0)
      return new LocatedBlocksWithMetaInfo(locatedBlocks.getFileLength(),
          locatedBlocks.getLocatedBlocks(), false,
          DataTransferProtocol.DATA_TRANSFER_VERSION, getNamespaceId(),
          this.nameNode.getClientProtocolMethodsFingerprint());
    List<LocatedBlock> newBlocks = new ArrayList<LocatedBlock>();

    readLock();
    try {
      for (LocatedBlock locBlock: locatedBlocks.getLocatedBlocks()) {
        Block block = locBlock.getBlock();
        int numNodes = blocksMap.numNodes(block);
        int numCorruptNodes = countNodes(block).corruptReplicas();
        int numCorruptReplicas = corruptReplicas.numCorruptReplicas(block); 

        if (numCorruptNodes != numCorruptReplicas) {
          LOG.warn("Inconsistent number of corrupt replicas for " + 
                   block + "blockMap has " + numCorruptNodes + 
                   " but corrupt replicas map has " + numCorruptReplicas);
        }

        boolean blockCorrupt = numCorruptNodes == numNodes;
        int numMachineSet = blockCorrupt ? numNodes : (numNodes - numCorruptNodes);
        DatanodeDescriptor[] machineSet = new DatanodeDescriptor[numMachineSet];

        if (numMachineSet > 0) {
          numNodes = 0;
          for(Iterator<DatanodeDescriptor> it = blocksMap.nodeIterator(block); 
              it.hasNext();) {
            DatanodeDescriptor dn = it.next();
            boolean replicaCorrupt = corruptReplicas.isReplicaCorrupt(block, dn);
            if (blockCorrupt || (!blockCorrupt && !replicaCorrupt))
              machineSet[numNodes++] = dn;
          }
        }

        // We need to make a copy of the block object before releasing the lock
        // to prevent the state of block is changed after that and before the
        // object is serialized to clients, to avoid potential inconsistency.
        // Further optimization is possible to avoid some object copy. Since it
        // is so far not a critical path. We leave a safe approach here.
        //
        Block blockCopy  = null;
        if (block != null) {
          blockCopy = new Block(block);
        }
        LocatedBlock newBlock = new LocatedBlock(blockCopy, machineSet, 0,
            blockCorrupt);
  newBlocks.add(newBlock);
      }
    } finally {
      readUnlock();
    }

    return new LocatedBlocksWithMetaInfo(locatedBlocks.getFileLength(),
        newBlocks, false, DataTransferProtocol.DATA_TRANSFER_VERSION,
        getNamespaceId(), this.nameNode.getClientProtocolMethodsFingerprint());
  }
999888
@Override
    protected int writeBytesWireFormat ( byte[] dst, int dstIndex ) {
        int start = dstIndex;
        SMBUtil.writeInt2(33, dst, dstIndex);
        dst[ dstIndex + 2 ] = this.infoType;
        dst[ dstIndex + 3 ] = this.fileInfoClass;
        dstIndex += 4;

        int bufferLengthOffset = dstIndex;
        dstIndex += 4;
        int bufferOffsetOffset = dstIndex;
        dstIndex += 4;

        SMBUtil.writeInt4(this.additionalInformation, dst, dstIndex);
        dstIndex += 4;

        System.arraycopy(this.fileId, 0, dst, dstIndex, 16);
        dstIndex += 16;

        SMBUtil.writeInt2(dstIndex - getHeaderStart(), dst, bufferOffsetOffset);
        int len = this.info.encode(dst, dstIndex);
        SMBUtil.writeInt4(len, dst, bufferLengthOffset);
        dstIndex += len;
        return dstIndex - start;
    }
618653
public static WorkerInfo fromProto(alluxio.grpc.WorkerInfo workerInfo) {
    return new WorkerInfo().setAddress(fromProto(workerInfo.getAddress()))
        .setCapacityBytes(workerInfo.getCapacityBytes())
        .setCapacityBytesOnTiers(workerInfo.getCapacityBytesOnTiers()).setId(workerInfo.getId())
        .setLastContactSec(workerInfo.getLastContactSec())
        .setStartTimeMs(workerInfo.getStartTimeMs()).setState(workerInfo.getState())
        .setUsedBytes(workerInfo.getUsedBytes())
        .setUsedBytesOnTiers(workerInfo.getUsedBytesOnTiersMap());
  }
225806
int getBlockIndex(INodeFile inode, Block blk, String file) throws IOException {
    if (inode == null) {
      throw new IOException("inode for file " + file + " is null");
    }
    readLock();
    try {
      return inode.getBlockIndex(blk, file);
    } finally {
      readUnlock();
    }
  }
271158
BlockId append(String fileName, IoBuffer buffer) {
		try {
			IoChannel fileChannel = getFileChannel(fileName);

			// Rewind the buffer for writing
			buffer.rewind();

			// Append the block to the file
			long newSize = fileChannel.append(buffer);

			// Return the new block id
			return new BlockId(fileName, newSize / BLOCK_SIZE - 1);

		} catch (IOException e) {
			e.printStackTrace();
			return null;
		}
	}
805501
public BoxFile.Info getFileInfo(String fileID) {
        URL url = FILE_INFO_URL_TEMPLATE.build(this.api.getBaseURL(), fileID);
        BoxAPIRequest request = new BoxAPIRequest(this.api, url, "GET");
        BoxJSONResponse response = (BoxJSONResponse) request.send();
        JsonObject jsonObject = JsonObject.readFrom(response.getJSON());

        BoxFile file = new BoxFile(this.api, jsonObject.get("id").asString());
        return file.new Info(response.getJSON());
    }
325356
private FieldTypeInfo genericReadTypeInfo(RecordInput rin, String tag) throws IOException {
    String fieldName = rin.readString(tag);
    TypeID id = genericReadTypeID(rin, tag);
    return new FieldTypeInfo(fieldName, id);
  }
837498
public function pasteFile(FileInfo $fileInfo, $type)
    {
        try {
            $target_file_path = $this->getFileManager()->getTargetFile()->getFilepath(true);
            $source_file_path = $fileInfo->getFilepath(true);

            $this->validateFile($fileInfo);
            $fileSystem = new Filesystem();
            if (!file_exists($target_file_path)) {
                $fileSystem->copy($source_file_path, $target_file_path);

                var_dump($type);
                if ($type == FileManager::FILE_CUT) {
                    $fileSystem->remove($source_file_path);
                }
            } else {
                $target_file = $this->getFileManager()->getTargetFile()->getFilename();
                throw new \Exception(sprintf("File '%s' already exists", $target_file));
            }
        } catch (\Exception $e) {
            $this->getFileManager()->throwError("Cannot paste file", 500, $e);
        }
    }
778040
static long parseGenerationStampInMetaFile(File blockFile, File metaFile
      ) throws IOException {
    String metaname = metaFile.getName();
    String gs = metaname.substring(blockFile.getName().length() + 1,
        metaname.length() - FSDataset.METADATA_EXTENSION.length());
    try {
      return Long.parseLong(gs);
    } catch(NumberFormatException nfe) {
      throw (IOException)new IOException("blockFile=" + blockFile
          + ", metaFile=" + metaFile).initCause(nfe);
    }
  }
999747
@Override
    protected FileInfo getFileInfoFromInputDataImpl(Message inputData)
    {
        FileInfo fileInfo=null;
        try
        {
            //get file info
            fileInfo=this.getFileInfo(inputData);
        }
        catch(MessagingException exception)
        {
            throw new FaxException("Unable to extract fax job file data from mail message.",exception);
        }
        catch(IOException exception)
        {
            throw new FaxException("Unable to extract fax job file data from mail message.",exception);
        }
        
        return fileInfo;
    }
540766
boolean removeBlock(String path, INodeFileUnderConstruction fileNode,
                      Block block) throws IOException {
    waitForReady();

    writeLock();
    try {
      // modify file-> block and blocksMap
      fileNode.removeBlock(block);
      getFSNamesystem().blocksMap.removeBlock(block);
      // Remove the block from corruptReplicasMap
      getFSNamesystem().corruptReplicas.removeFromCorruptReplicasMap(block);

      // write modified block locations to log
      fsImage.getEditLog().logOpenFile(path, fileNode);
      if (NameNode.stateChangeLog.isDebugEnabled()) {
        NameNode.stateChangeLog.debug("DIR* FSDirectory.removeBlock: "
                                      +path+" with "+block
                                      +" block is removed from the file system");
      }
    } finally {
      writeUnlock();
    }
    return true;
  }
372581
public alluxio.grpc.BlockInfo getBlockInfo() {
    return blockInfo_ == null ? alluxio.grpc.BlockInfo.getDefaultInstance() : blockInfo_;
  }
383513
public FileInfo getFileInfoFromInputData(T inputData)
    {
        if(!this.initialized)
        {
            throw new FaxException("Fax bridge not initialized.");
        }

        //get file info
        FileInfo fileInfo=this.getFileInfoFromInputDataImpl(inputData);
        
        return fileInfo;
    }
1235070
public void finalizeBlockInternal(int namespaceId, Block b, boolean reFinalizeOk)
    throws IOException {
    lock.writeLock().lock();
    DatanodeBlockInfo binfo = volumeMap.get(namespaceId, b);
    try {
      ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, b);
      if (activeFile == null) {
        if (reFinalizeOk) {
          return;
        } else {
          throw new IOException("Block " + b + " is already finalized.");
        }
      }
      File f = activeFile.getDataFile();
      if (f == null || !f.exists()) {
        throw new IOException("No temporary file " + f + " for block " + b);
      }
      FSVolume v = binfo.getBlockDataFile().getVolume();
      if (v == null) {
        throw new IOException("No volume for temporary file " + f + 
                              " for block " + b);
      }
          
      File dest = null;
      dest = v.addBlock(namespaceId, b, f, activeFile.isInlineChecksum(),
          binfo.getChecksumType(), binfo.getBytesPerChecksum());
      volumeMap.add(
          namespaceId,
          b,
          new DatanodeBlockInfo(v, dest, activeFile.getBytesWritten(), true,
              activeFile.isInlineChecksum(), binfo.getChecksumType(),
              binfo.getBytesPerChecksum(),
              activeFile.getCrcUpdater().isCrcValid(activeFile.getBytesWritten()),
              activeFile.getCrcUpdater().getBlockCrc()));
      ActiveFile af = volumeMap.removeOngoingCreates(namespaceId, b);
      af.blockFinalize();
    } finally {
      lock.writeLock().unlock();
    }
  }
990856
public ObjectType createAnonymousObjectType(JSDocInfo info) {
    PrototypeObjectType type = new PrototypeObjectType(
        this, null, null, true /* anonymousType */);
    type.setPrettyPrint(true);
    type.setJSDocInfo(info);
    return type;
  }
311579
BlockInfo[] setReplication(String src,
                         short replication,
                         int[] oldReplication
                         ) throws IOException {
    waitForReady();
    BlockInfo[] fileBlocks = unprotectedSetReplication(src, replication, oldReplication);
    if (fileBlocks != null)  // log replication change
      fsImage.getEditLog().logSetReplication(src, replication);
    return fileBlocks;
  }