scriptlla并发问题?

时间:2013-03-11 09:12:47

标签: parallel-processing scriptella antcall

我使用“antcall”scriptlla并发调用,但出现“javax.mail.Management InstanceNotFoundException”。 我设置了10个并发,有时可以10个,有时只有少数可以上升。

<target name="PAIR_CONN">
        <etl debug="true">
            <fileset file="Pair_Conn.xml" />
        </etl>
    </target>
    <target name="pair_conn_mult">
        <parallel threadCount='5'>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="1" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="2" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="3" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="4" />
            </antcall>
            <antcall target="PAIR_CONN">
                <param name="g_flag" value="0" />
            </antcall>
        </parallel>
    </target>

无法取消注册mbean scriptella:type = etl,url =“file:/informatica/infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml” javax.management.InstanceNotFoundException:scriptella:type = etl,url =“file:/informatica/infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml”

我查看了scriptella源代码,代码已经同步,

public synchronized void register() {
    if (name != null) {
        throw new IllegalStateException("MBean already registered");
    }
    server = getMBeanServer();
    String url = ctx.getScriptFileURL().toString();
    System.out.println("LM:"+url);
    boolean registered = false;
    for (int i = 0; i < 1000; i++) {
        if (name == null || server.isRegistered(name)) {
            registered = true;
            name = toObjectName(url, i);
            System.out.println("LM:"+name);
        } else {
            registered = false;
            break;
        }
    }
    etlThread = Thread.currentThread();
    if (!registered) {
        try {
            server.registerMBean(this, name);
            started = new Date();
            LOG.info("Registered JMX mbean: " + name);
        } catch (Exception e) {
            throw new SystemException("Unable to register mbean " + name, e);
        }
    } else {
        throw new SystemException("Unable to register mbean for url " + url + ": too many equal tasks already registered");
    }
}

对于这种情况,您有什么建议?我应该尝试什么,或者我应该阅读什么才能找到解决方案?

1 个答案:

答案 0 :(得分:0)

感谢您指出一个严重的错误。我已打开JavaForge ticket来跟踪此问题。

作为一种解决方法,您可以切换到<java fork="true">任务以在分叉的VM中运行Scriptella,因此Ant脚本将变为如下所示:

<path id="scriptella.class.path">
    <pathelement location="../../build/scriptella.jar"/>
</path>
<taskdef resource="antscriptella.properties" classpathref="scriptella.class.path"/>

<target name="PAIR_CONN">
    <java fork="yes" classname="scriptella.tools.launcher.EtlLauncher" classpathref="scriptella.class.path">
        <arg value="Pair_Conn.xml"/>
        <arg value="-d"/>
        <sysproperty key="g_flag" value="${g_flag}"/>
    </java>
</target>


<target name="pair_conn_mult">
    <parallel threadCount='5'>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="1" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="2" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="3" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="4" />
        </antcall>
        <antcall target="PAIR_CONN">
            <param name="g_flag" value="0" />
        </antcall>
    </parallel>
</target>