Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ jobs:
- name: Check license header
uses: apache/skywalking-eyes@v0.6.0

code-style:
name: "Check code style"
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- run: ./mvnw clean spotless:check

build:
runs-on: ubuntu-latest
strategy:
Expand Down
1 change: 0 additions & 1 deletion .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ header:
- '**/target/**'
- '**/*.ftl'
- '**/*.log'
- '**/codestyle/*'
- '.git/'
- '.github/**'
- '**/.gitignore'
Expand Down
5 changes: 2 additions & 3 deletions bigtop-manager-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
~ specific language governing permissions and limitations
~ under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.bigtop</groupId>
Expand Down Expand Up @@ -48,6 +46,7 @@
<dependency>
<groupId>org.apache.bigtop</groupId>
<artifactId>bigtop-manager-common</artifactId>
<version>${revision}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,43 +18,41 @@
*/
package org.apache.bigtop.manager.agent;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MultiGauge;
import org.apache.bigtop.manager.agent.monitoring.AgentHostMonitoring;
import org.apache.bigtop.manager.agent.monitoring.ZookeeperHealthyMonitoring;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MultiGauge;

@SpringBootApplication(scanBasePackages = {"org.apache.bigtop.manager.agent", "org.apache.bigtop.manager.common"})
public class AgentApplication {

public static void main(String[] args) {
SpringApplication.run(AgentApplication.class, args);
}

@Qualifier("diskMultiGauge")
@Bean
public MultiGauge diskMultiGauge(MeterRegistry meterRegistry) {
@Qualifier("diskMultiGauge") public MultiGauge diskMultiGauge(MeterRegistry meterRegistry) {
return AgentHostMonitoring.newDiskMultiGauge(meterRegistry);
}

@Qualifier("cpuMultiGauge")
@Bean
public MultiGauge cpuMultiGauge(MeterRegistry meterRegistry) {
@Qualifier("cpuMultiGauge") public MultiGauge cpuMultiGauge(MeterRegistry meterRegistry) {
return AgentHostMonitoring.newCPUMultiGauge(meterRegistry);
}

@Qualifier("memMultiGauge")
@Bean
public MultiGauge memMultiGauge(MeterRegistry meterRegistry) {
@Qualifier("memMultiGauge") public MultiGauge memMultiGauge(MeterRegistry meterRegistry) {
return AgentHostMonitoring.newMemMultiGauge(meterRegistry);
}

@Qualifier("zookeeperMultiGauge")
@Bean
public MultiGauge zookeeperMultiGauge(MeterRegistry meterRegistry) {
@Qualifier("zookeeperMultiGauge") public MultiGauge zookeeperMultiGauge(MeterRegistry meterRegistry) {
return ZookeeperHealthyMonitoring.registerZookeeperHealthyGauge(meterRegistry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

@Getter
public enum AgentExceptionStatus {

AGENT_MONITORING_ERROR(10001, "Get agent host monitoring info failed"),

COMMAND_FAILED(10002, "Run command failed"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
*/
package org.apache.bigtop.manager.agent.executor;

import static org.apache.bigtop.manager.common.constants.CacheFiles.CLUSTER_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.COMPONENTS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.CONFIGURATIONS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.HOSTS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.REPOS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.SETTINGS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.USERS_INFO;

import org.apache.bigtop.manager.common.constants.Constants;
import org.apache.bigtop.manager.common.constants.MessageConstants;
import org.apache.bigtop.manager.common.message.entity.command.CommandMessageType;
import org.apache.bigtop.manager.common.message.entity.payload.CacheMessagePayload;
import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.stack.common.utils.linux.LinuxFileUtils;

import java.text.MessageFormat;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;

import lombok.extern.slf4j.Slf4j;

import java.text.MessageFormat;

import static org.apache.bigtop.manager.common.constants.CacheFiles.CLUSTER_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.COMPONENTS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.CONFIGURATIONS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.HOSTS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.REPOS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.SETTINGS_INFO;
import static org.apache.bigtop.manager.common.constants.CacheFiles.USERS_INFO;

@Slf4j
@org.springframework.stereotype.Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
Expand All @@ -53,24 +53,22 @@ public CommandMessageType getCommandMessageType() {
@Override
public void doExecute() {
CacheMessagePayload cacheMessagePayload =
JsonUtils.readFromString(commandRequestMessage.getMessagePayload(),
CacheMessagePayload.class);
JsonUtils.readFromString(commandRequestMessage.getMessagePayload(), CacheMessagePayload.class);
log.info("[agent executeTask] taskEvent is: {}", commandRequestMessage);
String cacheDir = Constants.STACK_CACHE_DIR;

LinuxFileUtils.createDirectories(cacheDir, "root", "root", "rwxr-xr-x", false);

JsonUtils.writeToFile(cacheDir + SETTINGS_INFO, cacheMessagePayload.getSettings());
JsonUtils.writeToFile(cacheDir + CONFIGURATIONS_INFO,
cacheMessagePayload.getConfigurations());
JsonUtils.writeToFile(cacheDir + CONFIGURATIONS_INFO, cacheMessagePayload.getConfigurations());
JsonUtils.writeToFile(cacheDir + HOSTS_INFO, cacheMessagePayload.getClusterHostInfo());
JsonUtils.writeToFile(cacheDir + USERS_INFO, cacheMessagePayload.getUserInfo());
JsonUtils.writeToFile(cacheDir + COMPONENTS_INFO, cacheMessagePayload.getComponentInfo());
JsonUtils.writeToFile(cacheDir + REPOS_INFO, cacheMessagePayload.getRepoInfo());
JsonUtils.writeToFile(cacheDir + CLUSTER_INFO, cacheMessagePayload.getClusterInfo());

commandResponseMessage.setCode(MessageConstants.SUCCESS_CODE);
commandResponseMessage.setResult(MessageFormat.format("Host [{0}] cached successful!!!",
commandRequestMessage.getHostname()));
commandResponseMessage.setResult(
MessageFormat.format("Host [{0}] cached successful!!!", commandRequestMessage.getHostname()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import org.apache.bigtop.manager.agent.holder.SpringContextHolder;
import org.apache.bigtop.manager.common.message.entity.command.CommandMessageType;

import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CommandExecutors {

Expand All @@ -48,7 +48,8 @@ private static synchronized void load() {
return;
}

for (Map.Entry<String, CommandExecutor> entry : SpringContextHolder.getCommandExecutors().entrySet()) {
for (Map.Entry<String, CommandExecutor> entry :
SpringContextHolder.getCommandExecutors().entrySet()) {
String beanName = entry.getKey();
CommandExecutor commandExecutor = entry.getValue();
if (COMMAND_EXECUTORS.containsKey(commandExecutor.getCommandMessageType())) {
Expand All @@ -57,7 +58,9 @@ private static synchronized void load() {
}

COMMAND_EXECUTORS.put(commandExecutor.getCommandMessageType(), beanName);
log.info("Load JobRunner: {} with identifier: {}", commandExecutor.getClass().getName(),
log.info(
"Load JobRunner: {} with identifier: {}",
commandExecutor.getClass().getName(),
commandExecutor.getCommandMessageType());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
*/
package org.apache.bigtop.manager.agent.executor;

import lombok.extern.slf4j.Slf4j;
import org.apache.bigtop.manager.common.message.entity.command.CommandMessageType;
import org.apache.bigtop.manager.common.message.entity.payload.CommandPayload;
import org.apache.bigtop.manager.common.shell.ShellResult;
import org.apache.bigtop.manager.common.utils.JsonUtils;
import org.apache.bigtop.manager.stack.core.executor.StackExecutor;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@org.springframework.stereotype.Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import org.apache.bigtop.manager.common.shell.ShellResult;
import org.apache.bigtop.manager.common.utils.os.TimeSyncDetection;

import java.util.List;
import java.util.function.Supplier;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.function.Supplier;

@Slf4j
@Component
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,15 @@
import org.apache.bigtop.manager.agent.executor.CommandExecutor;
import org.apache.bigtop.manager.agent.ws.AgentWebSocketHandler;

import java.util.Map;

import jakarta.annotation.Nonnull;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import lombok.Getter;

import jakarta.annotation.Nonnull;
import java.util.Map;

@Component
public class SpringContextHolder implements ApplicationContextAware {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,37 @@
*/
package org.apache.bigtop.manager.agent.metrics;

import io.micrometer.core.instrument.MultiGauge;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.bigtop.manager.agent.monitoring.AgentHostMonitoring;
import org.apache.bigtop.manager.agent.monitoring.ZookeeperHealthyMonitoring;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import io.micrometer.core.instrument.MultiGauge;
import lombok.extern.slf4j.Slf4j;

import jakarta.annotation.Resource;

@Slf4j
@Component
@EnableScheduling
@EnableAsync
public class MetricsCollector {

@Qualifier("diskMultiGauge")
@Resource
@Qualifier("diskMultiGauge") @Resource
private MultiGauge diskMultiGauge;
@Qualifier("memMultiGauge")
@Resource

@Qualifier("memMultiGauge") @Resource
private MultiGauge memMultiGauge;
@Qualifier("cpuMultiGauge")
@Resource

@Qualifier("cpuMultiGauge") @Resource
private MultiGauge cpuMultiGauge;
@Qualifier("zookeeperMultiGauge")
@Resource

@Qualifier("zookeeperMultiGauge") @Resource
private MultiGauge zookeeperMultiGauge;

@Async
Expand All @@ -62,5 +64,4 @@ private void scrape() {
AgentHostMonitoring.cpuMultiGaugeUpdateData(cpuMultiGauge);
ZookeeperHealthyMonitoring.zookeeperUpdateStatus(zookeeperMultiGauge);
}

}
Loading