-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add/link api #13
Merged
Merged
Add/link api #13
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
08e1c60
add tdd test for link
8b4d408
Merge branch 'master' into Add/link-api
45949d0
link : get all link api
340f1f6
add createLinkForMysql test
ab09b7b
Merge branch 'master' into Add/link-api
b679941
add getLinkAllForEmpty and deleteLinkAll
dabf58a
add createLinkForMysql
588f608
add updateLinkForMysql and getLinkByLinkName
6317a9d
add getLinkByConnectorName
36dfcd0
add updateLinkDisable and updateLinkEnable
020d9a8
add getLinkAll
377fb5b
fix
93e09bf
fix
9d23272
fix
ac456d0
fix
9647134
fix for merge
ad3a08f
Merge branch 'master' into Add/link-api
a6f20f7
support mysql-for-test
656b441
Merge branch 'Add/mysql-in-docker-for-test' into Add/link-api
ef261ff
fix
8c863b7
Merge branch 'master' into Add/link-api
39b060d
remove mysql docker
fb2636e
test connect to localhost mysql from docker
f6ab838
auto code style
39eb252
fix and use mysql docker for test
4b616fe
use lodash、promise.all、foreach and fix test expect
efaa604
add test for create hdfs
73b3d98
fix code style and use map
e5088f2
remove tostring, not use lodash if simple , use version not v1
f2ca8f5
Merge branch 'master' into Add/link-api
074784b
Merge branch 'master' into Add/link-api
jimexist c4c0e22
use faker for test data and use await instead of promise in async fun…
c0c0955
Merge branch 'Add/link-api' of https://github.com/Madadata/hasoop int…
f86a7c2
use await Promise.all(a list of promise) and use linkType.mysql inste…
96cda19
tear up setCreateLinkRequestBody into some smaller function and use _…
2976264
fix : add merge
1919690
use two separate functions for mysql and hdfs
f5e2f4e
use Object.assign not merge
2d4b220
use transform-object-rest-spread not Object.assign
5d0b45a
fix : remove -p in mysql docker
93f360f
fix code style : import / lodash / Object
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 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
"regenerator": true, | ||
"moduleName": "babel-runtime" | ||
} | ||
] | ||
], | ||
["transform-export-extensions"] | ||
] | ||
} |
This file contains 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 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 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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains 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,191 @@ | ||
/** | ||
* Created by Chyroc on 17/1/11. | ||
*/ | ||
import merge from 'merge' | ||
import _ from 'lodash' | ||
import { linkType } from './index' | ||
|
||
function setCreateLinkRequestMainBody (linkName, connectorName) { | ||
return { | ||
'id': -1, | ||
'name': linkName, | ||
'connector-name': connectorName, | ||
'enabled': true, | ||
'creation-date': Date.now(), | ||
'creation-user': null, | ||
'update-user': null, | ||
'update-date': Date.now() | ||
} | ||
} | ||
function setCreateLinkRequestMysqlBody (jdbcDriver, connectionString, fetchSize, identifierEnclose, linkConfig) { | ||
return { | ||
'link-config-values': { | ||
'configs': [ | ||
{ | ||
'validators': [], | ||
'inputs': [ | ||
{ | ||
'size': 128, | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.jdbcDriver', | ||
'id': 67, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'STRING', | ||
'value': jdbcDriver | ||
}, { | ||
'size': 2000, | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.connectionString', | ||
'id': 68, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'STRING', | ||
'value': encodeURIComponent(connectionString) | ||
}, { | ||
'size': 40, | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.username', | ||
'id': 69, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'STRING', | ||
'value': linkConfig['username'] | ||
}, { | ||
'size': 40, | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.password', | ||
'id': 70, | ||
'sensitive': true, | ||
'overrides': '', | ||
'type': 'STRING', | ||
'value': linkConfig['password'] | ||
}, { | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.fetchSize', | ||
'id': 71, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'INTEGER', | ||
'value': `${fetchSize}` | ||
}, { | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.jdbcProperties', | ||
'id': 72, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'MAP', | ||
'sensitive-pattern': '' | ||
} | ||
], | ||
'name': 'linkConfig', | ||
'id': 17, | ||
'type': 'LINK' | ||
}, | ||
{ | ||
'validators': [], | ||
'inputs': [ | ||
{ | ||
'size': 5, | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'dialect.identifierEnclose', | ||
'id': 73, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'STRING', | ||
'value': encodeURIComponent(identifierEnclose) | ||
} | ||
], | ||
'name': 'dialect', | ||
'id': 18, | ||
'type': 'LINK' | ||
} | ||
], | ||
'validators': [] | ||
} | ||
} | ||
} | ||
|
||
function setCreateLinkRequestHdfsBody (linkConfig) { | ||
return { | ||
'link-config-values': { | ||
'configs': [ | ||
{ | ||
'validators': [], | ||
'inputs': [ | ||
{ | ||
'size': 255, | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.uri', | ||
'id': 52, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'STRING', | ||
'value': encodeURIComponent(linkConfig['uri']) | ||
}, { | ||
'size': 255, | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.confDir', | ||
'id': 53, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'STRING' | ||
}, { | ||
'editable': 'ANY', | ||
'validators': [], | ||
'name': 'linkConfig.configOverrides', | ||
'id': 54, | ||
'sensitive': false, | ||
'overrides': '', | ||
'type': 'MAP', | ||
// 'value': {'key': 'value'}, TODO | ||
'sensitive-pattern': '' | ||
} | ||
], | ||
'name': 'linkConfig', | ||
'id': 13, | ||
'type': 'LINK' | ||
} | ||
], | ||
'validators': [] | ||
} | ||
} | ||
} | ||
|
||
export function setCreateLinkRequestBody (linkConfig) { | ||
if (linkConfig['linkType'] === linkType.mysql) { | ||
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. use two separate functions for mysql and hdfs |
||
const fetchSize = linkConfig['fetchSize'] || 1000 | ||
const identifierEnclose = linkConfig['identifierEnclose'] || '`' | ||
const port = linkConfig['port'] || 3306 | ||
const connectorName = 'generic-jdbc-connector' | ||
const jdbcDriver = 'com.mysql.jdbc.Driver' | ||
const connectionString = `jdbc:mysql://${linkConfig.host}:${port}/${linkConfig.databaseName}` | ||
const mainBody = setCreateLinkRequestMainBody(linkConfig.linkName, connectorName) | ||
const mysqlBody = setCreateLinkRequestMysqlBody(jdbcDriver, connectionString, fetchSize, identifierEnclose, linkConfig) | ||
return {'links': [merge(mainBody, mysqlBody)]} | ||
} else if (linkConfig['linkType'] === linkType.hdfs) { | ||
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. tear up this into two smaller functions |
||
const connectorName = 'hdfs-connector' | ||
const mainBody = setCreateLinkRequestMainBody(linkConfig.linkName, connectorName) | ||
const hdfsBody = setCreateLinkRequestHdfsBody(linkConfig) | ||
const createHdfsLinkBody = {'links': [merge(mainBody, hdfsBody)]} | ||
if (linkConfig['hadoopConfDir']) { | ||
_.set(createHdfsLinkBody, 'links[0].link-config-values.configs[0].inputs[1].value', encodeURIComponent(linkConfig['hadoopConfDir'])) | ||
} | ||
return createHdfsLinkBody | ||
} else { | ||
throw new Error('linkType must be mysql or hdfs') | ||
} | ||
} | ||
|
||
export function setUpdateLinkRequestBody (linkConfig) { | ||
return setCreateLinkRequestBody(linkConfig) | ||
} |
This file contains 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 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,16 +1,18 @@ | ||
/* eslint-env mocha */ | ||
|
||
import { expect } from 'chai' | ||
import _ from 'lodash' | ||
import { sqoopClient } from './index' | ||
|
||
suite('connector', () => { | ||
test('getConnectorAll', async () => { | ||
const data = await sqoopClient.getConnectorAll() | ||
expect(data['connectors'].length).to.equal(7) | ||
expect(data.connectors.length).to.equal(7) | ||
}) | ||
|
||
test('getConnectorByConnectorName', async () => { | ||
const connectorName = 'generic-jdbc-connector' | ||
const data = await sqoopClient.getConnectorByConnectorName(connectorName) | ||
expect(data['connectors'][0]['name']).to.equal('generic-jdbc-connector') | ||
expect(_.get(data, 'connectors[0].name')).to.equal('generic-jdbc-connector') | ||
}) | ||
}) |
This file contains 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
Oops, something went wrong.
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.
i think you need to look at
Promise.all
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.
also if you explicitly return
Promise
then you do not need to useasync
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.
async
是为了getLinkAll
,不是后面那些delete