> Hi,
>
>> >
>> This sounds like a logical think to do. I'll just have to figure out how
>> to move mongoose from the Remote service admin to a new service. I guess
>> this should be the first step and after having done that add ZeroMQ from
>> an open-source project.
>
> In the past I started some work on this. If you could give me some time I
> can look it up and share. It is not finished, but could give a good
> starting point.
I would like to start working on the implementation tomorrow so I don't
know how much time you would need to look it up. Pepijn and I created the
attached header files to base the new implementation on. The handler will
be giving a server to a RS and a Connection to the connecting client. What
do you think about this way of implementing it?
>> The flow of the RSA,a transport service (TS), and a remote service (RS)
>> would then be:
>> 1: The RSA starts and listens for TS and RS
>> 2: The TS starts. The RSA now knows about the transport service
>> 3: The RS starts, Asks the RSA for an endpoint based on supplied
>> endpoint
>> description.
>> 4: RSA asks known TS if they are capable of setting up an endpoint with
>> supplied endpoint description.
>> 5: RSA asks one of the capable TS for an endpoint.
>> 6: TS sets up endpoint.
>> 7: RSA returns to RS with a status if the endpoint is created or not.
>> 8: The TS now listens for incoming requests and calls the callback
>> function supplied by the endpoint description and thus directly the RS.
>> 9: RS handles the function call and returns to the TS.
>>
>> I think this is a logical way to handle the transport with remote
>> services. I do have some questions on what to do when the RSA stops.
>> 1: Should all the TS and RS stop as well or can they stay online?
>
> Stopping isn't needed I think, however.. If I am correct, the spec says
> that all endpoints are removed if a RSA is stopped. So if stopping implies
> this then yes. But if stopping means stopping a bundle then no.
Yes I meant removing the end points, closing connections and removing the
servers. The TS can still run.
>> 2: What should happen to an RS if the TS it uses stops? Stop the TS as
>> well or ask the RSA for a new TS if possible?
>
> Again, I think the spec should be leading here. As far as I know it is
> possible to have multiple endpoints for one remote service (based on
> configuration types), so asking for a new TS probably doesn't make sense.
> If there are multiple ts that can handle the configuration there are
> probably already multiple endpoints.
>
> Maybe it is a good idea to see a RSA TS and RS combination conceptually as
> one thing. If any of the three is gone, the others might need to "stop" as
> well. Stopping in this case is for a TS to remove the endpoints and for
> the
> RS to remove the broker.
>
> This gives:
> RSA gone: remove all endpoints and brokers created by that RSA. (there can
> be multiple RSA's).
>
> RS gone:
> Remove endpoints dependant on the RS. The broker is already gone as it is
> part of the RS.
>
> TS gone:
> Do nothing. The endpoints are already gone as part of the TS. The broker
> might as well be used by another TS, and the RSA might as well have
> exported different configuration types.
>
> Having said that, is a RS only needed if there is a broker? And is the TS
> used for other cases? Eg when a new Tcp socket is used for each service?
> Or
> is the RS a service factory for those cases? If so, when the TS is gone,
> then the service created by the factory (for the endpoints of the TS)
> should be removed as well.
I think every service will get it's own TCP socket or transport server. I
think this is a better way to do it. If one socket gets blocked because it
is busy the other sockets still can handle data, unless of course the
interface is blocked.
>>
>> Regards,
>>
>> Erik Jansman
>>
>>
>
/**
*Licensed to the Apache Software Foundation (ASF) under one
*or more contributor license agreements. See the NOTICE file
*distributed with this work for additional information
*regarding copyright ownership. The ASF licenses this file
*to you under the Apache License, Version 2.0 (the
*"License"); you may not use this file except in compliance
*with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing,
*software distributed under the License is distributed on an
*"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
*specific language governing permissions and limitations
*under the License.
*/
/*
* remote_transport_service.h
*
* \date Oct 13, 2011
* \author <a href="mailto:[email protected]">Apache Celix Project Team</a>
* \copyright Apache License, Version 2.0
*/
#ifndef REMOTE_SERVICE_TRANSPORT_CONNECTION_H_
#define REMOTE_SERVICE_TRANSPORT_CONNECTION_H_
#include <properties.h>
typedef struct remote_service_transport_connection *remote_service_transport_connection_t; //ADT
typedef void (*remote_service_tranport_connection_receive_callback_f)(char *bytes, int offset, int length);
// void remote_service_transport_connection_receive_callback_f(char *bytes, int offset, int length){}
typedef struct remote_service_transport_connection_service {
remote_service_transport_connection_t connection;
/**
* Closes the connection
*/
celix_status_t (*disconnect)(remote_service_transport_connection_t connection);
/**
* Send data over the connection, send the chars starting from the offset until lenght is reached.
*/
celix_status_t (*send)(remote_service_transport_connection_t connection, char *bytes, int offset, int length);
/**
* The callback function to call when data is recieved on the connection. Only works on recieving or duplex connections
*/
celix_status_t (*set_receive_callback)(remote_service_transport_connection_t connection, remote_service_tranport_connection_receive_callback_f receive);
/**
* Destroy the connection to clear the memory
*/
celix_status_t (*destroy)(remote_service_transport_connection_t connection);
};
typedef struct remote_service_transport_connection_service remote_service_transport_connection_service_t;
#endif /* REMOTE_SERVICE_TRANSPORT_CONNECTION_H_ *//**
*Licensed to the Apache Software Foundation (ASF) under one
*or more contributor license agreements. See the NOTICE file
*distributed with this work for additional information
*regarding copyright ownership. The ASF licenses this file
*to you under the Apache License, Version 2.0 (the
*"License"); you may not use this file except in compliance
*with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing,
*software distributed under the License is distributed on an
*"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
*specific language governing permissions and limitations
*under the License.
*/
/*
* remote_transport_service.h
*
* \date Oct 13, 2011
* \author <a href="mailto:[email protected]">Apache Celix Project Team</a>
* \copyright Apache License, Version 2.0
*/
#ifndef REMOTE_SERVICE_TRANSPORT_HANDLER_H_
#define REMOTE_SERVICE_TRANSPORT_HANDLER_H_
#include <properties.h>
#include "remote_service_transport_server.h"
#include "remote_service_transport_connection.h"
#define REMOTE_SERVICE_TRANSPORT_HANDLER "remote_service_transport_handler_service"
typedef struct remote_service_transport_handler *remote_service_transport_handler_t; //ADT
struct remote_service_transport_handler_service {
remote_service_transport_handler_t handler;
/**
* open a server connection for this (server) endpoints. Note this connection will modify the endpointProperties which will/should
* be published by discovery.
* e.g. add remote.transport.protocol=ActiveMq, remote.transport.port=8080
*/
celix_status_t (*openServer)(remote_service_transport_handler_t handler, properties_t endpointProperties, remote_service_transport_server_t *result);
/**
* Check if the transport handler support this endpoints based on the endpoint properties.
* e.g. the existing of remote.transport.protocol=ActiveMq
*/
celix_status_t (*supportsAsClient)(remote_service_transport_handler_t handler, properties_t endpointProperties, bool *result);
/**
* Connects with a server endpoint based on the endpointProperties.
* e.g. remote.transport.port=8080
*/
celix_status_t (*connectToServer)(remote_service_transport_handler_t handler, properties_t endpointProperties, remote_service_transport_connection_t *result);
};
typedef struct remote_service_transport_handler_service *remote_service_transport_handler_service_t;
#endif /* REMOTE_SERVICE_TRANSPORT_HANDLER_H_ *//**
*Licensed to the Apache Software Foundation (ASF) under one
*or more contributor license agreements. See the NOTICE file
*distributed with this work for additional information
*regarding copyright ownership. The ASF licenses this file
*to you under the Apache License, Version 2.0 (the
*"License"); you may not use this file except in compliance
*with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing,
*software distributed under the License is distributed on an
*"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
*specific language governing permissions and limitations
*under the License.
*/
/*
* remote_transport_service.h
*
* \date Oct 13, 2011
* \author <a href="mailto:[email protected]">Apache Celix Project Team</a>
* \copyright Apache License, Version 2.0
*/
#ifndef REMOTE_SERVICE_TRANSPORT_SERVER_H_
#define REMOTE_SERVICE_TRANSPORT_SERVER_H_
#include <properties.h>
typedef struct remote_service_transport_server *remote_service_transport_server_t; //ADT
typedef struct remote_service_transport_server_service {
remote_service_transport_server_t server;
/*
* Close the connection on the server side
*/
celix_status_t (*close)(remote_service_transport_server_t server);
/**
* Clean up memory
*/
celix_status_t (*destroy)(remote_service_transport_server_t server);
};
typedef struct remote_service_transport_server_service remote_service_transport_server_service_t;
#endif /* REMOTE_SERVICE_TRANSPORT_SERVER_H_ */