Compare commits
7 Commits
641cf3d2d4
...
75cd15a20c
| Author | SHA256 | Date | |
|---|---|---|---|
| 75cd15a20c | |||
| 992c2ca860 | |||
| ea7cdbaf46 | |||
| 35fa64fa23 | |||
| fe6e29a45e | |||
| ff0b81c432 | |||
| f44bdc4b8b |
+3
-1
@@ -3,4 +3,6 @@
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build
|
||||
/logs/
|
||||
|
||||
logs/*.log
|
||||
logs/*.log.gz
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AlarmAction {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
public enum AlarmTrigger {
|
||||
ONETIME,
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
public final class ConsoleAlarmAction implements AlarmAction {
|
||||
@Override
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
+7
-9
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
@@ -9,17 +9,16 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public final class Main {
|
||||
public final class JupiterPerpsAlarmImpl {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Config config;
|
||||
try {
|
||||
config = Config.parse(args, System.getenv());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
System.err.println(exception.getMessage());
|
||||
printUsage();
|
||||
System.exit(2);
|
||||
return;
|
||||
String errMsg = "Could not parse configuration for JupiterPerpsAlarm: " + exception.getMessage() + "!";
|
||||
throw new IllegalStateException(errMsg, exception);
|
||||
}
|
||||
|
||||
if (config.selfTest()) {
|
||||
@@ -32,9 +31,8 @@ public final class Main {
|
||||
try {
|
||||
definitions = AlarmConfigurationParser.parse(config.alarmConfiguration());
|
||||
} catch (Exception exception) {
|
||||
System.err.println("Could not load alarm configuration: " + exception.getMessage());
|
||||
System.exit(2);
|
||||
return;
|
||||
String errMsg = "Could not load alarm configuration: " + exception.getMessage() + "!";
|
||||
throw new IllegalStateException(errMsg, exception);
|
||||
}
|
||||
|
||||
List<AlarmAction> actions = new ArrayList<>();
|
||||
@@ -196,6 +194,6 @@ public final class Main {
|
||||
}
|
||||
}
|
||||
|
||||
private Main() {
|
||||
private JupiterPerpsAlarmImpl() {
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
public enum JupiterPerpsAsset {
|
||||
SOL("FYq2BWQ1V5P1WFBqr3qB2Kb5yHVvSv7upzKodgQE5zXh"),
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
public final class PriceAlarm {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URLEncoder;
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
package com.r35157.jupiterperpsalarm;
|
||||
package com.r35157.jupiterperpsalarm.impl.ref;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -1,18 +1,30 @@
|
||||
package com.r35157.nenjim.hubd;
|
||||
|
||||
import com.r35157.nenjim.hubd.journal.Journal;
|
||||
import crypto.r35157.nenjim.NenjimProcess;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
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.
|
||||
*/
|
||||
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.NenjimHub;
|
||||
//import org.apache.logging.log4j.LogManager;
|
||||
//import org.apache.logging.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import java.lang.management.ClassLoadingMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
@@ -15,13 +15,22 @@ import java.nio.file.Path;
|
||||
|
||||
public class Main {
|
||||
static void main(String[] args) throws Exception {
|
||||
new Main(args).start();
|
||||
}
|
||||
NenjimHub nenjimHub = new NenjimHubImpl();
|
||||
|
||||
public Main(String[] args) throws Exception {
|
||||
/*hub = new NenjimHubImpl();
|
||||
log.info("Initializing NenjimHub...");
|
||||
/* try {
|
||||
log.info("Auto-starting 2 Nenjim application(s)...");
|
||||
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 classesCacheDir = (classesCacheDirRaw.startsWith("~/"))
|
||||
? System.getProperty("user.home") + classesCacheDirRaw.substring(1)
|
||||
@@ -33,13 +42,13 @@ public class Main {
|
||||
System.exit(-1);
|
||||
}*/
|
||||
|
||||
//System.out.println("Initializing initial NenjimClassLoader with default context...");
|
||||
//JournalManager journalManager = new JournalManagerImpl();
|
||||
//ContextManager contextManager = new ContextManagerImpl();
|
||||
//Context defaultContext = contextManager.getDefault();
|
||||
//System.out.println("Initializing initial NenjimClassLoader with default context...");
|
||||
//JournalManager journalManager = new JournalManagerImpl();
|
||||
//ContextManager contextManager = new ContextManagerImpl();
|
||||
//Context defaultContext = contextManager.getDefault();
|
||||
|
||||
//NenjimClassLoader nenjimClassLoader = new NenjimClassLoader(journalManager, defaultContext);
|
||||
//Class<?> clazz = nenjimClassLoader.findClass("com.r35157.nenjim.hubd.impl.ref.NenjimHubImpl");
|
||||
//NenjimClassLoader nenjimClassLoader = new NenjimClassLoader(journalManager, defaultContext);
|
||||
//Class<?> clazz = nenjimClassLoader.findClass("com.r35157.nenjim.hubd.impl.ref.NenjimHubImpl");
|
||||
|
||||
/*NenjimHub nenjimHub = null;
|
||||
Context defaultContext = new Context();
|
||||
@@ -47,9 +56,8 @@ public class Main {
|
||||
Object instance = clazz.getDeclaredConstructor().newInstance();
|
||||
NenjimKicker kicker = (NenjimKicker)instance;
|
||||
*/
|
||||
//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.journal.Journal;
|
||||
import crypto.r35157.nenjim.NenjimProcess;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class NenjimHubImpl implements NenjimHub {
|
||||
@Override
|
||||
public void noop() {
|
||||
log.debug("NOOP executed.");
|
||||
public NenjimHubImpl() throws Exception {
|
||||
log.info("Initializing NenjimHub...");
|
||||
|
||||
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
|
||||
public void monitorJournal(@NotNull Journal journal) {
|
||||
log.warn("monitorJournal IS NOT IMPLEMENTED!");
|
||||
public void startProcess(String className) {
|
||||
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 HashMap<Integer, NenjimProcess> processes;
|
||||
//private StructuredTaskScope.ShutdownOnFailure processesScope;
|
||||
private int nextProcessId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user