Search in sources :

Example 1 with SetTaskModeMapping

use of org.apache.samza.coordinator.stream.messages.SetTaskModeMapping in project samza by apache.

the class CoordinatorStreamValueSerde method fromBytes.

@Override
public String fromBytes(byte[] bytes) {
    Map<String, Object> values = messageSerde.fromBytes(bytes);
    CoordinatorStreamMessage message = new CoordinatorStreamMessage(new Object[] {}, values);
    if (type.equalsIgnoreCase(SetExecutionEnvContainerIdMapping.TYPE)) {
        SetExecutionEnvContainerIdMapping executionContainerIdMapping = new SetExecutionEnvContainerIdMapping(message);
        return executionContainerIdMapping.getExecutionEnvironmentContainerId();
    } else if (type.equalsIgnoreCase(SetContainerHostMapping.TYPE)) {
        SetContainerHostMapping hostMapping = new SetContainerHostMapping(message);
        return hostMapping.getHostLocality();
    } else if (type.equalsIgnoreCase(SetTaskContainerMapping.TYPE)) {
        SetTaskContainerMapping setTaskContainerMapping = new SetTaskContainerMapping(message);
        return setTaskContainerMapping.getTaskAssignment();
    } else if (type.equalsIgnoreCase(SetChangelogMapping.TYPE)) {
        SetChangelogMapping changelogMapping = new SetChangelogMapping(message);
        return (changelogMapping.getPartition() != null) ? String.valueOf(changelogMapping.getPartition()) : null;
    } else if (type.equalsIgnoreCase(SetConfig.TYPE)) {
        SetConfig setConfig = new SetConfig(message);
        return setConfig.getConfigValue();
    } else if (type.equalsIgnoreCase(SetTaskModeMapping.TYPE)) {
        SetTaskModeMapping setTaskModeMapping = new SetTaskModeMapping(message);
        return String.valueOf(setTaskModeMapping.getTaskMode());
    } else if (type.equalsIgnoreCase(SetTaskPartitionMapping.TYPE)) {
        SetTaskPartitionMapping setTaskPartitionMapping = new SetTaskPartitionMapping(message);
        return setTaskPartitionMapping.getTaskNames();
    } else if (type.equalsIgnoreCase(SetJobCoordinatorMetadataMessage.TYPE)) {
        SetJobCoordinatorMetadataMessage jobCoordinatorMetadataMessage = new SetJobCoordinatorMetadataMessage(message);
        return jobCoordinatorMetadataMessage.getJobCoordinatorMetadata();
    } else {
        throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type));
    }
}
Also used : SetTaskModeMapping(org.apache.samza.coordinator.stream.messages.SetTaskModeMapping) SetTaskPartitionMapping(org.apache.samza.coordinator.stream.messages.SetTaskPartitionMapping) SetJobCoordinatorMetadataMessage(org.apache.samza.coordinator.stream.messages.SetJobCoordinatorMetadataMessage) SamzaException(org.apache.samza.SamzaException) CoordinatorStreamMessage(org.apache.samza.coordinator.stream.messages.CoordinatorStreamMessage) SetExecutionEnvContainerIdMapping(org.apache.samza.coordinator.stream.messages.SetExecutionEnvContainerIdMapping) SetChangelogMapping(org.apache.samza.coordinator.stream.messages.SetChangelogMapping) SetConfig(org.apache.samza.coordinator.stream.messages.SetConfig) SetContainerHostMapping(org.apache.samza.coordinator.stream.messages.SetContainerHostMapping) SetTaskContainerMapping(org.apache.samza.coordinator.stream.messages.SetTaskContainerMapping)

Aggregations

SamzaException (org.apache.samza.SamzaException)1 CoordinatorStreamMessage (org.apache.samza.coordinator.stream.messages.CoordinatorStreamMessage)1 SetChangelogMapping (org.apache.samza.coordinator.stream.messages.SetChangelogMapping)1 SetConfig (org.apache.samza.coordinator.stream.messages.SetConfig)1 SetContainerHostMapping (org.apache.samza.coordinator.stream.messages.SetContainerHostMapping)1 SetExecutionEnvContainerIdMapping (org.apache.samza.coordinator.stream.messages.SetExecutionEnvContainerIdMapping)1 SetJobCoordinatorMetadataMessage (org.apache.samza.coordinator.stream.messages.SetJobCoordinatorMetadataMessage)1 SetTaskContainerMapping (org.apache.samza.coordinator.stream.messages.SetTaskContainerMapping)1 SetTaskModeMapping (org.apache.samza.coordinator.stream.messages.SetTaskModeMapping)1 SetTaskPartitionMapping (org.apache.samza.coordinator.stream.messages.SetTaskPartitionMapping)1