-
Notifications
You must be signed in to change notification settings - Fork 14
feature: support mc settings #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
idleyui
wants to merge
1
commit into
master
Choose a base branch
from
feature/support_mc_settings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,9 +23,12 @@ | |
| import java.sql.Statement; | ||
| import java.util.ArrayList; | ||
| import java.util.Comparator; | ||
| import java.util.HashMap; | ||
| import java.util.Iterator; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import org.apache.commons.lang3.StringUtils; | ||
| import org.apache.commons.lang3.Validate; | ||
|
|
||
| import com.aliyun.odps.Odps; | ||
|
|
@@ -43,12 +46,25 @@ | |
|
|
||
| public class ConfigurationUtils { | ||
|
|
||
| public static Map<String, String> getSQLSettings(String config) throws MmaException { | ||
| Map<String, String> sqlSettings = new HashMap<>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 用一个immutable map更好些 |
||
| if (!StringUtils.isBlank(config)) { | ||
| for (String s : config.split(";")) { | ||
| String[] kv = s.split("="); | ||
| if (kv.length != 2) { | ||
| throw new MmaException("Unsupported SQL setting format: " + s); | ||
| } | ||
| sqlSettings.put(kv[0].trim(), kv[1].trim()); | ||
| } | ||
| } | ||
| return sqlSettings; | ||
| } | ||
|
|
||
| public static class PartitionComparator implements Comparator<List<String>> { | ||
|
|
||
| List<PartitionOrderType> partitionOrders; | ||
|
|
||
| public PartitionComparator(List<PartitionOrderType> partitionOrders){ | ||
| public PartitionComparator(List<PartitionOrderType> partitionOrders) { | ||
| this.partitionOrders = partitionOrders; | ||
| } | ||
|
|
||
|
|
@@ -96,7 +112,8 @@ public static void validateMcMetaSource(AbstractConfiguration config) throws Mma | |
| getCannotBeNullOrEmptyErrorMessage(AbstractConfiguration.METADATA_SOURCE_MC_ACCESS_KEY_ID)); | ||
| String accessKeySecret = Validate.notBlank( | ||
| config.get(AbstractConfiguration.METADATA_SOURCE_MC_ACCESS_KEY_SECRET), | ||
| getCannotBeNullOrEmptyErrorMessage(AbstractConfiguration.METADATA_SOURCE_MC_ACCESS_KEY_SECRET)); | ||
| getCannotBeNullOrEmptyErrorMessage( | ||
| AbstractConfiguration.METADATA_SOURCE_MC_ACCESS_KEY_SECRET)); | ||
| validateMcCredentials(endpoint, accessKeyId, accessKeySecret); | ||
| } | ||
|
|
||
|
|
@@ -155,7 +172,8 @@ public static void validateMcMetaDest(AbstractConfiguration config) throws MmaEx | |
| getCannotBeNullOrEmptyErrorMessage(AbstractConfiguration.METADATA_DEST_MC_ACCESS_KEY_ID)); | ||
| String accessKeySecret = Validate.notBlank( | ||
| config.get(AbstractConfiguration.METADATA_DEST_MC_ACCESS_KEY_SECRET), | ||
| getCannotBeNullOrEmptyErrorMessage(AbstractConfiguration.METADATA_DEST_MC_ACCESS_KEY_SECRET)); | ||
| getCannotBeNullOrEmptyErrorMessage( | ||
| AbstractConfiguration.METADATA_DEST_MC_ACCESS_KEY_SECRET)); | ||
| validateMcCredentials(endpoint, accessKeyId, accessKeySecret); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| /* | ||
| * Copyright 1999-2021 Alibaba Group Holding Ltd. | ||
| * | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
|
|
@@ -16,10 +16,14 @@ | |
|
|
||
| package com.aliyun.odps.mma.server.action; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import com.aliyun.odps.mma.config.AbstractConfiguration; | ||
| import com.aliyun.odps.mma.config.ConfigurationUtils; | ||
| import com.aliyun.odps.mma.config.JobConfiguration; | ||
| import com.aliyun.odps.mma.exception.MmaException; | ||
| import com.aliyun.odps.mma.meta.MetaSource; | ||
| import com.aliyun.odps.mma.util.McSqlUtils; | ||
| import com.aliyun.odps.mma.server.action.info.McSqlActionInfo; | ||
| import com.aliyun.odps.mma.meta.MetaSource.TableMetaModel; | ||
|
|
@@ -29,6 +33,7 @@ public class McToMcTableDataTransmissionAction extends McSqlAction { | |
|
|
||
| private TableMetaModel source; | ||
| private TableMetaModel dest; | ||
| private Map<String, String> settings; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 放在Task层面解析好一些,后续如果mc -> oss或oss -> mc需要加上数据验证的步骤,这个settings是需要复用的 |
||
|
|
||
| public McToMcTableDataTransmissionAction( | ||
| String id, | ||
|
|
@@ -39,10 +44,14 @@ public McToMcTableDataTransmissionAction( | |
| TableMetaModel source, | ||
| TableMetaModel dest, | ||
| Task task, | ||
| ActionExecutionContext context) { | ||
| ActionExecutionContext context) throws MmaException { | ||
| super(id, mcAccessKeyId, mcAccessKeySecret, mcProject, mcEndpoint, task, context); | ||
| this.source = source; | ||
| this.dest = dest; | ||
|
|
||
| JobConfiguration config = context.getConfig(); | ||
| settings = ConfigurationUtils.getSQLSettings( | ||
| config.get(AbstractConfiguration.JOB_EXECUTION_MC_SETTINGS)); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -62,8 +71,7 @@ public boolean hasResults() { | |
|
|
||
| @Override | ||
| public Map<String, String> getSettings() { | ||
| // TODO: | ||
| return new HashMap<>(); | ||
| return settings; | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
和hive的对齐比较好:mma.data.source.hive.settings.transmission