use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class BlockingPingClient method login.
/**
* Login to the manager.
* @param manager manager reference.
* @param sleepTimeMs ping sleep time in ms.
* @return client info, <code>null</code> on failure.
*/
private ClientInfo login(Manager manager, long sleepTimeMs) {
if (orb == null || manager == null)
return null;
System.out.println("Logging to the manager...");
try {
ClientImpl clientImpl = new ClientImpl(sleepTimeMs);
Client client = clientImpl._this(orb);
ClientInfo info = manager.login(client);
if (info == null)
throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
System.out.println("Logged in to the manager.");
return info;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to login to the manager.");
return null;
}
}
use of si.ijs.maci.ClientInfo 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.ClientInfo in project ACS by ACS-Community.
the class BuildingTest method login.
/**
* Login to the manager.
* @param manager manager reference.
* @return client info, <code>null</code> on failure.
*/
private ClientInfo login(Manager manager) {
if (orb == null || manager == null)
return null;
System.out.println("Logging to the manager...");
try {
ClientImpl clientImpl = new ClientImpl();
Client client = clientImpl._this(orb);
ClientInfo info = manager.login(client);
if (info == null)
throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
System.out.println("Logged in to the manager.");
return info;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to login to the manager.");
return null;
}
}
use of si.ijs.maci.ClientInfo 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();
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class SimpleMasterComponentTest method login.
/**
* Login to the manager.
* @param manager manager reference.
* @return client info, <code>null</code> on failure.
*/
private ClientInfo login(Manager manager) {
if (orb == null || manager == null)
return null;
System.out.println("Logging to the manager...");
try {
ClientImpl clientImpl = new ClientImpl();
Client client = clientImpl._this(orb);
ClientInfo info = manager.login(client);
if (info == null)
throw new Exception("Failed to login to the manager since returned ClientInfo is 'null'.");
System.out.println("Logged in to the manager.");
return info;
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("Failed to login to the manager.");
return null;
}
}
Aggregations