Search in sources :

Example 6 with ArkRuntimeException

use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.

the class ZookeeperConfigActivator method registryResource.

protected void registryResource(String path, CreateMode createMode) {
    try {
        LOGGER.info("Registry context path: {} with mode: {}.", path, createMode);
        zkClient.create().creatingParentContainersIfNeeded().withMode(createMode).forPath(path);
    } catch (KeeperException.NodeExistsException nodeExistsException) {
        if (LOGGER.isWarnEnabled()) {
            LOGGER.warn("Context path has exists in zookeeper, path=" + path);
        }
    } catch (Exception e) {
        throw new ArkRuntimeException("Failed to register resource to zookeeper registry!", e);
    }
}
Also used : KeeperException(org.apache.zookeeper.KeeperException) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException) KeeperException(org.apache.zookeeper.KeeperException) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 7 with ArkRuntimeException

use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.

the class StandardTelnetServerImpl method run.

@Override
public void run() {
    AssertUtils.isTrue(port > 0, "Telnet port should be positive integer.");
    try {
        LOGGER.info("Listening on port: " + port);
        CommonThreadPool workerPool = new CommonThreadPool().setCorePoolSize(WORKER_THREAD_POOL_SIZE).setDaemon(true).setThreadPoolName(Constants.TELNET_SERVER_WORKER_THREAD_POOL_NAME);
        ThreadPoolManager.registerThreadPool(Constants.TELNET_SERVER_WORKER_THREAD_POOL_NAME, workerPool);
        nettyTelnetServer = new NettyTelnetServer(port, workerPool.getExecutor());
        nettyTelnetServer.open();
    } catch (InterruptedException e) {
        LOGGER.error("Unable to open netty telnet server.", e);
        throw new ArkRuntimeException(e);
    }
}
Also used : CommonThreadPool(com.alipay.sofa.ark.common.thread.CommonThreadPool) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 8 with ArkRuntimeException

use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.

the class StandardTelnetServerImpl method shutdown.

@Override
public void shutdown() {
    if (shutdown.compareAndSet(false, true)) {
        try {
            if (nettyTelnetServer != null) {
                nettyTelnetServer.close();
                nettyTelnetServer = null;
            }
        } catch (Throwable t) {
            LOGGER.error("An error occurs when shutdown telnet server.", t);
            throw new ArkRuntimeException(t);
        }
    }
}
Also used : ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 9 with ArkRuntimeException

use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.

the class PluginDeployServiceImpl method unDeploy.

@Override
public void unDeploy() throws ArkRuntimeException {
    List<Plugin> pluginsInOrder = pluginManagerService.getPluginsInOrder();
    Collections.reverse(pluginsInOrder);
    for (Plugin plugin : pluginsInOrder) {
        try {
            unDeployPlugin(plugin);
        } catch (ArkRuntimeException e) {
            LOGGER.error(String.format("UnDeploy plugin: %s meet error", plugin.getPluginName()), e);
            throw e;
        }
    }
}
Also used : Plugin(com.alipay.sofa.ark.spi.model.Plugin) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 10 with ArkRuntimeException

use of com.alipay.sofa.ark.exception.ArkRuntimeException in project sofa-ark by alipay.

the class ExtensionServiceTest method testExtensionServiceNotInstance.

@Test
public void testExtensionServiceNotInstance() {
    PluginManagerService pluginManagerService = ArkServiceContainerHolder.getContainer().getService(PluginManagerService.class);
    PluginModel pluginModel = new PluginModel().setPluginClassLoader(this.getClass().getClassLoader()).setPluginName("mock-plugin");
    pluginManagerService.registerPlugin(pluginModel);
    try {
        ArkServiceLoader.loadExtensionFromArkPlugin(ServiceA.class, "", "mock-plugin");
    } catch (ArkRuntimeException ex) {
        Assert.assertTrue(ex.getMessage().contains("not type of"));
    }
}
Also used : PluginManagerService(com.alipay.sofa.ark.spi.service.plugin.PluginManagerService) PluginModel(com.alipay.sofa.ark.container.model.PluginModel) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException) ArkContainerTest(com.alipay.sofa.ark.container.ArkContainerTest) Test(org.junit.Test) BaseTest(com.alipay.sofa.ark.container.BaseTest)

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