use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class MaciInfo method getStartedComponents.
public List<ComponentInfo> getStartedComponents() {
// grab reference as it is in this very moment, this is atomic.
List<ComponentInfo> current = components;
List<ComponentInfo> ret = new ArrayList<ComponentInfo>(current.size());
for (ComponentInfo info : current) if (// skip non-activated components
info.h != 0)
ret.add(info);
return ret;
}
use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class AdministratorClient method components_released.
public void components_released(int[] clients, int[] components, long timeStamp) {
// of all the available components.
if (listener == null) {
return;
}
System.out.println("Components_released");
HashSet<Integer> compSet = new HashSet<Integer>();
for (int i = 0; i < components.length; i++) {
compSet.add(components[i]);
}
for (Integer handle : compSet) {
System.out.println("Looking for component with handle " + handle);
try {
ComponentInfo info = getComponentInfo(handle);
System.out.println("\tinfo" + info);
if (info == null) {
listener.componentLoggedOut(handle);
} else {
listener.componentReleased(info);
}
} catch (Exception e) {
}
}
}
use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class MaciSupervisorTest method setUp.
@Override
public void setUp() throws Exception {
System.out.println("\n--- " + getName() + " ----------------");
// make the manager
// -----------------------------------------------------------------
orb = Mockito.mock(ORB.class);
manager = Mockito.mock(Manager.class);
administrator = Mockito.mock(Administrator.class);
final int hhhhh = 0;
final int[] empty = new int[] {};
ComponentInfo comp100 = new ComponentInfo("type", "code", null, "comp100", empty, 10, "cont10", 100, 0, new String[] {});
ComponentInfo comp200 = new ComponentInfo("type", "code", null, "comp200", empty, 20, "cont20", 200, 0, new String[] {});
ComponentInfo comp300 = new ComponentInfo("type", "code", null, "comp300", empty, 30, "cont30", 300, 0, new String[] {});
ComponentInfo[] one_comp = { comp100 };
ComponentInfo[] two_comps = { comp100, comp200 };
ComponentInfo[] three_comps = { comp100, comp200, comp300 };
ContainerInfo cont10 = new ContainerInfo("cont10", 10, null, empty);
ContainerInfo cont20 = new ContainerInfo("cont20", 20, null, empty);
ContainerInfo cont30 = new ContainerInfo("cont30", 30, null, empty);
ContainerInfo[] one_cont = { cont10 };
ContainerInfo[] two_conts = { cont10, cont20 };
ContainerInfo[] three_conts = { cont10, cont20, cont30 };
ClientInfo clientA = new ClientInfo(0, null, empty, "clientA", 0);
ClientInfo client1 = new ClientInfo(1, null, empty, "client1", 0);
ClientInfo client2 = new ClientInfo(2, null, empty, "client2", 0);
ClientInfo client3 = new ClientInfo(3, null, empty, "client3", 0);
ClientInfo[] one_client = { client1 };
ClientInfo[] two_clients = { client1, client2 };
ClientInfo[] three_clients = { client1, client2, client3 };
Mockito.when(orb.string_to_object("dummy")).thenReturn(manager);
Mockito.when(manager.login(administrator)).thenReturn(clientA);
Mockito.when(manager.get_component_info(hhhhh, empty, "*", "*", false)).thenReturn(one_comp, two_comps, three_comps);
Mockito.when(manager.get_container_info(hhhhh, empty, "*")).thenReturn(one_cont, one_cont, two_conts, three_conts);
Mockito.when(manager.get_client_info(hhhhh, empty, "*")).thenReturn(one_client, two_clients, three_clients, two_clients, three_clients);
// make the supervisor
// -----------------------------------------------------------------
log = new Logger("Test", null) {
final long start = System.nanoTime();
@Override
public void log(LogRecord r) {
long sinceStart = (System.nanoTime() - start) / 1000 / 1000 / 1000;
System.out.println(String.format("%2d", sinceStart) + " " + r.getLevel() + " " + r.getMessage());
}
};
log.setLevel(Level.FINE);
testee = new MaciSupervisor("Test", "dummy", orb, log);
testee.acImpl = testee.new AdministratorImplementation() {
@Override
protected Administrator asCorbaObject(ORB orb) {
return administrator;
}
};
testee.start();
// assertions
// ----------------------------------------------------------------
maciListener = new MaciInfoListener();
MaciInfo maciInformation = testee.getMaciInformation();
maciInformation.addTreeModelListener(maciListener);
}
use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class AdministratorClient method components_requested.
public void components_requested(int[] clients, int[] components, long timeStamp) {
if (listener == null) {
return;
}
System.out.println("Components_requested");
HashSet<Integer> compSet = new HashSet<Integer>();
for (int i = 0; i < components.length; i++) {
compSet.add(components[i]);
}
for (Integer handle : compSet) {
try {
ComponentInfo info = getComponentInfo(handle);
if (info != null) {
listener.componentLoggedIn(info);
}
} catch (Exception e) {
}
}
}
use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.
the class BACIRemoteAccess method explodeDomainNode.
/**
* Insert the method's description here.
* Creation date: (1.11.2000 18:08:31)
* @return si.ijs.acs.objectexplorer.engine.BACI.BACITreeDataNode[]
* @param node si.ijs.acs.objectexplorer.engine.BACI.BACITreeDataNode
*/
private synchronized BACITreeDataNode[] explodeDomainNode(BACITreeDataNode n) {
if (n == null)
throw new NullPointerException("node");
if (n.childrenHolder == null)
return new BACITreeDataNode[0];
//TreeMap temp = new TreeMap();
ComponentInfo[] infos = new ComponentInfo[n.childrenHolder.size()];
n.childrenHolder.toArray(infos);
TreeMap tempTypes = new TreeMap();
TreeMap tempDomains = new TreeMap();
for (int i = 0; i < infos.length; i++) {
String cmp = null;
String domain = BACICURLResolver.resolveDomain(infos[i].name);
if (domain.endsWith("/"))
cmp = domain;
else
cmp = domain + "/";
if (n.domainRemainder.equals(cmp)) {
BACITreeDataNode node = (BACITreeDataNode) tempTypes.get(infos[i]);
if (node != null) {
// node.childrenHolder.add(infos[i].cob_curl);
node.childrenHolder.add(infos[i].name);
} else {
try {
node = new BACITreeDataNode(TYPE, BACIIntrospector.fullTypeToType(infos[i].type), BACIIntrospector.fullTypeToType(infos[i].type), parent.getTree(), getIcon(DOMAIN));
} catch (IntrospectionInconsistentException iie) {
notifier.reportError("Invalid IDL type '" + infos[i].type + "'.", iie);
continue;
}
node.childrenHolder = new ArrayList();
// node.childrenHolder.add(infos[i].cob_curl);
node.childrenHolder.add(infos[i].name);
tempTypes.put(infos[i].type, node);
}
} else {
if (domain.startsWith("/"))
domain = domain.substring(1);
if (!domain.endsWith("/"))
domain = domain + "/";
String dpart = domain.substring(n.domainRemainder.length(), domain.indexOf('/'));
BACITreeDataNode node = (BACITreeDataNode) tempDomains.get(dpart);
if (node != null) {
node.childrenHolder.add(infos[i]);
} else {
node = new BACITreeDataNode(DOMAIN, dpart, infos[i], parent.getTree(), getIcon(DOMAIN));
node.childrenHolder = new ArrayList();
node.childrenHolder.add(infos[i]);
node.domainRemainder = n.domainRemainder + dpart + "/";
tempDomains.put(dpart, node);
}
}
}
BACITreeDataNode[] arrayTypes = new BACITreeDataNode[tempTypes.size()];
tempTypes.values().toArray(arrayTypes);
BACITreeDataNode[] arrayDomains = new BACITreeDataNode[tempDomains.size()];
tempDomains.values().toArray(arrayDomains);
BACITreeDataNode[] retVal = new BACITreeDataNode[arrayTypes.length + arrayDomains.length];
System.arraycopy(arrayDomains, 0, retVal, 0, arrayDomains.length);
System.arraycopy(arrayTypes, 0, retVal, arrayDomains.length, arrayTypes.length);
notifier.reportDebug("BACIRemoteAccess::explodeDomainNode", "Processing for node '" + n + "' complete.");
//2010.02.05 panta@naoj
java.util.Arrays.sort(retVal);
return retVal;
}
Aggregations