Search in sources :

Example 16 with JobImpl

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;
}
Also used : JobImpl(org.opencastproject.job.api.JobImpl) JaxbJob(org.opencastproject.job.api.JaxbJob) IOException(java.io.IOException) JaxbJob(org.opencastproject.job.api.JaxbJob) Job(org.opencastproject.job.api.Job) Date(java.util.Date)

Example 17 with JobImpl

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);
}
Also used : JobImpl(org.opencastproject.job.api.JobImpl) Job(org.opencastproject.job.api.Job) JpaJob(org.opencastproject.job.jpa.JpaJob) JpaJob(org.opencastproject.job.jpa.JpaJob) Test(org.junit.Test)

Example 18 with JobImpl

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);
}
Also used : MediaPackageElementBuilder(org.opencastproject.mediapackage.MediaPackageElementBuilder) JobImpl(org.opencastproject.job.api.JobImpl) ComposerService(org.opencastproject.composer.api.ComposerService) ArrayList(java.util.ArrayList) EncodingProfileList(org.opencastproject.composer.api.EncodingProfileList) EncodingProfile(org.opencastproject.composer.api.EncodingProfile) Dimension(org.opencastproject.composer.layout.Dimension) EncodingProfileImpl(org.opencastproject.composer.api.EncodingProfileImpl) Before(org.junit.Before)

Example 19 with JobImpl

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);
}
Also used : JobImpl(org.opencastproject.job.api.JobImpl) ServiceRegistry(org.opencastproject.serviceregistry.api.ServiceRegistry) Job(org.opencastproject.job.api.Job) Test(org.junit.Test)

Example 20 with JobImpl

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);
}
Also used : MediaPackageElementBuilder(org.opencastproject.mediapackage.MediaPackageElementBuilder) JobImpl(org.opencastproject.job.api.JobImpl) SoxService(org.opencastproject.sox.api.SoxService) Before(org.junit.Before)

Aggregations

JobImpl (org.opencastproject.job.api.JobImpl)21 Job (org.opencastproject.job.api.Job)17 Before (org.junit.Before)9 Test (org.junit.Test)9 File (java.io.File)7 ServiceRegistry (org.opencastproject.serviceregistry.api.ServiceRegistry)7 Workspace (org.opencastproject.workspace.api.Workspace)7 ArrayList (java.util.ArrayList)6 MediaPackage (org.opencastproject.mediapackage.MediaPackage)6 URI (java.net.URI)5 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)5 OrganizationDirectoryService (org.opencastproject.security.api.OrganizationDirectoryService)5 InputStream (java.io.InputStream)4 List (java.util.List)4 SecurityService (org.opencastproject.security.api.SecurityService)4 WorkflowInstanceImpl (org.opencastproject.workflow.api.WorkflowInstanceImpl)4 Date (java.util.Date)3 TrackImpl (org.opencastproject.mediapackage.track.TrackImpl)3 JaxbRole (org.opencastproject.security.api.JaxbRole)3 JaxbUser (org.opencastproject.security.api.JaxbUser)3