Skip to content

codewind-resources/codewind-vscode-openliberty-walkthrough

Repository files navigation

Codewind Quicklab

Moving workloads to the cloud introduces a steep learning curve for developers accustomed to traditional web application development. Cloud-native applications are usually containerized (either Docker or OCI containers) and are run on orchestrated platforms like Kubernetes. These are complex technologies that bring big changes to the development workflow. Can this be simplified? Can developers create cloud-native applications and deploy them to Kubernetes without climbing the mountainous learning curve?

In this quicklab we will take a look at a use case involving Eclipse Codewind, a technology that simplify development of containerized cloud-native applications. Codewind is an IDE plugin that allows you to work with containerized applications in a familiar way. With Codewind, developers can start building cloud-native applications like experts without having to be an expert in all the cloud-native technologies.

Prerequistes

If you're running this lab on your own laptop, make sure you have a few things already installed.

Click to expand

Configure Local System

This quicklab requires the following tools:

  1. Docker
  2. VS Code
  3. VS Code Codewind extension

We recommend working with the latest available version of each.

Improving Developer Productivity with Eclipse Codewind

Eclipse Codewind is a plugin for IDEs, currently available in VS Code, Eclipse, and Eclipse Che, that helps improve developer productivity when developing containerized applications. Let's explore how Codewind can help you be a more productive developer.

  1. Open VS Code (on the Mac, press command + space bar and type "code" into the dialog box)

  2. In the explorer window under CODEWIND click on the "+" to create a new project Show user how to create a new project

  3. In the dialog pop-up search for "Open Liberty" and select the "Open Liberty (Default templates)" option Show user how to find and select an Open Liberty template

  4. Enter cloud-native-microprofile as the project name and hit enter. You will see a dialogue asking what parent directory you want for your projects. For the purposes of this lab, create a "codewind-workspace" directory during this step (if it does not already exist). In reality, you can choose to place the projects wherever it makes sense for you. name your project

Automated Code Reload

A key to increasing developer productivity is shortening and reducing the friction in the feedback loop. Codewind improves your inner loop experience, enabling you to create a microservice quickly, rapidly iterate on changes and make improvements to performance. As you develop, Codewind automatically pushes your code changes to your container as efficiently as possible. 

Let's look at this feature in action.

  1. In the project workspace under src/main/java/io/openliberty/sample create a new file HelloResource.java Create a file called HelloResource.java
  2. Edit HelloResource.java to look like below:
package io.openliberty.sample;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.QueryParam;

import java.awt.*;

@Path("/hello")
public class HelloResource {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public Response hello(@QueryParam("name") String name) {
        
        return Response.ok( "Hello " + name).build();

    }

}
  1. You can view the status of the re-build and re-deploy by looking at the status indicator next to the project under the Codewind context. Once status returns to [Running][Build Suceeded] you can refresh your browser window to view the change we made. Please be aware that it can take a few seconds until something happens. See app status
  2. In VS Code click the "Open Application" icon.
  3. Append /system/hello?name=Cloud Native Microprofile to the end of the url. You can try adding your own name next time. append url to see your example work

Other Actions

View the Metrics Dashboard

You can use the Metrics Dashboard to help you determine if your application is performing as intended. For example, an application might look like it is functioning well, but these metrics can reveal if an application is working harder than it should be. This action is only available when the application is running or debugging.

  1. Navigate to the Project Overview page. You can do this either by right-clicking on the project in the Codewind explorer and selecting "Open Project Overview" or simply click the (i) information icon. Open project overview
  2. Enable "Inject Appmetrics." Inject Appmetrics Wait for the Application Status to go back to Running - it shouldn't take long.
  3. When the status reflects [Running][Build Succeeded], navigate to the Metrics Dashboard.

  • CPU: View this graph to see whether your computer is keeping up with the work you’re doing. If you have spare CPU cycles, your machine is likely keeping up with your throughput. If you don’t have spare CPU cycles, you might notice a degradation in performance.
  • HTTP Incoming Requests: View this graph to see the incoming requests that your microservice receives. You can track the incoming requests and their response times. The graph doesn’t show each request. Instead, it shows requests at specific points in time. Use this graph to see whether your application responds to the requests as quickly as intended or if a change created delays in response times.
  • Memory: Straight horizontal lines and lines that plateau indicates good memory. An ascending line indicates a memory leak and that the computer is running out of memory.
  • HTTP Throughput: This graph indicates how fast the application is processing the requests that are coming into it.
  • Heap: This graph is only available for Java and Node.js projects. It displays the heap size and the used heap on a timeline.
  • HTTP Outbound Requests: This graph is similar to the HTTP Incoming Requests graph and shows the number of outbound requests at specific points in time.
  • Loop Times: This graph indicates how fast a Node.js project is processing through an event loop.
  • Other Requests: This graph indicates the Socket.IO and other requests that the application processes.

View Application Logs

Viewing the logs of your application running in a docker container is easy from the IDE with Codewind.

To view the logs for an application, right click on it and select "Show All Logs"

The logs for the running application will be shown in the IDE console log window on the bottom right of the page.

# codewind-vscode-openliberty-walkthrough

About

Try Codewind on your local machine and experience deploying a cloud native application within minutes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published