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());
}
}
}
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);
}
}
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;
}
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;
}
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);
}
}
}
}
Aggregations