Fix initial deployment issues
This commit is contained in:
parent
6cd0cb31ec
commit
23bcc1d985
@ -99,7 +99,6 @@ import net.frozenorb.apiv3.util.SpringUtils;
|
|||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.core.env.Environment;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -132,13 +131,13 @@ public final class APIv3 extends AbstractVerticle implements ApplicationContextA
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
setupHttpServer();
|
|
||||||
|
|
||||||
BannedAsn.updateCache();
|
BannedAsn.updateCache();
|
||||||
BannedCellCarrier.updateCache();
|
BannedCellCarrier.updateCache();
|
||||||
Rank.updateCache();
|
Rank.updateCache();
|
||||||
Server.updateCache();
|
Server.updateCache();
|
||||||
ServerGroup.updateCache();
|
ServerGroup.updateCache();
|
||||||
|
|
||||||
|
setupHttpServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ import io.vertx.core.Vertx;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
class Main {
|
public class Main {
|
||||||
|
|
||||||
@Autowired private APIv3 verticle;
|
@Autowired private APIv3 verticle;
|
||||||
@Autowired private Environment environment;
|
@Autowired private Environment environment;
|
||||||
|
@ -51,21 +51,15 @@ public final class BannedAsn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCache() {
|
public static void updateCache() {
|
||||||
bannedAsnsCollection.find().into(new LinkedList<>(), SyncUtils.vertxWrap((bannedAsns, error) -> {
|
List<BannedAsn> bannedAsns = SyncUtils.runBlocking(v -> bannedAsnsCollection.find().into(new LinkedList<>(), v));
|
||||||
if (error != null) {
|
Map<Integer, BannedAsn> working = new HashMap<>();
|
||||||
error.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Integer, BannedAsn> working = new HashMap<>();
|
for (BannedAsn bannedAsn : bannedAsns) {
|
||||||
|
working.put(bannedAsn.getId(), bannedAsn);
|
||||||
|
}
|
||||||
|
|
||||||
for (BannedAsn bannedAsn : bannedAsns) {
|
bannedAsnIdCache = working;
|
||||||
working.put(bannedAsn.getId(), bannedAsn);
|
bannedAsnCache = bannedAsns;
|
||||||
}
|
|
||||||
|
|
||||||
bannedAsnIdCache = working;
|
|
||||||
bannedAsnCache = bannedAsns;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BannedAsn() {} // For Jackson
|
private BannedAsn() {} // For Jackson
|
||||||
|
@ -52,21 +52,15 @@ public final class BannedCellCarrier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCache() {
|
public static void updateCache() {
|
||||||
bannedCellCarriersCollection.find().into(new LinkedList<>(), SyncUtils.vertxWrap((bannedCellCarriers, error) -> {
|
List<BannedCellCarrier> bannedCellCarriers = SyncUtils.runBlocking(v -> bannedCellCarriersCollection.find().into(new LinkedList<>(), v));
|
||||||
if (error != null) {
|
Map<Integer, BannedCellCarrier> working = new HashMap<>();
|
||||||
error.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Integer, BannedCellCarrier> working = new HashMap<>();
|
for (BannedCellCarrier bannedCellCarrier : bannedCellCarriers) {
|
||||||
|
working.put(bannedCellCarrier.getId(), bannedCellCarrier);
|
||||||
|
}
|
||||||
|
|
||||||
for (BannedCellCarrier bannedCellCarrier : bannedCellCarriers) {
|
bannedCellCarrierIdCache = working;
|
||||||
working.put(bannedCellCarrier.getId(), bannedCellCarrier);
|
bannedCellCarrierCache = bannedCellCarriers;
|
||||||
}
|
|
||||||
|
|
||||||
bannedCellCarrierIdCache = working;
|
|
||||||
bannedCellCarrierCache = bannedCellCarriers;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BannedCellCarrier() {} // For Jackson
|
private BannedCellCarrier() {} // For Jackson
|
||||||
|
@ -57,21 +57,15 @@ public final class Rank {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCache() {
|
public static void updateCache() {
|
||||||
ranksCollection.find().into(new LinkedList<>(), SyncUtils.vertxWrap((ranks, error) -> {
|
List<Rank> ranks = SyncUtils.runBlocking(v -> ranksCollection.find().into(new LinkedList<>(), v));
|
||||||
if (error != null) {
|
Map<String, Rank> working = new HashMap<>();
|
||||||
error.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Rank> working = new HashMap<>();
|
for (Rank rank : ranks) {
|
||||||
|
working.put(rank.getId().toLowerCase(), rank);
|
||||||
|
}
|
||||||
|
|
||||||
for (Rank rank : ranks) {
|
rankIdCache = working;
|
||||||
working.put(rank.getId().toLowerCase(), rank);
|
rankCache = ranks;
|
||||||
}
|
|
||||||
|
|
||||||
rankIdCache = working;
|
|
||||||
rankCache = ranks;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Rank() {} // For Jackson
|
private Rank() {} // For Jackson
|
||||||
|
@ -61,21 +61,15 @@ public final class Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCache() {
|
public static void updateCache() {
|
||||||
serversCollection.find().into(new LinkedList<>(), SyncUtils.vertxWrap((servers, error) -> {
|
List<Server> servers = SyncUtils.runBlocking(v -> serversCollection.find().into(new LinkedList<>(), v));
|
||||||
if (error != null) {
|
Map<String, Server> working = new HashMap<>();
|
||||||
error.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Server> working = new HashMap<>();
|
for (Server server : servers) {
|
||||||
|
working.put(server.getId().toLowerCase(), server);
|
||||||
|
}
|
||||||
|
|
||||||
for (Server server : servers) {
|
serverIdCache = working;
|
||||||
working.put(server.getId().toLowerCase(), server);
|
serverCache = servers;
|
||||||
}
|
|
||||||
|
|
||||||
serverIdCache = working;
|
|
||||||
serverCache = servers;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateTimedOutServers() {
|
private static void updateTimedOutServers() {
|
||||||
|
@ -59,21 +59,15 @@ public final class ServerGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void updateCache() {
|
public static void updateCache() {
|
||||||
serverGroupsCollection.find().into(new LinkedList<>(), SyncUtils.vertxWrap((serverGroups, error) -> {
|
List<ServerGroup> serverGroups = SyncUtils.runBlocking(v -> serverGroupsCollection.find().into(new LinkedList<>(), v));
|
||||||
if (error != null) {
|
Map<String, ServerGroup> working = new HashMap<>();
|
||||||
error.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, ServerGroup> working = new HashMap<>();
|
for (ServerGroup serverGroup : serverGroups) {
|
||||||
|
working.put(serverGroup.getId().toLowerCase(), serverGroup);
|
||||||
|
}
|
||||||
|
|
||||||
for (ServerGroup serverGroup : serverGroups) {
|
serverGroupIdCache = working;
|
||||||
working.put(serverGroup.getId().toLowerCase(), serverGroup);
|
serverGroupCache = serverGroups;
|
||||||
}
|
|
||||||
|
|
||||||
serverGroupIdCache = working;
|
|
||||||
serverGroupCache = serverGroups;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServerGroup() {} // For Jackson
|
private ServerGroup() {} // For Jackson
|
||||||
|
Loading…
Reference in New Issue
Block a user