/** * 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 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 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)); } }