Package com.surftools.BeanstalkClient

Examples of com.surftools.BeanstalkClient.Job


    client.useTube((String) tubeNames[1]);
    long jobId = client.put(65536, 0, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    // consumer
    Job job = client.reserve(null);
    assertNotNull(job);
    long newJobId = job.getJobId();
    assertEquals(jobId, newJobId);

    String dstString = new String(job.getData());
    assertEquals(srcString, dstString);

    client.delete(job.getJobId());

    popWatchedTubes(client, tubeNames);
  }
View Full Code Here


    long putMillis = System.currentTimeMillis();
    long jobId = client.put(65536, timeoutSeconds, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    // consumer
    Job job = client.reserve(timeoutSeconds);
    long getMillis = System.currentTimeMillis();

    assertNotNull(job);
    long newJobId = job.getJobId();
    assertEquals(jobId, newJobId);

    String dstString = new String(job.getData());
    assertEquals(srcString, dstString);

    long deltaSeconds = (getMillis - putMillis) / 1000;
    assertTrue(deltaSeconds >= timeoutSeconds);

    client.delete(job.getJobId());

    // now try to achieve a TIMED_OUT
    jobId = client.put(65536, 2 * timeoutSeconds, 120, srcString.getBytes());
    assertTrue(jobId > 0);

View Full Code Here

    client.useTube((String) tubeNames[1]);
    long jobId = client.put(65536, 0, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    Job job = client.reserve(null);
    assertNotNull(job);
    boolean ok = client.delete(job.getJobId());
    assertTrue(ok);

    // delete a second time
    ok = client.delete(job.getJobId());
    assertFalse(ok);

    popWatchedTubes(client, tubeNames);
  }
View Full Code Here

    // not found
    boolean ok = client.release(jobId, 65536, 0);
    assertFalse(ok);

    Job job = client.reserve(null);
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());

    // quick release
    ok = client.release(jobId, 65536, 0);
    assertTrue(ok);

    job = client.reserve(null);
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());

    ok = client.delete(jobId);
    assertTrue(ok);

    ok = client.release(jobId, 65536, 0);
View Full Code Here

    // we haven't reserved, so we can't bury
    ok = client.bury(jobId, 65536);
    assertFalse(ok);

    // we can bury
    Job job = client.reserve(0);
    assertNotNull(job);
    ok = client.bury(jobId, 65536);
    assertTrue(ok);

    // nothing to reserve
    job = client.reserve(0);
    assertNull(job);

    // kick nothing
    int count = client.kick(0);
    assertEquals(0, count);
    job = client.reserve(0);
    assertNull(job);

    // kick something
    count = client.kick(1);
    assertEquals(1, count);
    job = client.reserve(0);
    assertNotNull(job);
    assertEquals(jobId, job.getJobId());
    assertEquals(srcString, new String(job.getData()));

    client.delete(jobId);

    popWatchedTubes(client, tubeNames);
  }
View Full Code Here

    // we haven't reserved, so we can't bury
    ok = client.bury(jobId, 65536);
    assertFalse(ok);

    // we can bury
    Job job = client.reserve(0);
    assertNotNull(job);
    ok = client.bury(jobId, 65536);
    assertTrue(ok);

    // nothing to reserve
View Full Code Here

    // we haven't reserved, so we can't touch
    ok = client.touch(jobId);
    assertFalse(ok);

    // reserve the job
    Job job = client.reserve(null);
    assertNotNull(job);

    // try to reserve another job
    try {
      job = client.reserve(2 * timeoutSeconds);
 
View Full Code Here

    // producer
    client.useTube((String) tubeNames[1]);
    long jobId = client.put(65536, 0, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    Job job = client.reserve(null);
    assertNotNull(job);
    client.delete(jobId);

    map = client.statsTube((String) tubeNames[1]);
    assertNotNull(map);
View Full Code Here

    // producer
    client.useTube((String) tubeNames[1]);
    long jobId = client.put(65536, 0, 120, srcString.getBytes());
    assertTrue(jobId > 0);

    Job job = client.reserve(null);
    assertNotNull(job);

    map = client.statsJob(jobId);
    assertNotNull(map);
View Full Code Here

    Client client = new ClientImpl(TEST_HOST, TEST_PORT);

    Object[] tubeNames = pushWatchedTubes(client);
    client.useTube((String) tubeNames[1]);

    Job job = client.peek(-1);
    assertNull(job);
    job = client.peek(0);
    assertNull(job);

    String srcString = "testPeek-";

    int nJobs = 3;
    long[] jobIds = new long[nJobs];

    // producer
    for (int i = 0; i < nJobs; ++i) {
      client.useTube((String) tubeNames[1]);
      long jobId = client.put(65536, 0, 120, (srcString + i).getBytes());
      assertTrue(jobId > 0);
      jobIds[i] = jobId;
    }

    // peek 'em once
    for (int i = 0; i < nJobs; ++i) {
      job = client.peek(jobIds[i]);
      assertNotNull(job);
      assertEquals(jobIds[i], job.getJobId());
    }

    // peek 'em again
    for (int i = 0; i < nJobs; ++i) {
      job = client.peek(jobIds[i]);
      assertNotNull(job);
      assertEquals(jobIds[i], job.getJobId());
    }

    // reserve and delete
    for (int i = 0; i < nJobs; ++i) {
      job = client.reserve(null);
      assertNotNull(job);
      assertEquals(jobIds[i], job.getJobId());
      client.delete(job.getJobId());
    }

    // peek one last time
    for (int i = 0; i < nJobs; ++i) {
      job = client.peek(jobIds[i]);
View Full Code Here

TOP

Related Classes of com.surftools.BeanstalkClient.Job

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.