use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class ManagerProxyImpl method release_component_async.
public void release_component_async(int id, String component_url, CBlong callback, CBDescIn desc) throws NoPermissionEx {
pendingRequests.incrementAndGet();
try {
// simply release Component
URI uri = null;
if (component_url != null)
uri = CURLHelper.createURI(component_url);
final CBlong fcallback = callback;
final CBDescOut descOut = new CBDescOut(0, desc.id_tag);
LongCompletionCallback lcc = null;
if (callback != null) {
lcc = new LongCompletionCallback() {
public void failed(int result, Throwable exception) {
if (exception instanceof AcsJException) {
AcsJException aex = (AcsJException) exception;
fcallback.done(result, aex.toAcsJCompletion().toCorbaCompletion(), descOut);
} else {
AcsJUnexpectedExceptionEx uex = new AcsJUnexpectedExceptionEx(exception);
fcallback.done(result, uex.toAcsJCompletion().toCorbaCompletion(), descOut);
}
}
public void done(int result) {
fcallback.done(result, new ACSErrOKAcsJCompletion().toCorbaCompletion(), descOut);
}
};
}
manager.releaseComponentAsync(id, uri, lcc);
} catch (AcsJNoPermissionEx nop) {
reportException(nop);
// rethrow CORBA specific
throw nop.toNoPermissionEx();
} catch (URISyntaxException usi) {
BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(usi.getMessage());
} catch (BadParametersException bpe) {
BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
reportException(hbpe);
// rethrow CORBA specific
throw new BAD_PARAM(bpe.getMessage());
} catch (NoResourcesException nre) {
NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
reportException(hnre);
// rethrow CORBA specific
throw new NO_RESOURCES(nre.getMessage());
} catch (Throwable ex) {
CoreException hce = new CoreException(ex.getMessage(), ex);
reportException(hce);
// rethrow CORBA specific
throw new UNKNOWN(ex.getMessage());
} finally {
pendingRequests.decrementAndGet();
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class ResponderUtil method giveCompletion.
// ========================================================
// ===================== Response =======================
// ========================================================
public static Completion giveCompletion(Exception exc) {
Completion ret;
// wrap Exception in a AcsJException
AcsJException acsJExc = new MyAcsJException(exc);
// wrap AcsJException in a AcsJCompletion
MyAcsJCompletion c = new MyAcsJCompletion(acsJExc);
// transform AcsJCompletion to a Completion
ret = c.toCorbaCompletion();
return ret;
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class RWCommonComparablePropertyImpl method setSync.
/*********************** [ RW<type> helpers ] ***********************/
/**
* @see alma.ACSErr.Completion alma.ACS.RW<type>Operations#set_sync(<type>)
*/
protected Completion setSync(Object value) throws AcsJException {
try {
// check limits
if (value instanceof Comparable) {
Comparable c = (Comparable) value;
if (c.compareTo(minValue) < 0 || c.compareTo(maxValue) > 0) {
OutOfBoundsAcsJCompletion compl = new OutOfBoundsAcsJCompletion();
compl.setMinValue(minValue.toString());
compl.setMaxValue(maxValue.toString());
compl.setRequestedValue(value.toString());
return compl.toCorbaCompletion();
}
}
CompletionHolder completionHolder = CompletionUtil.createCompletionHolder();
dataAccess.set(value, completionHolder);
// generate no-error completion, if not generated
if (completionHolder.value == null)
completionHolder.value = CompletionUtil.generateNoErrorCompletion();
return completionHolder.value;
} catch (AcsJException acsex) {
throw new AcsJCouldntPerformActionEx("Failed to set value.", acsex);
}
}
use of alma.acs.exceptions.AcsJException in project ACS by ACS-Community.
the class AcsContainer method activate_component_async.
/* (non-Javadoc)
* @see si.ijs.maci.ContainerOperations#activate_component_async(int, long, java.lang.String, java.lang.String, java.lang.String, si.ijs.maci.CBComponentInfo, alma.ACS.CBDescIn)
*/
public void activate_component_async(final int h, final long execution_id, final String name, final String exe, final String type, final CBComponentInfo callback, final CBDescIn desc) {
m_logger.finer("activate_component_async request received for '" + name + "', enqueueing (taskCount: " + threadPoolExecutor.getTaskCount() + ", active threads: " + threadPoolExecutor.getActiveCount() + ", maxPoolSize: " + threadPoolExecutor.getMaximumPoolSize() + ").");
threadPoolExecutor.execute(new Runnable() {
@Override
public void run() {
m_logger.finer("activate_component_async request for '" + name + "' is being processed now.");
CBDescOut descOut = new CBDescOut(0, desc.id_tag);
ComponentInfo componentInfo = null;
try {
componentInfo = activate_component(h, execution_id, name, exe, type);
} catch (CannotActivateComponentEx ae) {
AcsJCannotActivateComponentEx aae = AcsJCannotActivateComponentEx.fromCannotActivateComponentEx(ae);
ComponentInfo dummyComponentInfo = new ComponentInfo(type, exe, null, name, new int[0], 0, m_containerName, h, 0, new String[0]);
callback.done(dummyComponentInfo, aae.toAcsJCompletion().toCorbaCompletion(), descOut);
} catch (Throwable th) {
AcsJException ae = new AcsJUnknownEx(th);
ComponentInfo dummyComponentInfo = new ComponentInfo(type, exe, null, name, new int[0], 0, m_containerName, h, 0, new String[0]);
callback.done(dummyComponentInfo, ae.toAcsJCompletion().toCorbaCompletion(), descOut);
}
// Try to invoke the callback several times before giving up
int retry = 0;
boolean notified = false;
while (retry < 3 && !notified) {
try {
m_logger.log(AcsLogLevel.DELOUSE, "Calling maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'");
callback.done(componentInfo, new alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion().toCorbaCompletion(), descOut);
notified = true;
m_logger.log(AcsLogLevel.DELOUSE, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' completed");
} catch (Throwable t) {
retry++;
m_logger.log(AcsLogLevel.DELOUSE, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' failed, retrying...", t);
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
}
}
}
if (!notified) {
m_logger.log(AcsLogLevel.ERROR, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' failed, deactivating the component.");
try {
deactivate_component(h);
} catch (ComponentDeactivationUncleanEx e) {
m_logger.log(AcsLogLevel.WARNING, "UNclean deactivation of component descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", e);
} catch (ComponentDeactivationFailedEx e) {
m_logger.log(AcsLogLevel.WARNING, "Deactivation of component failed descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", e);
} catch (Throwable t) {
m_logger.log(AcsLogLevel.WARNING, "Deactivation of component failed descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", t);
}
}
}
});
}
Aggregations