parallel-processingscriptellaantcall

scriptlla concurrency issues?


I use "antcall" scriptlla concurrent invocations, but appear "javax.mail. Management InstanceNotFoundException". I set up 10 concurrent, sometimes can be 10, sometimes only a few can rise.

<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>

Unable to unregister 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"

I view scriptella source code, the code is already synchronized,

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");
    }
}

What suggestions to you have for this situation ? What should I try, or what should I read in order to find a solution ?


Solution

  • Thanks for pointing out a serious bug. I've opened JavaForge ticket to track this issue.

    As a workaround you can switch to <java fork="true"> task to run Scriptella in a forked VM, so the Ant script will become something like this:

    <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>