Package net.greghaines.jesque

Examples of net.greghaines.jesque.WorkerStatus


    }

    @Test
    public void serializeWorkerStatus() throws Exception {
        final Job job = new Job("TestAction", new Object[] { 1, 2.3, true, "test", Arrays.asList("inner", 4.5) });
        final WorkerStatus workerStatus = new WorkerStatus();
        assertSerializeRoundTrip(workerStatus);
        workerStatus.setPayload(job);
        workerStatus.setQueue("foo");
        workerStatus.setRunAt(new Date());
        workerStatus.setPaused(true);
        assertSerializeRoundTrip(workerStatus);
    }
View Full Code Here


        wInfo.setPid(pid);
        Assert.assertEquals(pid, wInfo.getPid());
        final List<String> queues = Arrays.asList("queue1", "queue2");
        wInfo.setQueues(queues);
        Assert.assertEquals(queues, wInfo.getQueues());
        final WorkerStatus status = new WorkerStatus();
        wInfo.setStatus(status);
        Assert.assertEquals(status, wInfo.getStatus());
    }
View Full Code Here

        Assert.assertTrue(wi1.equals(wi1));
        final WorkerInfo wi2 = new WorkerInfo();
        Assert.assertEquals(0, wi1.compareTo(wi2));
        Assert.assertTrue(wi1.equals(wi2));
        Assert.assertEquals(wi1.hashCode(), wi2.hashCode());
        final WorkerStatus status1 = new WorkerStatus();
        wi1.setStatus(status1);
        Assert.assertTrue(wi1.compareTo(wi2) > 0);
        Assert.assertFalse(wi1.equals(wi2));
        wi2.setStatus(status1);
        Assert.assertEquals(0, wi1.compareTo(wi2));
        Assert.assertTrue(wi1.equals(wi2));
        Assert.assertEquals(wi1.hashCode(), wi2.hashCode());
        wi1.setStatus(null);
        Assert.assertTrue(wi1.compareTo(wi2) < 0);
        Assert.assertFalse(wi1.equals(wi2));
        wi1.setStatus(status1);
        final Date runAt1 = new Date();
        status1.setRunAt(runAt1);
        Assert.assertEquals(0, wi1.compareTo(wi2));
        Assert.assertTrue(wi1.equals(wi2));
        Assert.assertEquals(wi1.hashCode(), wi2.hashCode());
        final WorkerStatus status2 = new WorkerStatus();
        wi2.setStatus(status2);
        Assert.assertTrue(wi1.compareTo(wi2) > 0);
        Assert.assertFalse(wi1.equals(wi2));
        final Date runAt2 = new Date(runAt1.getTime() + 1000);
        status2.setRunAt(runAt2);
        Assert.assertTrue(wi1.compareTo(wi2) < 0);
        Assert.assertFalse(wi1.equals(wi2));
        status1.setRunAt(null);
        Assert.assertTrue(wi1.compareTo(wi2) < 0);
        Assert.assertFalse(wi1.equals(wi2));
View Full Code Here

    protected boolean isWorkerInState(final String workerName, final WorkerInfo.State requestedState,
            final Jedis jedis) throws IOException {
        boolean proceed = true;
        if (requestedState != null) {
            final String statusPayload = jedis.get(key(WORKER, workerName));
            final WorkerStatus status = (statusPayload == null)
                    ? null
                    : ObjectMapperFactory.get().readValue(statusPayload, WorkerStatus.class);
            switch (requestedState) {
                case IDLE:
                    proceed = (status == null);
                    break;
                case PAUSED:
                    proceed = (status == null) ? true : status.isPaused();
                    break;
                case WORKING:
                    proceed = (status == null) ? false : !status.isPaused();
                    break;
            }
        }
        return proceed;
    }
View Full Code Here

     * @return the JSON representation of a new WorkerStatus
     * @throws IOException
     *             if there was an error serializing the WorkerStatus
     */
    protected String statusMsg(final String queue, final Job job) throws IOException {
        final WorkerStatus status = new WorkerStatus();
        status.setRunAt(new Date());
        status.setQueue(queue);
        status.setPayload(job);
        return ObjectMapperFactory.get().writeValueAsString(status);
    }
View Full Code Here

     * @return the JSON representation of a new WorkerStatus
     * @throws IOException
     *             if there was an error serializing the WorkerStatus
     */
    protected String pauseMsg() throws IOException {
        final WorkerStatus status = new WorkerStatus();
        status.setRunAt(new Date());
        status.setPaused(isPaused());
        return ObjectMapperFactory.get().writeValueAsString(status);
    }
View Full Code Here

TOP

Related Classes of net.greghaines.jesque.WorkerStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.