Search in sources :

Example 71 with Job

use of com.google.cloud.video.transcoder.v1.Job in project java-talent by googleapis.

the class JobSearchCreateJobCustomAttributes method sampleCreateJob.

/**
 * Create Job with Custom Attributes
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenantd
 */
public static void sampleCreateJob(String projectId, String tenantId, String companyName, String requisitionId, String languageCode) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        Job job = Job.newBuilder().setCompany(companyName).setRequisitionId(requisitionId).setLanguageCode(languageCode).build();
        CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
        Job response = jobServiceClient.createJob(request);
        System.out.printf("Created job: %s\n", response.getName());
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest)

Example 72 with Job

use of com.google.cloud.video.transcoder.v1.Job in project java-talent by googleapis.

the class JobSearchGetJob method sampleGetJob.

/**
 * Get Job
 */
public static void sampleGetJob(String projectId, String tenantId, String jobId) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        JobName name = JobWithTenantName.of(projectId, tenantId, jobId);
        GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();
        Job response = jobServiceClient.getJob(request);
        System.out.printf("Job name: %s\n", response.getName());
        System.out.printf("Requisition ID: %s\n", response.getRequisitionId());
        System.out.printf("Title: %s\n", response.getTitle());
        System.out.printf("Description: %s\n", response.getDescription());
        System.out.printf("Posting language: %s\n", response.getLanguageCode());
        for (String address : response.getAddressesList()) {
            System.out.printf("Address: %s\n", address);
        }
        for (String email : response.getApplicationInfo().getEmailsList()) {
            System.out.printf("Email: %s\n", email);
        }
        for (String websiteUri : response.getApplicationInfo().getUrisList()) {
            System.out.printf("Website: %s\n", websiteUri);
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : GetJobRequest(com.google.cloud.talent.v4beta1.GetJobRequest) JobName(com.google.cloud.talent.v4beta1.JobName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job)

Example 73 with Job

use of com.google.cloud.video.transcoder.v1.Job in project java-dataproc by googleapis.

the class SubmitJob method submitJob.

public static void submitJob(String projectId, String region, String clusterName) throws IOException, InterruptedException {
    String myEndpoint = String.format("%s-dataproc.googleapis.com:443", region);
    // Configure the settings for the job controller client.
    JobControllerSettings jobControllerSettings = JobControllerSettings.newBuilder().setEndpoint(myEndpoint).build();
    // but this can also be done manually with the .close() method.
    try (JobControllerClient jobControllerClient = JobControllerClient.create(jobControllerSettings)) {
        // Configure cluster placement for the job.
        JobPlacement jobPlacement = JobPlacement.newBuilder().setClusterName(clusterName).build();
        // Configure Spark job settings.
        SparkJob sparkJob = SparkJob.newBuilder().setMainClass("org.apache.spark.examples.SparkPi").addJarFileUris("file:///usr/lib/spark/examples/jars/spark-examples.jar").addArgs("1000").build();
        Job job = Job.newBuilder().setPlacement(jobPlacement).setSparkJob(sparkJob).build();
        // Submit an asynchronous request to execute the job.
        OperationFuture<Job, JobMetadata> submitJobAsOperationAsyncRequest = jobControllerClient.submitJobAsOperationAsync(projectId, region, job);
        Job response = submitJobAsOperationAsyncRequest.get();
        // Print output from Google Cloud Storage.
        Matcher matches = Pattern.compile("gs://(.*?)/(.*)").matcher(response.getDriverOutputResourceUri());
        matches.matches();
        Storage storage = StorageOptions.getDefaultInstance().getService();
        Blob blob = storage.get(matches.group(1), String.format("%s.000000000", matches.group(2)));
        System.out.println(String.format("Job finished successfully: %s", new String(blob.getContent())));
    } catch (ExecutionException e) {
        // If the job does not complete successfully, print the error message.
        System.err.println(String.format("submitJob: %s ", e.getMessage()));
    }
}
Also used : JobControllerSettings(com.google.cloud.dataproc.v1.JobControllerSettings) JobMetadata(com.google.cloud.dataproc.v1.JobMetadata) Blob(com.google.cloud.storage.Blob) Storage(com.google.cloud.storage.Storage) Matcher(java.util.regex.Matcher) JobPlacement(com.google.cloud.dataproc.v1.JobPlacement) SparkJob(com.google.cloud.dataproc.v1.SparkJob) JobControllerClient(com.google.cloud.dataproc.v1.JobControllerClient) SparkJob(com.google.cloud.dataproc.v1.SparkJob) Job(com.google.cloud.dataproc.v1.Job) ExecutionException(java.util.concurrent.ExecutionException)

Example 74 with Job

use of com.google.cloud.video.transcoder.v1.Job in project kubernetes-client by fabric8io.

the class JobExample method main.

public static void main(String[] args) {
    final ConfigBuilder configBuilder = new ConfigBuilder();
    if (args.length > 0) {
        configBuilder.withMasterUrl(args[0]);
    }
    try (KubernetesClient client = new KubernetesClientBuilder().withConfig(configBuilder.build()).build()) {
        final String namespace = "default";
        final Job job = new JobBuilder().withApiVersion("batch/v1").withNewMetadata().withName("pi").withLabels(Collections.singletonMap("label1", "maximum-length-of-63-characters")).withAnnotations(Collections.singletonMap("annotation1", "some-very-long-annotation")).endMetadata().withNewSpec().withNewTemplate().withNewSpec().addNewContainer().withName("pi").withImage("perl").withArgs("perl", "-Mbignum=bpi", "-wle", "print bpi(2000)").endContainer().withRestartPolicy("Never").endSpec().endTemplate().endSpec().build();
        logger.info("Creating job pi.");
        client.batch().v1().jobs().inNamespace(namespace).createOrReplace(job);
        // Get All pods created by the job
        PodList podList = client.pods().inNamespace(namespace).withLabel("job-name", job.getMetadata().getName()).list();
        // Wait for pod to complete
        client.pods().inNamespace(namespace).withName(podList.getItems().get(0).getMetadata().getName()).waitUntilCondition(pod -> pod.getStatus().getPhase().equals("Succeeded"), 2, TimeUnit.MINUTES);
        // Print Job's log
        String joblog = client.batch().v1().jobs().inNamespace(namespace).withName("pi").getLog();
        logger.info(joblog);
    } catch (KubernetesClientException e) {
        logger.error("Unable to create job", e);
    }
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) PodList(io.fabric8.kubernetes.api.model.PodList) KubernetesClientBuilder(io.fabric8.kubernetes.client.KubernetesClientBuilder) JobBuilder(io.fabric8.kubernetes.api.model.batch.v1.JobBuilder) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) Job(io.fabric8.kubernetes.api.model.batch.v1.Job) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Example 75 with Job

