in the end it got simple. in the MXBean i let inject
IContainerManager and then use:
@Override
public int getConnectedClients() {
if (containerManager == null) {
return 0;
}
final Set<ID> clientIDs = new HashSet<ID>();
for (final IContainer container :
containerManager.getAllContainers()) {
final IReliableContainer rc = (IReliableContainer)
container.getAdapter(IReliableContainer.class);
clientIDs.addAll(Arrays.asList(rc.getGroupMemberIDs()));
}
return clientIDs.size() -
containerManager.getAllContainers().length;
}
Of cource the "server" sort out also could have done by comparing
the ID's of the container with the ones in the GroupMember List but
I think that should work too.
The IConnectHandlerPolicy variant was not enough in this case,
because i couldn't track a disconnect of clients this way.
Scott, thanks again for your pleasant help and support on this!
Merry Xmas to everyone
bye, peter
Am 17.12.2015 um 18:54 schrieb Scott
Lewis:
T
Hi Peter,
On 12/17/2015 3:58 AM, Peter Hermsdorf wrote:
<stuff deleted>
Collection<ExportReference> getExportedServices();
Collection<ImportReference> getImportedServices();
i tries that and i'm getting a ExportReference for every
exported service, but the information I'm seeking seems not to
be in there. Basically there is only the EndpointDescription of
the exported Servie and the service itself in there.
Yes. One of the things I recently added to ECF's RSA
implementation was the ability to get more information from the
ExportReference (i.e. more than is specified by RSA
ExportReference class). Specifically, see:
http://download.eclipse.org/rt/ecf/3.12.0/javadoc/org/eclipse/ecf/osgi/services/remoteserviceadmin/RemoteServiceAdmin.html
The getExportedServices() method returns instances of
RemoteServiceAdmin.ExportReference. And there are is also method
on RemoteServiceAdmin.getExportedRegistrations() which returns
instances of RemoteServiceAdmin.ExportRegistration. SObviously,
these are ECF only/not standardized.
You will notice that the ECF RemoteServiceAdmin.ExportReference
has methods: getContainerID() and getRemoteServiceId().
It's also possible to receive either
synchronous or asynchronous notifications from the
RemoteServiceAdmin service using the
RemoteServiceAdminListener and RemoteServiceAdminEvent.
same here. I see no event on server side when a client connects
or disconnects.
What I'm looking for is the number of connected clients (in
other words: the number of times the service has been imported
by a client) and preferable the ip and/or hostname of the
client(s).
I see. So there is no standardized AP for that (yet). It's
possible that it would be added, but so far I've not seen any
discussion about it in the EEG. I would happily bring it up for
possible standardization, but I can't commit the necessary
personal resources right now.
In any event, there are ways to get to it with
ECF-generic-provider specific APIs, and I think that's what you
are using.
Let me try to help guide that:
The generic provider server is based upon this class:
org.eclipse.ecf.provider.generic.ServerSOContainer
As you can see, it implements
org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager.
What this means is that if you can get the IContainer instance on
the server (which you should be able to via the IContainerManager
service), then you can adapt it to the
ISharedObjectContainerGroupManager...e.g.
ISharedObjectContainerGroupManager cgm =
(ISharedObjectContainerGroupManager)
container.getAdapter(ISharedObjectContainerGroupManager.class);
Note that if it's not a generic provider (e.g. rosgi or any other)
getAdapter will return null.
The ISharedObjectContainerGroupManager has a method:
setConnectPolicy(IConnectHandlerPolicy policy) which will be
called when clients connect...with information about their tcpip
address, their id, etc.
There is another adapter for IContainer:
org.eclipse.ecf.core.IReliableContainer all generic provider
servers and clients implement this, so you should also be able to
do:
IReliableContainer rc = (IReliableContainer)
container.getAdapter(IReliableContainer.class);
and get a non-null rc.
IReliableContainer has a method:
IReliableContainer.getGroupMemberIDs() that has returns an ID[].
These are all of the current group members (clients and server in
TCP). You can associate the information gained in
IConnectHandlerPolicy (address, etc) with the ID in the ID[].
I and Wim have been thinking about adding API (and impl) to allow
easier access to statistics about remote services (e.g. like
client info, usage info, etc). But we haven't gotten to it
yet. If I can find someone to support it with my time, I would
happily do it (and even suggest standardization in future versions
of RSA via the EEG).
Note that there are also container events that are delivered to
any listeners (via IContainer.addContainerListener). That's
perhaps more involved so I'll leave it at that for now.
Let me know if this helps and we will discuss further if
necessary.
Scott
Maybe I have misunderstood your suggestions ;)
Any more hints on this would be great!
Thank you!
bye, peter
BTW: I'm using ECF 3.9.3
_______________________________________________
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
|
E-Mail: peter.hermsdorf@xxxxxxxxx
Telefon: +49 3641 287-0
Telefax: +49 3641 287-287
Internet: www.godyo-p4.de
|

|
GODYO
Business Solutions AG, Prüssingstraße 35, 07745 Jena,
Vorstand: Hans-Uwe Schramm, Aufsichtsratsvorsitzender: Dirk
Waltje,
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.
|