Search in sources :

Example 1 with InternalQueue

use of org.apache.synapse.commons.executors.InternalQueue in project wso2-synapse by wso2.

the class PriorityExecutorSerializerTest method testSerializeWithUnboundedQueues.

/**
 * Test serializing a PriorityExecutor created with UnboundedQueues
 */
public void testSerializeWithUnboundedQueues() {
    PriorityExecutor priorityExecutor = new PriorityExecutor();
    priorityExecutor.setName("executor1");
    List<InternalQueue> internalQueueList = new ArrayList<>();
    internalQueueList.add(new UnboundedQueue(10));
    internalQueueList.add(new UnboundedQueue(5));
    MultiPriorityBlockingQueue multiPriorityBlockingQueue = new MultiPriorityBlockingQueue(internalQueueList, false, new PRRNextQueueAlgorithm());
    priorityExecutor.setQueue(multiPriorityBlockingQueue);
    OMElement element = PriorityExecutorSerializer.serialize(null, priorityExecutor, "http://ws.apache.org/ns/synapse");
    assertEquals("Invalid serialization of PriorityExecutor", "<priorityExecutor xmlns=\"http://ws.apache.org/ns/synapse\" name=\"executor1\">" + "<queues isFixedSize=\"false\"><queue priority=\"10\" /><queue priority=\"5\" /></queues>" + "<threads max=\"100\" core=\"20\" keep-alive=\"5\" />" + "</priorityExecutor>", element.toString());
}
Also used : PRRNextQueueAlgorithm(org.apache.synapse.commons.executors.PRRNextQueueAlgorithm) UnboundedQueue(org.apache.synapse.commons.executors.queues.UnboundedQueue) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) MultiPriorityBlockingQueue(org.apache.synapse.commons.executors.MultiPriorityBlockingQueue) InternalQueue(org.apache.synapse.commons.executors.InternalQueue)

Example 2 with InternalQueue

use of org.apache.synapse.commons.executors.InternalQueue in project wso2-synapse by wso2.

the class PriorityExecutorSerializerTest method testSerialize.

/**
 * Test serializing a PriorityExecutor created with FixedSizeQueues
 */
public void testSerialize() {
    PriorityExecutor priorityExecutor = new PriorityExecutor();
    priorityExecutor.setName("executor1");
    List<InternalQueue> internalQueueList = new ArrayList<>();
    internalQueueList.add(new FixedSizeQueue(10, 10));
    internalQueueList.add(new FixedSizeQueue(5, 25));
    MultiPriorityBlockingQueue multiPriorityBlockingQueue = new MultiPriorityBlockingQueue(internalQueueList, true, new PRRNextQueueAlgorithm());
    priorityExecutor.setQueue(multiPriorityBlockingQueue);
    OMElement element = PriorityExecutorSerializer.serialize(null, priorityExecutor, "http://ws.apache.org/ns/synapse");
    assertEquals("Invalid serialization of PriorityExecutor", "<priorityExecutor xmlns=\"http://ws.apache.org/ns/synapse\" name=\"executor1\">" + "<queues><queue size=\"10\" priority=\"10\" /><queue size=\"25\" priority=\"5\" /></queues>" + "<threads max=\"100\" core=\"20\" keep-alive=\"5\" />" + "</priorityExecutor>", element.toString());
}
Also used : FixedSizeQueue(org.apache.synapse.commons.executors.queues.FixedSizeQueue) PRRNextQueueAlgorithm(org.apache.synapse.commons.executors.PRRNextQueueAlgorithm) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) MultiPriorityBlockingQueue(org.apache.synapse.commons.executors.MultiPriorityBlockingQueue) InternalQueue(org.apache.synapse.commons.executors.InternalQueue)

Example 3 with InternalQueue

use of org.apache.synapse.commons.executors.InternalQueue in project wso2-synapse by wso2.

the class PriorityExecutorSerializerTest method testSerializeGivenParentElement.

/**
 * Test serializing a PriorityExecutor when parent element is defined
 * @throws XMLStreamException
 */
public void testSerializeGivenParentElement() throws XMLStreamException {
    OMElement parentElement = AXIOMUtil.stringToOM("<definitions></definitions>");
    PriorityExecutor priorityExecutor = new PriorityExecutor();
    priorityExecutor.setName("executor1");
    List<InternalQueue> internalQueueList = new ArrayList<>();
    internalQueueList.add(new FixedSizeQueue(10, 10));
    internalQueueList.add(new FixedSizeQueue(5, 25));
    MultiPriorityBlockingQueue multiPriorityBlockingQueue = new MultiPriorityBlockingQueue(internalQueueList, true, new PRRNextQueueAlgorithm());
    priorityExecutor.setQueue(multiPriorityBlockingQueue);
    PriorityExecutorSerializer.serialize(parentElement, priorityExecutor, "http://ws.apache.org/ns/synapse");
    assertEquals("Invalid serialization of PriorityExecutor", "<definitions>" + "<priorityExecutor xmlns=\"http://ws.apache.org/ns/synapse\" name=\"executor1\">" + "<queues><queue size=\"10\" priority=\"10\" /><queue size=\"25\" priority=\"5\" /></queues>" + "<threads max=\"100\" core=\"20\" keep-alive=\"5\" />" + "</priorityExecutor>" + "</definitions>", parentElement.toString());
}
Also used : FixedSizeQueue(org.apache.synapse.commons.executors.queues.FixedSizeQueue) PRRNextQueueAlgorithm(org.apache.synapse.commons.executors.PRRNextQueueAlgorithm) ArrayList(java.util.ArrayList) OMElement(org.apache.axiom.om.OMElement) PriorityExecutor(org.apache.synapse.commons.executors.PriorityExecutor) MultiPriorityBlockingQueue(org.apache.synapse.commons.executors.MultiPriorityBlockingQueue) InternalQueue(org.apache.synapse.commons.executors.InternalQueue)

Aggregations

ArrayList (java.util.ArrayList)3 OMElement (org.apache.axiom.om.OMElement)3 InternalQueue (org.apache.synapse.commons.executors.InternalQueue)3 MultiPriorityBlockingQueue (org.apache.synapse.commons.executors.MultiPriorityBlockingQueue)3 PRRNextQueueAlgorithm (org.apache.synapse.commons.executors.PRRNextQueueAlgorithm)3 PriorityExecutor (org.apache.synapse.commons.executors.PriorityExecutor)3 FixedSizeQueue (org.apache.synapse.commons.executors.queues.FixedSizeQueue)2 UnboundedQueue (org.apache.synapse.commons.executors.queues.UnboundedQueue)1