use of si.ijs.maci.Manager in project ACS by ACS-Community.
the class DumpManagerState method test.
/**
* Main test routine.
*/
public void test() {
initializeCORBA();
Manager manager = resolveManager();
if (manager != null) {
ClientInfo clientInfo = login(manager);
if (clientInfo != null) {
System.out.println("All initialization done.");
try {
ComponentInfo[] componentInfo = manager.get_component_info(clientInfo.h, new int[0], "*", "*", true);
if (componentInfo == null)
throw new Exception("null client info returned.");
System.out.println(componentInfo.length + " component(s) returned:");
for (int i = 0; i < componentInfo.length; i++) {
System.out.println("\tName : " + componentInfo[i].name);
System.out.println("\tHandle : " + componentInfo[i].h + ", " + HandleHelper.toString(componentInfo[i].h));
System.out.println("\tType : " + componentInfo[i].type);
System.out.println("\tCode : " + componentInfo[i].code);
System.out.println("\tContainer name : " + componentInfo[i].container_name);
System.out.println("\tContainer handle: " + HandleHelper.toString(componentInfo[i].container));
System.out.println("\tClients : count = " + componentInfo[i].clients.length);
for (int j = 0; j < componentInfo[i].clients.length; j++) System.out.println("\t \t" + componentInfo[i].clients[j]);
System.out.println("\t-------------------------------");
}
} catch (Throwable th) {
th.printStackTrace();
}
System.out.println();
System.out.println();
System.out.println();
try {
ContainerInfo[] containersInfo = manager.get_container_info(clientInfo.h, new int[0], "*");
if (containersInfo == null)
throw new Exception("null container info returned.");
System.out.println(containersInfo.length + " container(s) returned:");
for (int i = 0; i < containersInfo.length; i++) {
System.out.println("\tName : " + containersInfo[i].name);
System.out.println("\tHandle : " + containersInfo[i].h + ", " + HandleHelper.toString(containersInfo[i].h));
System.out.println("\tComponents : count = " + containersInfo[i].components.length);
for (int j = 0; j < containersInfo[i].components.length; j++) System.out.println("\t \t" + containersInfo[i].components[j]);
System.out.println("\t-------------------------------");
}
} catch (Throwable th) {
th.printStackTrace();
}
System.out.println();
System.out.println();
System.out.println();
try {
ClientInfo[] clientsInfo = manager.get_client_info(clientInfo.h, new int[0], "*");
if (clientsInfo == null)
throw new Exception("null component info returned.");
System.out.println(clientsInfo.length + " clients(s) returned:");
for (int i = 0; i < clientsInfo.length; i++) {
System.out.println("\tName : " + clientsInfo[i].name);
System.out.println("\tHandle : " + clientsInfo[i].h + ", " + HandleHelper.toString(clientsInfo[i].h));
System.out.println("\tComponents : count = " + clientsInfo[i].components.length);
for (int j = 0; j < clientsInfo[i].components.length; j++) System.out.println("\t \t" + clientsInfo[i].components[j]);
System.out.println("\t-------------------------------");
}
} catch (Throwable th) {
th.printStackTrace();
}
logout(manager, clientInfo);
}
}
finalizeCORBA();
}
use of si.ijs.maci.Manager in project ACS by ACS-Community.
the class DumpManagerState method resolveManager.
/**
* Resolves manager reference.
* @return manager reference, <code>null</code> on failure.
*/
private Manager resolveManager() {
if (orb == null)
return null;
String managerReference = System.getProperty("ACS.manager");
if (managerReference == null)
managerReference = "corbaloc::localhost:3000/Manager";
System.out.println("Resolving manager reference '" + managerReference + "'.");
try {
org.omg.CORBA.Object obj = orb.string_to_object(managerReference);
if (obj == null)
throw new NullPointerException("'null' reference returned.");
Manager manager = ManagerHelper.narrow(obj);
if (manager == null)
throw new NullPointerException("'null' narrowed reference returned.");
System.out.println("Manager reference successfully resolved.");
return manager;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to resolve manager reference.");
return null;
}
}
use of si.ijs.maci.Manager in project ACS by ACS-Community.
the class ContainerHandleTest method testContainerHandles.
public void testContainerHandles() throws Throwable {
String managerRef = AcsLocations.figureOutManagerLocation();
m_logger.info("Using manager reference: " + managerRef);
org.omg.CORBA.Object mgrObj = acsCorba.getORB().string_to_object(managerRef);
Manager manager = ManagerHelper.narrow(mgrObj);
m_logger.info("Manager reference resolved and narrowed.");
final int MANAGER_HANDLE = 0x05555555;
m_logger.info("Querying manager for container info.");
ContainerInfo[] infos = manager.get_container_info(MANAGER_HANDLE, new int[0], "*");
m_logger.info("Got infos from " + infos.length + " container(s).");
for (ContainerInfo info : infos) {
try {
int h = info.reference.get_handle();
m_logger.info("Manager reported handle 0x" + Integer.toHexString(info.h) + ", get_handle() returned 0x" + Integer.toHexString(h));
assertEquals(info.name + " handle mismatch.", info.h, h);
} catch (Throwable th) {
m_logger.info("get_handle() call failed for container with handle 0x" + Integer.toHexString(info.h));
}
}
}
use of si.ijs.maci.Manager in project ACS by ACS-Community.
the class BuildingTest method resolveManager.
/**
* Resolves manager reference.
* @return manager reference, <code>null</code> on failure.
*/
private Manager resolveManager() {
if (orb == null)
return null;
String managerReference = System.getProperty("ACS.manager");
if (managerReference == null)
managerReference = "corbaloc::" + ACSPorts.getIP() + ":3000/Manager";
System.out.println("Resolving manager reference '" + managerReference + "'.");
try {
org.omg.CORBA.Object obj = orb.string_to_object(managerReference);
if (obj == null)
throw new NullPointerException("'null' reference returned.");
Manager manager = ManagerHelper.narrow(obj);
if (manager == null)
throw new NullPointerException("'null' narrowed reference returned.");
System.out.println("Manager reference successfully resolved.");
return manager;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to resolve manager reference.");
return null;
}
}
use of si.ijs.maci.Manager in project ACS by ACS-Community.
the class BuildingTest method test.
/**
* Main test routine.
*/
public void test() {
initializeCORBA();
Manager manager = resolveManager();
if (manager != null) {
ClientInfo clientInfo = login(manager);
if (clientInfo != null) {
System.out.println("All initialization done.");
//
// get component
//
final String COMPONENT_NAME = "BUILDING1";
org.omg.CORBA.Object obj;
try {
obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
Building building = BuildingHelper.narrow(obj);
ROstring version = building.version();
// syncvalue retrival
System.out.println("Version: " + version.get_sync(new CompletionHolder()));
// create a monitor
Monitor monitor = version.create_monitor(new CBstringImpl()._this(orb), new CBDescIn());
// sleep for a while
try {
Thread.sleep(10000);
} catch (InterruptedException ie) {
}
;
monitor.destroy();
} catch (Exception e) {
// CannotGetComponentEx, ComponentConfigurationNotFoundEx
System.err.println("Failed to obtain component: " + COMPONENT_NAME);
}
// release now
try {
manager.release_component(clientInfo.h, COMPONENT_NAME);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to release component.");
}
logout(manager, clientInfo);
}
}
finalizeCORBA();
}
Aggregations