use of org.apache.activemq.artemis.core.client.impl.ClientProducerInternal in project activemq-artemis by apache.
the class ProducerFlowControlTest method testProducerCreditsCaching4.
@Test
public void testProducerCreditsCaching4() throws Exception {
server = createServer(false, isNetty());
server.start();
waitForServerToStart(server);
sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
session.createQueue("address", "queue1", null, false);
ClientProducerCredits credits = null;
for (int i = 0; i < ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE; i++) {
ClientProducer prod = session.createProducer("address" + i);
ClientProducerCredits newCredits = ((ClientProducerInternal) prod).getProducerCredits();
if (credits != null) {
Assert.assertFalse(newCredits == credits);
}
credits = newCredits;
prod.close();
Assert.assertEquals(i + 1, ((ClientSessionInternal) session).getProducerCreditManager().creditsMapSize());
Assert.assertEquals(i + 1, ((ClientSessionInternal) session).getProducerCreditManager().unReferencedCreditsSize());
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientProducerInternal in project activemq-artemis by apache.
the class ProducerFlowControlTest method testProducerCreditsCaching1.
@Test
public void testProducerCreditsCaching1() throws Exception {
server = createServer(false, isNetty());
server.start();
waitForServerToStart(server);
sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
session.createQueue("address", "queue1", null, false);
ClientProducerCredits credits = null;
for (int i = 0; i < ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE * 2; i++) {
ClientProducer prod = session.createProducer("address");
ClientProducerCredits newCredits = ((ClientProducerInternal) prod).getProducerCredits();
if (credits != null) {
Assert.assertTrue(newCredits == credits);
}
credits = newCredits;
Assert.assertEquals(1, ((ClientSessionInternal) session).getProducerCreditManager().creditsMapSize());
Assert.assertEquals(0, ((ClientSessionInternal) session).getProducerCreditManager().unReferencedCreditsSize());
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientProducerInternal in project activemq-artemis by apache.
the class ProducerFlowControlTest method testProducerCreditsCaching2.
@Test
public void testProducerCreditsCaching2() throws Exception {
server = createServer(false, isNetty());
server.start();
waitForServerToStart(server);
sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
session.createQueue("address", "queue1", null, false);
ClientProducerCredits credits = null;
for (int i = 0; i < ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE * 2; i++) {
ClientProducer prod = session.createProducer("address");
ClientProducerCredits newCredits = ((ClientProducerInternal) prod).getProducerCredits();
if (credits != null) {
Assert.assertTrue(newCredits == credits);
}
credits = newCredits;
prod.close();
Assert.assertEquals(1, ((ClientSessionInternal) session).getProducerCreditManager().creditsMapSize());
Assert.assertEquals(1, ((ClientSessionInternal) session).getProducerCreditManager().unReferencedCreditsSize());
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientProducerInternal in project activemq-artemis by apache.
the class ProducerFlowControlTest method testProducerCreditsCaching3.
@Test
public void testProducerCreditsCaching3() throws Exception {
server = createServer(false, isNetty());
server.start();
waitForServerToStart(server);
sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
session.createQueue("address", "queue1", null, false);
ClientProducerCredits credits = null;
for (int i = 0; i < ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE; i++) {
ClientProducer prod = session.createProducer("address" + i);
ClientProducerCredits newCredits = ((ClientProducerInternal) prod).getProducerCredits();
if (credits != null) {
Assert.assertFalse(newCredits == credits);
}
credits = newCredits;
Assert.assertEquals(i + 1, ((ClientSessionInternal) session).getProducerCreditManager().creditsMapSize());
Assert.assertEquals(0, ((ClientSessionInternal) session).getProducerCreditManager().unReferencedCreditsSize());
}
}
use of org.apache.activemq.artemis.core.client.impl.ClientProducerInternal in project activemq-artemis by apache.
the class ProducerFlowControlTest method testProducerCreditsCaching5.
@Test
public void testProducerCreditsCaching5() throws Exception {
server = createServer(false, isNetty());
server.start();
waitForServerToStart(server);
sf = createSessionFactory(locator);
session = sf.createSession(false, true, true, true);
session.createQueue("address", "queue1", null, false);
ClientProducerCredits credits = null;
List<ClientProducerCredits> creditsList = new ArrayList<>();
for (int i = 0; i < ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE; i++) {
ClientProducer prod = session.createProducer("address" + i);
ClientProducerCredits newCredits = ((ClientProducerInternal) prod).getProducerCredits();
if (credits != null) {
Assert.assertFalse(newCredits == credits);
}
credits = newCredits;
Assert.assertEquals(i + 1, ((ClientSessionInternal) session).getProducerCreditManager().creditsMapSize());
Assert.assertEquals(0, ((ClientSessionInternal) session).getProducerCreditManager().unReferencedCreditsSize());
creditsList.add(credits);
}
Iterator<ClientProducerCredits> iter = creditsList.iterator();
for (int i = 0; i < ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE; i++) {
ClientProducer prod = session.createProducer("address" + i);
ClientProducerCredits newCredits = ((ClientProducerInternal) prod).getProducerCredits();
Assert.assertTrue(newCredits == iter.next());
Assert.assertEquals(ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE, ((ClientSessionInternal) session).getProducerCreditManager().creditsMapSize());
Assert.assertEquals(0, ((ClientSessionInternal) session).getProducerCreditManager().unReferencedCreditsSize());
}
for (int i = 0; i < 10; i++) {
session.createProducer("address" + (i + ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE));
Assert.assertEquals(ClientProducerCreditManagerImpl.MAX_UNREFERENCED_CREDITS_CACHE_SIZE + i + 1, ((ClientSessionInternal) session).getProducerCreditManager().creditsMapSize());
Assert.assertEquals(0, ((ClientSessionInternal) session).getProducerCreditManager().unReferencedCreditsSize());
}
}
Aggregations