SINTEF-9012 / cloudml

CloudML: Transparent deployment of cloud applications
GNU Lesser General Public License v3.0
27 stars 8 forks source link

CloudML facade won't return the current deployment model #33

Closed rickdesantis closed 9 years ago

rickdesantis commented 9 years ago

Using the CloudML facade, after a correct deploy of the model, using:

CloudML cml = Factory.getInstance().getCloudML(serverUri)
CommandFactory fcommand = new CommandFactory();
CloudMlCommand cmd = fcommand.loadDeployment(pathToModel);
cml.fireAndWait(cmd);
cmd = fcommand.deploy();
cml.fireAndWait(cmd);
// wait some time until the instances are running...

it doesn't return the actual deployment model or the list of instances via

CloudMlCommand cmd = fcommand.snapshot("/");
cml.fireAndWait(cmd);
// or
cmd = fcommand.listInstances();
cml.fireAndWait(cmd);

where both of those commands return the error

No deployment model. Please first load a deployment model

The error occurs while using Amazon services.

nicolasferry commented 9 years ago

Are you really using the following line (with the serverUri)?

CloudML cml = Factory.getInstance().getCloudML(serverUri)

The commands you are looking for are not yet implemented in the facade for interaction with remote models@runtime. Also the command "snapshot" creates a snapshot of a specific VM instance and doesn't return the list of components in the model.

Is this what you are looking for? (I mean to use the facade in order to interact with a remote models@runtime engine). For now I just added support for the "GetDeployment" command which returns a deployment model in JSON. This way you can load it using the JSONCodec and thus exploit all the features offered by CloudML to manipulate a model (e.g., retrieve only VMs, externalComponents, internalComponents etc.).

CloudMlCommand cmd2 = fcommand.getDeployment();
cml.fireAndWait(cmd2);

In both cases (remote or not) to retrieve the results from commands you have to implement an EventHandler and to register it in the facade:

CloudML cml= Factory.getInstance().getCloudML();
        EventHandler eh=new EventHandler() {
            @Override
            public void handle(Event event) {
                System.out.println(event);
            }

            @Override
            public void handle(Message message) {
                this.handle((Event) message);
            }

            @Override
            public void handle(Data data) {
                this.handle((Event) data);
            }

            @Override
            public void handle(ComponentList componentList) {
                this.handle((Event) componentList);
            }

            @Override
            public void handle(ComponentData componentData) {
                this.handle((Event) componentData);
            }

            @Override
            public void handle(ComponentInstanceList componentInstanceList) {
                this.handle((Event) componentInstanceList);
            }

            @Override
            public void handle(ComponentInstanceData componentInstanceData) {
                this.handle((Event) componentInstanceData);
            }
        };
        cml.register(eh);

In the remote case, the result is a string that you need to handle. The message stating that a deployment is completed is:

!ack {fromPeer: org.cloudml.facade.commands.Deploy, status: completed}
rickdesantis commented 9 years ago

Yes, I was looking for that getDeployment() function and for some reason I mistook the two. Somebody else told me that the facade was incomplete, I was just testing it and reporting what I thought was a bug :). I'm well aware of the event handler mechanism, but it doesn't have anything to do with the reported case.

Thank you, I'll look into it. For now I'll just keep using the web socket client directly.

nicolasferry commented 9 years ago

Yes thank you for the report :) I will close this comment only once all commands will be available in the RemoteFacade The new facade is now available in the maven repo