public VPartitionTupleBufferManager(IPartitionedMemoryConstrain constrain, int partitions, IDeallocatableFramePool framePool) throws HyracksDataException { this.constrain = constrain; this.framePool = framePool; this.partitionArray = new IFrameBufferManager[partitions]; this.numTuples = new int[partitions]; this.appendFrame = new FixedSizeFrame(); this.appender = new FixedSizeFrameTupleAppender(); this.tempInfo = new BufferInfo(null, -1, -1); }
private void deleteTupleFromBuffer(BufferInfo bufferInfo) throws HyracksDataException { if (bufferInfo.getBuffer() != appendFrame.getBuffer()) { appendFrame.reset(bufferInfo.getBuffer()); appender.reset(appendFrame, false); } if (!appender.cancelAppend()) { throw new HyracksDataException("Undoing the last insertion in the given frame couldn't be done."); } }
private int createNewBuffer(int partition, int size) throws HyracksDataException { ByteBuffer newBuffer = requestNewBufferFromPool(size); if (newBuffer == null) { return -1; } appendFrame.reset(newBuffer); appender.reset(appendFrame, true); return partitionArray[partition].insertFrame(newBuffer); }
@Override public void reset() throws HyracksDataException { for (IFrameBufferManager part : partitionArray) { if (part != null) { for (int i = 0; i < part.getNumFrames(); i++) { framePool.deAllocateBuffer(part.getFrame(i, tempInfo).getBuffer()); } part.reset(); } } Arrays.fill(numTuples, 0); appendFrame.reset(null); }
public VPartitionTupleBufferManager(IHyracksFrameMgrContext ctx, IPartitionedMemoryConstrain constrain, int partitions, int frameLimitInBytes) throws HyracksDataException { this.constrain = constrain; this.framePool = new DeallocatableFramePool(ctx, frameLimitInBytes); this.partitionArray = new IFrameBufferManager[partitions]; this.numTuples = new int[partitions]; this.appendFrame = new FixedSizeFrame(); this.appender = new FixedSizeFrameTupleAppender(); this.tempInfo = new BufferInfo(null, -1, -1); }
private int appendTupleToBuffer(BufferInfo bufferInfo, int[] fieldEndOffsets, byte[] byteArray, int start, int size) throws HyracksDataException { assert (bufferInfo.getStartOffset() == 0) : "Haven't supported yet in FrameTupleAppender"; if (bufferInfo.getBuffer() != appendFrame.getBuffer()) { appendFrame.reset(bufferInfo.getBuffer()); appender.reset(appendFrame, false); } if (fieldEndOffsets == null) { if (appender.append(byteArray, start, size)) { return appender.getTupleCount() - 1; } } else { if (appender.append(fieldEndOffsets, byteArray, start, size)) { return appender.getTupleCount() - 1; } } return -1; }
@Test public void failedJobPartitionRequestTest() throws Exception { final NodeControllerService nc1 = integrationUtil.ncs[0]; final NodeControllerService nc2 = integrationUtil.ncs[1]; final JobId failedJob = new JobId(-1); nc2.getPartitionManager().jobCompleted(failedJob, JobStatus.FAILURE); final NetworkAddress localNetworkAddress = nc2.getNetworkManager().getPublicNetworkAddress(); final InetSocketAddress nc2Address = new InetSocketAddress(localNetworkAddress.getAddress(), localNetworkAddress.getPort()); PartitionId id = new PartitionId(failedJob, new ConnectorDescriptorId(1), 0, 1); NetworkInputChannel inputChannel = new NetworkInputChannel(nc1.getNetworkManager(), nc2Address, id, 1); InputChannelFrameReader frameReader = new InputChannelFrameReader(inputChannel); inputChannel.registerMonitor(frameReader); AtomicBoolean failed = new AtomicBoolean(false); Thread reader = new Thread(() -> { try { failed.set(!frameReader.nextFrame(new FixedSizeFrame())); } catch (HyracksDataException e) { e.printStackTrace(); } }); reader.start(); final IHyracksCommonContext context = Mockito.mock(IHyracksCommonContext.class); Mockito.when(context.getInitialFrameSize()).thenReturn(2000); inputChannel.open(context); reader.join(5000); Assert.assertTrue(failed.get()); } }