@Test public void testLinkUpgrade() throws Exception { MLinkConfig originalConfigs = new MLinkConfig(new LinkedList<MConfig>()); MLinkConfig newConfigs = new MLinkConfig(ConfigUtils.toConfigs(LinkConfiguration.class)); originalConfigs.getConfigs().add(new MConfig("linkConfig", new LinkedList<MInput<?>>())); originalConfigs.getConfigs().get(0).getInputs().add(new MStringInput("linkConfig.hdfsHostAndPort", false, InputEditable.ANY, StringUtils.EMPTY, (short)255)); originalConfigs.getInput("linkConfig.hdfsHostAndPort").setValue("test:8020"); upgrader.upgradeLinkConfig(originalConfigs, newConfigs); assertEquals("test:8020", newConfigs.getInput("linkConfig.authority").getValue()); }
@Override public void upgradeLinkConfig(MLinkConfig original, MLinkConfig upgradeTarget) { Map<String, MConfig> configMap = new HashMap<String, MConfig>(); for (MConfig config : original.getConfigs()) { configMap.put(config.getName(), config); } for (MConfig config : upgradeTarget.getConfigs()) { List<MInput<?>> inputs = config.getInputs(); MConfig originalConfig = configMap.get(config.getName()); if (originalConfig == null) { LOG.warn("Config: '" + config.getName() + "' not present in old " + "configurable. So it and its inputs will not be transferred by the upgrader."); continue; } for (MInput input : inputs) { try { if (LINK_CONFIG_MAP.containsKey(input.getName())) { input.setValue(originalConfig.getInput(LINK_CONFIG_MAP.get(input.getName())).getValue()); } else { input.setValue(originalConfig.getInput(input.getName()).getValue()); } } catch (SqoopException ex) { LOG.warn("Input: '" + input.getName() + "' not present in old " + "configurable. So it will not be transferred by the upgrader."); } } } }
KiteConnectorUpgrader extends ConnectorConfigurableUpgrader { @Override public void upgradeLinkConfig(MLinkConfig original, MLinkConfig upgradeTarget) { Map<String, MConfig> configMap = new HashMap<String, MConfig>(); for (MConfig config : original.getConfigs()) { configMap.put(config.getName(), config); } for (MConfig config : upgradeTarget.getConfigs()) { List<MInput<?>> inputs = config.getInputs(); MConfig originalConfig = configMap.get(config.getName()); if (originalConfig == null) { LOG.warn("Config: '" + config.getName() + "' not present in old " + "configurable. So it and its inputs will not be transferred by the upgrader."); continue; } for (MInput input : inputs) { try { if (LINK_CONFIG_MAP.containsKey(input.getName())) { input.setValue(originalConfig.getInput(LINK_CONFIG_MAP.get(input.getName())).getValue()); } else { input.setValue(originalConfig.getInput(input.getName()).getValue()); } } catch (SqoopException ex) { LOG.warn("Input: '" + input.getName() + "' not present in old " + "configurable. So it will not be transferred by the upgrader."); } } } } }
KiteConnectorUpgrader extends ConnectorConfigurableUpgrader { @Override public void upgradeLinkConfig(MLinkConfig original, MLinkConfig upgradeTarget) { Map<String, MConfig> configMap = new HashMap<String, MConfig>(); for (MConfig config : original.getConfigs()) { configMap.put(config.getName(), config); } for (MConfig config : upgradeTarget.getConfigs()) { List<MInput<?>> inputs = config.getInputs(); MConfig originalConfig = configMap.get(config.getName()); if (originalConfig == null) { LOG.warn("Config: '" + config.getName() + "' not present in old " + "configurable. So it and its inputs will not be transferred by the upgrader."); continue; } for (MInput input : inputs) { try { if (LINK_CONFIG_MAP.containsKey(input.getName())) { input.setValue(originalConfig.getInput(LINK_CONFIG_MAP.get(input.getName())).getValue()); } else { input.setValue(originalConfig.getInput(input.getName()).getValue()); } } catch (SqoopException ex) { LOG.warn("Input: '" + input.getName() + "' not present in old " + "configurable. So it will not be transferred by the upgrader."); } } } }  }
KiteConnectorUpgrader extends ConnectorConfigurableUpgrader { @Override public void upgradeLinkConfig(MLinkConfig original, MLinkConfig upgradeTarget) { Map<String, MConfig> configMap = new HashMap<String, MConfig>(); for (MConfig config : original.getConfigs()) { configMap.put(config.getName(), config); } for (MConfig config : upgradeTarget.getConfigs()) { List<MInput<?>> inputs = config.getInputs(); MConfig originalConfig = configMap.get(config.getName()); if (originalConfig == null) { LOG.warn("Config: '" + config.getName() + "' not present in old " + "configurable. So it and its inputs will not be transferred by the upgrader."); continue; } for (MInput input : inputs) { try { if (LINK_CONFIG_MAP.containsKey(input.getName())) { input.setValue(originalConfig.getInput(LINK_CONFIG_MAP.get(input.getName())).getValue()); } else { input.setValue(originalConfig.getInput(input.getName()).getValue()); } } catch (SqoopException ex) { LOG.warn("Input: '" + input.getName() + "' not present in old " + "configurable. So it will not be transferred by the upgrader."); } } } }  @Override void upgradeLinkConfig(MLinkConfig original, MLinkConfig upgradeTarget); @Override void upgradeFromJobConfig(MFromConfig original, MFromConfig upgradeTarget); @Override void upgradeToJobConfig(MToConfig original, MToConfig upgradeTarget); }
KiteConnectorUpgrader extends ConnectorConfigurableUpgrader { @Override public void upgradeLinkConfig(MLinkConfig original, MLinkConfig upgradeTarget) { Map<String, MConfig> configMap = new HashMap<String, MConfig>(); for (MConfig config : original.getConfigs()) { configMap.put(config.getName(), config); } for (MConfig config : upgradeTarget.getConfigs()) { List<MInput<?>> inputs = config.getInputs(); MConfig originalConfig = configMap.get(config.getName()); if (originalConfig == null) { LOG.warn("Config: '" + config.getName() + "' not present in old " + "configurable. So it and its inputs will not be transferred by the upgrader."); continue; } for (MInput input : inputs) { try { if (LINK_CONFIG_MAP.containsKey(input.getName())) { input.setValue(originalConfig.getInput(LINK_CONFIG_MAP.get(input.getName())).getValue()); } else { input.setValue(originalConfig.getInput(input.getName()).getValue()); } } catch (SqoopException ex) { LOG.warn("Input: '" + input.getName() + "' not present in old " + "configurable. So it will not be transferred by the upgrader."); } } } }  @Override void upgradeLinkConfig(MLinkConfig original, MLinkConfig upgradeTarget); @Override void upgradeFromJobConfig(MFromConfig original, MFromConfig upgradeTarget); @Override void upgradeToJobConfig(MToConfig original, MToConfig upgradeTarget);  }