use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class ArkContainer method prepareArkConfig.
/**
* Prepare to read ark conf
* @throws ArkRuntimeException
*/
public void prepareArkConfig() throws ArkRuntimeException {
try {
// Forbid to Monitoring and Management Using JMX, because it leads to conflict when setup multi spring boot app.
ArkConfigs.setSystemProperty(Constants.SPRING_BOOT_ENDPOINTS_JMX_ENABLED, String.valueOf(false));
// ignore thread class loader when loading classes and resource in log4j
ArkConfigs.setSystemProperty(Constants.LOG4J_IGNORE_TCL, String.valueOf(true));
// compatible sofa-hessian4, refer to https://github.com/sofastack/sofa-hessian/issues/38
ArkConfigs.setSystemProperty(Constants.RESOLVE_PARENT_CONTEXT_SERIALIZER_FACTORY, "false");
// read ark conf file
List<URL> urls = getProfileConfFiles(pipelineContext.getLaunchCommand().getProfiles());
ArkConfigs.init(urls);
} catch (Throwable throwable) {
throw new ArkRuntimeException(throwable);
}
}
use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class FileUtils method createTempDir.
/**
* Atomically creates a new directory somewhere beneath the system's
* temporary directory (as defined by the {@code java.io.tmpdir} system
*/
public static File createTempDir(String subPath) {
File baseDir = new File(System.getProperty("java.io.tmpdir"));
File tempDir = new File(baseDir, subPath);
if (tempDir.exists()) {
return tempDir;
} else if (tempDir.mkdir()) {
return tempDir;
}
throw new ArkRuntimeException("Failed to create temp file");
}
use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.
the class ClassLoaderUtils method getAgentClassPath.
public static URL[] getAgentClassPath() {
List<String> inputArguments = AccessController.doPrivileged(new PrivilegedAction<List<String>>() {
@Override
public List<String> run() {
return ManagementFactory.getRuntimeMXBean().getInputArguments();
}
});
List<URL> agentPaths = new ArrayList<>();
for (String argument : inputArguments) {
if (!argument.startsWith(JAVA_AGENT_MARK)) {
continue;
}
argument = argument.substring(JAVA_AGENT_MARK.length());
try {
String path = argument.split(JAVA_AGENT_OPTION_MARK)[0];
URL url = new File(path).toURI().toURL();
agentPaths.add(url);
} catch (Throwable e) {
throw new ArkRuntimeException("Failed to create java agent classloader", e);
}
}
return agentPaths.toArray(new URL[] {});
}
Aggregations