use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class DynAnyParserTest method parsePttDataEvent.
public ParsedAnyData[] parsePttDataEvent() {
pde = new pttDataEvent(new actuatorSpace(new double[2952]), new actuatorSpace(new double[2952]), 25, 32L);
try {
se = seCreator.createEvent(pde);
} catch (AcsJException e) {
e.printStackTrace();
fail("Couldn't create structured event for pttDataEvent");
}
eventName = se.header.fixed_header.event_type.type_name;
eventAny = se.filterable_data[0].value;
StopWatch sw = new StopWatch(logger);
parser = new DynAnyParser(eventAny, eventName);
ParsedAnyData[] pResults = parser.getParsedResults(null);
sw.logLapTime("parse this eventAny");
return pResults;
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class EventDetailTestHarness method parsePttDataEvent.
public static ParsedAnyData[] parsePttDataEvent() {
pttDataEvent pde = new pttDataEvent(new actuatorSpace(new double[2952]), new actuatorSpace(new double[2952]), 25, 32L);
StructuredEvent se = null;
String eventName = null;
Any eventAny = null;
try {
se = seCreator.createEvent(pde);
eventName = se.header.fixed_header.event_type.type_name;
eventAny = se.filterable_data[0].value;
} catch (AcsJException e) {
e.printStackTrace();
System.err.println("Couldn't create structured event for pttDataEvent");
}
StopWatch sw = new StopWatch(logger);
DynAnyParser parser = new DynAnyParser(eventAny, eventName);
ParsedAnyData[] pResults = parser.getParsedResults(null);
sw.logLapTime("parse this eventAny");
return pResults;
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class BACIRemoteAccess method internalManagerConnect.
/**
* Insert the method's description here.
* Creation date: (2.11.2000 0:34:52)
* @param node si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
*/
private void internalManagerConnect(BACIRemoteNode baciNode) throws AcsJObjectExplorerConnectEx {
/* we are connecting directly to the Manager to obtain the object reference */
//System.out.println("DEBUG: imc "+baciNode);
String curl = (String) baciNode.getUserObject();
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Requesting component: '" + curl + "', activate = true");
notifier.reportMessage("Connecting to '" + curl + "'.");
baciNode.setNonSticky(connectNonSticky);
org.omg.CORBA.Object obj = null;
if (connectNonSticky) {
try {
obj = manager.get_component_non_sticky(handle, curl);
} catch (Throwable e) {
String message = "Connection to component '" + curl + "' failed. \n" + "'Connect as non-sticky' mode is enabled: in this mode component will not be activated by ObjectExplorer,\n" + "only already activated components can be accessed.";
int ans = choiceForNonStickyComponentConnection(message);
switch(ans) {
case 0:
baciNode.setNonSticky(false);
System.out.println("BACIRemoteAccess.internalManagerConnect setNonSticky to " + baciNode.isNonSticky() + " @ " + baciNode.hashCode());
break;
case 1:
baciEngineMenu.setNonSticky(false);
baciNode.setNonSticky(false);
break;
case 2:
{
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
default:
{
// should not happen.
notifier.reportError("Unexpected choice.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
}
}
}
try {
if (obj == null) {
obj = manager.get_component(handle, curl, true);
}
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Manager returns OK");
}/*
* We wrap into a specific exception and report up
*/
catch (CannotGetComponentEx e) {
notifier.reportError("Connection to component '" + curl + "' failed.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
} catch (org.omg.CORBA.TRANSIENT e) {
notifier.reportError("Connection to component '" + curl + "' failed.\nCouldn't connect to the manager.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
} catch (Throwable e) {
notifier.reportError("Connection to component '" + curl + "' failed.\nUnknown Reason.");
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
String irfid = null;
try {
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "Querying component '" + curl + "' for CORBA type id.");
ComponentInfo[] cobInfos = manager.get_component_info(handle, new int[0], curl, "*", true);
if (cobInfos.length != 1) {
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
acsjex.setReason("Manager did not return valid ComponentInfo for '" + curl + "'.");
throw acsjex;
}
irfid = cobInfos[0].type;
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "component '" + curl + "' has id: " + irfid);
} catch (Exception e) {
notifier.reportError("Cannot retrieve Interface Repository ID for component '" + curl + "'", e);
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx(e);
acsjex.setCurl(curl);
throw acsjex;
}
// baciNode.setNonSticky(connectNonSticky);
baciNode.setCORBARef(obj);
try {
baciNode.setIFDesc(getIFDesc(irfid));
if (baciNode.getIFDesc() != null)
notifier.reportDebug("BACIRemoteAccess::internalManagerConnect", "IR Query OK.");
else {
AcsJObjectExplorerConnectEx acsjex = new AcsJObjectExplorerConnectEx();
acsjex.setCurl(curl);
acsjex.setReason("Cannot retrieve Interface Repository description for component for '" + curl + "'.");
throw acsjex;
}
} catch (Exception e) {
baciNode.setCORBARef(null);
notifier.reportError("Failed to retrieve interface description from IR, releasing component on Manager, if needed.", e);
AcsJException releaseCompEx = null;
try {
if (manager != null && obj != null && !baciNode.isNonSticky()) {
manager.release_component(handle, curl);
}
} catch (NoPermissionEx npe) {
releaseCompEx = AcsJNoPermissionEx.fromNoPermissionEx(npe);
} catch (CannotDeactivateComponentEx ex) {
// @TODO remove this catch once we remove this ex from maci.idl
releaseCompEx = AcsJCannotDeactivateComponentEx.fromCannotDeactivateComponentEx(ex);
} catch (ComponentDeactivationUncleanEx ex) {
releaseCompEx = AcsJComponentDeactivationUncleanEx.fromComponentDeactivationUncleanEx(ex);
} catch (ComponentDeactivationFailedEx ex) {
releaseCompEx = AcsJComponentDeactivationFailedEx.fromComponentDeactivationFailedEx(ex);
}
if (releaseCompEx != null) {
notifier.reportError("Failed to release component", releaseCompEx);
logACSException(releaseCompEx);
}
AcsJObjectExplorerInterfaceRepositoryAccessEx acsjex = new AcsJObjectExplorerInterfaceRepositoryAccessEx(e);
acsjex.setCurl(curl);
acsjex.setIRid(irfid);
AcsJObjectExplorerConnectEx acsjex2 = new AcsJObjectExplorerConnectEx(acsjex);
acsjex2.setCurl(curl);
throw acsjex2;
}
notifier.reportMessage("Connected to '" + curl + "'.");
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class Executor method remoteDaemonForServices.
/**
* Starts or stops ACS via the ACS services daemon.
* This call returns only when the action has completed.
* Exceptions will be returned instead of thrown.
* @return any exception that occurs underways
*/
/* msc 2009-12: this method has never thrown exceptions, instead they can be detected through
* Flow listening, and as of today also by looking at the return value. Starting to throw exceptions
* would be too big a change that I don't want to risk. I have no time to verify it doesn't harm. */
public static Exception remoteDaemonForServices(String host, int instance, boolean startStop, String cmdFlags, NativeCommand.Listener listener) {
if (listener != null) {
listener.stdoutWritten(null, "\nIn daemon mode, output cannot be displayed.\n" + "See logs in <daemon-owner>/.acs/commandcenter on host " + host + "\n");
}
String info = ((startStop) ? "Starting" : "Stopping") + " Acs Suite on host '" + host + "' (instance " + instance + ")";
remoteServicesDaemonFlow.reset(info);
ServicesDaemon daemon = null;
// msc 2014-11 ICT-3753: finer-grained logging
String step = "";
try {
org.omg.CORBA.ORB orb;
AcsCorba acsCorba = null;
remoteServicesDaemonFlow.trying(RemoteServicesDaemonFlow.INIT_CORBA);
step = "access acs-corba object";
// throws OrbInitException
acsCorba = firestarter.giveAcsCorba();
step = "access orb";
orb = acsCorba.getORB();
remoteServicesDaemonFlow.success(RemoteServicesDaemonFlow.INIT_CORBA);
remoteServicesDaemonFlow.trying(RemoteServicesDaemonFlow.CONNECT_DAEMON);
step = "convert host name to daemon address";
String daemonLoc = AcsLocations.convertToServicesDaemonLocation(host);
step = "convert daemon address to corba reference";
org.omg.CORBA.Object object = orb.string_to_object(daemonLoc);
step = "narrow corba reference to daemon object";
daemon = ServicesDaemonHelper.narrow(object);
step = "sanity check daemon object";
if (daemon == null)
throw new NullPointerException("received null trying to retrieve acsdaemon " + daemonLoc);
try {
if (// this may be superfluous with daemons but shouldn't hurt either
daemon._non_existent())
log.log(Level.INFO, "acsdaemon '" + daemonLoc + "' reported as non_existent, trying to use it nonetheless.");
} catch (Exception exc) {
log.log(Level.INFO, "problem verifying acsdaemon " + daemonLoc + " exists, trying to use it anyhow.", exc);
}
remoteServicesDaemonFlow.success(RemoteServicesDaemonFlow.CONNECT_DAEMON);
remoteServicesDaemonFlow.trying(RemoteServicesDaemonFlow.SEND_COMMAND);
final BlockingQueue<Completion> sync = new ArrayBlockingQueue<Completion>(1);
DaemonSequenceCallbackPOA daemonCallbackImpl = new DaemonSequenceCallbackPOA() {
public void done(Completion comp) {
sync.add(comp);
}
public void working(String service, String host, short instance_number, Completion comp) {
}
};
step = "create daemon callback";
DaemonSequenceCallback daemonCallback = DaemonSequenceCallbackHelper.narrow(acsCorba.activateOffShoot(daemonCallbackImpl, acsCorba.getRootPOA()));
step = "send request to daemon";
if (startStop == true)
daemon.start_acs(daemonCallback, (short) instance, cmdFlags);
else
daemon.stop_acs(daemonCallback, (short) instance, cmdFlags);
remoteServicesDaemonFlow.success(RemoteServicesDaemonFlow.SEND_COMMAND);
remoteServicesDaemonFlow.trying(RemoteServicesDaemonFlow.AWAIT_RESPONSE);
// The services daemon's start/stop methods are implemented asynchronously,
// which means we need to wait for the callback notification.
// @TODO: Perhaps a 10 minute timeout is too much though?
step = "poll on reply queue";
long timeout = 10;
TimeUnit timeoutUnit = TimeUnit.MINUTES;
Completion daemonReplyRaw = sync.poll(timeout, timeoutUnit);
if (daemonReplyRaw == null)
throw new RuntimeException("Timeout: Acs daemon did not " + (startStop ? "start" : "stop") + " Acs within " + timeout + " " + timeoutUnit);
step = "deserialize daemon response";
AcsJCompletion daemonReply = AcsJCompletion.fromCorbaCompletion(daemonReplyRaw);
if (daemonReply.isError()) {
AcsJException exc = daemonReply.getAcsJException();
throw new Exception("daemon responded with error " + exc.getMessage(), exc);
}
remoteServicesDaemonFlow.success(RemoteServicesDaemonFlow.AWAIT_RESPONSE);
return null;
} catch (Exception exc) {
remoteServicesDaemonFlow.failure(exc);
return new Exception(remoteServicesDaemonFlow.current() + ":" + step + ": " + exc.getMessage(), exc);
} finally {
// msc 2014-11 ICT-3753: omc-to-daemon connection can get stale. this apparently helps.
if (daemon != null) {
try {
daemon._release();
} catch (Exception exc) {
log.log(Level.INFO, "failure releasing internal resources for daemon, ignoring: " + exc.getMessage(), exc);
}
}
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class SimpleSupplierReconnClient method createPublisherAndSubscriber.
public void createPublisherAndSubscriber() {
try {
m_client = new ComponentClient(m_logger, System.getProperty("ACS.manager"), "SimpleSupplierReconnClient");
m_publisher = m_client.getContainerServices().createNotificationChannelPublisher(CHANNEL_NAME, IDLEntity.class);
((NCPublisher) m_publisher).setAutoreconnect(m_autoreconnect);
m_publisher.enableEventQueue(100, m_cbObj);
//m_publisher.setAutoreconnect(m_autoreconnect);
} catch (AcsJContainerServicesEx e) {
// Silently ignore the errors
} catch (AcsJException e) {
// Shouldn't happen
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations