use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.
the class CounterSupplierImpl method sendBlocks.
/////////////////////////////////////////////////////////////
// Implementation of CounterSupplierOperations
/////////////////////////////////////////////////////////////
/**
* @throws CouldntPerformActionEx
* @see alma.COUNTER.CounterConsumerOperations#getBlocks()
*/
public int sendBlocks(int initVal, int lastVal, int changeVal, float period) throws CouldntPerformActionEx {
try {
String myString = "Java supplier";
int periodMs = (int) (period * 1000.f);
int val = initVal;
while (val < lastVal) {
if (val < changeVal) {
flag = false;
} else {
flag = true;
}
m_supplier.publishEvent(new statusBlockEvent(OnOffStates.ON, myString, val, lastVal, changeVal, flag, period));
//m_supplier.publishEvent(new statusBlockEvent(1.0f, val, lastVal, changeVal, flag, period));
//m_logger.info("Counting ongoing with period " + period + "s up to " + lastVal + ", now " + val );
val++;
eventCount++;
Thread.sleep(periodMs);
}
// Tell consumers this is the last event.
// Note that this gets sent even if initVal > lastVal !!
myString = "Last event from Java supplier";
m_supplier.publishEvent(new statusBlockEvent(OnOffStates.OFF, myString, lastVal, lastVal, changeVal, true, period));
//m_supplier.publishEvent(new statusBlockEvent(0.0f, lastVal, lastVal, changeVal, true, period));
m_logger.info("Counter stopped, last value " + val);
eventCount++;
} catch (Exception e) {
// HSO: Commenting out the supplier disconnect, because the caught exception may be some other problem,
// and future invocation may succeed. This makes supplier creation/cleanup symmetric, done in the component lifecycle methods.
// if (m_supplier != null) {
// m_supplier.disconnect();
// }
AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
ex.setProperty(PROP_ASSERTION_MESSAGE, "failed to connect as an event supplier to channel " + alma.COUNTER.CHANNELNAME_COUNTER.value);
throw ex.toCouldntPerformActionEx();
}
return eventCount;
}
use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx 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.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.
the class ContainerServicesTesterImpl method testGetComponentNonSticky.
public void testGetComponentNonSticky(String curl, boolean release) throws CouldntPerformActionEx {
String msg = "component '" + curl + "'";
m_logger.info("Received call to testGetComponentNonSticky for " + msg);
try {
org.omg.CORBA.Object compObj = m_containerServices.getComponentNonSticky(curl);
if (compObj == null) {
throw new NullPointerException("Got null reference for " + msg);
}
if (release) {
// releasing a non-sticky component ref should be a no-op
m_containerServices.releaseComponent(curl);
}
} catch (Throwable thr) {
throw (new AcsJCouldntPerformActionEx("testGetComponentNonSticky failed for " + msg, thr)).toCouldntPerformActionEx();
}
}
use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.
the class ContainerServicesTesterImpl method testGetCollocatedComponent.
public void testGetCollocatedComponent(String curl, String compType, String targetCurl) throws CouldntPerformActionEx {
String msg = "component '" + curl + "' of type '" + compType + "' collocated with '" + targetCurl + "'";
m_logger.info("Received call to testGetCollocatedComponent for " + msg);
try {
ComponentQueryDescriptor cqd = new ComponentQueryDescriptor(curl, compType);
org.omg.CORBA.Object compObj = m_containerServices.getCollocatedComponent(cqd, false, targetCurl);
if (compObj == null) {
throw new NullPointerException("Got null reference for " + msg);
}
// curl could be given as "*" or null for dynamic name assignment, therefore we ask the name() from the component
m_containerServices.releaseComponent(ACSComponentHelper.narrow(compObj).name());
} catch (Throwable thr) {
throw (new AcsJCouldntPerformActionEx("testGetCollocatedComponent failed for " + msg, thr)).toCouldntPerformActionEx();
}
}
use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.
the class JconttestUtil method getSystemLevelOrbTimeoutMillis.
/**
* We get the timeout property value from the ORB configuration.
* System-level timeout defaults are not standardized in Corba, thus we need jacorb-specific access.
* @throws IllegalArgumentException if the ORB timeout is configured as a negative value
* @throws AcsJCouldntPerformActionEx if the ORB-level timeout could not be read, e.g. because the ORB is not jacorb.
*/
public int getSystemLevelOrbTimeoutMillis() throws AcsJCouldntPerformActionEx {
int orbLevelTimeout = -1;
ORB orb = containerServices.getAdvancedContainerServices().getORB();
if (orb instanceof org.jacorb.orb.ORB) {
try {
orbLevelTimeout = ((org.jacorb.orb.ORB) orb).getConfiguration().getAttributeAsInteger(PROPERTYNAME_CLIENTORBTIMEOUT);
if (orbLevelTimeout < 0) {
throw new IllegalArgumentException("system-level roundtrip timeout must be non-negative!");
}
} catch (ConfigurationException e) {
logger.log(Level.SEVERE, "Failed to read the system-level ORB timeout setting.", e);
throw new AcsJCouldntPerformActionEx();
}
} else {
logger.log(Level.SEVERE, "Wrong ORB " + orb.getClass().getName());
throw new AcsJCouldntPerformActionEx();
}
return orbLevelTimeout;
}
Aggregations