use of org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable in project flink by apache.
the class MemoryManagerLazyAllocationTest method allocateAllSingle.
@Test
public void allocateAllSingle() {
try {
final AbstractInvokable mockInvoke = new DummyInvokable();
List<MemorySegment> segments = new ArrayList<MemorySegment>();
try {
for (int i = 0; i < NUM_PAGES; i++) {
segments.add(this.memoryManager.allocatePages(mockInvoke, 1).get(0));
}
} catch (MemoryAllocationException e) {
fail("Unable to allocate memory");
}
for (MemorySegment seg : segments) {
this.memoryManager.release(seg);
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable in project flink by apache.
the class MemoryManagerTest method allocateAllMulti.
@Test
public void allocateAllMulti() {
try {
final AbstractInvokable mockInvoke = new DummyInvokable();
final List<MemorySegment> segments = new ArrayList<MemorySegment>();
try {
for (int i = 0; i < NUM_PAGES / 2; i++) {
segments.addAll(this.memoryManager.allocatePages(mockInvoke, 2));
}
} catch (MemoryAllocationException e) {
Assert.fail("Unable to allocate memory");
}
this.memoryManager.release(segments);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable in project flink by apache.
the class TaskStopTest method testStopExecutionFail.
@Test(expected = RuntimeException.class)
public void testStopExecutionFail() throws Exception {
AbstractInvokable taskMock = mock(AbstractInvokable.class);
doMocking(taskMock);
task.stopExecution();
}
use of org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable in project flink by apache.
the class MemoryManagerLazyAllocationTest method allocateAllMulti.
@Test
public void allocateAllMulti() {
try {
final AbstractInvokable mockInvoke = new DummyInvokable();
final List<MemorySegment> segments = new ArrayList<MemorySegment>();
try {
for (int i = 0; i < NUM_PAGES / 2; i++) {
segments.addAll(this.memoryManager.allocatePages(mockInvoke, 2));
}
} catch (MemoryAllocationException e) {
Assert.fail("Unable to allocate memory");
}
this.memoryManager.release(segments);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobgraph.tasks.AbstractInvokable in project flink by apache.
the class MemoryManagerLazyAllocationTest method allocateMultipleOwners.
@Test
public void allocateMultipleOwners() {
final int NUM_OWNERS = 17;
try {
AbstractInvokable[] owners = new AbstractInvokable[NUM_OWNERS];
@SuppressWarnings("unchecked") List<MemorySegment>[] mems = (List<MemorySegment>[]) new List<?>[NUM_OWNERS];
for (int i = 0; i < NUM_OWNERS; i++) {
owners[i] = new DummyInvokable();
mems[i] = new ArrayList<MemorySegment>(64);
}
// allocate all memory to the different owners
for (int i = 0; i < NUM_PAGES; i++) {
final int owner = this.random.nextInt(NUM_OWNERS);
mems[owner].addAll(this.memoryManager.allocatePages(owners[owner], 1));
}
// free one owner at a time
for (int i = 0; i < NUM_OWNERS; i++) {
this.memoryManager.releaseAll(owners[i]);
owners[i] = null;
Assert.assertTrue("Released memory segments have not been destroyed.", allMemorySegmentsFreed(mems[i]));
mems[i] = null;
// check that the owner owners were not affected
for (int k = i + 1; k < NUM_OWNERS; k++) {
Assert.assertTrue("Non-released memory segments are accidentaly destroyed.", allMemorySegmentsValid(mems[k]));
}
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations