Search in sources :

Example 11 with FatalError

use of com.arjuna.ats.arjuna.exceptions.FatalError in project narayana by jbosstm.

the class StateManager method setupStore.

/**
 * Make sure the object store is set up, if required.
 *
 * @param rootName
 *            indicates the root of the object store.
 */
@SuppressWarnings("unchecked")
protected synchronized void setupStore(String rootName, String objectStoreType) {
    if (tsLogger.logger.isTraceEnabled()) {
        tsLogger.logger.trace("StateManager::setupStore ( " + ((rootName != null) ? rootName : "null") + " )");
    }
    if (!loadObjectState())
        return;
    if (participantStore != null)
        return;
    if (rootName == null)
        rootName = arjPropertyManager.getObjectStoreEnvironmentBean().getLocalOSRoot();
    if (storeRoot != null) {
        if ((rootName == null) || (rootName.compareTo("") == 0) || (rootName.compareTo(storeRoot) == 0)) {
            return;
        }
        /* No - destroy old store and create new */
        participantStore = null;
    }
    if (rootName == null) {
        rootName = "";
    }
    /* Create store now */
    storeRoot = new String(rootName);
    if ((myType == ObjectType.ANDPERSISTENT) || (myType == ObjectType.NEITHER)) {
        int sharedStatus = ((objectModel == ObjectModel.SINGLE) ? StateType.OS_UNSHARED : StateType.OS_SHARED);
        participantStore = StoreManager.setupStore(rootName, sharedStatus);
    } else {
        try {
            participantStore = new TwoPhaseVolatileStore(new ObjectStoreEnvironmentBean());
        } catch (final Throwable ex) {
            tsLogger.i18NLogger.warn_StateManager_13();
            throw new FatalError(tsLogger.i18NLogger.get_StateManager_14());
        }
    }
}
Also used : ObjectStoreEnvironmentBean(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) TwoPhaseVolatileStore(com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore)

Example 12 with FatalError

use of com.arjuna.ats.arjuna.exceptions.FatalError in project narayana by jbosstm.

the class TransactionStatusManager method start.

/*
    * Removes the TransactionStatusManager from the object store
    * and closes down the listener thread.

    * this will never work as a finalizer because the listener thread is always running and keeping this
    * instance from being garbage collected. we need a proper shutdown method which closes the
    * listener socket causing the thread to shut down
    *
   // TODO consider adding a shutdown operation (signature change)
   public void finalize()
   {
       if ( ! _finalizeCalled )
       {
	  _finalizeCalled = true ;

	   _listener.stopListener() ;
	   TransactionStatusManagerItem.removeThis( Utility.getProcessUid() ) ;
      }
   }
    */
/**
 * Create service and Transaction status manager item.
 */
private void start(String serviceName, String host, int port) {
    try {
        Service service = ClassloadingUtility.loadAndInstantiateClass(Service.class, serviceName, null);
        if (service == null) {
            tsLogger.i18NLogger.warn_recovery_TransactionStatusManager_4(serviceName);
            return;
        }
        ServerSocket socketServer = getTsmServerSocket(host, port);
        addService(service, socketServer);
        TransactionStatusManagerItem.createAndSave(socketServer.getInetAddress().getHostAddress(), socketServer.getLocalPort());
        if (recoveryPropertyManager.getRecoveryEnvironmentBean().getTransactionStatusManagerPort() == 0) {
            tsLogger.i18NLogger.info_recovery_TransactionStatusManager_3(Integer.toString(socketServer.getLocalPort()), socketServer.getInetAddress().getHostAddress(), serviceName);
        } else {
            tsLogger.logger.debugf("TransactionStatusManager started on port %s and host %s with service %s", Integer.toString(socketServer.getLocalPort()), socketServer.getInetAddress().getHostAddress(), serviceName);
        }
    } catch (IOException ex) {
        tsLogger.i18NLogger.warn_recovery_TransactionStatusManager_14(getListenerHostName(), Integer.toString(getListenerPort(-1)));
        throw new FatalError(tsLogger.i18NLogger.get_recovery_TransactionStatusManager_9(), ex);
    }
}
Also used : FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException)

Example 13 with FatalError

use of com.arjuna.ats.arjuna.exceptions.FatalError in project narayana by jbosstm.

the class DataSourceJDBCAccess method getConnection.

public Connection getConnection() throws SQLException {
    DataSource dataSource;
    try {
        dataSource = (DataSource) context.lookup(datasourceName);
    } catch (NamingException ex) {
        throw new FatalError(toString() + " : " + ex, ex);
    }
    Connection connection = dataSource.getConnection();
    connection.setAutoCommit(false);
    return connection;
}
Also used : FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) Connection(java.sql.Connection) NamingException(javax.naming.NamingException) DataSource(javax.sql.DataSource)

Example 14 with FatalError

use of com.arjuna.ats.arjuna.exceptions.FatalError in project narayana by jbosstm.

the class MBeanProcessId method getpid.

/**
 * @return the process id. This had better be unique between processes on
 *         the same machine. If not we're in trouble!
 */
