Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exec connection #852

Merged
merged 1 commit into from
Jan 24, 2019
Merged

Conversation

boaks
Copy link
Contributor

@boaks boaks commented Jan 21, 2019

Remove synchronization on dtls session and move serial executor fro inet socket address into connection. Preparation for connection id support.

Signed-off-by: Achim Kraus achim.kraus@bosch-si.com

ApplicationMessage message = (ApplicationMessage) record.getFragment();
session.markRecordAsRead(record.getEpoch(), record.getSequenceNumber());
// create application message.
RawData receivedApplicationMessage = RawData.inbound(message.getData(), session.getConnectionReadContext(), false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receivedApplicationMessage can not be null ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see only possible Exceptions, but no null.

executor.shutdownNow(pending);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once a ConnectionStore is stopped, it can never be restarted, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least for unitests the "restart" is used. Therefore the connections kept in the store. See markAllAsResumptionRequired call in start(InetSocketAddress).

if (serialExecutor != null) {
serialExecutor.execute(new Runnable() {
SerialExecutor serialExecutor = connection.getExecutor();
serialExecutor.execute(new Runnable() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serialExecutor is never null ? because a connection still have an alive executor ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only "ticket" connections use a null SerialExecutor, but they re only returned in find(SessionId).

}
} else if (!connection.isExecuting() && running.get()) {
LOGGER.debug("Recreate new connection for {}", connection);
newConnection = new Connection(connection, new SerialExecutor(executor));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check create parameter for recreate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a connection (may be after restart), but we need one with a active executor. "create" means a really new connection not only a revived one.

* If the provided connection has either a handshaker or a established
* session, create a new connection.
*
* @param connection connection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior of this method is not so clear to me, we give a connection and we get a new one. Maybe more javadoc could help.

missing removeFromSessionCache parameter which has not an obvious utility in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method returns a "fresh active connection" without handshaker nor session and an active executor. The missing javadoc will be added.

@@ -1356,11 +1451,13 @@ private void startNewHandshake(final ClientHello clientHello, final Record recor
initializeHandshaker(handshaker);
handshaker.processMessage(record);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed.

error = new IllegalStateException("connector's serial-executors-cache is exhausted!");
connection = getAliveConnection(msg.getInetSocketAddress(), !serverOnly);
if (connection == null) {
if (connectionStore.remainingCapacity() > 0 && serverOnly) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if connectionStore.remainingCapacity() > 0 and we are not in serverOnly mode we raise new IllegalStateException("connection store is exhausted!"), is it normal ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If serverOnly is false, new connections are created, and so null is returned, if the the store is exhausted and the put failed.
If serverOnly is true, the remaining call is not required. I will remove it.

connection.cancelPendingFlight();
synchronized (connectionStore) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add a new atomic function in connectionStore ? (e.g. replace ?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be at the end of the "connection id wip".

@@ -1839,15 +1937,13 @@ protected void sendNextDatagramOverNetwork(final DatagramPacket datagramPacket)
}
}

private void handleTimeout(DTLSFlight flight) {
private void handleTimeout(DTLSFlight flight, Connection connection) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some formatting issue in this method

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix it.

@boaks boaks force-pushed the exec_connection branch 4 times, most recently from 7253098 to c542d75 Compare January 24, 2019 06:00
@boaks
Copy link
Contributor Author

boaks commented Jan 24, 2019

I cleaned up the formatting of the changes. Though some of the stuff is changed again with the other parts of the related wip, I would prefer to have that part merged.

@sbernard31
Copy link
Contributor

👍

Decouple serial execution from InetSocketAddress to prepare for
connection id support. Remove synchronization on dtls session. With the
introduction of serialized execution based on the connection,
synchronization based on the dtls session is obsolete.

Signed-off-by: Achim Kraus <achim.kraus@bosch-si.com>
@boaks boaks merged commit f61c070 into eclipse-californium:2.0.x Jan 24, 2019
@boaks boaks deleted the exec_connection branch April 5, 2019 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants