use of org.apache.samza.container.placement.ContainerPlacementMessage in project samza by apache.
the class TestContainerPlacementObjectMapper method testContainerPlacementRequestMessage.
private void testContainerPlacementRequestMessage(ContainerPlacementRequestMessage requestMessage) throws IOException {
ObjectMapper objectMapper = ContainerPlacementMessageObjectMapper.getObjectMapper();
ContainerPlacementMessage message = objectMapper.readValue(objectMapper.writeValueAsString(requestMessage), ContainerPlacementMessage.class);
assertTrue(message instanceof ContainerPlacementRequestMessage);
ContainerPlacementRequestMessage deserializedRequest = (ContainerPlacementRequestMessage) message;
assertEquals(requestMessage, deserializedRequest);
}
use of org.apache.samza.container.placement.ContainerPlacementMessage in project samza by apache.
the class TestContainerPlacementObjectMapper method testContainerPlacementResponseMessage.
private void testContainerPlacementResponseMessage(ContainerPlacementResponseMessage responseMessage) throws IOException {
ObjectMapper objectMapper = ContainerPlacementMessageObjectMapper.getObjectMapper();
ContainerPlacementMessage message = objectMapper.readValue(objectMapper.writeValueAsString(responseMessage), ContainerPlacementMessage.class);
assertTrue(message instanceof ContainerPlacementResponseMessage);
ContainerPlacementResponseMessage deserializedResponse = (ContainerPlacementResponseMessage) message;
assertEquals(responseMessage, deserializedResponse);
}
use of org.apache.samza.container.placement.ContainerPlacementMessage in project samza by apache.
the class ContainerPlacementMetadataStore method readAllContainerPlacementRequestMessages.
@VisibleForTesting
List<ContainerPlacementRequestMessage> readAllContainerPlacementRequestMessages() {
Preconditions.checkState(!stopped, "Underlying metadata store not available");
List<ContainerPlacementRequestMessage> newActions = new ArrayList<>();
Map<String, byte[]> messageBytes = containerPlacementMessageStore.all();
for (byte[] action : messageBytes.values()) {
try {
ContainerPlacementMessage message = objectMapper.readValue(action, ContainerPlacementMessage.class);
if (message instanceof ContainerPlacementRequestMessage) {
newActions.add((ContainerPlacementRequestMessage) message);
}
} catch (IOException e) {
throw new SamzaException(e);
}
}
// Sort the actions in order of timestamp
newActions.sort(Comparator.comparingLong(ContainerPlacementRequestMessage::getTimestamp));
return newActions;
}
Aggregations