Skip to content

Commit

Permalink
fixed/added missing default branch in CmwLightClient and exposed inte…
Browse files Browse the repository at this point in the history
…rnal variables as protected

N.B. allows/facilitates further extension
  • Loading branch information
RalphSteinhagen committed Nov 13, 2020
1 parent 5b1bff4 commit 41a1110
Showing 1 changed file with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ public class CmwLightClient {
private static final Logger LOGGER = LoggerFactory.getLogger(CmwLightClient.class);
private static final AtomicLong connectionIdGenerator = new AtomicLong(0); // global counter incremented for each connection
private static final AtomicInteger requestIdGenerator = new AtomicInteger(0);
private final AtomicInteger channelId = new AtomicInteger(0); // connection local counter incremented for each channel
private final ZMQ.Context context;
private final ZMQ.Socket controlChannel;
private final AtomicReference<ConnectionState> connectionState = new AtomicReference<>(ConnectionState.DISCONNECTED);
private final String address;
private String sessionId;
private long connectionId;
Map<Long, Subscription> subscriptions = Collections.synchronizedMap(new HashMap<>()); // all subscriptions added to the server
protected final AtomicInteger channelId = new AtomicInteger(0); // connection local counter incremented for each channel
protected final ZMQ.Context context;
protected final ZMQ.Socket controlChannel;
protected final AtomicReference<ConnectionState> connectionState = new AtomicReference<>(ConnectionState.DISCONNECTED);
protected final String address;
protected String sessionId;
protected long connectionId;
protected final Map<Long, Subscription> subscriptions = Collections.synchronizedMap(new HashMap<>()); // all subscriptions added to the server
// private final List<QueuedRequests> queuedRequests = new LimitedArrayList(); // all requests which are waiting for a reply/timeout from the server
private long lastHbReceived = -1;
private long lastHbSent = -1;
private final int heartbeatInterval = 1000; // time between to heartbeats in ms
private final int heartbeatAllowedMisses = 3; // number of heartbeats which can be missed before resetting the conection
private final long subscriptionTimeout = 1000; // maximum time after which a connection should be reconnected
private int backOff = 20;
protected long lastHbReceived = -1;
protected long lastHbSent = -1;
protected final int heartbeatInterval = 1000; // time between to heartbeats in ms
protected final int heartbeatAllowedMisses = 3; // number of heartbeats which can be missed before resetting the conection
protected final long subscriptionTimeout = 1000; // maximum time after which a connection should be reconnected
protected int backOff = 20;

public void unsubscribe(final Subscription subscription) throws CmwLightProtocol.RdaLightException {
subscriptions.remove(subscription);
subscriptions.remove(subscription.id);
sendUnsubscribe(subscription);
}

Expand Down Expand Up @@ -195,10 +195,14 @@ public boolean housekeeping(final long currentTime) throws CmwLightProtocol.RdaL
case SUBSCRIBED:
// do nothing
break;
default:
throw new IllegalStateException("unexpected subscription state: " + sub.subscriptionState);
}
}
}
break;
default:
throw new IllegalStateException("unexpected connection state: " + connectionState.get());
}
return false;
}
Expand Down

0 comments on commit 41a1110

Please sign in to comment.