use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class ServiceRegistryInMemoryImpl method createJob.
/**
* {@inheritDoc}
*
* @see org.opencastproject.serviceregistry.api.ServiceRegistry#createJob(java.lang.String, java.lang.String,
* java.util.List, java.lang.String, boolean, org.opencastproject.job.api.Job, Float)
*/
@Override
public Job createJob(String type, String operation, List<String> arguments, String payload, boolean queueable, Job parentJob, Float jobLoad) throws ServiceRegistryException {
if (getServiceRegistrationsByType(type).size() == 0)
logger.warn("Service " + type + " not available");
Job job = null;
synchronized (this) {
job = new JobImpl(idCounter.addAndGet(1));
if (securityService != null) {
job.setCreator(securityService.getUser().getUsername());
job.setOrganization(securityService.getOrganization().getId());
}
job.setDateCreated(new Date());
job.setJobType(type);
job.setOperation(operation);
job.setArguments(arguments);
job.setPayload(payload);
if (queueable)
job.setStatus(Status.QUEUED);
else
job.setStatus(Status.INSTANTIATED);
if (parentJob != null)
job.setParentJobId(parentJob.getId());
job.setJobLoad(jobLoad);
}
synchronized (jobs) {
try {
jobs.put(job.getId(), JobParser.toXml(new JaxbJob(job)));
} catch (IOException e) {
throw new IllegalStateException("Error serializing job " + job, e);
}
}
return job;
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class ServiceRegistrationJpaImplTest method testToString.
@Test
public void testToString() throws Exception {
Job newJob = new JobImpl(3L, "test", "test_org", 0L, "simple", "do", null, DISPATCHING, "localhost", "remotehost", null, null, null, 100L, 200L, "result", 3L, 1L, true, null, 1.5F, null, 4L);
JpaJob jpaJob = JpaJob.from(newJob);
String jobString = "Job {id:3, operation:do, status:DISPATCHING}";
assertEquals(jpaJob.toString(), jobString);
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class ComposerRestServiceTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder();
// Set up our arguments and return values
audioTrack = (Track) builder.newElement(Track.TYPE, MediaPackageElements.PRESENTATION_SOURCE);
audioTrack.setIdentifier("audio1");
videoTrack = (Track) builder.newElement(Track.TYPE, MediaPackageElements.PRESENTATION_SOURCE);
videoTrack.setIdentifier("video1");
profileId = "profile1";
job = new JobImpl(1);
job.setStatus(Job.Status.QUEUED);
job.setJobType(ComposerService.JOB_TYPE);
profile = new EncodingProfileImpl();
profile.setIdentifier(profileId);
List<EncodingProfileImpl> list = new ArrayList<EncodingProfileImpl>();
list.add(profile);
profileList = new EncodingProfileList(list);
// Train a mock composer with some known behavior
ComposerService composer = EasyMock.createNiceMock(ComposerService.class);
EasyMock.expect(composer.encode(videoTrack, profileId)).andReturn(job).anyTimes();
EasyMock.expect(composer.mux(videoTrack, audioTrack, profileId)).andReturn(job).anyTimes();
EasyMock.expect(composer.listProfiles()).andReturn(list.toArray(new EncodingProfile[list.size()]));
EasyMock.expect(composer.getProfile(profileId)).andReturn(profile);
EasyMock.expect(composer.concat(EasyMock.eq(profileId), EasyMock.eq(new Dimension(640, 480)), (Track) EasyMock.notNull(), (Track) EasyMock.notNull())).andReturn(job);
EasyMock.expect(composer.concat(EasyMock.eq(profileId), EasyMock.eq(new Dimension(640, 480)), EasyMock.gt(0.0f), (Track) EasyMock.notNull(), (Track) EasyMock.notNull())).andReturn(job);
EasyMock.replay(composer);
// Set up the rest endpoint
restService = new ComposerRestService();
restService.setComposerService(composer);
restService.activate(null);
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class TimelinePreviewsServiceImplTest method testCreateTimelinePreviewImages.
/**
* Test of createTimelinePreviewImages method of class TimelinePreviewsServiceImpl.
* @throws java.lang.Exception
*/
@Test
public void testCreateTimelinePreviewImages() throws Exception {
Job expectedJob = new JobImpl(1);
ServiceRegistry serviceRegistry = EasyMock.createNiceMock(ServiceRegistry.class);
EasyMock.expect(serviceRegistry.createJob(EasyMock.eq(TimelinePreviewsServiceImpl.JOB_TYPE), EasyMock.eq(TimelinePreviewsServiceImpl.Operation.TimelinePreview.toString()), (List<String>) EasyMock.anyObject(), EasyMock.anyFloat())).andReturn(expectedJob);
EasyMock.replay(serviceRegistry);
TimelinePreviewsServiceImpl instance = new TimelinePreviewsServiceImpl();
instance.setServiceRegistry(serviceRegistry);
Job job = instance.createTimelinePreviewImages(track, 10);
assertEquals(expectedJob, job);
}
use of org.opencastproject.job.api.JobImpl in project opencast by opencast.
the class SoxRestServiceTest method setUp.
@Before
public void setUp() throws Exception {
MediaPackageElementBuilder builder = MediaPackageElementBuilderFactory.newInstance().newElementBuilder();
// Set up our arguments and return values
audioTrack = (Track) builder.newElement(Track.TYPE, MediaPackageElements.PRESENTATION_SOURCE);
audioTrack.setIdentifier("audio1");
job = new JobImpl();
job.setStatus(Job.Status.QUEUED);
job.setJobType(SoxService.JOB_TYPE);
// Train a mock composer with some known behavior
SoxService sox = EasyMock.createNiceMock(SoxService.class);
EasyMock.expect(sox.analyze(audioTrack)).andReturn(job).anyTimes();
EasyMock.expect(sox.normalize(audioTrack, -30f)).andReturn(job).anyTimes();
EasyMock.replay(sox);
// Set up the rest endpoint
restService = new SoxRestService();
restService.setSoxService(sox);
restService.activate(null);
}
Aggregations