[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ecf-dev] connections/threads are not cleaned up after failing importService call

Hi Scott,

thanks for your suggestion, but the described fix does not seem to work. The returned container is always null and so cannot be disconnected. This is caused by the importEndpoint of the importReference being null.

This is what I'm doing:

1) register my remote service and a reconnect listener for that service:

ÂÂÂ ÂÂÂ final ImportRegistration registration = remoteServiceAdmin.importService(endpointDescription);

ÂÂÂ ÂÂÂ final ReconnectServiceAdminListener reconnectListener = new ReconnectServiceAdminListener(remoteServiceAdmin,
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ containerManager,
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ registration, endpointDescription);
ÂÂÂ ÂÂÂ context.registerService(RemoteServiceAdminListener.class.getName(), reconnectListener, null);

2) inside the ReconnectListener I basically try to re-import the service when the registration/connection fails:

public class ReconnectServiceAdminListener implements RemoteServiceAdminListener {

ÂÂÂ private static final Duration RECONNECT_DELAY = Duration.ofSeconds(10);

ÂÂÂ private final ReconnectJob reconnectJob;
ÂÂÂ private final EndpointDescription endpointDescription;
ÂÂÂ private final RemoteServiceAdmin remoteServiceAdmin;
ÂÂÂ private ImportRegistration registration;

ÂÂÂ private final IContainerManager containerManager;

ÂÂÂ public ReconnectServiceAdminListener(final RemoteServiceAdmin remoteServiceAdmin,
ÂÂÂ ÂÂÂ ÂÂÂ final IContainerManager containerManager, final ImportRegistration registration,
ÂÂÂ ÂÂÂ ÂÂÂ final EndpointDescription endpointDescription) {
ÂÂÂ ÂÂÂ this.remoteServiceAdmin = remoteServiceAdmin;
ÂÂÂ ÂÂÂ this.containerManager = containerManager;
ÂÂÂ ÂÂÂ this.registration = registration;
ÂÂÂ ÂÂÂ this.endpointDescription = endpointDescription;
ÂÂÂ ÂÂÂ reconnectJob = new ReconnectJob();
ÂÂÂ ÂÂÂ if (registration.getException() != null) {
ÂÂÂ ÂÂÂ ÂÂÂ reconnectJob.schedule(RECONNECT_DELAY.toMillis());
ÂÂÂ ÂÂÂ }
ÂÂÂ }

ÂÂÂ @Override
ÂÂÂ public void remoteAdminEvent(final RemoteServiceAdminEvent e) {
ÂÂÂ ÂÂÂ final org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.RemoteServiceAdminEvent event = (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.RemoteServiceAdminEvent) e;
ÂÂÂ ÂÂÂ if (event.getEndpointDescription().isSameService(endpointDescription)) {
ÂÂÂ ÂÂÂ ÂÂÂ switch (event.getType()) {
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ case RemoteServiceAdminEvent.IMPORT_UNREGISTRATION:
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ case RemoteServiceAdminEvent.IMPORT_ERROR:
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ reconnectJob.schedule(RECONNECT_DELAY.toMillis());
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ break;
ÂÂÂ ÂÂÂ ÂÂÂ }
ÂÂÂ ÂÂÂ }
ÂÂÂ }

ÂÂÂ class ReconnectJob extends Job {

ÂÂÂ ÂÂÂ public ReconnectJob() {
ÂÂÂ ÂÂÂ ÂÂÂ super("ReconnectJob");
ÂÂÂ ÂÂÂ }

ÂÂÂ ÂÂÂ @Override
ÂÂÂ ÂÂÂ protected IStatus run(final IProgressMonitor monitor) {

ÂÂÂ ÂÂÂ ÂÂÂ final org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration remoteServiceImportRegistration = (org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration) registration;
ÂÂÂ ÂÂÂ ÂÂÂ final ID containerID = remoteServiceImportRegistration.getContainerID();
ÂÂÂ ÂÂÂ ÂÂÂ final IContainer container = containerManager.getContainer(containerID);
ÂÂÂ ÂÂÂ ÂÂÂ if (container != null) {
ÂÂÂ ÂÂÂ ÂÂÂ ÂÂÂ container.disconnect();
ÂÂÂ ÂÂÂ ÂÂÂ }

ÂÂÂ ÂÂÂ ÂÂÂ registration.close();
ÂÂÂ ÂÂÂ ÂÂÂ registration = remoteServiceAdmin.importService(endpointDescription);
ÂÂÂ ÂÂÂ ÂÂÂ return Status.OK_STATUS;
ÂÂÂ ÂÂÂ }
ÂÂÂ }

}

