-
Notifications
You must be signed in to change notification settings - Fork 749
[GOBBLIN-1967] Add external data node for generic ingress/egress on GaaS #3838
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
74f9f55
Add external data node for generic ingress/egress on GaaS
Will-Lo 9119ad3
Address reviews and cleanup
Will-Lo 47f004b
Use URI representation for external dataset descriptor node
Will-Lo f5480f3
Fix error message in containing check
Will-Lo fcf7079
Address review
Will-Lo 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
58 changes: 58 additions & 0 deletions
58
...e/src/main/java/org/apache/gobblin/service/modules/dataset/ExternalDatasetDescriptor.java
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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.gobblin.service.modules.dataset; | ||
|
|
||
| import com.google.common.base.Preconditions; | ||
| import com.typesafe.config.Config; | ||
| import java.io.IOException; | ||
| import java.util.ArrayList; | ||
| import lombok.Getter; | ||
| import org.apache.gobblin.service.modules.flowgraph.DatasetDescriptorConfigKeys; | ||
| import org.apache.gobblin.service.modules.flowgraph.DatasetDescriptorErrorUtils; | ||
| import org.apache.gobblin.util.ConfigUtils; | ||
|
|
||
|
|
||
| /** | ||
| * Describes a external dataset not on HDFS | ||
| * e.g, https://some-api:443/user/123/names where the path is the full URI | ||
| */ | ||
| public class ExternalDatasetDescriptor extends BaseDatasetDescriptor implements DatasetDescriptor { | ||
|
|
||
| @Getter | ||
| private final String path; | ||
|
|
||
| public ExternalDatasetDescriptor(Config config) throws IOException { | ||
| super(config); | ||
| Preconditions.checkArgument(config.hasPath(DatasetDescriptorConfigKeys.PATH_KEY), "Dataset descriptor config must specify path"); | ||
| // refers to the full HTTP url | ||
| this.path = ConfigUtils.getString(config, DatasetDescriptorConfigKeys.PATH_KEY, ""); | ||
|
Will-Lo marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * Check if this dataset descriptor is equivalent to another dataset descriptor | ||
| * | ||
| * @param inputDatasetDescriptorConfig whose path should be in the format of an external path (e.g. http url) | ||
| */ | ||
| @Override | ||
| protected ArrayList<String> isPathContaining(DatasetDescriptor inputDatasetDescriptorConfig) { | ||
|
Will-Lo marked this conversation as resolved.
|
||
| ArrayList<String> errors = new ArrayList<>(); | ||
| String otherPath = inputDatasetDescriptorConfig.getPath(); | ||
| DatasetDescriptorErrorUtils.populateErrorForDatasetDescriptorKey(errors, inputDatasetDescriptorConfig.getIsInputDataset(), DatasetDescriptorConfigKeys.PATH_KEY, this.getPath(), otherPath, false); | ||
| return errors; | ||
| } | ||
| } | ||
44 changes: 44 additions & 0 deletions
44
...rc/main/java/org/apache/gobblin/service/modules/flowgraph/datanodes/ExternalDataNode.java
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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.gobblin.service.modules.flowgraph.datanodes; | ||
|
|
||
| import com.typesafe.config.Config; | ||
| import org.apache.gobblin.service.modules.dataset.ExternalDatasetDescriptor; | ||
| import org.apache.gobblin.service.modules.flowgraph.BaseDataNode; | ||
|
|
||
|
|
||
| /** | ||
| * A DataNode for generic ingress/egress data movement outside of HDFS (HTTP or otherwise) | ||
| */ | ||
| public class ExternalDataNode extends BaseDataNode { | ||
|
Will-Lo marked this conversation as resolved.
Outdated
|
||
| public static final String EXTERNAL_PLATFORM_NAME = "external"; | ||
|
Will-Lo marked this conversation as resolved.
Outdated
|
||
|
|
||
| public ExternalDataNode(Config nodeProps) throws DataNodeCreationException { | ||
| super(nodeProps); | ||
| } | ||
|
|
||
| @Override | ||
| public String getDefaultDatasetDescriptorPlatform() { | ||
| return EXTERNAL_PLATFORM_NAME; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDefaultDatasetDescriptorClass() { | ||
| return ExternalDatasetDescriptor.class.getCanonicalName(); | ||
| } | ||
| } | ||
53 changes: 53 additions & 0 deletions
53
...c/test/java/org/apache/gobblin/service/modules/dataset/ExternalDatasetDescriptorTest.java
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 |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.gobblin.service.modules.dataset; | ||
|
|
||
| import com.typesafe.config.Config; | ||
| import com.typesafe.config.ConfigFactory; | ||
| import com.typesafe.config.ConfigValueFactory; | ||
| import java.io.IOException; | ||
| import org.apache.gobblin.service.modules.flowgraph.DatasetDescriptorConfigKeys; | ||
| import org.junit.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
|
|
||
| public class ExternalDatasetDescriptorTest { | ||
|
|
||
| @Test | ||
| public void testContains() throws IOException { | ||
| Config config1 = ConfigFactory.empty() | ||
| .withValue(DatasetDescriptorConfigKeys.PLATFORM_KEY, ConfigValueFactory.fromAnyRef("external")) | ||
| .withValue(DatasetDescriptorConfigKeys.PATH_KEY, ConfigValueFactory.fromAnyRef("https://a.com/b")); | ||
| ExternalDatasetDescriptor descriptor1 = new ExternalDatasetDescriptor(config1); | ||
|
|
||
| // Verify that same path points to same dataset | ||
| Config config2 = ConfigFactory.empty() | ||
| .withValue(DatasetDescriptorConfigKeys.PLATFORM_KEY, ConfigValueFactory.fromAnyRef("external")) | ||
| .withValue(DatasetDescriptorConfigKeys.PATH_KEY, ConfigValueFactory.fromAnyRef("https://a.com/b")); | ||
| ExternalDatasetDescriptor descriptor2 = new ExternalDatasetDescriptor(config2); | ||
| Assert.assertEquals(descriptor2.contains(descriptor1).size(), 0); | ||
|
Will-Lo marked this conversation as resolved.
|
||
|
|
||
| // Verify that different path points to different dataset | ||
| Config config3 = ConfigFactory.empty() | ||
| .withValue(DatasetDescriptorConfigKeys.PLATFORM_KEY, ConfigValueFactory.fromAnyRef("external")) | ||
| .withValue(DatasetDescriptorConfigKeys.PATH_KEY, ConfigValueFactory.fromAnyRef("https://a.com/c")); | ||
| ExternalDatasetDescriptor descriptor3 = new ExternalDatasetDescriptor(config3); | ||
| Assert.assertNotEquals(descriptor3.contains(descriptor1).size(), 0); | ||
|
|
||
| } | ||
| } | ||
47 changes: 47 additions & 0 deletions
47
...est/java/org/apache/gobblin/service/modules/flowgraph/datanodes/ExternalDataNodeTest.java
|
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. no biggie... but this probably ought to be |
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 |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You 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. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.gobblin.service.modules.flowgraph.datanodes; | ||
|
|
||
| import com.typesafe.config.Config; | ||
| import com.typesafe.config.ConfigFactory; | ||
| import com.typesafe.config.ConfigValueFactory; | ||
| import org.apache.gobblin.service.modules.dataset.ExternalDatasetDescriptor; | ||
| import org.apache.gobblin.service.modules.flowgraph.DataNode; | ||
| import org.apache.gobblin.service.modules.flowgraph.FlowGraphConfigurationKeys; | ||
| import org.apache.gobblin.util.ConfigUtils; | ||
| import org.junit.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
|
|
||
| public class ExternalDataNodeTest { | ||
|
|
||
| @Test | ||
| public void testConfig() throws DataNode.DataNodeCreationException { | ||
| String expectedNodeId = "some-node-id"; | ||
|
|
||
| Config config = ConfigFactory.empty() | ||
| .withValue(FlowGraphConfigurationKeys.DATA_NODE_ID_KEY, ConfigValueFactory.fromAnyRef(expectedNodeId)); | ||
| ExternalDataNode node = new ExternalDataNode(config); | ||
|
|
||
| // Verify the node id | ||
| String id = node.getId(); | ||
| Assert.assertEquals(id, expectedNodeId); | ||
| Assert.assertEquals(node.getDefaultDatasetDescriptorPlatform(), "external"); | ||
| Assert.assertEquals(node.getDefaultDatasetDescriptorClass(), ExternalDatasetDescriptor.class.getCanonicalName()); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.