this.data = new FileReadModuleStageData(httpSpec, maxFileCount); this.data.setPathCache(pc);
private void storeNewFileData(TrieParser trie, final int rootSize, StringBuilder builder, Path path, final int newPathId, byte[] asBytes, final int bytesLength, int typeId, FileChannel activeFileChannel) throws IOException { data.getPaths()[newPathId] = path; long fileSize = activeFileChannel.size(); trie.setValue(asBytes, rootSize, bytesLength, Integer.MAX_VALUE, newPathId); builder.setLength(0); data.getType()[newPathId] = typeId; data.getFcId()[newPathId] = channelHolder.add(activeFileChannel); data.getEtagBytes()[newPathId] = Appendables.appendHexDigits(builder, data.getFcId()[newPathId]).toString().getBytes(); data.getFileSizes()[newPathId] = fileSize; builder.setLength(0); }
if (newPathId>data.getType().length) { throw new UnsupportedOperationException("FileReader only supports "+data.getType().length+" files, attempted to add more than this."); FileChannel activeFileChannel = data.fileSystem.provider().newFileChannel(path, data.getReadOptions());
final long fcId = data.getFcId()[pathId]; final long fileSize = data.getFileSizes()[pathId]; if (supportInFlightCopy && /*Only use if the file was written previously*/ oldBlobPosition>0 && activeMessageStart = publishBodyPart(channelHigh, channelLow, sequence, output, len, data.getFcId()[pathId]); activeMessageStart = publishBodyPart(channelHigh, channelLow, sequence, output, (int)len, data.getFcId()[pathId]); PipeHashTable.replaceItem(outputHash, data.getFcId()[pathId], dataPos); PipeHashTable.replaceItem(outputHash, data.getFcId()[pathId], dataPos);
if (null!=(activeFileChannel = channelHolder.getValid(data.getFcId()[pathId]))) { } else { findAgainFileChannel(pathId);
private void beginSendingFile(int httpRevision, int requestContext, int pathId, int verb, int sequence, Pipe<HTTPRequestSchema> input, Pipe<ServerResponseSchema> output) { try { activePayloadSizeRemaining = data.getFileSizes()[pathId]; byte[] contentType = httpSpec.contentTypes[data.getType()[pathId]].getBytes(); assert(data.getFileSizes()[pathId]<Integer.MAX_VALUE) : "Can not support files larger than 2G at this time."; boolean chunked = false; int headerSize = Pipe.addMsgIdx(output, ServerResponseSchema.MSG_TOCHANNEL_100); //channel, sequence, context, payload status, requestContext, data.getEtagBytes()[pathId], contentType, (int)data.getFileSizes()[pathId], chunked, reportServer, writer, 1&(requestContext>>ServerCoordinator.CLOSE_CONNECTION_SHIFT),
int pathId = selectActiveFileChannel(pathCacheReader, data.getPathCache(), bytesLength-2, bytesBackingArray, bytesPosition+2, bytesMask);
private void findAgainFileChannel(int pathId) { /////////////// //we lost our file channel and need to request a new one. ////////////// try { assert( data.getPaths().length > 0); assert( data.getPaths()[pathId].toFile().isFile() ); assert( data.getPaths()[pathId].toFile().exists() ); //logger.info("looking for {}",data.getPaths()[pathId]); activeFileChannel = data.fileSystem.provider().newFileChannel(data.getPaths()[pathId], data.getReadOptions()); data.getFcId()[pathId] = channelHolder.add(activeFileChannel); data.getFileSizes()[pathId] = activeFileChannel.size(); } catch (IOException e) { throw new RuntimeException(e); } }
private void storeNewFileData(TrieParser trie, final int rootSize, StringBuilder builder, int newPathId, byte[] asBytes, final int bytesLength, int typeId, FileChannel activeFileChannel) throws IOException { long fileSize = activeFileChannel.size(); trie.setValue(asBytes, rootSize, bytesLength, Integer.MAX_VALUE, newPathId); builder.setLength(0); data.getType()[newPathId] = typeId; data.getFcId()[newPathId] = channelHolder.add(activeFileChannel); data.getEtagBytes()[newPathId] = Appendables.appendHexDigits(builder, data.getFcId()[newPathId]).toString().getBytes(); data.getFileSizes()[newPathId] = fileSize; builder.setLength(0); }
public FileReadModuleStageData(HTTPSpecification httpSpec, int maxFileCount) { fileExtensionTable = httpSpec.fileExtHashTable; setPaths(new Path[maxFileCount]); setFcId(new long[maxFileCount]); setFileSizes(new long[maxFileCount]); setEtagBytes(new byte[maxFileCount][]); setType(new int[maxFileCount]); setReadOptions(new HashSet<OpenOption>()); getReadOptions().add(StandardOpenOption.READ); }