mchades commented on code in PR #7531: URL: https://github.com/apache/gravitino/pull/7531#discussion_r2192359657
########## api/src/main/java/org/apache/gravitino/job/SupportsJobs.java: ########## @@ -0,0 +1,123 @@ +/* + * 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.gravitino.job; + +import java.util.List; +import java.util.Map; +import org.apache.gravitino.exceptions.InUseException; +import org.apache.gravitino.exceptions.JobTemplateAlreadyExistsException; +import org.apache.gravitino.exceptions.NoSuchJobException; +import org.apache.gravitino.exceptions.NoSuchJobTemplateException; + +/** + * Interface for job management operations. This interface will be mixed with GravitinoClient to + * provide the ability to manage job templates and jobs within the Gravitino system. + */ +public interface SupportsJobs { + + /** + * Lists all the registered job templates in Gravitino. + * + * @return a list of job templates + */ + List<JobTemplate> listJobTemplates(); + + /** + * Register a job template with the specified job template to Gravitino. The registered job will + * be maintained in Gravitino, allowing it to be executed later. + * + * @param jobTemplate the template for the job + * @throws JobTemplateAlreadyExistsException if a job template with the same name already exists + */ + void registerJobTemplate(JobTemplate jobTemplate) throws JobTemplateAlreadyExistsException; + + /** + * Retrieves a job template by its name. + * + * @param jobTemplateName the name of the job template to retrieve + * @return the job template associated with the specified name + * @throws NoSuchJobTemplateException if no job template with the specified name exists + */ + JobTemplate getJobTemplate(String jobTemplateName) throws NoSuchJobTemplateException; + + /** + * Deletes a job template by its name. This will remove the job template from Gravitino, and it + * will no longer be available for execution. Only when all the jobs associated with this job + * template are completed or cancelled, the job template can be deleted successfully, otherwise it Review Comment: completed, cancelled, or failed? ########## api/src/main/java/org/apache/gravitino/job/SupportsJobs.java: ########## @@ -0,0 +1,123 @@ +/* + * 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.gravitino.job; + +import java.util.List; +import java.util.Map; +import org.apache.gravitino.exceptions.InUseException; +import org.apache.gravitino.exceptions.JobTemplateAlreadyExistsException; +import org.apache.gravitino.exceptions.NoSuchJobException; +import org.apache.gravitino.exceptions.NoSuchJobTemplateException; + +/** + * Interface for job management operations. This interface will be mixed with GravitinoClient to + * provide the ability to manage job templates and jobs within the Gravitino system. + */ +public interface SupportsJobs { + + /** + * Lists all the registered job templates in Gravitino. + * + * @return a list of job templates + */ + List<JobTemplate> listJobTemplates(); + + /** + * Register a job template with the specified job template to Gravitino. The registered job will + * be maintained in Gravitino, allowing it to be executed later. + * + * @param jobTemplate the template for the job + * @throws JobTemplateAlreadyExistsException if a job template with the same name already exists + */ + void registerJobTemplate(JobTemplate jobTemplate) throws JobTemplateAlreadyExistsException; + + /** + * Retrieves a job template by its name. + * + * @param jobTemplateName the name of the job template to retrieve + * @return the job template associated with the specified name + * @throws NoSuchJobTemplateException if no job template with the specified name exists + */ + JobTemplate getJobTemplate(String jobTemplateName) throws NoSuchJobTemplateException; + + /** + * Deletes a job template by its name. This will remove the job template from Gravitino, and it + * will no longer be available for execution. Only when all the jobs associated with this job + * template are completed or cancelled, the job template can be deleted successfully, otherwise it + * will throw an exception. + * + * <p>The deletion of a job template will also delete all the jobs associated with this template. + * + * @param jobTemplateName the name of the job template to delete + * @return true if the job template was successfully deleted, false if the job template does not + * exist + * @throws InUseException if there are still jobs associated with the job template Review Comment: started and queued jobs ? ########## api/src/main/java/org/apache/gravitino/job/JobHandle.java: ########## @@ -0,0 +1,66 @@ +/* + * 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.gravitino.job; + +/** + * JobHandle is an interface that is returned by the job submission, which provides methods to get + * the job name, job ID, job status, and to add listeners for jobs. + */ +public interface JobHandle { + + /** The status of the job. */ + enum Status { + + /** The job is in the queue and waiting to be executed. */ + QUEUED, + + /** The job is currently being executed. */ + STARTED, Review Comment: What is the initial status of a job? queued or started? Using "RUNNING" instead of "STARTED" would be clearer? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
