/** * Write the taskName to partition mapping. * @param changelogEntries The entries that needs to be written to the coordinator stream, the map takes the taskName * and it's corresponding changelog partition. */ public void writePartitionMapping(Map<TaskName, Integer> changelogEntries) { LOG.debug("Updating changelog information with: "); for (Map.Entry<TaskName, Integer> entry : changelogEntries.entrySet()) { LOG.debug("TaskName: {} to Partition: {}", entry.getKey().getTaskName(), entry.getValue()); coordinatorStreamManager.send(new SetChangelogMapping(SOURCE, entry.getKey().getTaskName(), entry.getValue())); } }
/** * Write the taskName to partition mapping. * @param changelogEntries The entries that needs to be written to the coordinator stream, the map takes the taskName * and it's corresponding changelog partition. */ public void writePartitionMapping(Map<TaskName, Integer> changelogEntries) { LOG.debug("Updating changelog information with: "); for (Map.Entry<TaskName, Integer> entry : changelogEntries.entrySet()) { LOG.debug("TaskName: {} to Partition: {}", entry.getKey().getTaskName(), entry.getValue()); coordinatorStreamManager.send(new SetChangelogMapping(SOURCE, entry.getKey().getTaskName(), entry.getValue())); } }
/** * Write the taskName to partition mapping. * @param changelogEntries The entries that needs to be written to the coordinator stream, the map takes the taskName * and it's corresponding changelog partition. */ public void writePartitionMapping(Map<TaskName, Integer> changelogEntries) { LOG.debug("Updating changelog information with: "); for (Map.Entry<TaskName, Integer> entry : changelogEntries.entrySet()) { LOG.debug("TaskName: {} to Partition: {}", entry.getKey().getTaskName(), entry.getValue()); coordinatorStreamManager.send(new SetChangelogMapping(SOURCE, entry.getKey().getTaskName(), entry.getValue())); } }
/** * Write the taskName to partition mapping. * @param changelogEntries The entries that needs to be written to the coordinator stream, the map takes the taskName * and it's corresponding changelog partition. */ public void writePartitionMapping(Map<TaskName, Integer> changelogEntries) { LOG.debug("Updating changelog information with: "); for (Map.Entry<TaskName, Integer> entry : changelogEntries.entrySet()) { LOG.debug("TaskName: {} to Partition: {}", entry.getKey().getTaskName(), entry.getValue()); coordinatorStreamManager.send(new SetChangelogMapping(SOURCE, entry.getKey().getTaskName(), entry.getValue())); } }
/** * Write the taskName to partition mapping. * @param changelogEntries The entries that needs to be written to the coordinator stream, the map takes the taskName * and it's corresponding changelog partition. */ public void writePartitionMapping(Map<TaskName, Integer> changelogEntries) { LOG.debug("Updating changelog information with: "); for (Map.Entry<TaskName, Integer> entry : changelogEntries.entrySet()) { LOG.debug("TaskName: {} to Partition: {}", entry.getKey().getTaskName(), entry.getValue()); coordinatorStreamManager.send(new SetChangelogMapping(SOURCE, entry.getKey().getTaskName(), entry.getValue())); } }
/** * Read the taskName to partition mapping that is being maintained by this ChangelogManager * @return TaskName to change LOG partition mapping, or an empty map if there were no messages. */ public Map<TaskName, Integer> readPartitionMapping() { LOG.debug("Reading changelog partition information"); final HashMap<TaskName, Integer> changelogMapping = new HashMap<>(); for (CoordinatorStreamMessage coordinatorStreamMessage : coordinatorStreamManager.getBootstrappedStream(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapEntry = new SetChangelogMapping(coordinatorStreamMessage); changelogMapping.put(new TaskName(changelogMapEntry.getTaskName()), changelogMapEntry.getPartition()); LOG.debug("TaskName: {} is mapped to {}", changelogMapEntry.getTaskName(), changelogMapEntry.getPartition()); } return changelogMapping; }
/** * Read the taskName to partition mapping that is being maintained by this ChangelogManager * @return TaskName to change LOG partition mapping, or an empty map if there were no messages. */ public Map<TaskName, Integer> readPartitionMapping() { LOG.debug("Reading changelog partition information"); final HashMap<TaskName, Integer> changelogMapping = new HashMap<>(); for (CoordinatorStreamMessage coordinatorStreamMessage : coordinatorStreamManager.getBootstrappedStream(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapEntry = new SetChangelogMapping(coordinatorStreamMessage); changelogMapping.put(new TaskName(changelogMapEntry.getTaskName()), changelogMapEntry.getPartition()); LOG.debug("TaskName: {} is mapped to {}", changelogMapEntry.getTaskName(), changelogMapEntry.getPartition()); } return changelogMapping; }
/** * Read the taskName to partition mapping that is being maintained by this ChangelogManager * @return TaskName to change LOG partition mapping, or an empty map if there were no messages. */ public Map<TaskName, Integer> readPartitionMapping() { LOG.debug("Reading changelog partition information"); final HashMap<TaskName, Integer> changelogMapping = new HashMap<>(); for (CoordinatorStreamMessage coordinatorStreamMessage : coordinatorStreamManager.getBootstrappedStream(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapEntry = new SetChangelogMapping(coordinatorStreamMessage); changelogMapping.put(new TaskName(changelogMapEntry.getTaskName()), changelogMapEntry.getPartition()); LOG.debug("TaskName: {} is mapped to {}", changelogMapEntry.getTaskName(), changelogMapEntry.getPartition()); } return changelogMapping; }
/** * Read the taskName to partition mapping that is being maintained by this ChangelogManager * @return TaskName to change LOG partition mapping, or an empty map if there were no messages. */ public Map<TaskName, Integer> readPartitionMapping() { LOG.debug("Reading changelog partition information"); final HashMap<TaskName, Integer> changelogMapping = new HashMap<>(); for (CoordinatorStreamMessage coordinatorStreamMessage : coordinatorStreamManager.getBootstrappedStream(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapEntry = new SetChangelogMapping(coordinatorStreamMessage); changelogMapping.put(new TaskName(changelogMapEntry.getTaskName()), changelogMapEntry.getPartition()); LOG.debug("TaskName: {} is mapped to {}", changelogMapEntry.getTaskName(), changelogMapEntry.getPartition()); } return changelogMapping; }
/** * Read the taskName to partition mapping that is being maintained by this ChangelogManager * @return TaskName to change LOG partition mapping, or an empty map if there were no messages. */ public Map<TaskName, Integer> readPartitionMapping() { LOG.debug("Reading changelog partition information"); final HashMap<TaskName, Integer> changelogMapping = new HashMap<>(); for (CoordinatorStreamMessage coordinatorStreamMessage : coordinatorStreamManager.getBootstrappedStream(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapEntry = new SetChangelogMapping(coordinatorStreamMessage); changelogMapping.put(new TaskName(changelogMapEntry.getTaskName()), changelogMapEntry.getPartition()); LOG.debug("TaskName: {} is mapped to {}", changelogMapEntry.getTaskName(), changelogMapEntry.getPartition()); } return changelogMapping; }
@Override public String fromBytes(byte[] bytes) { Map<String, Object> values = messageSerde.fromBytes(bytes); CoordinatorStreamMessage message = new CoordinatorStreamMessage(new Object[]{}, values); 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 String.valueOf(changelogMapping.getPartition()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } }
@Override public String fromBytes(byte[] bytes) { Map<String, Object> values = messageSerde.fromBytes(bytes); CoordinatorStreamMessage message = new CoordinatorStreamMessage(new Object[]{}, values); 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 String.valueOf(changelogMapping.getPartition()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } }
@Override public byte[] toBytes(String value) { if (type.equalsIgnoreCase(SetContainerHostMapping.TYPE)) { SetContainerHostMapping hostMapping = new SetContainerHostMapping(SOURCE, "", value, "", ""); return messageSerde.toBytes(hostMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetTaskContainerMapping.TYPE)) { SetTaskContainerMapping setTaskContainerMapping = new SetTaskContainerMapping(SOURCE, "", value); return messageSerde.toBytes(setTaskContainerMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapping = new SetChangelogMapping(SOURCE, "", Integer.valueOf(value)); return messageSerde.toBytes(changelogMapping.getMessageMap()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } } }
@Override public byte[] toBytes(String value) { if (type.equalsIgnoreCase(SetContainerHostMapping.TYPE)) { SetContainerHostMapping hostMapping = new SetContainerHostMapping(SOURCE, "", value, "", ""); return messageSerde.toBytes(hostMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetTaskContainerMapping.TYPE)) { SetTaskContainerMapping setTaskContainerMapping = new SetTaskContainerMapping(SOURCE, "", value); return messageSerde.toBytes(setTaskContainerMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapping = new SetChangelogMapping(SOURCE, "", Integer.valueOf(value)); return messageSerde.toBytes(changelogMapping.getMessageMap()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } } }
@Override public String fromBytes(byte[] bytes) { Map<String, Object> values = messageSerde.fromBytes(bytes); CoordinatorStreamMessage message = new CoordinatorStreamMessage(new Object[]{}, values); 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 String.valueOf(changelogMapping.getPartition()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } }
@Override public String fromBytes(byte[] bytes) { Map<String, Object> values = messageSerde.fromBytes(bytes); CoordinatorStreamMessage message = new CoordinatorStreamMessage(new Object[]{}, values); 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 String.valueOf(changelogMapping.getPartition()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } }
@Override public byte[] toBytes(String value) { if (type.equalsIgnoreCase(SetContainerHostMapping.TYPE)) { SetContainerHostMapping hostMapping = new SetContainerHostMapping(SOURCE, "", value, "", ""); return messageSerde.toBytes(hostMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetTaskContainerMapping.TYPE)) { SetTaskContainerMapping setTaskContainerMapping = new SetTaskContainerMapping(SOURCE, "", value); return messageSerde.toBytes(setTaskContainerMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapping = new SetChangelogMapping(SOURCE, "", Integer.valueOf(value)); return messageSerde.toBytes(changelogMapping.getMessageMap()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } } }
@Override public byte[] toBytes(String value) { if (type.equalsIgnoreCase(SetContainerHostMapping.TYPE)) { SetContainerHostMapping hostMapping = new SetContainerHostMapping(SOURCE, "", value, "", ""); return messageSerde.toBytes(hostMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetTaskContainerMapping.TYPE)) { SetTaskContainerMapping setTaskContainerMapping = new SetTaskContainerMapping(SOURCE, "", value); return messageSerde.toBytes(setTaskContainerMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapping = new SetChangelogMapping(SOURCE, "", Integer.valueOf(value)); return messageSerde.toBytes(changelogMapping.getMessageMap()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } } }
@Override public String fromBytes(byte[] bytes) { Map<String, Object> values = messageSerde.fromBytes(bytes); CoordinatorStreamMessage message = new CoordinatorStreamMessage(new Object[]{}, values); 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 String.valueOf(changelogMapping.getPartition()); } 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 { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } }
@Override public byte[] toBytes(String value) { if (type.equalsIgnoreCase(SetContainerHostMapping.TYPE)) { SetContainerHostMapping hostMapping = new SetContainerHostMapping(SOURCE, "", value, "", ""); return messageSerde.toBytes(hostMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetTaskContainerMapping.TYPE)) { SetTaskContainerMapping setTaskContainerMapping = new SetTaskContainerMapping(SOURCE, "", value); return messageSerde.toBytes(setTaskContainerMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetTaskModeMapping.TYPE)) { SetTaskModeMapping setTaskModeMapping = new SetTaskModeMapping(SOURCE, "", value); return messageSerde.toBytes(setTaskModeMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetChangelogMapping.TYPE)) { SetChangelogMapping changelogMapping = new SetChangelogMapping(SOURCE, "", Integer.valueOf(value)); return messageSerde.toBytes(changelogMapping.getMessageMap()); } else if (type.equalsIgnoreCase(SetConfig.TYPE)) { SetConfig setConfig = new SetConfig(SOURCE, "", value); return messageSerde.toBytes(setConfig.getMessageMap()); } else { throw new SamzaException(String.format("Unknown coordinator stream message type: %s", type)); } } }