use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class RemoteLogDispatcher method sendLogRecords.
/**
* Attempts to send <code>logRecords</code> over to the remote logging service.
* To not lose any log records in case of failure, they can be obtained from the returned
* <code>FailedLogRecords</code> object, and should be fed back to the log record queue in order to try again later.
* <p>
* Should not be called concurrently (which can't happen since we use a single threaded executor
* in <code>DispatchingLogQueue</code>).
* <p>
* Sorts all log records by timestamp before converting them for remote transmission.
*
* @param logRecords
* @return those LogRecords that failed to be sent, either because they could not be converted to Any,
* or because the remote logger failed.
*/
FailedLogRecords sendLogRecords(LogRecord[] logRecords) {
// sort this set of records by timestamp (queue delivers them by level/timestamp)
Arrays.sort(logRecords, timestampLogRecordComparator);
FailedLogRecords failures = new FailedLogRecords();
// used for feeding back these LogRecords if the sending fails
List<LogRecord> candidateLogRecords = new ArrayList<LogRecord>();
if (useAcsLogServiceExtensions) {
// create CORBA XmlLogRecord containing XML representations of log records and the log level as a separate field
List<XmlLogRecord> remoteLogRecords = new ArrayList<XmlLogRecord>();
for (int i = 0; i < logRecords.length; i++) {
if (i < getBufferSize()) {
try {
String xml = ((AcsXMLLogFormatter) logFormatter).format(logRecords[i]);
int level = AcsLogLevel.getNativeLevel(logRecords[i].getLevel()).getAcsLevel().value;
XmlLogRecord remoteLogRecord = new XmlLogRecord(xml, (short) level);
remoteLogRecords.add(remoteLogRecord);
candidateLogRecords.add(logRecords[i]);
} catch (RuntimeException e) {
failures.addSerializationFailure(logRecords[i]);
}
} else {
// records that don't fit into one remote call must be sent later
// this should never happen except for during concurrently changing buffer size.
failures.addSendFailure(logRecords[i]);
}
}
// send the log records over CORBA
if (!remoteLogRecords.isEmpty()) {
XmlLogRecord[] remoteLogRecordsArray = remoteLogRecords.toArray(new XmlLogRecord[remoteLogRecords.size()]);
writeRecords(remoteLogRecordsArray);
}
} else {
// default is Corba telecom Log interface that requires records inside Anys
List<Any> anyLogRecords = new ArrayList<Any>();
for (int i = 0; i < logRecords.length; i++) {
if (i < getBufferSize()) {
try {
Any anyLogRecord = orb.create_any();
anyLogRecord = logFormatter.formatAny(anyLogRecord, logRecords[i]);
anyLogRecords.add(anyLogRecord);
candidateLogRecords.add(logRecords[i]);
} catch (RuntimeException e) {
failures.addSerializationFailure(logRecords[i]);
}
} else {
// records that don't fit into one remote call must be sent later
failures.addSendFailure(logRecords[i]);
}
}
// send the log records over CORBA
if (!anyLogRecords.isEmpty()) {
Any[] anyLogRecordsArray = anyLogRecords.toArray(new Any[anyLogRecords.size()]);
try {
writeRecords(anyLogRecordsArray);
}// // LogOffDuty - other exotic reasons to be not "on duty", such as log duration time or scheduling time
catch (Throwable thr) {
// feed back these records to we can try them again later
failures.addSendFailures(candidateLogRecords);
// Currently ACS does not make use of the semantics of the various exceptions specified here by CORBA, i.e.
// LogDisabled, LogOffDuty, LogLocked, LogFull (see above)
// There can also be java.net.ConnectException thrown.. @TODO perhaps we should print that to stdout, with repeatGuard.
}
}
}
return failures;
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class CharacteristicComponentImpl method get_characteristic_by_name.
/*********************** [ CharacteristicModel ] ***********************/
/**
* @see alma.ACS.CharacteristicModelOperations#get_characteristic_by_name(java.lang.String)
*/
public Any get_characteristic_by_name(String name) throws NoSuchCharacteristic {
//for create the Any
characteristicModelImpl.lendContainerServices(m_containerServices);
Any ret = characteristicModelImpl.get_characteristic_by_name(name);
if (ret != null)
return characteristicModelImpl.get_characteristic_by_name(name);
else
throw new NoSuchCharacteristic();
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class CharacteristicModelImpl method get_characteristic_by_name.
/*********************** [ CharacteristicModel ] ***********************/
/**
* @see alma.ACS.CharacteristicModelOperations#get_characteristic_by_name(java.lang.String)
*/
public Any get_characteristic_by_name(String name) throws NoSuchCharacteristic {
try {
String strVal = new String();
if (prefix == "")
strVal = dao.get_string(name);
else
strVal = dao.get_string(prefix + name);
//I needed the getAny() to create a new Any, since a constructor for
// Any (i.e: new Any() ), doesn't exist
Any value_p = m_container.getAdvancedContainerServices().getAny();
value_p.insert_string(strVal);
return value_p;
} catch (CDBFieldDoesNotExistEx fde) {
NoSuchCharacteristic nsc = new NoSuchCharacteristic();
nsc.characteristic_name = name;
nsc.component_name = modelName;
throw nsc;
} catch (SystemException se) {
throw se;
} catch (WrongCDBDataTypeEx wct) {
}
throw new NoSuchCharacteristic();
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class CharacteristicModelImpl method get_all_characteristics.
/**
* @see alma.ACS.CharacteristicModelOperations#get_all_characteristics()
*/
public PropertySet get_all_characteristics() {
String[] allSeq;
try {
if (prefix == "")
allSeq = dao.get_string_seq("");
else
allSeq = dao.get_string_seq(prefix);
Property[] p = new Property[allSeq.length];
for (int i = 0; i < allSeq.length; i++) {
Any a = get_characteristic_by_name(allSeq[i]);
p[i] = new Property(allSeq[i], a);
}
//dangerous methods!!
ORB orb = m_container.getAdvancedContainerServices().getORB();
POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
PropertySetImpl psetImpl = new PropertySetImpl(p);
PropertySetPOATie psetTie = new PropertySetPOATie(psetImpl, rootpoa);
return psetTie._this(orb);
} catch (CDBFieldDoesNotExistEx e) {
} catch (WrongCDBDataTypeEx e) {
} catch (NoSuchCharacteristic e) {
} catch (MultipleExceptions e) {
} catch (InvalidName e) {
} catch (AdapterInactive e) {
} catch (NullPointerException e) {
System.out.println(e);
}
throw new NO_IMPLEMENT();
}
use of org.omg.CORBA.Any in project ACS by ACS-Community.
the class AcsCorba method setORBLevelRoundtripTimeout.
/**
* Sets the roundtrip timeout for all calls going out through the ORB that is encapsulated by this class.
* For example, this applies to all corba calls made by a container and any of its components.
* @param timeoutSeconds
* @throws AcsJContainerServicesEx
* @see {@link #wrapForRoundtripTimeout(Object, double)}
*/
public void setORBLevelRoundtripTimeout(double timeoutSeconds) throws AcsJContainerServicesEx {
if (!isInitialized()) {
throw new IllegalStateException("Only call when this object has been initialized!");
}
try {
Any rrtPolicyAny = m_orb.create_any();
rrtPolicyAny.insert_ulonglong(UTCUtility.durationJavaMillisToOmg((long) timeoutSeconds * 1000));
Policy p = m_orb.create_policy(RELATIVE_RT_TIMEOUT_POLICY_TYPE.value, rrtPolicyAny);
// about PolicyManager, see Corba spec (2.4) section 4.9.1
PolicyManager pm = PolicyManagerHelper.narrow(m_orb.resolve_initial_references("ORBPolicyManager"));
pm.set_policy_overrides(new Policy[] { p }, SetOverrideType.SET_OVERRIDE);
p.destroy();
} catch (Throwable thr) {
AcsJContainerServicesEx ex2 = new AcsJContainerServicesEx(thr);
ex2.setContextInfo("Failed to set the ORB-level client-side corba roundtrip timeout to " + timeoutSeconds);
throw ex2;
}
m_logger.fine("Set ORB level roundtrip timeout to " + timeoutSeconds + " seconds.");
}
Aggregations