sequencepushconsumerimpl.java
来自「UCS (Ultra Corba Simulator) is one more 」· Java 代码 · 共 476 行 · 第 1/2 页
JAVA
476 行
FixedEventHeader fixedHeader = event.header.fixed_header;
Property[] properties = event.filterable_data;
Any remainder = event.remainder_of_body;
Property[] prop = fillWithRemainderOfBody(properties, remainder);
// strArray[0] = (new DateTimeZone()).toString();
strArray[1] = fixedHeader.event_type.domain_name;
strArray[2] = fixedHeader.event_type.type_name;
strArray[3] = fixedHeader.event_name;
for (int p = 0; p < prop.length; p++) {
String name = prop[p].name;
org.omg.CORBA.Any value = prop[p].value;
// Check settings for verbose mode
boolean isVerboseMode = false;
// if (client != null) {
// isVerboseMode = client.getVerboseModeValue();
// }
// String valueStr = toStringNoCRNoLF(value,
// isVerboseMode);
//
// LOG.info(name + "=" + valueStr);
// for (int c = 0; c < names.length; c++) {
// if (names[c].equals(name)) {
// if (name.equals("b")) {
// valueStr = getReadableTimeInfo(value);
// }
// if (name.equals("o")) {
// valueStr = getCommentSet(value);
// }
// strArray[3 + c] = valueStr;
// break;
// }
// }
}
return strArray;
}
static private String getReadableTimeInfo(Any value) {
return "";
// return
// DateTimeUtils.makeJavaTime(UtcTHelper.extract(value)).toString();
}
private static String toStringNoCRNoLF(org.omg.CORBA.Any value,
boolean verbose) {
String valueStr = CorbaFacility.toString(value, verbose);
// Masquerade any line feeds and carriage returns
if (valueStr != null) {
valueStr = valueStr.replace('\n', '$');
valueStr = valueStr.replace('\r', '$');
}
return valueStr;
}
/**
* See org.omg.CosNotifyComm.SequencePushConsumerOperations.
*
* @see org.omg.CosNotifyComm.SequencePushConsumerOperations#disconnect_sequence_push_consumer()
*/
public void disconnect_sequence_push_consumer() {
// nothing to be done here
// isRec = false;
}
/**
* See org.omg.CosNotifyComm.SequencePushConsumerOperations.
*
* @see org.omg.CosNotifyComm.NotifyPublishOperations#offer_change(org.omg.CosNotification.EventType[],
* org.omg.CosNotification.EventType[])
*/
public void offer_change(EventType[] arg0, EventType[] arg1)
throws InvalidEventType {
// nothing to be done here
}
class BuffReadThread implements Runnable {
private SequencePushConsumerImpl tr;
public BuffReadThread(SequencePushConsumerImpl tr) {
this.tr = tr;
}
public void run() {
int len;
StructuredEvent pdu;
int postFix = 0;
String logTrapFile = CorbaMNQ.projectDir + File.separator
+ "log" + File.separator + "seqPushConsumerLog.";
while (isRec) {
len = tr.buff.size();
Vector c = new Vector();
if (len > 0) {
if (len > 500) {
len = 500;
}
// Start to open file for logging the traps.
File logFile = null;
FileWriter fout = null;
try {
try {
if (tr.isLog) {
do {
logFile = new File(logTrapFile
+ postFix + ".xml");
if (logFile.length() < tr.traploglen * 1000) {
break;
}
postFix++;
} while (true);
if (logFile.exists()) {
fout = new FileWriter(logFile, true);
} else {
fout = new FileWriter(logTrapFile
+ postFix + ".xml");
NotificationXMLTableWriter
.writeHeader(fout);
}
}
if (fout != null) {
NotificationXMLTableWriter
.writeTrapListOpenTag(fout);
}
} catch (IOException e) {
LOG
.log(
Level.SEVERE,
"IOException in trap callback function.",
e);
fout = null;
}
for (int i = 0; i < len; i++) {
// pdu = (SnmpPDU) buff.remove(0);
pdu = (StructuredEvent) tr.buff.get(i);
tr.pduHandling(pdu, fout);
c.add(pdu);
}
tr.buff.removeAll(c);
// Write the TrapListClose Tag in the file
try {
if (fout != null) {
NotificationXMLTableWriter
.writeTrapListCloseTag(fout);
}
} catch (IOException e) {
LOG
.log(
Level.SEVERE,
"IOException in SnmpClient.callback",
e);
fout = null;
}
} catch (Exception e) {
LOG.log(Level.SEVERE, e.getMessage(), e);
} finally {
if (fout != null) {
try {
fout.close();
} catch (IOException e) {
LOG
.log(
Level.SEVERE,
"IOException in SnmpClient.callback"
+ " - cannot close logfile",
e);
}
}
}
} else {
try {
// Sleep 0.2 seconds
Thread.sleep(200);
} catch (Exception e) {
LOG.severe(e.getClass().toString() + ": "
+ e.getMessage());
}
}
}
}
}
/**
* Begin to enter into the test mode.
*/
public static void startTestMode() {
isTestMode = true;
totalNum = 0;
startTime = System.currentTimeMillis();
MNQmainFrame.commonPane
.appendln("SequencePushConsuemr begins to entering <TestMode> at "
+ new Date());
}
public static void stopTestMode() {
isTestMode = false;
long duration = (System.currentTimeMillis() - startTime) / 1000;
MNQmainFrame.commonPane
.appendln("SequencePushConsuemr leaves <TestMode>: \n"
+ "\t Total notifications: " + totalNum
+ "\n\t Total time: " + duration + " seconds\n\t"
+ " Receiving rate: " + totalNum *1.0 / duration
+ " notifications/second");
}
/** used for java.util.logging */
private static final Logger LOG = Logger
.getLogger(SequencePushConsumerImpl.class.getName());
public static boolean isSleep() {
return isSleep;
}
public static void setSleep(boolean isSleep) {
SequencePushConsumerImpl.isSleep = isSleep;
}
public static boolean isTestMode() {
return isTestMode;
}
public static void setTestMode(boolean isTestMode) {
SequencePushConsumerImpl.isTestMode = isTestMode;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?