forked from MinecraftUtilities/Backend
maybe
This commit is contained in:
parent
3ac4bfe2ee
commit
046df7fd1f
1
pom.xml
1
pom.xml
@ -174,7 +174,6 @@
|
||||
<groupId>de.flapdoodle.embed</groupId>
|
||||
<artifactId>de.flapdoodle.embed.mongo.spring3x</artifactId>
|
||||
<version>4.12.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
package xyz.mcutils.backend.config;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
@Configuration
|
||||
@EnableMongoRepositories(basePackages = "xyz.mcutils.backend.repository.mongo")
|
||||
public class MongoConfig {
|
||||
}
|
||||
public class MongoConfig { }
|
||||
|
@ -1,9 +1,6 @@
|
||||
package xyz.mcutils.backend.repository.mongo;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import xyz.mcutils.backend.service.metric.Metric;
|
||||
|
||||
/**
|
||||
@ -11,4 +8,4 @@ import xyz.mcutils.backend.service.metric.Metric;
|
||||
*
|
||||
* @author Braydon
|
||||
*/
|
||||
public interface MetricsRepository extends CrudRepository<Metric<?>, String> { }
|
||||
public interface MetricsRepository extends MongoRepository<Metric<?>, String> { }
|
@ -1,8 +1,6 @@
|
||||
package xyz.mcutils.backend.repository.redis;
|
||||
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import xyz.mcutils.backend.model.cache.CachedEndpointStatus;
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,6 @@
|
||||
package xyz.mcutils.backend.repository.redis;
|
||||
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import xyz.mcutils.backend.model.cache.CachedMinecraftServer;
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,6 @@
|
||||
package xyz.mcutils.backend.repository.redis;
|
||||
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import xyz.mcutils.backend.model.cache.CachedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -1,8 +1,6 @@
|
||||
package xyz.mcutils.backend.repository.redis;
|
||||
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import xyz.mcutils.backend.model.cache.CachedPlayerName;
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,6 @@
|
||||
package xyz.mcutils.backend.repository.redis;
|
||||
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import xyz.mcutils.backend.model.cache.CachedPlayerSkinPart;
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import xyz.mcutils.backend.common.Timer;
|
||||
import xyz.mcutils.backend.config.Config;
|
||||
import xyz.mcutils.backend.repository.mongo.MetricsRepository;
|
||||
import xyz.mcutils.backend.service.metric.Metric;
|
||||
import xyz.mcutils.backend.service.metric.metrics.*;
|
||||
@ -55,6 +56,7 @@ public class MetricService {
|
||||
collectorEnabled.put(metric, metric.isCollector());
|
||||
}
|
||||
|
||||
if (Config.INSTANCE.isProduction()) {
|
||||
// Load the metrics from Redis
|
||||
loadMetrics();
|
||||
|
||||
@ -67,6 +69,7 @@ public class MetricService {
|
||||
writeToInflux();
|
||||
}, saveInterval, saveInterval);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a metric.
|
||||
|
@ -9,7 +9,6 @@ import lombok.ToString;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import xyz.mcutils.backend.service.MetricService;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter @Setter @ToString
|
||||
|
@ -1,6 +1,5 @@
|
||||
package xyz.mcutils.backend.service.metric.metrics;
|
||||
|
||||
import xyz.mcutils.backend.service.MetricService;
|
||||
import xyz.mcutils.backend.service.metric.impl.IntegerMetric;
|
||||
import xyz.mcutils.backend.websocket.MetricsWebSocketHandler;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package xyz.mcutils.backend.service.metric.metrics;
|
||||
|
||||
import xyz.mcutils.backend.service.MetricService;
|
||||
import xyz.mcutils.backend.service.metric.impl.IntegerMetric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package xyz.mcutils.backend.service.metric.metrics;
|
||||
|
||||
import xyz.mcutils.backend.service.MetricService;
|
||||
import xyz.mcutils.backend.service.metric.impl.IntegerMetric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package xyz.mcutils.backend.service.metric.metrics.process;
|
||||
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
import xyz.mcutils.backend.service.MetricService;
|
||||
import xyz.mcutils.backend.service.metric.impl.DoubleMetric;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package xyz.mcutils.backend.service.metric.metrics.process;
|
||||
|
||||
import xyz.mcutils.backend.service.MetricService;
|
||||
import xyz.mcutils.backend.service.metric.impl.MapMetric;
|
||||
|
||||
public class MemoryMetric extends MapMetric<String, Long> {
|
||||
|
@ -4,8 +4,6 @@ import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import lombok.NonNull;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import redis.embedded.RedisServer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -1,7 +1,10 @@
|
||||
package xyz.mcutils.backend.test.tests;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo;
|
||||
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -15,6 +18,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
@SpringBootTest(classes = { TestRedisConfig.class })
|
||||
@AutoConfigureMockMvc
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class PlayerControllerTests {
|
||||
|
||||
private final String testPlayerUuid = "eeab5f8a-18dd-4d58-af78-2b3c4543da48";
|
||||
|
@ -1,7 +1,10 @@
|
||||
package xyz.mcutils.backend.test.tests;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo;
|
||||
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
@ -14,6 +17,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
|
||||
@SpringBootTest(classes = { TestRedisConfig.class })
|
||||
@AutoConfigureMockMvc
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class ServerControllerTests {
|
||||
|
||||
private final String testServer = "play.hypixel.net";
|
||||
|
Loading…
Reference in New Issue
Block a user