use of com.google.cloud.video.transcoder.v1.Job in project kubernetes-client by fabric8io.

the class JobIT method testCreateWithGenerateName.

@Test
public void testCreateWithGenerateName() {
    // Given
    Job job = getJobBuilder().editMetadata().withName(null).withGenerateName("test-job-").endMetadata().build();
    // When
    Job jobCreated = client.batch().jobs().inNamespace(session.getNamespace()).create(job);
    // Then
    assertNotNull(jobCreated);
    assertTrue(jobCreated.getMetadata().getName().contains("test-job-"));
    assertEquals("test-job-", jobCreated.getMetadata().getGenerateName());
    assertNotNull(jobCreated.getMetadata().getName());
    assertNotEquals("test-job-", jobCreated.getMetadata().getName());
    assertTrue(client.batch().jobs().inNamespace(session.getNamespace()).withName(jobCreated.getMetadata().getName()).delete());
}
Also used : Job(io.fabric8.kubernetes.api.model.batch.v1.Job) Test(org.junit.Test)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)80 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)33 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)22 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 Job (com.google.cloud.talent.v4beta1.Job)20 HashMap (java.util.HashMap)20 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)18 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)16 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 JobBuilder (io.fabric8.kubernetes.api.model.batch.v1.JobBuilder)11 Map (java.util.Map)11 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)10