Search in sources :

Example 6 with ComponentSpec

use of si.ijs.maci.ComponentSpec in project ACS by ACS-Community.

the class StressStartComponents method testStartComponents.

/**
	 * The test concurrently starts {@link StressStartComponents#totComponentsToStart} components
	 * in {@link StressStartComponents#totThreads} threads.
	 * 
	 * @throws Exception
	 */
public void testStartComponents() throws Exception {
    startContainers();
    ContainerData[] containers = new ContainerData[startedContainers.size()];
    startedContainers.toArray(containers);
    // The names of the components to start and stop
    Vector<String> componentNames = new Vector<String>(totComponentsToStart);
    // Start the components
    Vector<Future<MountOperations>> tasks = new Vector<Future<MountOperations>>();
    // to cycle through containers in the array
    int c = 0;
    long startLoadTime = System.currentTimeMillis();
    for (int t = 0; t < totComponentsToStart; t++) {
        String name = componentNameTrailing + t;
        String contName = containers[c].name;
        c = (c + 1) % containers.length;
        logger.info("Starting " + name);
        ComponentSpec spec = new ComponentSpec(name, "IDL:alma/testManager/Mount:1.0", "mount", contName);
        tasks.add(componentAccessUtil.getDynamicComponentConcurrent(spec, MountOperations.class));
        componentNames.addElement(name);
    }
    assertEquals("The size of the names and the components to start does not match!", totComponentsToStart, componentNames.size());
    // wait for the termination of all the tasks
    int n = 1;
    logger.info("Waiting termination of " + tasks.size() + " tasks");
    for (Future<MountOperations> ft : tasks) {
        try {
            ft.get(5, TimeUnit.MINUTES);
            if (ft instanceof InstrumentedFutureTask<?>) {
                InstrumentedFutureTask ift = (InstrumentedFutureTask) ft;
                logTime("Component loaded in ", ift.getExecutionTime());
            }
            logger.info("A task got the component. Number of terminated tasks: " + n);
        } catch (ExecutionException ee) {
            logger.severe("Exception returned from task while getting component: " + ee.getMessage());
        } catch (CancellationException ce) {
            logger.warning("Task cancelled while getting component: " + ce.getMessage());
        } catch (TimeoutException te) {
            logger.severe("Timeout from task while getting component: " + te.getMessage());
        } finally {
            n++;
        }
    }
    long endLoadTime = System.currentTimeMillis();
    logTime("The threads got all the components in ", endLoadTime - startLoadTime);
    // In this case a message is logged and will trigger a failure in the tat test
    if (endLoadTime - startLoadTime > 120 * 1000) {
        logTime(AcsLogLevel.WARNING, "It seems that the load time of the components was too slow (expected<2min): ", endLoadTime - startLoadTime);
    }
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ie) {
    }
    assertEquals("Num of requested components mismatch", totComponentsToStart, adminOperations.getNumOfRequestedComps());
    assertEquals("Num of activated component mismatch", totComponentsToStart, adminOperations.getNumOfActivatedComps());
    logger.info("Releasing components");
    // release all the components in parallel
    long startTime = System.currentTimeMillis();
    // Randomly sort the collection to randomly relase components
    Collections.shuffle(componentNames);
    componentAccessUtil.releaseComponents(componentNames, true);
    long endTime = System.currentTimeMillis();
    logTime("Components released in ", endTime - startTime);
    // In this case a message is logged and will trigger a failure in the tat test
    if (endTime - startTime > 120 * 1000) {
        logTime(AcsLogLevel.WARNING, "It seems that the unload time of the components was too slow (expected<2min): ", endTime - startTime);
    }
    // Wait for th ennotification of componentes releases deactivations before shutting down
    // the containers
    startTime = System.currentTimeMillis();
    while (adminOperations.getNumOfDeactivatedComps() != totComponentsToStart && System.currentTimeMillis() < startTime + 120000) {
        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            continue;
        }
    }
    if (adminOperations.getNumOfDeactivatedComps() != totComponentsToStart) {
        logger.log(AcsLogLevel.ERROR, "Deactivated " + adminOperations.getNumOfDeactivatedComps() + " instead of " + totComponentsToStart);
    } else {
        logger.log(AcsLogLevel.INFO, "All components deactivated");
    }
    startTime = System.currentTimeMillis();
    while (adminOperations.getNumOfReleasedComps() != totComponentsToStart && System.currentTimeMillis() < startTime + 120000) {
        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            continue;
        }
    }
    if (adminOperations.getNumOfReleasedComps() != totComponentsToStart) {
        logger.log(AcsLogLevel.ERROR, "Released " + adminOperations.getNumOfReleasedComps() + " instead of " + totComponentsToStart);
    } else {
        logger.log(AcsLogLevel.INFO, "All components released");
    }
    logger.info("Stopping containers");
    // Stop containers
    startTime = System.currentTimeMillis();
    stopContainers();
    endTime = System.currentTimeMillis();
    logTime("Containers stopped in ", endTime - startTime);
}
Also used : ComponentSpec(si.ijs.maci.ComponentSpec) TimeoutException(java.util.concurrent.TimeoutException) CancellationException(java.util.concurrent.CancellationException) ExecutionException(java.util.concurrent.ExecutionException) InstrumentedFutureTask(acs.benchmark.util.ConcurrentComponentAccessUtil.InstrumentedFutureTask) CancellationException(java.util.concurrent.CancellationException) MountOperations(alma.testManager.MountOperations) Future(java.util.concurrent.Future) ExecutionException(java.util.concurrent.ExecutionException) Vector(java.util.Vector) TimeoutException(java.util.concurrent.TimeoutException)

