TieredStorageAssetManagerJobProducer extends AbstractJobProducer { @Override protected String process(Job job) throws ServiceRegistryException { Operation op = null; String operation = job.getOperation(); List<String> arguments = job.getArguments(); String id; String targetStore = arguments.get(0); VersionImpl version; Date start; Date end; try { op = Operation.valueOf(operation); switch (op) { case MoveById: id = arguments.get(1); return internalMoveById(id, targetStore); case MoveByIdAndVersion: id = arguments.get(1); version = VersionImpl.mk(Long.parseLong(arguments.get(2))); return internalMoveByIdAndVersion(version, id, targetStore); case MoveByDate: start = new Date(Long.parseLong(arguments.get(1))); end = new Date(Long.parseLong(arguments.get(2))); return internalMoveByDate(start, end, targetStore); case MoveByIdAndDate: id = arguments.get(1); start = new Date(Long.parseLong(arguments.get(2))); end = new Date(Long.parseLong(arguments.get(3))); return internalMoveByIdAndDate(id, start, end, targetStore); default: throw new IllegalArgumentException("Unknown operation '" + operation + "'"); } } catch (NotFoundException e) { throw new ServiceRegistryException("Error running job", e); } catch (Exception e) { throw new ServiceRegistryException("Error handling operation '" + op + "'", e); } } TieredStorageAssetManagerJobProducer(); @Override void activate(ComponentContext cc); boolean datastoreExists(String storeId); Job moveByIdAndVersion(final Version version, final String mpId, final String targetStorage); Job moveById(final String mpId, final String targetStorage); Job moveByDate(final Date start, final Date end, final String targetStorage); Job moveByIdAndDate(final String mpId, final Date start, final Date end, final String targetStorage); static final String JOB_TYPE; static final Float JOB_LOAD; static final Float NONTERMINAL_JOB_LOAD; }
@Test public void testProcessById() throws ServiceRegistryException { String[] mp = createAndAddMediaPackagesSimple(2, 2, 2, Opt.<String>none()); List<Job> jobs = createIdAndVersionExpectation(mp[1], 0, 2); EasyMock.replay(sr); for (Job j : jobs) { Assert.assertEquals("OK", tsamjp.process(j)); } }
@Test public void testProcessByIdAndVersion() throws NotFoundException, ServiceRegistryException { String[] mp = createAndAddMediaPackagesSimple(2, 2, 2, Opt.<String>none()); List<Job> jobs = createIdAndVersionExpectation(mp[1], 1, 1); EasyMock.replay(sr); for (Job j : jobs) { Assert.assertEquals("OK", tsamjp.process(j)); } }
@Test public void testProcessByDate() throws NotFoundException, ServiceRegistryException { Date start = new Date(); String[] mps = createAndAddMediaPackagesSimple(2, 2, 2, Opt.<String>none()); Date after = new Date(); List<Job> jobs = createDateTriggerJob(mps, 2); EasyMock.replay(sr); for (Job j : jobs) { Assert.assertEquals("OK", tsamjp.process(j)); } EasyMock.verify(sr); }
@Test public void testProcessByIdAndDate() throws NotFoundException, ServiceRegistryException { String[] mp = createAndAddMediaPackagesSimple(2, 2, 2, Opt.<String>none()); List<Job> jobs = createDateTriggerJob(mp, 2); EasyMock.replay(sr); for (Job j : jobs) { Assert.assertEquals("OK", tsamjp.process(j)); } EasyMock.verify(sr); }