當前位置: 首頁>>代碼示例>>Java>>正文


Java BroadcasterReceiveServlet類代碼示例

本文整理匯總了Java中org.apache.kylin.rest.broadcaster.BroadcasterReceiveServlet的典型用法代碼示例。如果您正苦於以下問題:Java BroadcasterReceiveServlet類的具體用法?Java BroadcasterReceiveServlet怎麽用?Java BroadcasterReceiveServlet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BroadcasterReceiveServlet類屬於org.apache.kylin.rest.broadcaster包,在下文中一共展示了BroadcasterReceiveServlet類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setup

import org.apache.kylin.rest.broadcaster.BroadcasterReceiveServlet; //導入依賴的package包/類
@Before
public void setup() throws Exception {
    staticCreateTestMetadata();
    System.clearProperty("kylin.server.cluster-servers");
    int port = CheckUtil.randomAvailablePort(40000, 50000);
    logger.info("Chosen port for CacheServiceTest is " + port);
    configA = KylinConfig.getInstanceFromEnv();
    configA.setProperty("kylin.server.cluster-servers", "localhost:" + port);
    configB = KylinConfig.createKylinConfig(configA);
    configB.setProperty("kylin.server.cluster-servers", "localhost:" + port);
    configB.setMetadataUrl("../examples/test_metadata");

    server = new Server(port);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);

    final CacheService serviceA = new CacheService() {
        @Override
        public KylinConfig getConfig() {
            return configA;
        }
    };
    final CacheService serviceB = new CacheService() {
        @Override
        public KylinConfig getConfig() {
            return configB;
        }
    };

    context.addServlet(new ServletHolder(new BroadcasterReceiveServlet(new BroadcasterReceiveServlet.BroadcasterHandler() {
        @Override
        public void handle(String entity, String cacheKey, String event) {
            Broadcaster.Event wipeEvent = Broadcaster.Event.getEvent(event);
            final String log = "wipe cache type: " + entity + " event:" + wipeEvent + " name:" + cacheKey;
            logger.info(log);
            try {
                serviceA.notifyMetadataChange(entity, wipeEvent, cacheKey);
                serviceB.notifyMetadataChange(entity, wipeEvent, cacheKey);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    })), "/");
    server.start();
}
 
開發者ID:apache,項目名稱:kylin,代碼行數:47,代碼來源:MultiNodeManagerTestBase.java

示例2: beforeClass

import org.apache.kylin.rest.broadcaster.BroadcasterReceiveServlet; //導入依賴的package包/類
@BeforeClass
public static void beforeClass() throws Exception {
    createTestMetadata(LOCALMETA_TEST_DATA);
    configA = KylinConfig.getInstanceFromEnv();
    configB = KylinConfig.getKylinConfigFromInputStream(KylinConfig.getKylinPropertiesAsInputSteam());
    configB.setMetadataUrl("../examples/test_metadata");

    server = new Server(7070);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    server.setHandler(context);

    context.addServlet(new ServletHolder(new BroadcasterReceiveServlet(new BroadcasterReceiveServlet.BroadcasterHandler() {
        @Override
        public void handle(String type, String name, String event) {
            final CacheService cacheService = new CacheService() {
                @Override
                public KylinConfig getConfig() {
                    return configB;
                }
            };
            Broadcaster.TYPE wipeType = Broadcaster.TYPE.getType(type);
            Broadcaster.EVENT wipeEvent = Broadcaster.EVENT.getEvent(event);
            final String log = "wipe cache type: " + wipeType + " event:" + wipeEvent + " name:" + name;
            logger.info(log);
            counter.incrementAndGet();
            switch (wipeEvent) {
                case CREATE:
                case UPDATE:
                    cacheService.rebuildCache(wipeType, name);
                    break;
                case DROP:
                    cacheService.removeCache(wipeType, name);
                    break;
                default:
                    throw new RuntimeException("invalid type:" + wipeEvent);
            }
        }
    })), "/");
    server.start();
}
 
開發者ID:KylinOLAP,項目名稱:Kylin,代碼行數:42,代碼來源:CacheServiceTest.java


注:本文中的org.apache.kylin.rest.broadcaster.BroadcasterReceiveServlet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。