Example 7 with ComponentSpec

use of si.ijs.maci.ComponentSpec in project ACS by ACS-Community.

the class PubSubComponentAccessUtil method getDynamicSubscriberComponent.

public CorbaNotifyConsumerOperations getDynamicSubscriberComponent(String componentName, String containerName, ImplLangT implLang) throws AcsJContainerServicesEx {
    String code = null;
    switch(implLang.getType()) {
        case ImplLangT.JAVA_TYPE:
            // Cannot use class#getName because the component helper is not visible to the normal client classloader
            code = "acs.benchmark.nc.comp.subscriber.CorbaNotifyConsumerComponentHelper";
            break;
        default:
            throw new IllegalArgumentException("Component impl '" + implLang.toString() + "' not yet supported!");
    }
    ComponentSpec compSpec = new ComponentSpec(componentName, // "IDL:alma/benchmark/CorbaNotifyConsumer:1.0" 
    CorbaNotifyConsumerHelper.id(), code, containerName);
    return getDynamicComponent(compSpec, CorbaNotifyConsumerOperations.class);
}
Also used : ComponentSpec(si.ijs.maci.ComponentSpec)

Aggregations

ComponentSpec (si.ijs.maci.ComponentSpec)7 ExecutionException (java.util.concurrent.ExecutionException)2 Future (java.util.concurrent.Future)2 ComponentInfo (si.ijs.maci.ComponentInfo)2 InstrumentedFutureTask (acs.benchmark.util.ConcurrentComponentAccessUtil.InstrumentedFutureTask)1 InvalidComponentSpecEx (alma.maciErrType.InvalidComponentSpecEx)1 NoDefaultComponentEx (alma.maciErrType.NoDefaultComponentEx)1 DummyComponent (alma.managertest.DummyComponent)1 MountOperations (alma.testManager.MountOperations)1 ArrayList (java.util.ArrayList)1 Vector (java.util.Vector)1 Callable (java.util.concurrent.Callable)1 CancellationException (java.util.concurrent.CancellationException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 POAManager (org.omg.PortableServer.POAManager)1 ClientInfo (si.ijs.maci.ClientInfo)1 Manager (si.ijs.maci.Manager)1