Java Code Examples for org.apache.flink.runtime.io.network.buffer.Buffer#isRecycled()

The following examples show how to use org.apache.flink.runtime.io.network.buffer.Buffer#isRecycled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AsynchronousBufferFileWriterTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddWithFailingWriter() throws Exception {
	AsynchronousBufferFileWriter writer =
		new AsynchronousBufferFileWriter(ioManager.createChannel(), new RequestQueue<>());
	writer.close();

	exception.expect(IOException.class);

	Buffer buffer = new NetworkBuffer(MemorySegmentFactory.allocateUnpooledSegment(4096),
		FreeingBufferRecycler.INSTANCE);
	try {
		writer.writeBlock(buffer);
	} finally {
		if (!buffer.isRecycled()) {
			buffer.recycleBuffer();
			Assert.fail("buffer not recycled");
		}
		assertEquals("Shouln't increment number of outstanding requests.", 0, writer.getNumberOfOutstandingRequests());
	}
}
 
Example 2
Source File: AsynchronousBufferFileWriterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddWithFailingWriter() throws Exception {
	AsynchronousBufferFileWriter writer =
		new AsynchronousBufferFileWriter(ioManager.createChannel(), new RequestQueue<>());
	writer.close();

	exception.expect(IOException.class);

	Buffer buffer = new NetworkBuffer(MemorySegmentFactory.allocateUnpooledSegment(4096),
		FreeingBufferRecycler.INSTANCE);
	try {
		writer.writeBlock(buffer);
	} finally {
		if (!buffer.isRecycled()) {
			buffer.recycleBuffer();
			Assert.fail("buffer not recycled");
		}
		assertEquals("Shouln't increment number of outstanding requests.", 0, writer.getNumberOfOutstandingRequests());
	}
}
 
Example 3
Source File: AsynchronousBufferFileWriterTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddWithFailingWriter() throws Exception {
	AsynchronousBufferFileWriter writer =
		new AsynchronousBufferFileWriter(ioManager.createChannel(), new RequestQueue<>());
	writer.close();

	exception.expect(IOException.class);

	Buffer buffer = new NetworkBuffer(MemorySegmentFactory.allocateUnpooledSegment(4096),
		FreeingBufferRecycler.INSTANCE);
	try {
		writer.writeBlock(buffer);
	} finally {
		if (!buffer.isRecycled()) {
			buffer.recycleBuffer();
			Assert.fail("buffer not recycled");
		}
		assertEquals("Shouln't increment number of outstanding requests.", 0, writer.getNumberOfOutstandingRequests());
	}
}
 
Example 4
Source File: AbstractRecordReader.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public void clearBuffers() {
	for (RecordDeserializer<?> deserializer : recordDeserializers) {
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();
	}
}
 
Example 5
Source File: StreamInputProcessor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public void cleanup() throws IOException {
	// clear the buffers first. this part should not ever fail
	for (RecordDeserializer<?> deserializer : recordDeserializers) {
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();
	}

	// cleanup the barrier handler resources
	barrierHandler.cleanup();
}
 
Example 6
Source File: StreamTwoInputProcessor.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public void cleanup() throws IOException {
	// clear the buffers first. this part should not ever fail
	for (RecordDeserializer<?> deserializer : recordDeserializers) {
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();
	}

	// cleanup the barrier handler resources
	barrierHandler.cleanup();
}
 
Example 7
Source File: AbstractRecordReader.java    From flink with Apache License 2.0 5 votes vote down vote up
public void clearBuffers() {
	for (RecordDeserializer<?> deserializer : recordDeserializers) {
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();
	}
}
 
Example 8
Source File: TestInputChannel.java    From flink with Apache License 2.0 5 votes vote down vote up
private void assertReturnedBuffersAreRecycled(boolean assertBuffers, boolean assertEvents) {
	for (Buffer b : allReturnedBuffers) {
		if (b.isBuffer() && assertBuffers && !b.isRecycled()) {
			fail("Data Buffer " + b + " not recycled");
		}
		if (!b.isBuffer() && assertEvents && !b.isRecycled()) {
			fail("Event Buffer " + b + " not recycled");
		}
	}
}
 
Example 9
Source File: StreamTaskNetworkInput.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void close() throws IOException {
	// clear the buffers. this part should not ever fail
	for (RecordDeserializer<?> deserializer : recordDeserializers) {
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();
	}

	checkpointedInputGate.cleanup();
}
 
Example 10
Source File: StreamTwoInputProcessor.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void close() throws IOException {
	// clear the buffers first. this part should not ever fail
	for (RecordDeserializer<?> deserializer : recordDeserializers) {
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();
	}

	// cleanup the barrier handler resources
	barrierHandler.cleanup();
}
 
Example 11
Source File: AbstractRecordReader.java    From flink with Apache License 2.0 5 votes vote down vote up
public void clearBuffers() {
	for (RecordDeserializer<?> deserializer : recordDeserializers.values()) {
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();
	}
}
 
Example 12
Source File: TestInputChannel.java    From flink with Apache License 2.0 5 votes vote down vote up
private void assertReturnedBuffersAreRecycled(boolean assertBuffers, boolean assertEvents) {
	for (Buffer b : allReturnedBuffers) {
		if (b.isBuffer() && assertBuffers && !b.isRecycled()) {
			fail("Data Buffer " + b + " not recycled");
		}
		if (!b.isBuffer() && assertEvents && !b.isRecycled()) {
			fail("Event Buffer " + b + " not recycled");
		}
	}
}
 
Example 13
Source File: StreamTaskNetworkInput.java    From flink with Apache License 2.0 5 votes vote down vote up
private void releaseDeserializer(int channelIndex) {
	RecordDeserializer<?> deserializer = recordDeserializers[channelIndex];
	if (deserializer != null) {
		// recycle buffers and clear the deserializer.
		Buffer buffer = deserializer.getCurrentBuffer();
		if (buffer != null && !buffer.isRecycled()) {
			buffer.recycleBuffer();
		}
		deserializer.clear();

		recordDeserializers[channelIndex] = null;
	}
}