Search in sources :

Example 26 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class ServiceRegistryJpaImplTest method testHostsBeingRemovedFromPriorityList.

@Test
public void testHostsBeingRemovedFromPriorityList() throws Exception {
    if (serviceRegistryJpaImpl.scheduledExecutor != null)
        serviceRegistryJpaImpl.scheduledExecutor.shutdown();
    serviceRegistryJpaImpl.scheduledExecutor = Executors.newScheduledThreadPool(1);
    serviceRegistryJpaImpl.activate(null);
    Hashtable<String, String> properties = new Hashtable<>();
    properties.put("dispatchinterval", "1000");
    serviceRegistryJpaImpl.updated(properties);
    registerTestHostAndService();
    serviceRegistryJpaImpl.dispatchPriorityList.put(0L, TEST_HOST);
    Job testJob = serviceRegistryJpaImpl.createJob(TEST_HOST, TEST_SERVICE_2, TEST_OPERATION, null, null, true, null);
    JobBarrier barrier = new JobBarrier(null, serviceRegistryJpaImpl, testJob);
    try {
        barrier.waitForJobs(2000);
        Assert.fail();
    } catch (Exception e) {
        Assert.assertEquals(0, serviceRegistryJpaImpl.dispatchPriorityList.size());
    }
}
Also used : Hashtable(java.util.Hashtable) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) PropertyVetoException(java.beans.PropertyVetoException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) NotFoundException(org.opencastproject.util.NotFoundException) TrustedHttpClientException(org.opencastproject.security.api.TrustedHttpClientException) Test(org.junit.Test)

Example 27 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class ServiceRegistryJpaImplTest method testHostAddedToPriorityList.

@Test
public void testHostAddedToPriorityList() throws Exception {
    if (serviceRegistryJpaImpl.scheduledExecutor != null)
        serviceRegistryJpaImpl.scheduledExecutor.shutdown();
    serviceRegistryJpaImpl.scheduledExecutor = Executors.newScheduledThreadPool(1);
    serviceRegistryJpaImpl.activate(null);
    Hashtable<String, String> properties = new Hashtable<>();
    properties.put("dispatchinterval", "1000");
    serviceRegistryJpaImpl.updated(properties);
    registerTestHostAndService();
    Job testJob = serviceRegistryJpaImpl.createJob(TEST_HOST, TEST_SERVICE, TEST_OPERATION, null, null, true, null);
    JobBarrier barrier = new JobBarrier(null, serviceRegistryJpaImpl, testJob);
    try {
        barrier.waitForJobs(2000);
        Assert.fail();
    } catch (Exception e) {
        Assert.assertEquals(1, serviceRegistryJpaImpl.dispatchPriorityList.size());
    }
}
Also used : Hashtable(java.util.Hashtable) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) PropertyVetoException(java.beans.PropertyVetoException) ServiceRegistryException(org.opencastproject.serviceregistry.api.ServiceRegistryException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) NotFoundException(org.opencastproject.util.NotFoundException) TrustedHttpClientException(org.opencastproject.security.api.TrustedHttpClientException) Test(org.junit.Test)

Example 28 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class SoxServiceTest method testAnalyzeAudio.

@Test
public void testAnalyzeAudio() throws Exception {
    if (!soxInstalled)
        return;
    assertTrue(source.isFile());
    String sourceTrackXml = "<track xmlns=\"http://mediapackage.opencastproject.org\" id=\"track-1\" type=\"presentation/source\"><mimetype>audio/flac</mimetype>" + "<url>http://localhost:8080/workflow/samples/camera.mpg</url>" + "<checksum type=\"md5\">43b7d843b02c4a429b2f547a4f230d31</checksum><duration>14546</duration>" + "<audio><device type=\"UFG03\" version=\"30112007\" vendor=\"Unigraf\" />" + "<encoder type=\"H.264\" version=\"7.4\" vendor=\"Apple Inc\" /><channels>2</channels>" + "<bitdepth>16</bitdepth><samplingrate>44100</samplingrate></audio></track>";
    Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml);
    List<Job> jobs = new ArrayList<Job>();
    for (int i = 0; i < 10; i++) {
        jobs.add(soxService.analyze(sourceTrack));
    }
    boolean success = new JobBarrier(null, serviceRegistry, jobs.toArray(new Job[jobs.size()])).waitForJobs().isSuccess();
    assertTrue(success);
    for (Job j : jobs) {
        // Always check the service registry for the latest version of the job
        Job job = serviceRegistry.getJob(j.getId());
        TrackImpl track = (TrackImpl) MediaPackageElementParser.getFromXml(job.getPayload());
        AudioStream audioStream = track.getAudio().get(0);
        assertEquals(-8.55f, audioStream.getPkLevDb().floatValue(), 0.0002);
        assertEquals(-27.78f, audioStream.getRmsLevDb().floatValue(), 0.0002);
        assertEquals(-20.12f, audioStream.getRmsPkDb().floatValue(), 0.0002);
        assertEquals(Job.Status.FINISHED, job.getStatus());
    }
}
Also used : AudioStream(org.opencastproject.mediapackage.AudioStream) TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) ArrayList(java.util.ArrayList) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 29 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class SoxServiceTest method testNormalizeDecreaseAudio.

