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());
}
}
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());
}
}
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());
}
}
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());
}
}
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;
}
Aggregations