Search in sources :

Example 1 with CounterConsumer

use of alma.COUNTER.CounterConsumer in project ACS by ACS-Community.

the class CounterTest method testNC.

/**
	 * @throws Exception
	 */
public void testNC() throws Exception {
    // Start consumers first, then suppliers
    for (CounterConsumer consumer : consumers) {
        String componentName = consumer.name();
        try {
            consumer.getBlocks();
            m_logger.info(componentName + " now expecting blocks");
        } catch (CouldntPerformActionEx ex) {
            throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
        }
    }
    int blocksOut = 0;
    for (CounterSupplier supplier : suppliers) {
        String componentName = supplier.name();
        try {
            m_logger.info("requesting " + componentName + " to sendBlocks");
            blocksOut = supplier.sendBlocks(initVal, lastVal, changeVal, period);
            m_logger.info(componentName + " has sent " + blocksOut + " blocks");
        } catch (CouldntPerformActionEx ex) {
            throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
        }
    }
    // Now wait till all consumers are done ...
    int blocksIn = 0;
    for (CounterConsumer consumer : consumers) {
        String componentName = consumer.name();
        try {
            blocksIn = consumer.waitTillDone();
            m_logger.info(componentName + " has received " + blocksIn + " blocks");
            Assert.assertEquals(blocksOut, blocksIn);
        } catch (CouldntPerformActionEx ex) {
            throw AcsJCouldntPerformActionEx.fromCouldntPerformActionEx(ex);
        }
    }
// make sure there was enough time to let logs through 
//Thread.sleep(1000);
}
Also used : AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) CouldntPerformActionEx(alma.ACSErrTypeCommon.CouldntPerformActionEx) CounterSupplier(alma.COUNTER.CounterSupplier) CounterConsumer(alma.COUNTER.CounterConsumer)

Example 2 with CounterConsumer

use of alma.COUNTER.CounterConsumer in project ACS by ACS-Community.

the class CounterTest method setUp.

/**
	 * @see TestCase#setUp()
	 */
protected void setUp() throws Exception {
    super.setUp();
    // set names of test supplier/consumer components
    String compNames = System.getProperty(PROPERTYNAME_SUPPLIERNAMES);
    if (compNames != null) {
        // Note that the tokens need to be separated by slash or comma - the standard
        // whitespace separators cannot be used due to how acsStartJava eliminates quotes
        // with the help of "getopt -u". The way around that would be to set directly
        // the env var JAVA_OPTIONS.
        StringTokenizer tok = new StringTokenizer(compNames, " /,");
        while (tok.hasMoreTokens()) {
            supplierNames.add(tok.nextToken());
        }
        if (supplierNames.size() != 1) {
            Assert.fail("Property " + PROPERTYNAME_SUPPLIERNAMES + " must contain exactly 1 componentName");
        }
    }
    compNames = System.getProperty(PROPERTYNAME_CONSUMERNAMES);
    if (compNames != null) {
        StringTokenizer tok = new StringTokenizer(compNames, " /,");
        while (tok.hasMoreTokens()) {
            consumerNames.add(tok.nextToken());
        }
    }
    String number = System.getProperty(PROPERTYNAME_INITVALUE);
    if (number != null) {
        initVal = Integer.parseInt(number);
    }
    number = System.getProperty(PROPERTYNAME_LASTVALUE);
    if (number != null) {
        lastVal = Integer.parseInt(number);
    }
    changeVal = lastVal;
    number = System.getProperty(PROPERTYNAME_PERIOD);
    if (number != null) {
        period = Float.parseFloat(number);
    }
    suppliers = new ArrayList<CounterSupplier>();
    for (String compName : supplierNames) {
        suppliers.add(alma.COUNTER.CounterSupplierHelper.narrow(getContainerServices().getComponent(compName)));
    }
    consumers = new ArrayList<CounterConsumer>();
    for (String compName : consumerNames) {
        System.out.println("Bringing up consumer " + compName);
        consumers.add(alma.COUNTER.CounterConsumerHelper.narrow(getContainerServices().getComponent(compName)));
    }
    containerTestUtil = new ContainerTestUtil(getContainerServices(), m_acsManagerProxy);
    containerTestUtil.loginToManager();
}
Also used : CounterSupplier(alma.COUNTER.CounterSupplier) StringTokenizer(java.util.StringTokenizer) CounterConsumer(alma.COUNTER.CounterConsumer)

Aggregations

CounterConsumer (alma.COUNTER.CounterConsumer)2 CounterSupplier (alma.COUNTER.CounterSupplier)2 CouldntPerformActionEx (alma.ACSErrTypeCommon.CouldntPerformActionEx)1 AcsJCouldntPerformActionEx (alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)1 StringTokenizer (java.util.StringTokenizer)1