Welcome to the new world of connectors and web protocols! :-)

*Is this the same Terracotta that used to be open source?*
*If so, where is the code that implements your old TerracottaConnector?*

Is that a java.net.Socket I see?
It's important to point out that there are no traditional BIO facilities or
support in Jetty 9.
Jetty is 100% async/java.nio now.

You'll first need to implement a java.nio endpoint suitable for Jetty.
Ultimately it will be an implementation of org.eclipse.jetty.io.EndPoint.
But seeing the Socket in your example code snippet, you'll probably want
some basic networking support.
So start with implementing a TerracottaEndPoint that extend
org.eclipse.jetty.io.ChannelEndPoint

This TerracottaEndPoint will be important regardless of the next steps.

Basic implementation ...

Then try simply extending ServerConnector and providing an implementation of
protected ChannelEndPoint newEndPoint(SocketChannel channel,
ManagedSelector selectSet, SelectionKey key) throws IOException
that returns your TerracottaEndPoint instance.

Alternate approach ...

You might want a network that isn't quite a network connector.
If so, you might want to use the code examples found in our UnixSocket
support layer.
Note: you'll still need the above mentioned TerracottaEndPoint.

unix socket example code:
https://github.com/eclipse/jetty.project/tree/jetty-9.4.x/jetty-unixsocket/src/main/java/org/eclipse/jetty/unixsocket




Joakim Erdfelt / [email protected]

On Mon, Mar 19, 2018 at 3:46 PM, Anthony Dahanne <[email protected]>
wrote:

> Hello Jetty experts,
> First, I apologize if it's not the appropriate mailing list for this
> question (I was hesitating with jetty-dev) , but there is my question :
> what's the preferred path to migrate a custom connector from 8.1 to 9.4 ?
> Here's what I used to do : a cusotm connector that could understand HTTP,
> TC protocol, and SSL
>
> TCServerImpl.this.terracottaConnector = new 
> TerracottaConnector(TCServerImpl.this.configurationSetupManager.getSecurity() 
> != null);
> TCServerImpl.this.terracottaConnector.setName(CONNECTOR_NAME_TERRACOTTA);
>
>
> ----
>
> public class TerracottaConnector extends SocketConnector {
>   private final boolean secure;
>   private boolean shutdown = false;
>
>   public TerracottaConnector(boolean secure) {
>     this.secure = secure;
>   }
>
>   public void handleSocketFromDSO(Socket s, byte[] data) throws IOException {
>     ConnectorEndPoint connection = new ConnectorEndPoint(new SocketWrapper(s, 
> data));
>     connection.dispatch();
>   }
>
> etc.
> }
> ----
>
> I've read the new architecture document : https://www.eclipse.org/
> jetty/documentation/9.4.x/architecture.html but I'm still hitting my head
> on what to use, and if there were examples that are doing what I used to do
> (even if it's pretty clear from the architecture document that this use
> case is definitely supported)
>
> I've tried extending the ServerConnector instead, but doing so , I could
> not find the right API to handle a raw socket and raw bytes (Handlers are
> are about HTTPRequest, so I guess I should stick to the ServerConnector...)
> Anyway, if you have examples with custom ServerConnector, I'd be very
> thankful if you could point them out !
> Thanks in advance !
> Anthony
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to