Search in sources :

Example 46 with ORB

use of org.omg.CORBA.ORB in project ACS by ACS-Community.

the class AcsCorba method createOrb.

/**
	 * Creates an ORB with a port determined by the values given in {@link #setPortOptions(Integer, Integer)}.
	 * <p> 
	 * Aside from the logger, no instance variables are used in this method.
	 *  
	 * @param args  command line arguments for the ORB
	 * @param port  If port == null, OAPort property will not be set. 
	 * @return 
	 */
private ORB createOrb(String[] args, Integer port) {
    ORB orb = null;
    // sets CORBA options
    OrbConfigurator orbConf = OrbConfigurator.getOrbConfigurator();
    // IFR access is generally discouraged but needed if clients such as the sampling manager call "get_interface"
    // on a reference to a corba object inside this container.
    orbConf.setORBInitRef("InterfaceRepository", System.getProperty("ACS.repository"));
    // orbConf.setORBInitRef("NameService", System.getProperty("ACS.???")); // currently the JacORB-specific property ORBInitRef.NameService is set instead (acsStartJava)
    orbConf.setOptions(args);
    if (port != null) {
        orbConf.setPort(port.intValue());
    }
    String[] orbOpts = orbConf.getOptions();
    /*
		 * We start an ORB, which needs its own port ('OAPort'). There are, however, no
		 * conventions in Acs which port to assign to our ORB (which will be used by a
		 * ComponentClient or a Supervisor client). There is, on the other hand, an
		 * automatism in an ORB that finds free ports.
		 * 
		 * Thus: Don't set the OAPort property, instead let ORB choose the port itself
		 * 
		 * Problem: jacorb won't choose a port by itself when an OAPort has ever been set in
		 * this VM before
		 */
    boolean suppressPortProperty = (port == null);
    Properties orbProps = orbConf.getProperties(suppressPortProperty);
    StringBuffer logBuf = new StringBuffer("ORB options ");
    for (int i = 0; i < orbOpts.length; i++) {
        logBuf.append(orbOpts[i]).append(' ');
    }
    logBuf.append("  ORB properties: ");
    logBuf.append(orbProps.toString());
    m_logger.finer(logBuf.toString());
    orb = org.omg.CORBA.ORB.init(orbOpts, orbProps);
    if (orb == null) {
        // so better check here and fail fast.
        throw new NullPointerException("org.omg.CORBA.ORB.init returned null.");
    }
    m_logger.finer("ORB initialized.");
    return orb;
}
Also used : Properties(java.util.Properties) ORB(org.omg.CORBA.ORB) AcsProfilingORB(org.jacorb.orb.acs.AcsProfilingORB)

Example 47 with ORB

use of org.omg.CORBA.ORB in project ACS by ACS-Community.

the class AcsCorba method prepareOrb.

/////////////////////////////////////////////////////////////////////////////////////////////
////// code integrated from Exec::Firestarter.java 
/////////////////////////////////////////////////////////////////////////////////////////////	
/**
	 * Gets an ORB and initializes the root POA using {@link #initRootPoa(ORB)}.
	 * <p>
	 * If this method has been called before, the same ORB will be returned.
	 * Depending on the values given in {@link #setPortOptions(Integer, Integer)},
	 * a fixed port will be used (resulting in a failure if it can't be obtained),
	 * or the port will be chosen from a given range, or the ORB will be allowed to pick a port.
	 * <p>
	 * This class is <i>fail-fast</i> in that it tries to create an orb
	 * instantly on a call to this method. If this first call goes well, subsequent calls
	 * will succeed (aside from other general errors).
	 * 
	 * @param args 
	 * @throws AcsJContainerServicesEx 
	 */
public void prepareOrb(String[] args) {
    if (m_orb == null) {
        // deal with the special case
        if (this.isOrbChoosingPort) {
            ORB orb = createOrb(args, null);
            initRootPoa(orb);
            setORB(orb);
            return;
        }
        if (this.orbPortSearchRetry.intValue() <= 0) {
            ORB orb = createOrb(args, this.orbPort);
            initRootPoa(orb);
            setORB(orb);
        } else {
            RVtrialAndError re = trialAndError(args, orbPort.intValue(), orbPortSearchRetry.intValue());
            setORB(re.orb);
        }
    }
}
Also used : ORB(org.omg.CORBA.ORB) AcsProfilingORB(org.jacorb.orb.acs.AcsProfilingORB)

Example 48 with ORB

use of org.omg.CORBA.ORB in project ACS by ACS-Community.

the class AcsCorba method trialAndError.

