Hi Nirmal, Sorry I mistyped, I wanted to say that
"the ServiceCreatedMessageProcessor.process method does not seem to set the properties when it creates the Service class, not sure if it was on purpose or a bug." (see the code snipplet below) Was this intended to not set the properties ? Thanks Martin From: Nirmal Fernando [mailto:nirmal070...@gmail.com] Sent: Tuesday, March 18, 2014 6:47 PM To: dev@stratos.incubator.apache.org Subject: RE: Question: Setting a property on a service instance (adding a property to a cartridge) Hi, On Mar 19, 2014 6:31 AM, "Martin Eppel (meppel)" <mep...@cisco.com<mailto:mep...@cisco.com>> wrote: > > Hi Nirmal, > > > > Thanks - this was helpful, > > actually the ServiceCreatedMessageProcessor.process method does seem to set > the properties when it creates the Service class, not sure if it was on > purpose or a bug. > We are using the chain of responsibility pattern and *MessageProcessors are responsible for make some sense out of the events. > Another thing I noticed is that after unsubscribing and undeploying a > cartridge the complete topology event still shows the unsubscribed / > undeployed cartridges ( although not the cli tool / list-cartridges), even > after restarting all stratos processes, seems like the db still references it > ? > That shouldn't be the case. Can you verify again and post the logs please? > > > Thanks > > > > Martin > > > > ServiceCreatedMessageProcessor > > > > public boolean process(String type, String message, Object object) { > > ... > > Service service = new Service(event.getServiceName(), event.getServiceType()); > > service.addPorts(event.getPorts()); > > topology.addService(service); > > if (log.isInfoEnabled()) { > > log.info<http://log.info>(String.format("Service created: > [service] %s", event.getServiceName())); > > } > > notifyEventListeners(event); > > return true; > > ... > > } > > > > From: Nirmal Fernando > [mailto:nirmal070...@gmail.com<mailto:nirmal070...@gmail.com>] > Sent: Monday, March 17, 2014 9:10 PM > To: dev@stratos.incubator.apache.org<mailto:dev@stratos.incubator.apache.org> > Subject: Re: Question: Setting a property on a service instance (adding a > property to a cartridge) > > > > Hi Martin, > > > > On Mon, Mar 17, 2014 at 7:30 PM, Martin Eppel (meppel) > <mep...@cisco.com<mailto:mep...@cisco.com>> wrote: > > Hi, > > I am experimenting with some stratos code to add a property to a cartridge > (or service) which I can later retrieve from a service instance. >> >> >> Service.java (in org.apache.stratos.messaging.domain.topology) has >> getter/setter for properties but I have a hard time to figure out the flow / >> code where properties are actually retrieved from the cartridge definition >> (json) and set at the service instance (e.g. when subscribing to a >> cartridge). >> >> The idea is to add a new property to a cartridge json definition (see >> example below), assign it to a service instance and retrieve it in the >> context of autoscaler rules. Is there a better way to define properties at >> the service level ? > > > > Cartridge's properties should be available under > org.apache.stratos.messaging.domain.topology.Service's properties. If not > it's a bug :-) >> >> >> Also, another question is: I can see in the code that there is >> ServiceCreatedEvent which I would assume would be generated and handled when >> subscribing a cartridge (= service ?) but it seems that no such event is >> being processed ? (- however I do see the ClusterCreatedEvent being created >> and processed). When is ServiceCreatedEvent generated ? > > > > ServiceCreatedEvent generated when you deploy a new Cartridge. > > org.apache.stratos.messaging.event.topology.ServiceCreatedEvent.ServiceCreatedEvent(String, > ServiceType) > > |_org.apache.stratos.cloud.controller.topology.TopologyEventPublisher.sendServiceCreateEvent(List<Cartridge>) > > |_org.apache.stratos.cloud.controller.topology.TopologyBuilder.handleServiceCreated(List<Cartridge>) > > |_org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl.deployCartridgeDefinition(CartridgeConfig) >> >> >> Any pointers are highly appreciated >> >> Thanks >> >> Martin >> >> >> .... >> "property": [ >> { >> "name": "dependencies", >> "value": "service_name" >> } >> ... >> ] > > > > > -- > > Best Regards, > Nirmal > > Nirmal Fernando. > PPMC Member & Committer of Apache Stratos, > Senior Software Engineer, WSO2 Inc. > > > > Blog: http://nirmalfdo.blogspot.com/