[openrtm-commit:02823] r1043 - trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 9月 14日 (木) 17:48:55 JST
Author: t-katami
Date: 2017-09-14 17:48:55 +0900 (Thu, 14 Sep 2017)
New Revision: 1043
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerServant.java
Log:
[compat,newfunc->releng_1_2] When manager_name is not designated, a slave manager starts it by the manager_\<process number\>. refs #4187
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2017-09-13 07:52:02 UTC (rev 1042)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2017-09-14 08:48:55 UTC (rev 1043)
@@ -1795,6 +1795,8 @@
Properties prop = new Properties();
int i,len;
FactoryBase factory = findPropertyFormFactory(comp_id);
+ rtcout.println(Logbuf.PARANOID,
+ "findPropertyFormFactory(comp_id):" +factory);
if (factory == null) {
rtcout.println(Logbuf.ERROR,
"Factory not found: "
@@ -1879,6 +1881,8 @@
comp = factory.create(this);
+ rtcout.println(Logbuf.PARANOID,
+ "factory.create(this):" +comp);
if (comp == null) {
rtcout.println(Logbuf.ERROR,
"RTC creation failed: "
@@ -2894,6 +2898,10 @@
rtcout.println(Logbuf.ERROR, "Unknown Exception");
}
}
+
+ String form = m_config.getProperty("manager.instance_name");
+ String i_name = formatString(form,m_config);
+ m_config.setProperty("manager.instance_name",i_name);
}
/**
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerServant.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerServant.java 2017-09-13 07:52:02 UTC (rev 1042)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/ManagerServant.java 2017-09-14 08:48:55 UTC (rev 1043)
@@ -5,6 +5,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
+import java.util.regex.Matcher;
import jp.go.aist.rtm.RTC.log.Logbuf;
import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
@@ -555,20 +556,32 @@
rtcout.println(Logbuf.TRACE, "create_component("+module_name+")");
RTC.RTObject rtc = create_component_by_address(module_name);
+ rtcout.println(Logbuf.PARANOID, "create_component_by_address():"+rtc);
if(rtc != null){
return rtc;
}
rtc = create_component_by_mgrname(module_name);
+ rtcout.println(Logbuf.PARANOID, "create_component_by_mgrname():"+rtc);
if(rtc != null){
return rtc;
}
+ String[] temp = new String[1];
+ temp[0] = module_name;
+ get_parameter_by_modulename("manager_address",temp);
+ String manager_name = new String();
+ manager_name = get_parameter_by_modulename("manager_name",temp);
+ rtcout.println(Logbuf.PARANOID, "m_isMaster:"+m_isMaster);
if(m_isMaster){
synchronized(m_slaveMutex) {
+ rtcout.println(Logbuf.PARANOID,
+ "m_slaves.length:"+m_slaves.length);
for (int ic=0; ic < m_slaves.length; ++ic) {
try {
rtc = m_slaves[ic].create_component(module_name);
+ rtcout.println(Logbuf.PARANOID,
+ "m_slaves[ic].create_component():" +rtc);
if(rtc != null){
return rtc;
}
@@ -580,16 +593,30 @@
}
}
}
+ rtcout.println(Logbuf.PARANOID,
+ "manager_name:"+manager_name);
+ if(manager_name==null){
+ String name = module_name + "&manager_name=manager_%p";
+
+ rtc = create_component_by_mgrname(name);
+ rtcout.println(Logbuf.PARANOID,
+ "create_component_by_mgrname("
+ +name
+ +"):"
+ +rtc);
+ return rtc;
+ }
}
-
-
- // create on this manager
+ else {
+ // create on this manager
- RTObject_impl rtobj = m_mgr.createComponent(module_name);
- if(rtobj != null){
- return rtobj.getObjRef();
+ RTObject_impl rtobj = m_mgr.createComponent(module_name);
+ rtcout.println(Logbuf.PARANOID,
+ "m_mgr.createComponent():" +rtobj);
+ if(rtobj != null){
+ return rtobj.getObjRef();
+ }
}
-
return null;
}
@@ -1393,6 +1420,10 @@
*
*/
public RTC.RTObject create_component_by_mgrname(String module_name) {
+ rtcout.println(Logbuf.PARANOID,
+ "create_component_by_mgrname("
+ +module_name
+ +")");
String arg = module_name;
String[] tmp = new String[1];
tmp[0] = arg;
@@ -1399,6 +1430,9 @@
String mgrstr = get_parameter_by_modulename("manager_name",tmp);
arg = tmp[0];
+ rtcout.println(Logbuf.PARANOID,
+ "get_parameter_by_modulename(\"manager_name\",tmp):"
+ +mgrstr);
if(mgrstr==null){
return null;
}
@@ -1407,6 +1441,11 @@
}
RTM.Manager mgrobj = findManager_by_name(mgrstr);
+ rtcout.println(Logbuf.PARANOID,
+ "findManager_by_name("
+ +mgrstr
+ +"):"
+ +mgrobj);
tmp[0] = arg;
String language = get_parameter_by_modulename("language",tmp);
@@ -1454,6 +1493,7 @@
rtcout.println(Logbuf.DEBUG, "Invoking command: "+ cmd + ".");
try{
ProcessBuilder pb = new ProcessBuilder(cmd);
+ pb.redirectErrorStream(true);
Process p = pb.start();
}
catch(Exception ex){
@@ -1468,8 +1508,54 @@
//do nothing
}
int count = 0;
+
+ ArrayList slaves_name = new ArrayList();
+ java.util.regex.Pattern pattern
+ = java.util.regex.Pattern.compile(
+ "^manager_[0-9]+$");
+
+ if(mgrstr.equals("manager_%p")){
+ synchronized (m_slaveMutex) {
+ for (int ic=0; ic < m_slaves.length; ++ic) {
+ _SDOPackage.NameValue[] prof
+ = m_slaves[ic]. get_configuration();
+ NVListHolder nvholder =
+ new NVListHolder(prof);
+ Properties proper = new Properties();
+ NVUtil.copyToProperties(proper, nvholder);
+ String i_name
+ = proper.getProperty("manager.instance_name");
+ Matcher matcher = pattern.matcher(i_name);
+ if(matcher.matches()){
+ slaves_name.add(i_name);
+ }
+ }
+ }
+ }
+
while (mgrobj == null) {
- mgrobj = findManager_by_name(mgrstr);
+ if(mgrstr.equals("manager_%p")){
+ synchronized (m_slaveMutex) {
+ for (int ic=0; ic < m_slaves.length; ++ic) {
+ _SDOPackage.NameValue[] prof
+ = m_slaves[ic]. get_configuration();
+ NVListHolder nvholder =
+ new NVListHolder(prof);
+ Properties proper = new Properties();
+ NVUtil.copyToProperties(proper, nvholder);
+ String i_name
+ = proper.getProperty("manager.instance_name");
+ Matcher matcher = pattern.matcher(i_name);
+ if(matcher.matches() &&
+ !slaves_name.contains(i_name)){
+ mgrobj = m_slaves[ic];
+ }
+ }
+ }
+ }
+ else{
+ mgrobj = findManager_by_name(mgrstr);
+ }
++count;
if (count > 1000) {
break;
More information about the openrtm-commit
mailing list