Search in sources :

Example 21 with ArkRuntimeException

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);
    }
}
Also used : URL(java.net.URL) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 22 with ArkRuntimeException

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");
}
Also used : ZipFile(java.util.zip.ZipFile) File(java.io.File) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 23 with ArkRuntimeException

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[] {});
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) File(java.io.File) URL(java.net.URL) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Aggregations

ArkRuntimeException (com.alipay.sofa.ark.exception.ArkRuntimeException)23 Biz (com.alipay.sofa.ark.spi.model.Biz)6 URL (java.net.URL)4 ArkContainerTest (com.alipay.sofa.ark.container.ArkContainerTest)3 BaseTest (com.alipay.sofa.ark.container.BaseTest)3 PluginModel (com.alipay.sofa.ark.container.model.PluginModel)3 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)3 EventAdminService (com.alipay.sofa.ark.spi.service.event.EventAdminService)3 PluginManagerService (com.alipay.sofa.ark.spi.service.plugin.PluginManagerService)3 File (java.io.File)3 KeeperException (org.apache.zookeeper.KeeperException)3 Test (org.junit.Test)3 BizModel (com.alipay.sofa.ark.container.model.BizModel)2 Plugin (com.alipay.sofa.ark.spi.model.Plugin)2 Extensible (com.alipay.sofa.ark.spi.service.extension.Extensible)2 Extension (com.alipay.sofa.ark.spi.service.extension.Extension)2 HashSet (java.util.HashSet)2 NodeCache (org.apache.curator.framework.recipes.cache.NodeCache)2 NodeCacheListener (org.apache.curator.framework.recipes.cache.NodeCacheListener)2 ClassPathArchive (com.alipay.sofa.ark.bootstrap.ClasspathLauncher.ClassPathArchive)1