use of org.apache.samza.container.placement.ContainerPlacementResponseMessage in project samza by apache.
the class TestContainerPlacementMetadataStore method testContainerPlacementMessageDeletion.
@Test
public void testContainerPlacementMessageDeletion() {
Long timestamp = System.currentTimeMillis();
UUID requestMessage1UUID = containerPlacementMetadataStore.writeContainerPlacementRequestMessage("app-attempt-001", "4", "ANY_HOST", null, timestamp);
UUID requestMessage2UUID = containerPlacementMetadataStore.writeContainerPlacementRequestMessage("app-attempt-001", "1", "host2", Duration.ofMillis(100), timestamp);
ContainerPlacementResponseMessage responseMessage1 = new ContainerPlacementResponseMessage(requestMessage1UUID, "app-attempt-001", "4", "ANY_HOST", ContainerPlacementMessage.StatusCode.BAD_REQUEST, "Request ignored redundant", System.currentTimeMillis());
ContainerPlacementResponseMessage responseMessage2 = new ContainerPlacementResponseMessage(requestMessage2UUID, "app-attempt-001", "1", "ANY_HOST", ContainerPlacementMessage.StatusCode.IN_PROGRESS, "Requested resources", System.currentTimeMillis());
containerPlacementMetadataStore.writeContainerPlacementResponseMessage(responseMessage1);
containerPlacementMetadataStore.writeContainerPlacementResponseMessage(responseMessage2);
Assert.assertTrue(containerPlacementMetadataStore.readContainerPlacementRequestMessage(requestMessage1UUID).isPresent());
Assert.assertTrue(containerPlacementMetadataStore.readContainerPlacementResponseMessage(requestMessage2UUID).isPresent());
Assert.assertEquals(4, containerPlacementMetadataStore.getContainerPlacementStore().all().size());
containerPlacementMetadataStore.deleteContainerPlacementResponseMessage(requestMessage1UUID);
Assert.assertEquals(3, containerPlacementMetadataStore.getContainerPlacementStore().all().size());
Assert.assertTrue(containerPlacementMetadataStore.readContainerPlacementRequestMessage(requestMessage1UUID).isPresent());
containerPlacementMetadataStore.deleteContainerPlacementRequestMessage(requestMessage1UUID);
Assert.assertEquals(2, containerPlacementMetadataStore.getContainerPlacementStore().all().size());
assertContainerPlacementRequestMessage(requestMessage2UUID, "app-attempt-001", "1", "host2", Duration.ofMillis(100), timestamp, containerPlacementMetadataStore.readContainerPlacementRequestMessage(requestMessage2UUID).get());
Assert.assertEquals(containerPlacementMetadataStore.readContainerPlacementResponseMessage(requestMessage2UUID).get(), responseMessage2);
// requestMessage1 & associated responseMessage1 should not be present
Assert.assertTrue(!containerPlacementMetadataStore.readContainerPlacementRequestMessage(requestMessage1UUID).isPresent());
Assert.assertTrue(!containerPlacementMetadataStore.readContainerPlacementResponseMessage(requestMessage1UUID).isPresent());
requestMessage1UUID = containerPlacementMetadataStore.writeContainerPlacementRequestMessage("app-attempt-001", "4", "ANY_HOST", null, System.currentTimeMillis());
containerPlacementMetadataStore.writeContainerPlacementResponseMessage(responseMessage1);
containerPlacementMetadataStore.deleteAllContainerPlacementMessages(requestMessage1UUID);
// requestMessage1 & associated responseMessage1 should not be present
Assert.assertTrue(!containerPlacementMetadataStore.readContainerPlacementRequestMessage(requestMessage1UUID).isPresent());
Assert.assertTrue(!containerPlacementMetadataStore.readContainerPlacementResponseMessage(requestMessage1UUID).isPresent());
containerPlacementMetadataStore.deleteAllContainerPlacementMessages();
Assert.assertEquals(0, containerPlacementMetadataStore.readAllContainerPlacementRequestMessages().size());
}
use of org.apache.samza.container.placement.ContainerPlacementResponseMessage in project samza by apache.
the class TestContainerPlacementObjectMapper method testOutgoingContainerMessageSerDe.
@Test
public void testOutgoingContainerMessageSerDe() throws IOException {
testContainerPlacementResponseMessage(new ContainerPlacementResponseMessage(UUID.randomUUID(), "app-attempt-001", Integer.toString(new Random().nextInt(5)), "ANY_HOST", ContainerPlacementMessage.StatusCode.BAD_REQUEST, "Request ignored redundant", System.currentTimeMillis()));
testContainerPlacementResponseMessage(new ContainerPlacementResponseMessage(UUID.randomUUID(), "app-attempt-001", Integer.toString(new Random().nextInt(5)), "ANY_HOST", Duration.ofSeconds(10), ContainerPlacementMessage.StatusCode.IN_PROGRESS, "Request is in progress", System.currentTimeMillis()));
}
Aggregations