@Test
public void testNormalizeDecreaseAudio() throws Exception {
    if (!soxInstalled)
        return;
    assertTrue(source.isFile());
    String sourceTrackXml = "<track xmlns=\"http://mediapackage.opencastproject.org\" id=\"track-1\" type=\"presentation/source\"><mimetype>audio/flac</mimetype>" + "<url>http://localhost:8080/workflow/samples/camera.mpg</url>" + "<checksum type=\"md5\">43b7d843b02c4a429b2f547a4f230d31</checksum><duration>14546</duration>" + "<audio><device type=\"UFG03\" version=\"30112007\" vendor=\"Unigraf\" />" + "<encoder type=\"H.264\" version=\"7.4\" vendor=\"Apple Inc\" /><channels>2</channels>" + "<bitdepth>16</bitdepth><rmsleveldb>-27.78</rmsleveldb><samplingrate>44100</samplingrate></audio></track>";
    Track sourceTrack = (Track) MediaPackageElementParser.getFromXml(sourceTrackXml);
    List<Job> jobs = new ArrayList<Job>();
    for (int i = 0; i < 10; i++) {
        jobs.add(soxService.normalize(sourceTrack, -30f));
    }
    boolean success = new JobBarrier(null, serviceRegistry, jobs.toArray(new Job[jobs.size()])).waitForJobs().isSuccess();
    assertTrue(success);
    for (Job j : jobs) {
        // Always check the service registry for the latest version of the job
        Job job = serviceRegistry.getJob(j.getId());
        TrackImpl track = (TrackImpl) MediaPackageElementParser.getFromXml(job.getPayload());
        AudioStream audioStream = track.getAudio().get(0);
        assertEquals(-30f, audioStream.getRmsLevDb().floatValue(), 0.1);
        assertEquals(Job.Status.FINISHED, job.getStatus());
    }
}
Also used : AudioStream(org.opencastproject.mediapackage.AudioStream) TrackImpl(org.opencastproject.mediapackage.track.TrackImpl) ArrayList(java.util.ArrayList) Job(org.opencastproject.job.api.Job) JobBarrier(org.opencastproject.job.api.JobBarrier) Track(org.opencastproject.mediapackage.Track) Test(org.junit.Test)

Example 30 with JobBarrier

use of org.opencastproject.job.api.JobBarrier in project opencast by opencast.

the class VideoEditorServiceImpl method inspect.

/*
   * Inspect the output file
   */
protected Job inspect(Job job, URI workspaceURI) throws MediaInspectionException, ProcessFailedException {
    Job inspectionJob;
    try {
        inspectionJob = inspectionService.inspect(workspaceURI);
    } catch (MediaInspectionException e) {
        incident().recordJobCreationIncident(job, e);
        throw new MediaInspectionException("Media inspection of " + workspaceURI + " failed", e);
    }
    JobBarrier barrier = new JobBarrier(job, serviceRegistry, inspectionJob);
    if (!barrier.waitForJobs().isSuccess()) {
        throw new ProcessFailedException("Media inspection of " + workspaceURI + " failed");
    }
    return inspectionJob;
}
Also used : MediaInspectionException(org.opencastproject.inspection.api.MediaInspectionException) Job(org.opencastproject.job.api.Job) ProcessFailedException(org.opencastproject.videoeditor.api.ProcessFailedException) JobBarrier(org.opencastproject.job.api.JobBarrier)

Aggregations

Job (org.opencastproject.job.api.Job)30 JobBarrier (org.opencastproject.job.api.JobBarrier)30 Test (org.junit.Test)24 MediaPackage (org.opencastproject.mediapackage.MediaPackage)11 SearchQuery (org.opencastproject.search.api.SearchQuery)10 NotFoundException (org.opencastproject.util.NotFoundException)7 Catalog (org.opencastproject.mediapackage.Catalog)6 SearchResult (org.opencastproject.search.api.SearchResult)6 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)6 PropertyVetoException (java.beans.PropertyVetoException)5 File (java.io.File)5 Hashtable (java.util.Hashtable)5 AccessControlEntry (org.opencastproject.security.api.AccessControlEntry)5 TrustedHttpClientException (org.opencastproject.security.api.TrustedHttpClientException)5 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)5 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 MediaInspectionException (org.opencastproject.inspection.api.MediaInspectionException)3 Result (org.opencastproject.job.api.JobBarrier.Result)3 AudioStream (org.opencastproject.mediapackage.AudioStream)3