Java 类com.hazelcast.config.ManagementCenterConfig 实例源码

项目:jcache-samples    文件:CacheServer.java   
private static void enableManagementCenter(Config cfg) {
    ManagementCenterConfig mgtCenter = new ManagementCenterConfig("http://localhost:8080/mancenter", 3);
    mgtCenter.setEnabled(true);
    cfg.setManagementCenterConfig(mgtCenter);

}
项目:hazelcast-archive    文件:ManagementCenterService.java   
@SuppressWarnings("CallToThreadStartDuringObjectConstruction")
public ManagementCenterService(FactoryImpl factoryImpl) throws Exception {
    this.factory = factoryImpl;
    final ManagementCenterConfig config = factory.node.config.getManagementCenterConfig();
    this.instanceFilterMap = new StatsInstanceFilter(factoryImpl.node.getGroupProperties().MC_MAP_EXCLUDES.getString());
    this.instanceFilterQueue = new StatsInstanceFilter(factoryImpl.node.getGroupProperties().MC_QUEUE_EXCLUDES.getString());
    this.instanceFilterTopic = new StatsInstanceFilter(factoryImpl.node.getGroupProperties().MC_TOPIC_EXCLUDES.getString());
    this.instanceFilterAtomicNumber = new StatsInstanceFilter(factoryImpl.node.getGroupProperties().MC_ATOMIC_NUMBER_EXCLUDES.getString());
    this.instanceFilterCountDownLatch = new StatsInstanceFilter(factoryImpl.node.getGroupProperties().MC_COUNT_DOWN_LATCH_EXCLUDES.getString());
    this.instanceFilterSemaphore = new StatsInstanceFilter(factoryImpl.node.getGroupProperties().MC_SEMAPHORE_EXCLUDES.getString());
    updateMemberOrder();
    logger = factory.node.getLogger(ManagementCenterService.class.getName());
    maxVisibleInstanceCount = factory.node.groupProperties.MC_MAX_INSTANCE_COUNT.getInteger();
    commandHandler = new ConsoleCommandHandler(factory);

    String tmpWebServerUrl = config != null ? config.getUrl() : null;
    webServerUrl = tmpWebServerUrl != null ?
            (!tmpWebServerUrl.endsWith("/") ? tmpWebServerUrl + '/' : tmpWebServerUrl) : tmpWebServerUrl;
    updateIntervalMs = (config != null && config.getUpdateInterval() > 0) ? config.getUpdateInterval() * 1000 : 3000;

    factory.getCluster().addMembershipListener(this);
    factory.getLifecycleService().addLifecycleListener(this);

    final MemberImpl memberLocal = (MemberImpl) factory.getCluster().getLocalMember();
    thisAddress = memberLocal.getAddress();
    if (factory.node.groupProperties.MANCENTER_ENABLED.getBoolean()) {
        int port = calculatePort(thisAddress);
        datagramSocket = new DatagramSocket(port);
        serverSocket = new SocketReadyServerSocket(port, 1000, factory.node.config.isReuseAddress());
        udpListener = new UDPListener(datagramSocket, 1000, factory.node.config.isReuseAddress());
        udpSender = new UDPSender(datagramSocket);
        tcpListener = new TCPListener(serverSocket);
        for (int i = 0; i < 100; i++) {
            qClientHandlers.offer(new ClientHandler(i));
        }
        udpSender.start();
        tcpListener.start();
        udpListener.start();
        logger.log(Level.INFO, "Hazelcast Management Center started at port " + port + ".");
    }
    if (config != null && config.isEnabled()) {
        if (config.getUrl() != null) {
            taskPoller = new TaskPoller();
            stateSender = new StateSender();
            taskPoller.start();
            stateSender.start();
            logger.log(Level.INFO, "Hazelcast Management Center is listening from " + config.getUrl());
        } else {
            logger.log(Level.WARNING, "Hazelcast Management Center Web server url is null!");
        }
    }
    running = true; // volatile-write
}