/** trial-and-error: try out some ports, break on success */
protected RVtrialAndError trialAndError(String[] args, int first, int retries) {
    ORB orb = null;
    int next = first;
    int i;
    for (i = 0; i < retries; i++) {
        try {
            next = first + i;
            m_logger.info("trying to start an orb on port " + next);
            orb = createOrb(args, new Integer(next));
            initRootPoa(orb);
            break;
        } catch (RuntimeException exc) {
            m_logger.finer("failed due to " + exc);
            orb.shutdown(true);
            continue;
        }
    }
    if (i == retries) {
        throw new RuntimeException("tried ports " + first + " to " + next + ": couldn't start orb; giving up");
    }
    return new RVtrialAndError(orb, next);
}
Also used : ORB(org.omg.CORBA.ORB) AcsProfilingORB(org.jacorb.orb.acs.AcsProfilingORB)

Example 49 with ORB

use of org.omg.CORBA.ORB in project ACS by ACS-Community.

the class T112Sampler method runTest.

/**
	 * Perform a single sample.
	 * Perform a single sample for each iteration.  This method
	 * returns a <code>SampleResult</code> object.
	 * <code>SampleResult</code> has many fields which can be
	 * used.  At a minimum, the test should use
	 * <code>SampleResult.sampleStart</code> and
	 * <code>SampleResult.sampleEnd</code>to set the time that
	 * the test required to execute.  It is also a good idea to
	 * set the sampleLabel and the successful flag.
	 * 
	 * @see org.apache.jmeter.samplers.SampleResult#sampleStart()
	 * @see org.apache.jmeter.samplers.SampleResult#sampleEnd()
	 * @see org.apache.jmeter.samplers.SampleResult#setSuccessful(boolean)
	 * @see org.apache.jmeter.samplers.SampleResult#setSampleLabel(String)
	 * 
	 * @param context  the context to run with. This provides access
	 *                 to initialization parameters.
	 * 
	 * @return         a SampleResult giving the results of this
	 *                 sample.
	 */
public SampleResult runTest(JavaSamplerContext context) {
    SampleResult results = new SampleResult();
    try {
        long time = System.currentTimeMillis();
        POA rootPOA = null;
        OrbConfigurator orbConf = OrbConfigurator.getOrbConfigurator();
        ORB orb = ORB.init(orbConf.getOptions(), orbConf.getProperties());
        rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        rootPOA.the_POAManager().activate();
        results.setTime(System.currentTimeMillis() - time);
        results.setSuccessful(true);
        results.setSampleLabel(m_testName + "() @" + m_instanceID);
        if (orb != null)
            orb.destroy();
    } catch (Exception e) {
        results.setSuccessful(false);
        results.setResponseCode(e.getMessage());
        results.setSampleLabel("ERROR: " + e.getMessage());
        getLogger().error(this.getClass().getName() + ": Error during sample", e);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(whoAmI() + "\trunTest()" + "\tTime:\t" + results.getTime());
        listParameters(context);
    }
    return results;
}
Also used : OrbConfigurator(alma.acs.container.corba.OrbConfigurator) POA(org.omg.PortableServer.POA) SampleResult(org.apache.jmeter.samplers.SampleResult) ORB(org.omg.CORBA.ORB)

Example 50 with ORB

use of org.omg.CORBA.ORB in project ACS by ACS-Community.

the class BCTClient method setPropertyAsync.

/**
	 * TEST_2_2_2_* & TEST_3_2_2_*
	 * @param loop
	 * @param delay
	 * @return
	 */
public boolean setPropertyAsync(long loop, long delay) {
    m_cbNotified.setReturns(loop);
    ORB orb = ComponentClientSingleton.getInstance().getORB();
    m_startTime = System.currentTimeMillis();
    for (int i = 0; i < loop; i++) {
        m_property.set_async(0, m_cbNotified._this(orb), descIn);
        try {
            Thread.sleep(delay);
        } catch (Exception e) {
        }
    }
    m_midTime = System.currentTimeMillis();
    synchronized (m_cbNotified) {
        if (!m_cbNotified.isDone())
            try {
                m_cbNotified.wait();
            } catch (InterruptedException ie) {
            }
        m_endTime = System.currentTimeMillis();
    }
    return m_cbNotified.isDone();
}
Also used : ORB(org.omg.CORBA.ORB)

Aggregations

ORB (org.omg.CORBA.ORB)73 POA (org.omg.PortableServer.POA)12 Properties (java.util.Properties)10 NamingException (javax.naming.NamingException)8 Test (org.junit.Test)7 AcsProfilingORB (org.jacorb.orb.acs.AcsProfilingORB)6 IOException (java.io.IOException)5 Logger (java.util.logging.Logger)5 HashMap (java.util.HashMap)4 StartException (org.jboss.msc.service.StartException)4 Any (org.omg.CORBA.Any)4 ManagerImpl (com.cosylab.acs.maci.manager.ManagerImpl)3 FileWriter (java.io.FileWriter)3 PrintWriter (java.io.PrintWriter)3 MessageImpl (org.apache.cxf.message.MessageImpl)3 Monitorlong (alma.ACS.Monitorlong)2 DAL (com.cosylab.CDB.DAL)2 HandleDataStore (com.cosylab.acs.maci.manager.HandleDataStore)2 OutputStream (java.io.OutputStream)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2