9 Commits

Author SHA256 Message Date
minimons 641cf3d2d4 2: Swap System.exit from JupiterPerpsAlarmImpl with thrown exceptions 2026-06-19 09:51:05 +02:00
minimons dbdde7b7e3 2: Disable old autostart plugins 2026-06-19 09:42:56 +02:00
minimons 8b4c37b8ad Enable logging 2026-06-19 09:41:05 +02:00
minimons beffce2762 Lots of small updates 2026-06-18 15:58:36 +02:00
minimons 9c9c1e0e4e Lots of small updates 2026-06-18 15:58:20 +02:00
minimons 4821e1ff4b Add 2 applications as auto starting 2026-06-18 13:27:00 +02:00
minimons baf9bc91aa Add TickerService and API (dummy empty) 2026-06-18 13:27:00 +02:00
minimons fb83a8999a NenjimHub now autostarts Jupiter Alarm 2026-06-18 12:44:43 +02:00
minimons 0dd187dfb5 Enable logging 2026-06-18 10:14:36 +02:00
24 changed files with 163 additions and 53 deletions
+3 -1
View File
@@ -3,4 +3,6 @@
# Ignore Gradle build output directory # Ignore Gradle build output directory
build build
/logs/
logs/*.log
logs/*.log.gz
View File
@@ -0,0 +1,4 @@
package com.r35157.assetaz.core.service.ticker;
public interface TickerService {
}
@@ -0,0 +1,6 @@
package com.r35157.assetaz.core.service.ticker.impl.ref;
import com.r35157.assetaz.core.service.ticker.TickerService;
public class TickerServiceImpl implements TickerService {
}
@@ -0,0 +1,4 @@
package com.r35157.jupiterperpsalarm;
public class JupiterPerpsAlarm {
}
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
@FunctionalInterface @FunctionalInterface
public interface AlarmAction { public interface AlarmAction {
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
public enum AlarmTrigger { public enum AlarmTrigger {
ONETIME, ONETIME,
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.util.List; import java.util.List;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
public final class ConsoleAlarmAction implements AlarmAction { public final class ConsoleAlarmAction implements AlarmAction {
@Override @Override
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.net.URI; import java.net.URI;
import java.nio.file.Path; import java.nio.file.Path;
@@ -9,17 +9,16 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
public final class Main { public final class JupiterPerpsAlarmImpl {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
Config config; Config config;
try { try {
config = Config.parse(args, System.getenv()); config = Config.parse(args, System.getenv());
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
System.err.println(exception.getMessage());
printUsage(); printUsage();
System.exit(2); String errMsg = "Could not parse configuration for JupiterPerpsAlarm: " + exception.getMessage() + "!";
return; throw new IllegalStateException(errMsg, exception);
} }
if (config.selfTest()) { if (config.selfTest()) {
@@ -32,9 +31,8 @@ public final class Main {
try { try {
definitions = AlarmConfigurationParser.parse(config.alarmConfiguration()); definitions = AlarmConfigurationParser.parse(config.alarmConfiguration());
} catch (Exception exception) { } catch (Exception exception) {
System.err.println("Could not load alarm configuration: " + exception.getMessage()); String errMsg = "Could not load alarm configuration: " + exception.getMessage() + "!";
System.exit(2); throw new IllegalStateException(errMsg, exception);
return;
} }
List<AlarmAction> actions = new ArrayList<>(); List<AlarmAction> actions = new ArrayList<>();
@@ -196,6 +194,6 @@ public final class Main {
} }
} }
private Main() { private JupiterPerpsAlarmImpl() {
} }
} }
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
public enum JupiterPerpsAsset { public enum JupiterPerpsAsset {
SOL("FYq2BWQ1V5P1WFBqr3qB2Kb5yHVvSv7upzKodgQE5zXh"), SOL("FYq2BWQ1V5P1WFBqr3qB2Kb5yHVvSv7upzKodgQE5zXh"),
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger; import java.math.BigInteger;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.net.URI; import java.net.URI;
import java.net.http.HttpClient; import java.net.http.HttpClient;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
public final class PriceAlarm { public final class PriceAlarm {
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Objects; import java.util.Objects;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -1,4 +1,4 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.net.URI; import java.net.URI;
import java.net.URLEncoder; import java.net.URLEncoder;
@@ -1,7 +1,6 @@
package com.r35157.jupiterperpsalarm; package com.r35157.jupiterperpsalarm.impl.ref;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -1,18 +1,30 @@
package com.r35157.nenjim.hubd; package com.r35157.nenjim.hubd;
import com.r35157.nenjim.hubd.journal.Journal; import com.r35157.nenjim.hubd.journal.Journal;
import crypto.r35157.nenjim.NenjimProcess;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
public interface NenjimHub { public interface NenjimHub {
/**
* Starts a process based on the provided fully qualified interface name.
* The actual implementation that is run is binded according to the Context.
*
* @param fqInterfaceName the fully qualified interface name of the process to start. The interface must extend the {@code NenjimProcess} interface.
*/
void startProcess(String fqInterfaceName);
/**
* Provides a map of all running processes managed by the NenjimHub, keyed by the processId.
*
* @return a map of {@code NenjimProcess} running processes
*/
HashMap<Integer, NenjimProcess> getRunningProcesses();
/** /**
* A no-operation (noop). This method is suppoted to do nothing. * A no-operation (noop). This method is suppoted to do nothing.
*/ */
void noop(); void noop();
/**
*
* @param journal
*/
void monitorJournal(@NotNull Journal journal);
} }
@@ -2,8 +2,8 @@ package com.r35157.nenjim.hubd.impl.ref;
import com.r35157.nenjim.hubd.ctx.Context; import com.r35157.nenjim.hubd.ctx.Context;
import com.r35157.nenjim.hubd.NenjimHub; import com.r35157.nenjim.hubd.NenjimHub;
//import org.apache.logging.log4j.LogManager; import org.slf4j.Logger;
//import org.apache.logging.log4j.Logger; import org.slf4j.LoggerFactory;
import java.lang.management.ClassLoadingMXBean; import java.lang.management.ClassLoadingMXBean;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
@@ -15,13 +15,22 @@ import java.nio.file.Path;
public class Main { public class Main {
static void main(String[] args) throws Exception { static void main(String[] args) throws Exception {
new Main(args).start(); NenjimHub nenjimHub = new NenjimHubImpl();
}
public Main(String[] args) throws Exception { /* try {
/*hub = new NenjimHubImpl(); log.info("Auto-starting 2 Nenjim application(s)...");
log.info("Initializing NenjimHub..."); log.info(" Starting AssetAZCore...");
//com.r35157.;
log.info(" Starting jupiterperpsalarm...");
String[] params = new String[] {
"--config=/home/minimons/projects/com_r35157_nenjim-hubd-impl_ref/conf/alarms.conf"
};
com.r35157.jupiterperpsalarm.Main.main(params);
*/
//hub = new NenjimHubImpl();
/*
String classesCacheDirRaw = "~/.config/nenjim/cache/classes"; String classesCacheDirRaw = "~/.config/nenjim/cache/classes";
String classesCacheDir = (classesCacheDirRaw.startsWith("~/")) String classesCacheDir = (classesCacheDirRaw.startsWith("~/"))
? System.getProperty("user.home") + classesCacheDirRaw.substring(1) ? System.getProperty("user.home") + classesCacheDirRaw.substring(1)
@@ -50,6 +59,5 @@ public class Main {
//int a = 0; //int a = 0;
} }
private void start() { private static final Logger log = LoggerFactory.getLogger(Main.class);
}
} }
@@ -2,20 +2,97 @@ package com.r35157.nenjim.hubd.impl.ref;
import com.r35157.nenjim.hubd.NenjimHub; import com.r35157.nenjim.hubd.NenjimHub;
import com.r35157.nenjim.hubd.journal.Journal; import com.r35157.nenjim.hubd.journal.Journal;
import crypto.r35157.nenjim.NenjimProcess;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.HashMap;
public class NenjimHubImpl implements NenjimHub { public class NenjimHubImpl implements NenjimHub {
@Override public NenjimHubImpl() throws Exception {
public void noop() { log.info("Initializing NenjimHub...");
log.debug("NOOP executed.");
nextProcessId = 1;
//processesScope = new StructuredTaskScope.ShutdownOnFailure();
processes = new HashMap<>();
log.info("Starting autorun processes:");
startAutoRunProcesses();
waitForAndShutdown();
}
private void waitForAndShutdown() {
System.out.println("Done - Now online!");
/*
try {
processesScope.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
processesScope.close();
*/
System.out.println("Nenjim is now shutdown (stopped all processes)!");
}
private void startAutoRunProcesses() throws Exception {
String[] processesToAutoStart = {
//"com.r35157.jupiterperpsalarm.impl.ref.JupiterPerpsAlarmImpl"
//"crypto.r35157.nenjim.NenjimHubSocketAdminAdapter",
//"crypto.r35157.nenjim.NenjimHubRestAdminAdapter",
//"crypto.r35157.nenjim.NenjimHubRPCAdminAdapter",
//"crypto.r35157.nenjim.SuwimoHub",
//"crypto.r35157.nenjim.SodaTaskManager",
//"crypto.r35157.assetaz.hub.AssetAZHub"
};
for (String processInterfaceName : processesToAutoStart) {
startProcess(processInterfaceName);
}
} }
@Override @Override
public void monitorJournal(@NotNull Journal journal) { public void startProcess(String className) {
log.warn("monitorJournal IS NOT IMPLEMENTED!"); ClassLoader loader = ClassLoader.getSystemClassLoader();
/*processesScope.fork(() -> {
Class<?> clazz = loader.loadClass(className);
if (!NenjimProcess.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException("'" + className + "' does NOT implement NenjimProcess");
}
NenjimProcess proc = (NenjimProcess) clazz.getDeclaredConstructor().newInstance();
processes.put(nextProcessId, proc);
nextProcessId++;
NenjimContext context = new NenjimContext() { };
proc.setNenjimProcessContext(context);
proc.setNenjimHub(this);
Thread.currentThread().setName(proc.getProcessName());
System.out.println(" Starter Nenjim process '" + proc.getProcessName() + "'");
proc.run();
return null;
});*/
}
@Override
public HashMap<Integer, NenjimProcess> getRunningProcesses() {
return processes;
}
@Override
public void noop() {
System.out.println("NenjimHub command: 'noop'");
} }
private static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class); private static final Logger log = LoggerFactory.getLogger(NenjimHubImpl.class);
private HashMap<Integer, NenjimProcess> processes;
//private StructuredTaskScope.ShutdownOnFailure processesScope;
private int nextProcessId;
} }