1. Trampoline Overview
1.蹦床概述
Historically, a simple way to understand the state of our system at runtime was to run it manually in a terminal. Best case scenario, we’d automatize everything using scripts.
历史上,了解我们的系统在运行时的状态的一个简单方法是在终端手动运行。最好的情况是,我们会用脚本将一切自动化。
Of course, the DevOps movement changed all of that, and, fortunately, our industry has moved well past that approach. Trampoline is one of the solutions that solve this problem (for Unix and Windows users) in the Java ecosystem.
当然,DevOps运动改变了这一切,幸运的是,我们的行业已经远远超越了这种方法。Trampoline是解决Java生态系统中这一问题的解决方案之一(针对Unix和Windows用户)。。
The tool is built on top of Spring Boot and aims to help Spring Cloud developers in their daily development routine thanks to a clean and fresh User Interface.
该工具建立在Spring Boot之上,旨在帮助Spring Cloud开发者完成他们的日常开发工作,这要归功于一个干净而新鲜的用户界面。
Here are some of its capabilities:
以下是它的一些功能。
- Start instances using Gradle or Maven as a Build Tool
- Manage Spring Boot instances
- Configure VM arguments during launching phase
- Monitor deployed instances: Memory usage, Logs, and Traces
- Provide feedback to authors
In this quite article, we’ll review the problem Trampoline aspires to solve, as well as have a look at it in practice. We’ll go on a guided tour that covers registering a new service and starting one instance of that service.
在这篇文章中,我们将回顾一下Trampoline想要解决的问题,以及看看它的实践。我们将进行一次导游,包括注册一个新的服务和启动该服务的一个实例。
2. Microservices: Single Deployment Dead
2.微服务 单一部署死亡
As we discussed, the times when applications were deployed using a single deployment unit – are gone.
正如我们所讨论的,使用单一部署单元部署应用程序的时代–已经过去了。
This has positive consequences and, unfortunately, negative ones as well. Although Spring Boot and Spring Cloud help in this transition, there are side effects we need to take care of.
这有积极的影响,不幸的是也有消极的影响。虽然Spring Boot和Spring Cloud有助于这种过渡,但也有我们需要注意的副作用。
The journey from monoliths to microservices has introduced a huge improvement to the way developers structure their applications.
从单体到微服务的历程为开发人员构造其应用程序的方式带来了巨大的改进。
As we all know, it is not the same to open a project with a set of 30 classes, well-structured among packages and with its corresponding units tests, as opening a monster codebase with a huge number of classes, where things easily get complicated.
我们都知道,打开一个有30个类的项目,在包之间结构良好,并有相应的单元测试,和打开一个有大量类的怪物代码库是不一样的,在那里事情很容易变得复杂。
Not only that – reusability, decoupling, and separation of concerns have benefited from this evolution. Although the benefits are well-known, let’s list some of them:
不仅如此–可重用性、解耦和关注点的分离也从这一演变中受益。虽然这些好处是众所周知的,但让我们列举其中的一些。
- Single Responsibility Principle – important in terms of maintainability and testing
- Resiliency – failure in one service does not impact other services
- High scalability – demanding services can be deployed in multiple instances
But, we have to face some trade-off when using microservice architecture, especially regarding network overhead and deployments.
但是,在使用微服务架构时,我们必须面对一些权衡,特别是关于网络开销和部署。
However, focusing on deployment, we lost one of the monolith’s advantages – the single deployment. To solve it in a production environment, we’ve got a whole set of CD tools which will help and will make our lives easier there.
然而,专注于部署,我们失去了单片机的一个优势–单一部署。为了在生产环境中解决这个问题,我们有一整套CD工具,这将有助于并将使我们的生活在那里变得更容易。
3. Trampoline: Setting up the First Service
3.蹦床 设置第一个服务
In this section, we’ll register a service in Trampoline and we’ll show all available features.
在本节中,我们将在Trampoline中注册一个服务,我们将展示所有可用的功能。
3.1. Download Latest Release
3.1.下载最新版本
Going to Trampoline Repository, in the releases section, we’ll be able to download the latest published release.
进入Trampoline Repository,在releases部分,我们就可以下载最新发布的版本。
Then, start Trampoline, for instance using mvn spring-boot:run or ./gradlew (or gradle.bat) bootRun.
然后,启动Trampoline,例如使用mvn spring-boot:run 或 ./gradlew (或 gradle.bat) bootRun。
Finally, the UI can be accessed at http://localhost:8080.
最后,可以在http://localhost:8080访问用户界面。
3.2. Registering Services
3.2.注册服务
Once we have Trampoline up and running, let’s go to Settings section where we’ll be able to register our first service. We’ll find two examples of microservices in the Trampoline source code: microservice-example-gradle and microservice-example-maven.
一旦我们启动并运行了Trampoline,让我们去Settings部分,在那里我们将能够注册我们的第一个服务。我们将在Trampoline的源代码中找到两个微服务的例子。microservice-example-gradle 和 microservice-example-maven。
To register a service, the following information is needed: name*, default port*, pom or build location*, build tool*, actuator prefix, and VM default arguments.
要注册一个服务,需要以下信息。名称*,默认端口*,pom或构建位置*,构建工具*,执行器前缀,和VM默认参数。
If we decide to use Maven as a build tool, first we’ll have to set our Maven location. If we decide, however, to use a Gradle wrapper, it must be placed in our microservices folder. Nothing else will be required.
如果我们决定使用Maven作为构建工具,首先我们要设置Maven的位置。不过,如果我们决定使用Gradle包装器,则必须将其放在microservices文件夹中。其他的就不需要了。
In this example, we’ll set up both:
在这个例子中,我们将设置这两方面。
At any time, we’ll be able to review the service information by clicking on the info button or delete it clicking on the trash button.
在任何时候,我们都可以通过点击info按钮来审查服务信息,或者点击trash按钮来删除它。
Finally, to be able to enjoy all these features, the only requirement is to include actuator starter (see the snippet for an example) in our Spring Boot projects, as well as /logfile endpoint through well-known logging properties:
最后,为了能够享受所有这些功能,唯一的要求是在我们的Spring Boot项目中包括actuator starter(见片段中的例子),以及通过众所周知的日志属性包括/logfile端点。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
3.3. Managing Service Instances
3.3.管理服务实例
Now, we’re ready to move to Instances section. Here, we’ll be able to start and stop service instances and also monitor their statuses, traces, logs and memory consumption.
现在,我们准备进入实例部分。在这里,我们将能够启动和停止服务实例,并监视它们的状态、痕迹、日志和内存消耗。
For this tutorial, we start one instance of each service registered previously:
在本教程中,我们为之前注册的每个服务启动一个实例。
3.4. Dashboard
3.4.仪表板
Finally, let’s have a quick overview of the Dashboard section. Here, we can visualize some statistics, such as memory usage from our computer or services registered or launched.
最后,让我们快速浏览一下Dashboard部分。在这里,我们可以看到一些统计数据,如我们的计算机或注册或启动的服务的内存使用情况。
We’ll also be able to watch whether required Maven information has been introduced or not in the settings section:
我们还可以在设置部分观察是否引入了所需的Maven信息。
3.5. Feedback
3.5.反馈意见
And last but not least, we can find a Feedback button which redirects to the GitHub repo where it’s possible to create issues or raise questions and enhancements.
最后但并非最不重要的是,我们可以找到一个Feedback按钮,重定向到GitHub repo,在那里可以创建问题或提出问题和改进。
4. Conclusion
4.结论
During the course of this tutorial, we discussed the problem Trampoline aims to solve.
在本教程的过程中,我们讨论了Trampoline旨在解决的问题。
We’ve also shown an overview of its functionalities, as well as a short tutorial on how to register a service and how to monitor it.
我们还展示了它的功能概述,以及如何注册服务和如何监控服务的简短教程。
Finally, note that this is an open source project and you are welcome to contribute.
最后,请注意,这是一个开源项目,欢迎你来贡献。