use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class JournalImpl method runDirectJournalBlast.
@Override
public void runDirectJournalBlast() throws Exception {
final int numIts = 100000000;
ActiveMQJournalLogger.LOGGER.runningJournalBlast(numIts);
final CountDownLatch latch = new CountDownLatch(numIts * 2);
class MyAIOCallback implements IOCompletion {
@Override
public void done() {
latch.countDown();
}
@Override
public void onError(final int errorCode, final String errorMessage) {
}
@Override
public void storeLineUp() {
}
}
final MyAIOCallback task = new MyAIOCallback();
final int recordSize = 1024;
final byte[] bytes = new byte[recordSize];
class MyRecord implements EncodingSupport {
@Override
public void decode(final ActiveMQBuffer buffer) {
}
@Override
public void encode(final ActiveMQBuffer buffer) {
buffer.writeBytes(bytes);
}
@Override
public int getEncodeSize() {
return recordSize;
}
}
MyRecord record = new MyRecord();
for (int i = 0; i < numIts; i++) {
appendAddRecord(i, (byte) 1, record, true, task);
appendDeleteRecord(i, true, task);
}
latch.await();
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class JDBCSequentialFileFactoryTest method testCopyFile.
@Test
public void testCopyFile() throws Exception {
JDBCSequentialFile file = (JDBCSequentialFile) factory.createSequentialFile("test.txt");
file.open();
// Create buffer and fill with test data
int bufferSize = 1024;
ActiveMQBuffer src = ActiveMQBuffers.fixedBuffer(bufferSize);
for (int i = 0; i < bufferSize; i++) {
src.writeByte((byte) 5);
}
IOCallbackCountdown callback = new IOCallbackCountdown(1);
file.internalWrite(src, callback);
JDBCSequentialFile copy = (JDBCSequentialFile) factory.createSequentialFile("copy.txt");
file.copyTo(copy);
checkData(file, src);
checkData(copy, src);
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class JDBCSequentialFileFactoryTest method testCloneFile.
@Test
public void testCloneFile() throws Exception {
JDBCSequentialFile file = (JDBCSequentialFile) factory.createSequentialFile("test.txt");
file.open();
// Create buffer and fill with test data
int bufferSize = 1024;
ActiveMQBuffer src = ActiveMQBuffers.fixedBuffer(bufferSize);
for (int i = 0; i < bufferSize; i++) {
src.writeByte((byte) 5);
}
IOCallbackCountdown callback = new IOCallbackCountdown(1);
file.internalWrite(src, callback);
assertEquals(bufferSize, file.size());
JDBCSequentialFile copy = (JDBCSequentialFile) file.cloneFile();
copy.open();
assertEquals(bufferSize, copy.size());
assertEquals(bufferSize, file.size());
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class JDBCJournalRecord method setTxData.
void setTxData(EncodingSupport txData) {
this.txDataSize = txData.getEncodeSize();
ActiveMQBuffer encodedBuffer = ActiveMQBuffers.fixedBuffer(txDataSize);
txData.encode(encodedBuffer);
this.txData = new ActiveMQBufferInputStream(encodedBuffer);
}
use of org.apache.activemq.artemis.api.core.ActiveMQBuffer in project activemq-artemis by apache.
the class CoreClientTest method testCoreClient.
private void testCoreClient(final boolean netty, ServerLocator serverLocator) throws Exception {
final SimpleString QUEUE = new SimpleString("CoreClientTestQueue");
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(createDefaultConfig(netty), false));
server.start();
ServerLocator locator = serverLocator == null ? createNonHALocator(netty) : serverLocator;
ClientSessionFactory sf = createSessionFactory(locator);
ClientSession session = sf.createSession(false, true, true);
session.createQueue(QUEUE, QUEUE, null, false);
ClientProducer producer = session.createProducer(QUEUE);
final int numMessages = 1000;
for (int i = 0; i < numMessages; i++) {
ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
message.putStringProperty("foo", "bar");
// One way around the setting destination problem is as follows -
// Remove destination as an attribute from client producer.
// The destination always has to be set explicitly before sending a message
message.setAddress(QUEUE);
message.getBodyBuffer().writeString("testINVMCoreClient");
producer.send(message);
}
CoreClientTest.log.info("sent messages");
ClientConsumer consumer = session.createConsumer(QUEUE);
session.start();
for (int i = 0; i < numMessages; i++) {
ClientMessage message2 = consumer.receive();
ActiveMQBuffer buffer = message2.getBodyBuffer();
Assert.assertEquals("testINVMCoreClient", buffer.readString());
message2.acknowledge();
}
sf.close();
}
Aggregations