Skip to content

Commit

Permalink
reverted exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pfouto committed Jun 12, 2021
1 parent fe4f855 commit ed746ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>pt.unl.fct.di.novasys</groupId>
<artifactId>babel-core</artifactId>
<version>0.4.43</version>
<version>0.4.44</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/pt/unl/fct/di/novasys/babel/core/GenericProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ public abstract class GenericProtocol {
private static final Logger logger = LogManager.getLogger(GenericProtocol.class);

//TODO split in GenericConnectionlessProtocol and GenericConnectionProtocol?
private static final Babel babel = Babel.getInstance();

private final BlockingQueue<InternalEvent> queue;
private final Thread executionThread;
private final String protoName;
private final short protoId;

private int defaultChannel;

private final Map<Integer, ChannelHandlers> channels;
private final Map<Short, TimerHandler<? extends ProtoTimer>> timerHandlers;
private final Map<Short, RequestHandler<? extends ProtoRequest>> requestHandlers;
private final Map<Short, ReplyHandler<? extends ProtoReply>> replyHandlers;
private final Map<Short, NotificationHandler<? extends ProtoNotification>> notificationHandlers;

private static final Babel babel = Babel.getInstance();

//Debug
ProtocolMetrics metrics = new ProtocolMetrics();
private int defaultChannel;
//protected ThreadMXBean tmx = ManagementFactory.getThreadMXBean();

/**
Expand Down Expand Up @@ -129,13 +134,13 @@ public ProtocolMetrics getMetrics() {
return metrics;
}

protected long getMillisSinceBabelStart() {
protected long getMillisSinceBabelStart(){
return babel.getMillisSinceStart();
}

/* ------------------ PROTOCOL REGISTERS -------------------------------------------------*/

protected void registerMetric(Metric m) {
protected void registerMetric(Metric m){
MetricsManager.getInstance().registerMetric(m);
}

Expand Down Expand Up @@ -336,7 +341,7 @@ protected final void sendMessage(ProtoMessage msg, Host destination) {
* Sends a message to a specified destination using the given channel.
* May require the use of {@link #openConnection(Host)} beforehand.
*
* @param channelId the channel to send the message through
* @param channelId the channel to send the message through
* @param msg the message to send
* @param destination the ip/port to send the message to
*/
Expand Down Expand Up @@ -372,7 +377,7 @@ protected final void sendMessage(ProtoMessage msg, Host destination, int connect
* Sends a message to a specified destination, using a specific connection in a given channel.
* May require the use of {@link #openConnection(Host)} beforehand.
*
* @param channelId the channel to send the message through
* @param channelId the channel to send the message through
* @param connection the channel-specific connection to use.
* @param msg the message to send
* @param destination the ip/port to send the message to
Expand Down Expand Up @@ -616,9 +621,8 @@ final void deliverIPC(IPCEvent ipc) {
/* ------------------ MAIN LOOP -------------------------------------------------*/

private void mainLoop() {
try {
while (true) {

while (true) {
try {
InternalEvent pe = this.queue.take();
metrics.totalEventsCount++;
if (logger.isDebugEnabled())
Expand Down Expand Up @@ -667,10 +671,10 @@ private void mainLoop() {
throw new AssertionError("Unexpected event received by babel. protocol "
+ protoId + " (" + protoName + ")");
}
} catch (Exception e) {
logger.error("Unhandled exception in protocol " + getProtoName() +" ("+ getProtoId() +") " + e, e);
e.printStackTrace();
}
} catch (Exception e) {
logger.error("Protocol " + getProtoName() + " (" + getProtoId() + ") crashed with unhandled exception " + e, e);
e.printStackTrace();
}
}

Expand Down

0 comments on commit ed746ed

Please sign in to comment.