Search in sources :

Example 11 with ByteSequence

use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.

the class JobSchedulerTest method testAddLongLongIntStringByteSequence.

@Test
public void testAddLongLongIntStringByteSequence() throws Exception {
    final int COUNT = 10;
    final CountDownLatch latch = new CountDownLatch(COUNT);
    scheduler.addListener(new JobListener() {

        @Override
        public void scheduledJob(String id, ByteSequence job) {
            latch.countDown();
        }
    });
    long time = 2000;
    for (int i = 0; i < COUNT; i++) {
        String test = new String("test" + i);
        scheduler.schedule("id" + i, new ByteSequence(test.getBytes()), "", time, 10, -1);
    }
    assertTrue(latch.getCount() == COUNT);
    latch.await(3000, TimeUnit.SECONDS);
    assertTrue(latch.getCount() == 0);
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) ByteSequence(org.apache.activemq.util.ByteSequence) Test(org.junit.Test)

Example 12 with ByteSequence

use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.

the class JobSchedulerTest method testRemoveAllJobsInRange.

@Test
public void testRemoveAllJobsInRange() throws Exception {
    final int COUNT = 10;
    final String ID = "id:";
    long start = 10000;
    for (int i = 0; i < COUNT; i++) {
        String str = new String("test" + i);
        scheduler.schedule(ID + i, new ByteSequence(str.getBytes()), "", start + (i * 1000), 10000 + i, 0);
    }
    start = System.currentTimeMillis();
    long finish = start + 12000 + (COUNT * 1000);
    scheduler.removeAllJobs(start, finish);
    assertTrue(scheduler.getAllJobs().isEmpty());
}
Also used : ByteSequence(org.apache.activemq.util.ByteSequence) Test(org.junit.Test)

Example 13 with ByteSequence

use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.

the class JobSchedulerStoreCheckpointTest method setUp.

@Before
public void setUp() throws Exception {
    File directory = new File("target/test/ScheduledJobsDB");
    IOHelper.mkdirs(directory);
    IOHelper.deleteChildren(directory);
    startStore(directory);
    byte[] data = new byte[8192];
    for (int i = 0; i < data.length; ++i) {
        data[i] = (byte) (i % 256);
    }
    payload = new ByteSequence(data);
}
Also used : File(java.io.File) ByteSequence(org.apache.activemq.util.ByteSequence) Before(org.junit.Before)

Example 14 with ByteSequence

use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.

the class FilePendingMessageCursorTestSupport method createBrokerWithTempStoreLimit.

private void createBrokerWithTempStoreLimit() throws Exception {
    brokerService = new BrokerService();
    brokerService.setUseJmx(false);
    SystemUsage usage = brokerService.getSystemUsage();
    usage.getTempUsage().setLimit(1025 * 1024 * 15);
    // put something in the temp store to on demand initialise it
    PList dud = brokerService.getTempDataStore().getPList("dud");
    dud.addFirst("A", new ByteSequence("A".getBytes()));
}
Also used : PList(org.apache.activemq.store.PList) SystemUsage(org.apache.activemq.usage.SystemUsage) BrokerService(org.apache.activemq.broker.BrokerService) ByteSequence(org.apache.activemq.util.ByteSequence)

Example 15 with ByteSequence

use of org.apache.activemq.util.ByteSequence in project activemq-artemis by apache.

the class DataFileGeneratorTestSupport method assertByteSequencesEqual.

protected void assertByteSequencesEqual(String message, ByteSequence expected, Object actualValue) {
    assertTrue(message + ". Actual value should be a ByteSequence but was: " + actualValue, actualValue instanceof ByteSequence);
    ByteSequence actual = (ByteSequence) actualValue;
    int length = expected.getLength();
    assertEquals(message + ". Length", length, actual.getLength());
    int offset = expected.getOffset();
    assertEquals(message + ". Offset", offset, actual.getOffset());
    byte[] data = expected.getData();
    byte[] actualData = actual.getData();
    for (int i = 0; i < length; i++) {
        assertEquals(message + ". Offset " + i, data[offset + i], actualData[offset + i]);
    }
}
Also used : ByteSequence(org.apache.activemq.util.ByteSequence)

Aggregations

ByteSequence (org.apache.activemq.util.ByteSequence)31 Test (org.junit.Test)13 CountDownLatch (java.util.concurrent.CountDownLatch)6 File (java.io.File)4 ActiveMQDestination (org.apache.activemq.command.ActiveMQDestination)4 ActiveMQBuffer (org.apache.activemq.artemis.api.core.ActiveMQBuffer)3 ArrayList (java.util.ArrayList)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 ActiveMQMessage (org.apache.activemq.command.ActiveMQMessage)2 DataStructure (org.apache.activemq.command.DataStructure)2 MessageId (org.apache.activemq.command.MessageId)2 ProducerId (org.apache.activemq.command.ProducerId)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 Calendar (java.util.Calendar)1 Deflater (java.util.zip.Deflater)1 MessageConsumer (javax.jms.MessageConsumer)1 Session (javax.jms.Session)1 ActiveMQConnection (org.apache.activemq.ActiveMQConnection)1 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)1