public int getpid() {
    synchronized (MBeanProcessId._lock) {
        if (_pid == -1) {
            String name = ManagementFactory.getRuntimeMXBean().getName();
            String[] parsed = name.split("@");
            try {
                _pid = Integer.valueOf(parsed[0]);
            } catch (final Exception ex) {
                throw new FatalError(tsLogger.i18NLogger.get_utils_MBeanProcessId_2() + " " + name, ex);
            }
        }
    }
    if (_pid == -1)
        throw new FatalError(tsLogger.i18NLogger.get_utils_MBeanProcessId_1());
    return _pid;
}
Also used : FatalError(com.arjuna.ats.arjuna.exceptions.FatalError)

Example 15 with FatalError

use of com.arjuna.ats.arjuna.exceptions.FatalError in project narayana by jbosstm.

the class OTSImpleManager method init.

private static final synchronized void init() {
    if (_current == null) {
        if (OTSImpleManager._theFactory == null) {
            /*
				 * Only check once, when the factory is first created.
				 */
            int resolver = Services.CONFIGURATION_FILE;
            boolean requireTransactionManager = false;
            if (jtsPropertyManager.getJTSEnvironmentBean().isTransactionManager()) {
                requireTransactionManager = true;
                String resolveMechanism = opPropertyManager.getOrbPortabilityEnvironmentBean().getResolveService();
                if (resolveMechanism.compareTo("NAME_SERVICE") == 0)
                    resolver = Services.NAME_SERVICE;
                else {
                    if (resolveMechanism.compareTo("BIND_CONNECT") == 0)
                        resolver = Services.BIND_CONNECT;
                }
            }
            if (requireTransactionManager) {
                try {
                    if (resolver != Services.BIND_CONNECT) {
                        String[] params = new String[1];
                        params[0] = Services.otsKind;
                        org.omg.CORBA.Object obj = ORBManager.getServices().getService(Services.transactionService, params, resolver);
                        params = null;
                        OTSImpleManager._theFactoryRef = org.omg.CosTransactions.TransactionFactoryHelper.narrow(obj);
                    } else {
                    }
                    if (OTSImpleManager._theFactoryRef == null)
                        throw new BAD_PARAM();
                } catch (InvalidName e1) {
                    jtsLogger.i18NLogger.warn_otsserverfailed(e1);
                    throw new FatalError(e1.toString(), e1);
                } catch (BAD_PARAM ex1) {
                    jtsLogger.i18NLogger.warn_otsserverfailed(ex1);
                    throw new FatalError(ex1.toString(), ex1);
                } catch (IOException e2) {
                    jtsLogger.i18NLogger.warn_otsservererror(e2);
                    throw new FatalError(e2.toString(), e2);
                } catch (SystemException e3) {
                    jtsLogger.i18NLogger.warn_otsservererror(e3);
                    throw new FatalError(e3.toString(), e3);
                } catch (UserException e4) {
                    jtsLogger.i18NLogger.warn_otsservererror(e4);
                    throw new FatalError(e4.toString(), e4);
                }
            } else {
                /* force to be local */
                OTSImpleManager._theFactory = new TransactionFactoryImple();
            }
        }
        if (OTSImpleManager._current == null) {
            try {
                OTSImpleManager._current = new CurrentImple();
                OTSImpleManager._currentRef = OTSImpleManager._current;
            } catch (Exception e) {
                OTSImpleManager._current = null;
                throw new com.arjuna.ats.arjuna.exceptions.FatalError("OTSImpleManager.current: " + e.toString(), e);
            }
        }
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) IOException(java.io.IOException) CurrentImple(com.arjuna.ats.internal.jts.orbspecific.CurrentImple) SystemException(org.omg.CORBA.SystemException) UserException(org.omg.CORBA.UserException) IOException(java.io.IOException) FatalError(com.arjuna.ats.arjuna.exceptions.FatalError) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) SystemException(org.omg.CORBA.SystemException) TransactionFactoryImple(com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple) UserException(org.omg.CORBA.UserException)

Aggregations

FatalError (com.arjuna.ats.arjuna.exceptions.FatalError)19 Codec (org.omg.IOP.Codec)6 UnknownEncoding (org.omg.IOP.CodecFactoryPackage.UnknownEncoding)6 Encoding (org.omg.IOP.Encoding)6 ClientRequestInterceptor (org.omg.PortableInterceptor.ClientRequestInterceptor)6 DuplicateName (org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName)6 ServerRequestInterceptor (org.omg.PortableInterceptor.ServerRequestInterceptor)6 IOException (java.io.IOException)4 Test (org.junit.Test)3 ObjectStoreEnvironmentBean (com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean)2 CurrentImple (com.arjuna.ats.internal.jts.orbspecific.CurrentImple)2 File (java.io.File)2 Uid (com.arjuna.ats.arjuna.common.Uid)1 ObjectStoreError (com.arjuna.ats.arjuna.exceptions.ObjectStoreError)1 ObjectStoreException (com.arjuna.ats.arjuna.exceptions.ObjectStoreException)1 TwoPhaseVolatileStore (com.arjuna.ats.internal.arjuna.objectstore.TwoPhaseVolatileStore)1 TransactionFactoryImple (com.arjuna.ats.internal.jts.orbspecific.TransactionFactoryImple)1 ORB (com.arjuna.orbportability.ORB)1 RootOA (com.arjuna.orbportability.RootOA)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1