The Thread count still increases with every run of the ReconnectJob.


Any suggestions on how to solve this issue?

Thanks!
Bye Peter

Am 16.09.2017 um 05:03 schrieb Scott Lewis:
Hi Peter,

I'm assuming that you are using the generic provider.

I think you can do what you need to do by:

1) You can cast the ImportRegistration to org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration
2) Call org.eclipse.ecf.osgi.services.remoteserviceadmin.RemoteServiceAdmin.ImportRegistration.getContainerID() to get the container ID
3) Using the IContainerManager service (a singleton ecf service) and the ID from 2 call:ÂÂ IContainer c = containerManager.getContainer(id) to get the associated container instance.
4) Call c.disconnect() to release the connection and associated threads.

Scott



On 9/15/2017 7:27 AM, Peter Hermsdorf wrote:
Hi,

we encountered a problem while trying to import services exported from a process running in a local VM (_not_ JVM). The VM forwards the necessary port to the host machine.

As for the problem: RemoteAdminService#importService causes a RemoteAdminServiceEvent.IMPORT_ERROR to be signalled and the connections/threads opened due to the importService call do not get closed, even though we call ImportRegistration#close() on failed attempts. The latter does not happen, if there is no one listening on the port at all. Since, we have code that regularly calls importService again for services, that should be, but are not currently imported (according to RemoteAdminService#getImportedEndpoints), we slowly accumulate more and more threads.

The tcp connection to the local VM seems to be successful, but due to issues regarding requested hostname and actual hostname ECF (correctly) does not "connect the services" (see https://dev.eclipse.org/mhonarc/lists//ecf-dev/msg07259.html for a discussion of the "hostname problem - localhost != getCanonicalHostname()" in EndPointDescriptions; in this case it is host::getCanonicalHostname() != VM::getCanonicalHostname())

So importService creates threads/connections, fails to import, and even with a call to ImportRegistration#close() does not clean up the threads/connections.

Any suggestions on how to solve this issue or more generally handle this reconnect use-case are more than welcome!

Best regards,

Bye Peter


PS: we use the ecf generic provider on the latest ecf release

_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ecf-dev


_______________________________________________
ecf-dev mailing list
ecf-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ecf-dev

--

Mit freundlichen GrÃÃen

Peter Hermsdorf

Â

Â

GODYO Business Solutions AG
PrÃssingstraÃe 35
07745 Jena

Peter Hermsdorf
Senior Software Developer
Teamleiter Softwareentwicklung

E-Mail: peter.hermsdorf@xxxxxxxxx
Telefon: +49 3641 287-0
Telefax: +49 3641 287-287
Mobil: +49 151 287111
Internet: www.godyo.com


ÂGODYO P4

Â

GODYO Business Solutions AG, PrÃssingstraÃe 35, 07745 Jena,
Ein Unternehmen der ACP Gruppe

Â

Vorstand: Hans-Uwe Schramm, Aufsichtsratsvorsitzender: GÃnther Schiller,
Amtsgericht Jena HRB 502 129

Â

Diese E-Mail ist vertraulich. Wenn Sie nicht der vorgesehene EmpfÃnger sind, verwenden Sie bitte keine Inhalte dieser E-Mail und leiten sie diese auch nicht weiter. Wenn Sie fÃlschlicherweise diese E-Mail bekommen haben, informieren Sie uns bitte umgehend und lÃschen dieses Dokument. This e-mail is confidential. If you are not the intended recipient, please do not disclose or use the contents of the e-mail. If you have erroneously received this e-mail, please inform us immediately by return e-mail and delete the document.

PNG image