2017-04-27 3 views
1

클라우드 기능이 데이터 흐름 작업이 성공했는지 여부를 확인하는 방법이 있습니까 ?? 내가 시도클라우드 기능에서 데이터 흐름 작업 성공 확인

클라우드 기능 :

const google = require('googleapis'); 

exports.statusJob = function(event, callback) { 
const file = event.data; 
if (file.resourceState === 'exists' && file.name) { 
    console.log(file.name); 
    console.log(event.data); 
    google.auth.getApplicationDefault(function (err, authClient, projectId) { 
    if (err) { 
     throw err; 
    } 

    if (authClient.createScopedRequired && authClient.createScopedRequired()) { 
     authClient = authClient.createScoped([ 
     'https://www.googleapis.com/auth/cloud-platform', 
     'https://www.googleapis.com/auth/userinfo.email' 
     ]); 
    } 

    const dataflow = google.dataflow({ version: 'v1b3', auth: authClient }); 

    dataflow.projects.jobs.get({ 
     projectId: 'my-project-id', 
     resource: { 
     jobId: 'some_number' 
     } 
    }, function(err, response) { 
     if (err) { 
     console.error("problem running dataflow template, error was: ", err); 
     } 
     console.log("Dataflow template response: ", response); 
     callback(); 
    }); 

    }); 
} 
}; 

패키지 JSON :

{ 
    "name": "test", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "", 
    "license": "ISC", 
    "dependencies": { 
    "googleapis": "^18.0.0" 
    } 
} 

위의 것은 완벽하게 ONCE 날 위해 일했습니다. 내가 가진 것으로 응답했다 :

Dataflow template response: { id: 'some_number', projectId: 'my-project-id', name: 'cloud-fn', type: 'JOB_TYPE_BATCH', environment: { userAgent: { name: 'Google Cloud Dataflow SDK for Java', support: [Object], 'build.date': '2017-05-23 19:46', version: '2.0.0' }, version: { major: '6', job_type: 'JAVA_BATCH_AUTOSCALING' } }, currentState: 'JOB_STATE_DONE',........ 

는 그럼 그 말 이후에 매번 오류를 주었다

problem running dataflow template, error was: Error: Missing required parameters: jobId at createAPIRequest (/user_code/node_modules/googleapis/lib/apirequest.js:110:14) at Object.get (/user_code/node_modules/googleapis/apis/dataflow/v1b3.js:670:16) at /user_code/index.js:22:29 at callback (/user_code/node_modules/googleapis/node_modules/google-auth-library/lib/auth/googleauth.js:42:14) at /user_code/node_modules/googleapis/node_modules/google-auth-library/lib/auth/googleauth.js:289:13 at _combinedTickCallback (internal/process/next_tick.js:73:7) at process._tickDomainCallback (internal/process/next_tick.js:128:9) 

사람이에 대해 아무것도 알고 있나요?

감사

답변

1

당신은 작업이 실패 또는 성공 여부를 결정하기 위해 데이터 흐름 CLI를 사용할 수 있습니다. 작업 목록을 표시하고 실패/성공/실행/취소 상태를 확인할 수도 있습니다. 특히

, 단일 작업의 상태를 확인하기 위해, 당신은 실행할 수 있습니다 : 추가 정보를 위해

gcloud beta dataflow jobs describe <JOB_ID> 

이 문서를 확인하십시오

https://cloud.google.com/dataflow/pipelines/dataflow-command-line-intf

+0

참고 : 성공적인 작업이 "완료 표시됩니다 실패한 작업은 출력의 상태 필드에 대해 "실패"를 표시합니다. –

+0

오케이 ... JavaScript에서 Cloud Functions 코드를 통해 동일하게 확인하고 싶다면 어떻게해야합니까? Cloudflow 함수를 호출하여 데이터 흐름 작업을 호출한다고 가정하고 완료 후 성공했는지 여부를 알고 싶습니다. – rish0097

+0

클라우드 기능을 호출하여 여기에 나온 안내에 따라 데이터 흐름 작업을 시작한다고 가정합니다. https://shinesolutions.com/2017/03/23/triggering-dataflow-pipelines-with-cloud-functions/ 이 예에서는 자바 스크립트 googleApis에 액세스합니다. Google API를 호출하고 dataflow.projects.templates.get을 호출하는 다른 클라우드 함수를 작성할 수 있습니다. 아쉽게도 JS API에 대한 문서/코드 샘플을 찾을 수 없습니다. 하지만 projectId와 jobId 매개 변수를 사용하여 호출 할 수 있다고 생각합니다. –

관련 문제