use of com.cosylab.acs.maci.StatusHolder in project ACS by ACS-Community.
the class ManagerImpl method containerPostLoginActivation.
/**
* Container post login activation, activate startup and unavailable components.
* NOTE: to be run in separate thread.
*
* @param containerInfo container info for which to perform post login activation.
* @param recoverContainer recovery mode flag.
*/
private void containerPostLoginActivation(final ContainerInfo containerInfo, boolean recoverContainer) {
// give containers some time to fully initialize
if (containerInfo.getImplLang() == ImplLang.cpp || containerInfo.getImplLang() == ImplLang.not_specified) {
try {
Thread.sleep(3000);
} catch (InterruptedException ie) {
}
}
// shutdown check
if (isShuttingDown())
return;
// CDB startup
if (cdbActivation != null && containerInfo.getName().equals(cdbActivation.getContainer())) {
try {
StatusHolder status = new StatusHolder();
ComponentInfo cdbInfo = internalRequestComponent(this.getHandle(), cdbActivation.getName(), cdbActivation.getType(), cdbActivation.getCode(), cdbActivation.getContainer(), RELEASE_IMMEDIATELY, status, true);
if (status.getStatus() != ComponentStatus.COMPONENT_ACTIVATED)
logger.log(Level.SEVERE, "Failed to activate CDB, reason: '" + status.getStatus() + "'.");
else if (cdbInfo == null || cdbInfo.getHandle() == 0 || cdbInfo.getComponent() == null)
logger.log(Level.SEVERE, "Failed to activate CDB, invalid ComponentInfo returned: '" + cdbInfo + "'.");
else {
logger.log(Level.INFO, "CDB activated on container '" + containerInfo.getName() + "'.");
}
} catch (Throwable ex) {
logger.log(Level.SEVERE, "Failed to activate CDB on container '" + containerInfo.getName() + "'.", ex);
}
}
// used for fast lookups
Map<String, Integer> activationRequests = new HashMap<String, Integer>();
// order is important, preserve it
ArrayList<URI> activationRequestsList = new ArrayList<URI>();
// get CDB access daos
DAOProxy dao = getManagerDAOProxy();
DAOProxy componentsDAO = getComponentsDAOProxy();
//
if (dao != null && componentsDAO != null) {
try {
// query startup components
String[] startup = dao.get_string_seq("Startup");
final Integer managerHandle = new Integer(this.getHandle());
for (int i = 0; i < startup.length; i++) {
// TODO simulator test workaround
if (startup[i].length() == 0)
continue;
// read container field
String containerName = readStringCharacteristics(componentsDAO, startup[i] + "/Container");
if (containerName == null) {
logger.log(Level.WARNING, "Misconfigured CDB, there is no container of component '" + startup[i] + "' defined.");
continue;
}
// if container name matches, add activation request
if (containerInfo.getName().equals(containerName)) {
try {
URI curl = CURLHelper.createURI(startup[i]);
// check CURL
try {
checkCURL(curl);
} catch (RuntimeException e) {
// @todo Auto-generated catch block
e.printStackTrace();
}
activationRequestsList.add(curl);
activationRequests.put(startup[i], managerHandle);
} catch (URISyntaxException usi) {
logger.log(Level.WARNING, "Failed to create URI from component name '" + startup[i] + "'.", usi);
}
}
}
} catch (Throwable th) {
logger.log(Level.WARNING, "Failed to retrieve list of startup components.", th);
}
}
//
// autostart components (<component>.Autostart attribute)
//
final String TRUE_STRING = "true";
if (componentsDAO != null) {
try {
final Integer managerHandle = new Integer(this.getHandle());
// get names of all components
// TODO here to check if CDB is available
componentsDAO.get_field_data("");
/*String[] ids =*/
String[] ids = getComponentsList();
// test names
for (int i = 0; i < ids.length; i++) {
// read name
//readStringCharacteristics(componentsDAO, ids[i]+"/Name");
String name = ids[i];
if (name == null) {
logger.log(Level.WARNING, "Misconfigured CDB, there is no name of component '" + ids[i] + "' defined.");
continue;
}
// read autostart silently
String autostart = readStringCharacteristics(componentsDAO, ids[i] + "/Autostart", true);
if (autostart == null) {
logger.log(Level.WARNING, "Misconfigured CDB, there is no autostart attribute of component '" + ids[i] + "' defined.");
continue;
} else if (autostart.equalsIgnoreCase(TRUE_STRING) && !activationRequests.containsKey(name)) /* TODO to be removed */
{
// read container silently
String componentContainer = readStringCharacteristics(componentsDAO, ids[i] + "/Container", true);
if (componentContainer == null) {
logger.log(Level.WARNING, "Misconfigured CDB, there is no container attribute of component '" + ids[i] + "' defined.");
continue;
} else if (!containerInfo.getName().equals(componentContainer))
continue;
try {
URI curl = CURLHelper.createURI(name);
// check CURL, no non-local curls
try {
checkCURL(curl, false);
} catch (RuntimeException e) {
reportException(e);
}
activationRequestsList.add(curl);
activationRequests.put(name, managerHandle);
} catch (URISyntaxException usi) {
logger.log(Level.WARNING, "Failed to create URI from component name '" + name + "'.", usi);
}
}
}
} catch (Throwable ex) {
logger.log(Level.WARNING, "Failed to retrieve list of components.", ex);
}
}
// list of componentInfo to be cleaned up (cannot be immediately, due to lock)
ArrayList<ComponentInfo> cleanupList = new ArrayList<ComponentInfo>();
// check unavailable components
if (unavailableComponents.size() > 0) {
if (componentsDAO != null) {
try {
final Integer reactivateHandle = new Integer(0);
synchronized (unavailableComponents) {
String[] names = unavailableComponents.keySet().toArray(new String[unavailableComponents.size()]);
// reverse
for (int i = names.length - 1; i >= 0; i--) {
String name = names[i];
boolean reactivate = false;
// dynamic component check
ComponentInfo componentInfo = unavailableComponents.get(name);
if (componentInfo != null && componentInfo.isDynamic() && componentInfo.getDynamicContainerName() != null && componentInfo.getDynamicContainerName().equals(containerInfo.getName())) {
// reactivate dynamic component
reactivate = true;
} else {
// read container field
String containerName = readStringCharacteristics(componentsDAO, name + "/Container");
if (containerName == null) {
logger.log(Level.WARNING, "Misconfigured CDB, there is no container of component '" + name + "' defined.");
//continue;
} else // if container name matches, add (override) activation request
if (containerInfo.getName().equals(containerName)) {
reactivate = true;
}
}
if (reactivate) {
// clean up if in non-recovery mode
if (!recoverContainer) {
// and if not already in activation list (startup component)
if (!activationRequests.containsKey(name)) {
cleanupList.add(componentInfo);
continue;
}
}
// this Component needs reactivation
if (activationRequests.containsKey(name)) {
activationRequests.put(name, reactivateHandle);
} else // put to activation list
{
try {
activationRequestsList.add(CURLHelper.createURI(name));
activationRequests.put(name, reactivateHandle);
} catch (URISyntaxException usi) {
logger.log(Level.WARNING, "Failed to create URI from component name '" + name + "'.", usi);
}
}
}
}
}
} catch (Throwable ex) {
CoreException ce = new CoreException("Failed to obtain component data from the CDB.", ex);
reportException(ce);
}
}
}
if (cleanupList.size() > 0) {
Iterator<ComponentInfo> iter = cleanupList.iterator();
while (iter.hasNext()) {
ComponentInfo componentInfo = iter.next();
componentsLock.lock();
try {
// remove from its owners list ...
int[] owners = componentInfo.getClients().toArray();
for (int j = 0; j < owners.length; j++) removeComponentOwner(componentInfo.getHandle(), owners[j]);
// ... and deallocate
executeCommand(new ComponentCommandDeallocate(componentInfo.getHandle() & HANDLE_MASK, componentInfo.getHandle(), WhyUnloadedReason.REMOVED));
executeCommand(new UnavailableComponentCommandRemove(componentInfo.getName()));
// remove component from container component list
synchronized (containerInfo.getComponents()) {
if (containerInfo.getComponents().contains(componentInfo.getHandle()))
executeCommand(new ContainerInfoCommandComponentRemove(containerInfo.getHandle() & HANDLE_MASK, componentInfo.getHandle()));
}
} finally {
componentsLock.unlock();
}
// unbind from remote directory
//unbind(convertToHiearachical(componentInfo.getName()), "O");
}
}
logger.log(Level.INFO, "Container '" + containerInfo.getName() + "' startup statistics: " + activationRequestsList.size() + " components queued to be activated.");
// send message to the container
sendMessage(containerInfo.getContainer(), "Startup statistics: " + activationRequestsList.size() + " components queued to be activated.", MessageType.MSG_INFORMATION, ClientOperations.MSGID_AUTOLOAD_START);
// activate startup components
int activated = 0;
StatusHolder status = new StatusHolder();
Iterator<URI> iterator = activationRequestsList.iterator();
while (iterator.hasNext()) {
URI uri = iterator.next();
try {
String name = extractName(uri);
int requestor = activationRequests.get(name);
internalRequestComponent(requestor, uri, status);
if (status.getStatus() != ComponentStatus.COMPONENT_ACTIVATED)
logger.log(Level.WARNING, "Failed to activate autostart component '" + uri + "', reason: '" + status.getStatus() + "'.");
else
activated++;
} catch (Throwable ex) {
logger.log(Level.WARNING, "Failed to activate autostart component '" + uri + "'.", ex);
}
}
logger.log(Level.INFO, "Container '" + containerInfo.getName() + "' startup statistics: " + activated + " of " + activationRequestsList.size() + " components activated.");
// send message to the container
sendMessage(containerInfo.getContainer(), "Startup statistics: " + activated + " of " + activationRequestsList.size() + " components activated.", MessageType.MSG_INFORMATION, ClientOperations.MSGID_AUTOLOAD_END);
// notify about new container login
synchronized (containerLoggedInMonitor) {
containerLoggedInMonitor.notifyAll();
}
}
use of com.cosylab.acs.maci.StatusHolder in project ACS by ACS-Community.
the class ManagerImpl method internalRequestDefaultComponent.
/**
* Internal method for requesting default components.
* @param requestor requestor of the component.
* @param typr type of the component
* @return componentInfo <code>ComponentInfo</code> of requested default component.
*/
private ComponentInfo internalRequestDefaultComponent(int requestor, String type) throws NoDefaultComponentException {
String defaultComponentName = null;
ComponentInfo defaultComponentInfo = null;
// first check default components table
synchronized (defaultComponents) {
defaultComponentInfo = defaultComponents.get(type);
}
if (defaultComponentInfo != null)
defaultComponentName = defaultComponentInfo.getName();
// if not found, search for the default component in the CDB
if (defaultComponentName == null) {
DAOProxy componentsDAO = getComponentsDAOProxy();
if (componentsDAO != null) {
try {
// get names of all components
// @todo here to check if CDB is available
componentsDAO.get_field_data("");
/*String[] ids =*/
String[] ids = getComponentsList();
// test names
for (int i = 0; i < ids.length; i++) {
// read name
//readStringCharacteristics(componentsDAO, ids[i]+"/Name");
String name = ids[i];
if (name == null) {
logger.log(Level.WARNING, "Misconfigured CDB, there is no type of component '" + ids[i] + "' defined.");
continue;
}
// do not search dynamic components (they cannot be marked as default in CDB anyway)
if (!name.equals(ComponentSpec.COMPSPEC_ANY)) {
// read type
String componentType = readStringCharacteristics(componentsDAO, ids[i] + "/Type");
if (type == null) {
logger.log(Level.WARNING, "Misconfigured CDB, there is no type of component '" + name + "' defined.");
continue;
}
// test type
final String TRUE_STRING = "true";
if (type.equals(componentType)) {
// check if it is default, read silently
String isDefault = readStringCharacteristics(componentsDAO, ids[i] + "/Default", true);
if (isDefault == null || !isDefault.equalsIgnoreCase(TRUE_STRING))
continue;
// got the match
defaultComponentName = name;
break;
}
}
}
} catch (Throwable ex) {
CoreException ce = new CoreException("Failed to obtain component data from the CDB.", ex);
reportException(ce);
}
}
}
// if found get the component
if (defaultComponentInfo != null) {
try {
StatusHolder status = new StatusHolder();
ContainerInfo containerInfo = getContainerInfo(defaultComponentInfo.getContainer());
if (containerInfo == null) {
CoreException huse = new CoreException("Failed to return default component: '" + defaultComponentName + "', container with '" + HandleHelper.toString(defaultComponentInfo.getContainer()) + "' not logged in.");
reportException(huse);
return null;
}
ComponentInfo componentInfo = internalRequestComponent(requestor, defaultComponentInfo.getName(), defaultComponentInfo.getType(), defaultComponentInfo.getCode(), containerInfo.getName(), RELEASE_IMMEDIATELY, status, true);
if (componentInfo == null || status.getStatus() != ComponentStatus.COMPONENT_ACTIVATED) {
CoreException huse = new CoreException("Failed to obtain default component: '" + defaultComponentName + "'.");
reportException(huse);
// no error handling...
return null;
}
return componentInfo;
} catch (Throwable t) {
CoreException huse = new CoreException("Failed to return default component: '" + defaultComponentName + "'.", t);
reportException(huse);
return null;
}
} else if (defaultComponentName != null) {
// create CURL
URI curl = null;
try {
curl = CURLHelper.createURI(defaultComponentName);
} catch (URISyntaxException use) {
CoreException huse = new CoreException("Failed to create CURL from default component name: '" + defaultComponentName + "'.", use);
reportException(huse);
return null;
}
try {
// request for component
StatusHolder status = new StatusHolder();
Component component = internalRequestComponent(requestor, curl, status, true);
if (component == null || status.getStatus() != ComponentStatus.COMPONENT_ACTIVATED) {
CoreException huse = new CoreException("Failed to obtain default component: '" + defaultComponentName + "'.");
reportException(huse);
return null;
}
// return component info
ComponentInfo[] componentInfo = getComponentInfo(requestor, new int[0], defaultComponentName, type, true);
if (componentInfo == null || componentInfo.length != 1) {
CoreException huse = new CoreException("Failed to obtain activated default component ComponentInfo: '" + defaultComponentName + "'.");
reportException(huse);
return null;
} else
return componentInfo[0];
} catch (Throwable t) {
CoreException huse = new CoreException("Failed to return default component: '" + defaultComponentName + "'.", t);
reportException(huse);
return null;
}
}
// not found
NoDefaultComponentException ndce = new NoDefaultComponentException("No default component for type '" + type + "' found.");
throw ndce;
}
use of com.cosylab.acs.maci.StatusHolder in project ACS by ACS-Community.
the class ManagerImpl method internalRequestDynamicComponent.
/**
* Internal method for requesting dynamic components.
*
* Resolution:
* <code>component_name</code> and <code>component_type</code> can be considered as "determinator" fields,
* they play important role in search algorithm.
* <code>component_code</code> and <code>container_name</code> can be considered as "override" fields,
* they only help to find closest match.
* Rule: unspecified <code>component_name</code> case implies that a new component will be activated.
* Search points (8,4,2,1): <code>component_name</code>, <code>component_type</code>, <code>component_code</code>, <code>container_name</code>.
* <pre>
*
* name | type | search criteria
* -----------------------------
* * | * | throw IncompleteComponentSpecException
* X | * | (equals, wildcard)
* * | X | (equals, equals) w/ name generation
* X | X | (wildcard, equals) - overriding type is not allowed
*
* </pre>
* 'name' can be also something like "ANT1/*" (ends with) and is threated just like "*".
*
* @param requestor requestor of the component.
* @param componentSpec requested component <code>ComponentSpec</code>
* @return componentInfo <code>ComponentInfo</code> of requested dynamic component.
*/
private ComponentInfo internalRequestDynamicComponent(int requestor, ComponentSpec componentSpec) throws AcsJCannotGetComponentEx, AcsJSyncLockFailedEx, AcsJNoPermissionEx, AcsJIncompleteComponentSpecEx, AcsJInvalidComponentSpecEx, AcsJComponentSpecIncompatibleWithActiveComponentEx {
boolean unspecifiedName = componentSpec.getName().endsWith(ComponentSpec.COMPSPEC_ANY);
boolean unspecifiedType = componentSpec.getType().equals(ComponentSpec.COMPSPEC_ANY);
// * | * | throw IncompleteComponentSpecException
if (unspecifiedName && unspecifiedType) {
AcsJInvalidComponentSpecEx ex = new AcsJInvalidComponentSpecEx();
ex.setReason("'name' and 'type' cannot be both '" + ComponentSpec.COMPSPEC_ANY + "'.");
throw ex;
} else // all fields are fully specified, no search needed
if (!unspecifiedName && !unspecifiedType && !componentSpec.getCode().equals(ComponentSpec.COMPSPEC_ANY) && !componentSpec.getContainer().equals(ComponentSpec.COMPSPEC_ANY)) {
StatusHolder statusHolder = new StatusHolder();
// We let exceptions occurring here fly up
return internalRequestComponent(requestor, componentSpec.getName(), componentSpec.getType(), componentSpec.getCode(), componentSpec.getContainer(), RELEASE_TIME_UNDEFINED, statusHolder, true);
}
//
// prepare search conditions
//
final String[] fieldNames = new String[] { "Name", "Type", "Code", "Container" };
final String[] requiredValues = new String[] { componentSpec.getName(), componentSpec.getType(), componentSpec.getCode(), componentSpec.getContainer() };
final int[] equalityPoints = new int[] { 8, 4, /* never used */
2, 1 };
boolean[] equalityRequired = null;
boolean allowNameGeneration = false;
boolean prohibitSearch = false;
// X | X | (wildcard, equals)
if (!unspecifiedName && !unspecifiedType) {
equalityRequired = new boolean[] { false, true, false, false };
allowNameGeneration = true;
} else // X | * | (equals, wildcard)
if (!unspecifiedName && unspecifiedType) {
equalityRequired = new boolean[] { true, false, false, false };
} else // prefix* | X | (equals, equals) w/ name generation
if (unspecifiedName && !unspecifiedType) {
equalityRequired = new boolean[] { true, true, false, false };
// no search needed case...
if (!componentSpec.getCode().equals(ComponentSpec.COMPSPEC_ANY) && !componentSpec.getContainer().equals(ComponentSpec.COMPSPEC_ANY))
prohibitSearch = true;
allowNameGeneration = true;
}
// search
IntHolder keepAliveTimeHolder = new IntHolder(RELEASE_TIME_UNDEFINED);
String[] result = prohibitSearch ? null : searchDynamicComponent(fieldNames, requiredValues, equalityRequired, equalityPoints, keepAliveTimeHolder);
// none found
if (result == null) {
boolean failed = true;
// only name or container not speficied...
if ((allowNameGeneration || !unspecifiedName) && !unspecifiedType && !componentSpec.getCode().equals(ComponentSpec.COMPSPEC_ANY)) {
// container name already specified, i.e. name is *, which is OK
if (!componentSpec.getContainer().equals(ComponentSpec.COMPSPEC_ANY)) {
result = new String[] { componentSpec.getName(), componentSpec.getType(), componentSpec.getCode(), componentSpec.getContainer() };
failed = false;
} else // container name is *, use load balancing if available
if (loadBalancingStrategy != null) {
String containerName = loadBalancingStrategy.selectContainer(getClientInfo(requestor), getContainersInfo());
if (containerName != null) {
result = new String[] { componentSpec.getName(), componentSpec.getType(), componentSpec.getCode(), containerName };
failed = false;
}
}
}
if (failed) {
AcsJInvalidComponentSpecEx ex = new AcsJInvalidComponentSpecEx();
ex.setReason("Requested ComponentSpec does not match any entry in the CDB.");
throw ex;
}
}
// override...
for (int i = 0; i < result.length; i++) if (!requiredValues[i].equals(ComponentSpec.COMPSPEC_ANY))
result[i] = requiredValues[i];
// check completeness
int i = 0;
if (allowNameGeneration)
i++;
for (; i < result.length; i++) if (result[i].equals(ComponentSpec.COMPSPEC_ANY)) {
// if load balancing strategy is registered, use it to determine container name
if (fieldNames[i].equals("Container") && loadBalancingStrategy != null) {
String containerName = loadBalancingStrategy.selectContainer(getClientInfo(requestor), getContainersInfo());
if (containerName != null) {
result[i] = containerName;
continue;
}
}
AcsJIncompleteComponentSpecEx ex = new AcsJIncompleteComponentSpecEx();
ex.setReason("'" + fieldNames[i] + "' equals '" + ComponentSpec.COMPSPEC_ANY + "'.");
throw ex;
}
// generate name if necessary
if (allowNameGeneration && result[0].endsWith(ComponentSpec.COMPSPEC_ANY)) {
synchronized (this) {
/// @todo not perfect
if (result[0].equals(ComponentSpec.COMPSPEC_ANY))
result[0] = result[1] + "_" + System.currentTimeMillis();
else
// ends with case
result[0] = result[0].substring(0, result[0].length() - 1) + "_" + System.currentTimeMillis();
// flatten hierarchical name (remove IDL separators)
if (result[0].indexOf('/') >= 0)
result[0] = result[0].replaceAll("/", "_");
}
}
StatusHolder statusHolder = new StatusHolder();
// Same exceptions are let flying up
return internalRequestComponent(requestor, result[0], result[1], result[2], result[3], keepAliveTimeHolder.value, statusHolder, true);
}
use of com.cosylab.acs.maci.StatusHolder in project ACS by ACS-Community.
the class ManagerImplTest method testRestartComponent.
public void testRestartComponent() {
try {
try {
manager.restartComponent(0, null);
fail();
} catch (AcsJBadParameterEx bpe) {
System.out.println("This is OK: null parameter");
}
try {
manager.restartComponent(Integer.MAX_VALUE, null);
fail();
} catch (AcsJBadParameterEx bpe) {
System.out.println("This is OK: null parameter");
}
try {
manager.restartComponent(dummyHandle, dummyURI);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
} catch (AcsJBadParameterEx bpe) {
fail();
}
TestClient client = new TestClient(clientName);
ClientInfo info = manager.login(client);
assertTrue(info.getHandle() != 0);
try {
manager.restartComponent(info.getHandle(), null);
fail();
} catch (AcsJBadParameterEx bpe) {
System.out.println("This is OK: null parameter");
}
URI mount = null;
try {
mount = new URI("MOUNT3");
Component component = manager.restartComponent(info.getHandle(), mount);
assertEquals(null, component);
} catch (AcsJBadParameterEx bpe) {
fail();
} catch (URISyntaxException usi) {
fail();
}
TestContainer container = new TestContainer("Container");
Map supportedComponents = new HashMap();
Component mount3COB = new TestComponent("MOUNT3");
supportedComponents.put("MOUNT3", mount3COB);
container.setSupportedComponents(supportedComponents);
/*ClientInfo containerInfo = */
manager.login(container);
// activate
try {
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount, true, status);
assertEquals(mount3COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
} catch (Exception ex) {
fail();
}
// restart
try {
Component returnedComponent = manager.restartComponent(info.getHandle(), mount);
assertEquals(mount3COB, returnedComponent);
} catch (Exception ex) {
fail();
}
// no owner client test
TestClient client2 = new TestClient("thief");
ClientInfo info2 = manager.login(client2);
assertTrue(info2.getHandle() != 0);
try {
manager.restartComponent(info2.getHandle(), mount);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
} catch (AcsJBadParameterEx bpe) {
fail();
}
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
use of com.cosylab.acs.maci.StatusHolder in project ACS by ACS-Community.
the class ManagerImplTest method testReleaseComponentAsync.
public void testReleaseComponentAsync() throws Throwable {
try {
try {
manager.releaseComponentAsync(0, null, null);
fail();
} catch (AcsJBadParameterEx bpe) {
System.out.println("This is OK: null parameter");
}
try {
manager.releaseComponentAsync(Integer.MAX_VALUE, null, null);
fail();
} catch (AcsJBadParameterEx bpe) {
System.out.println("This is OK: null parameter");
}
try {
manager.releaseComponentAsync(dummyHandle, dummyURI, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
} catch (AcsJBadParameterEx bpe) {
fail();
}
TestClient client = new TestClient(clientName);
ClientInfo info = manager.login(client);
TestClient client2 = new TestClient("anotherClient");
ClientInfo info2 = manager.login(client2);
TestContainer container = new TestContainer("Container");
Map supportedComponents = new HashMap();
Component mount1COB = new TestComponent("MOUNT1");
supportedComponents.put("MOUNT1", mount1COB);
Component mount4COB = new TestComponent("MOUNT4", false, true);
supportedComponents.put("MOUNT4", mount4COB);
container.setSupportedComponents(supportedComponents);
ClientInfo containerInfo = manager.login(container);
// here also parallel activation will be tested (autostart and activation bellow)
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), new URI("MOUNT1"), true, status);
assertEquals(mount1COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
status = new StatusHolder();
ref = manager.getComponent(info2.getHandle(), new URI("MOUNT1"), true, status);
assertEquals(mount1COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
ref = manager.getComponent(info.getHandle(), new URI("MOUNT4"), true, status);
assertEquals(mount4COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
try {
LongCompletionCallbackTestImpl lcc = new LongCompletionCallbackTestImpl();
synchronized (lcc) {
manager.releaseComponentAsync(info2.getHandle(), new URI("MOUNT1"), lcc);
if (!lcc.doneFlag)
lcc.wait(SLEEP_TIME_MS);
if (!lcc.doneFlag)
fail("callback not called");
assertEquals(1, lcc.result);
assertNull(lcc.exception);
lcc.reset();
manager.releaseComponentAsync(info.getHandle(), new URI("MOUNT1"), lcc);
if (!lcc.doneFlag)
lcc.wait(SLEEP_TIME_MS);
if (!lcc.doneFlag)
fail("callback not called");
assertEquals(0, lcc.result);
assertNull(lcc.exception);
lcc.reset();
manager.releaseComponentAsync(info.getHandle(), new URI("MOUNT4"), lcc);
if (!lcc.doneFlag)
lcc.wait(SLEEP_TIME_MS);
if (!lcc.doneFlag)
fail("callback not called");
assertEquals(0, lcc.result);
assertNotNull(lcc.exception);
}
} catch (Exception ex) {
fail(ex.toString());
}
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
Aggregations